Esempio n. 1
0
 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));
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 /**
  * @dataProvider burgerProvider
  */
 public function testIsValid(Burger $burger, bool $expected)
 {
     $this->assertSame($expected, $burger->isValid());
 }
Esempio n. 5
0
 private function ensureBurgerIsValid(Burger $burger)
 {
     if (!$burger->isValid()) {
         throw new BadRequestHttpException('Invalid request');
     }
 }