private function addGrayscalePrefixIfNecessary(string $filename, Burger $burger) : string { if ($burger->isGrayscale()) { return self::GRAYSCALE_PREFIX . self::SEPARATOR . $filename; } return $filename; }
/** * @dataProvider testConvertDataProvider */ public function testConvert(int $width, int $height, bool $grayscale, string $expected) { $converter = new Descriptive(); $burger = new Burger($width, $height); if ($grayscale) { $burger->applyGrayscale(); } $this->assertSame($expected, $converter->convert($burger)); }
public function forge(Burger $burger) : Forger { $sourceBurgerImage = $this->imagine->open($this->burgerPicker->pick()); $resizeFilter = (new ResizeKeepRatio($sourceBurgerImage, $burger))->build(); $resizeFilter->apply($sourceBurgerImage); $cropFilter = (new CropCenter($sourceBurgerImage->getSize(), $burger))->build(); $cropFilter->apply($sourceBurgerImage); if ($burger->isGrayscale()) { $sourceBurgerImage->effects()->grayscale(); } $sourceBurgerImage->save($this->buildBurgerImagePath($burger)); return $this; }
/** * @dataProvider burgerProvider */ public function testIsValid(Burger $burger, bool $expected) { $this->assertSame($expected, $burger->isValid()); }
private function ensureBurgerIsValid(Burger $burger) { if (!$burger->isValid()) { throw new BadRequestHttpException('Invalid request'); } }