Вход Регистрация
Файл: concrete5.7.5.6/concrete/vendor/imagine/imagine/lib/Imagine/Filter/Advanced/RelativeResize.php
Строк: 50
<?php

/*
 * This file is part of the Imagine package.
 *
 * (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ImagineFilterAdvanced;

use 
ImagineExceptionInvalidArgumentException;
use 
ImagineFilterFilterInterface;
use 
ImagineImageImageInterface;

/**
 * The RelativeResize filter allows images to be resized relative to their
 * existing dimensions.
 */
class RelativeResize implements FilterInterface
{
    private 
$method;
    private 
$parameter;

    
/**
     * Constructs a RelativeResize filter with the given method and argument.
     *
     * @param string $method    BoxInterface method
     * @param mixed  $parameter Parameter for BoxInterface method
     */
    
public function __construct($method$parameter)
    {
        if (!
in_array($method, array('heighten''increase''scale''widen'))) {
            throw new 
InvalidArgumentException(sprintf('Unsupported method: '$method));
        }

        
$this->method $method;
        
$this->parameter $parameter;
    }

    
/**
     * {@inheritdoc}
     */
    
public function apply(ImageInterface $image)
    {
        return 
$image->resize(call_user_func(array($image->getSize(), $this->method), $this->parameter));
    }
}
Онлайн: 1
Реклама