eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader\BorderFilterLoader::load PHP Method

load() public method

public load ( Imagine\Image\ImageInterface $image, array $options = [] )
$image Imagine\Image\ImageInterface
$options array
    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);
    }

Usage Example

 /**
  * @dataProvider loadProvider
  */
 public function testLoad($thickX, $thickY, $color)
 {
     $image = $this->getMock('\\Imagine\\Image\\ImageInterface');
     $options = array($thickX, $thickY, $color);
     $palette = $this->getMock('\\Imagine\\Image\\Palette\\PaletteInterface');
     $image->expects($this->once())->method('palette')->will($this->returnValue($palette));
     $palette->expects($this->once())->method('color')->with($color)->will($this->returnValue($this->getMock('\\Imagine\\Image\\Palette\\Color\\ColorInterface')));
     $box = $this->getMock('\\Imagine\\Image\\BoxInterface');
     $image->expects($this->once())->method('getSize')->will($this->returnValue($box));
     $box->expects($this->any())->method('getWidth')->will($this->returnValue(1000));
     $box->expects($this->any())->method('getHeight')->will($this->returnValue(1000));
     $drawer = $this->getMock('\\Imagine\\Draw\\DrawerInterface');
     $image->expects($this->once())->method('draw')->will($this->returnValue($drawer));
     $drawer->expects($this->any())->method('line')->will($this->returnValue($drawer));
     $loader = new BorderFilterLoader();
     $this->assertSame($image, $loader->load($image, $options));
 }
BorderFilterLoader