/** * Basic usage * * @return void */ public function testInvalidWatermarkType() { $this->expectException(Watermark\Exception\RuntimeException::class); $this->expectExceptionMessage('Watermark is not an instance of AdapterInterface!'); $filter = new Watermark(); $filter->filter($this->image); }
/** * {@inheritdoc} */ public function filter($value) { $return = parent::filter($value); $imagePath = isset($return['tmp_name']) ? $return['tmp_name'] : $return; $watermarkOptions = $this->getWatermark(); $watermark = new Watermark(); if (!$watermarkOptions['image'] instanceof Watermark\Adapter\AdapterInterface) { $watermarkOptions['image'] = new $watermarkOptions['adapter']($watermarkOptions['image']); } $watermark->setWatermark($watermarkOptions['image']); $watermark->setPosition($watermarkOptions['position']); $watermark->setMargins($watermarkOptions['margins']); if (!$imagePath instanceof Watermark\Adapter\AdapterInterface) { $imagePath = new $watermarkOptions['adapter']($imagePath); } $watermark->filter($imagePath); return $return; }