Пример #1
0
 public function load(ImageInterface $image, array $options = array())
 {
     $optionsCount = count($options);
     if ($optionsCount < 2) {
         throw new InvalidArgumentException('Invalid options for border filter. You must provide array(width, height)');
     }
     $color = static::DEFAULT_BORDER_COLOR;
     if ($optionsCount > 2) {
         list($width, $height, $color) = $options;
     } else {
         list($width, $height) = $options;
     }
     $border = new Border($image->palette()->color($color), $width, $height);
     return $border->apply($image);
 }
Пример #2
0
 public function testBorderImage()
 {
     $color = new Color('fff');
     $width = 2;
     $height = 4;
     $image = $this->getImage();
     $imageWidth = 200;
     $imageHeight = 100;
     $size = $this->getMock('Imagine\\Image\\BoxInterface');
     $size->expects($this->once())->method('getWidth')->will($this->returnValue($width));
     $size->expects($this->once())->method('getHeight')->will($this->returnValue($height));
     $draw = $this->getDrawer();
     $draw->expects($this->exactly(4))->method('line')->will($this->returnValue($draw));
     $image->expects($this->once())->method('getSize')->will($this->returnValue($size));
     $image->expects($this->once())->method('draw')->will($this->returnValue($draw));
     $filter = new Border($color, $width, $height);
     $this->assertSame($image, $filter->apply($image));
 }