Skip to content

Commit

Permalink
Merge 2a397ae into 40297cd
Browse files Browse the repository at this point in the history
  • Loading branch information
maximgubar committed Jun 18, 2018
2 parents 40297cd + 2a397ae commit 687e902
Show file tree
Hide file tree
Showing 56 changed files with 2,391 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Binary/Locator/FileSystemInsecureLocator.php
Expand Up @@ -21,9 +21,9 @@ class FileSystemInsecureLocator extends FileSystemLocator
*/
protected function generateAbsolutePath(string $root, string $path): ?string
{
if (false === mb_strpos($path, '..'.DIRECTORY_SEPARATOR) &&
false === mb_strpos($path, DIRECTORY_SEPARATOR.'..') &&
false !== file_exists($absolute = $root.DIRECTORY_SEPARATOR.$path)
if (false === mb_strpos($path, '..'.\DIRECTORY_SEPARATOR) &&
false === mb_strpos($path, \DIRECTORY_SEPARATOR.'..') &&
false !== file_exists($absolute = $root.\DIRECTORY_SEPARATOR.$path)
) {
return $absolute;
}
Expand Down
2 changes: 1 addition & 1 deletion Binary/Locator/FileSystemLocator.php
Expand Up @@ -60,7 +60,7 @@ public function locate(string $path): string
*/
protected function generateAbsolutePath(string $root, string $path): ?string
{
if (false !== $absolute = realpath($root.DIRECTORY_SEPARATOR.$path)) {
if (false !== $absolute = realpath($root.\DIRECTORY_SEPARATOR.$path)) {
return $absolute;
}

Expand Down
44 changes: 44 additions & 0 deletions Config/Filter/Argument/Point.php
@@ -0,0 +1,44 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Config\Filter\Argument;

/**
* @codeCoverageIgnore
*/
final class Point
{
/**
* @var int
*/
private $x;

/**
* @var int
*/
private $y;

public function __construct(int $x = null, int $y = null)
{
$this->x = $x;
$this->y = $y;
}

public function getX(): ?int
{
return $this->x;
}

public function getY(): ?int
{
return $this->y;
}
}
48 changes: 48 additions & 0 deletions Config/Filter/Argument/Size.php
@@ -0,0 +1,48 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Config\Filter\Argument;

/**
* @codeCoverageIgnore
*/
final class Size
{
/**
* @var int
*/
private $width;

/**
* @var int
*/
private $height;

/**
* To allow keeping aspect ratio, it is allowed to only specify one of width or height.
* It is however not allowed to specify neither dimension.
*/
public function __construct(int $width = null, int $height = null)
{
$this->width = $width;
$this->height = $height;
}

public function getWidth(): ?int
{
return $this->width;
}

public function getHeight(): ?int
{
return $this->height;
}
}
20 changes: 20 additions & 0 deletions Config/Filter/Type/AutoRotate.php
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Config\Filter\Type;

/**
* @codeCoverageIgnore
*/
final class AutoRotate extends FilterAbstract
{
const NAME = 'auto_rotate';
}
80 changes: 80 additions & 0 deletions Config/Filter/Type/Background.php
@@ -0,0 +1,80 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Config\Filter\Type;

use Liip\ImagineBundle\Config\Filter\Argument\Size;

/**
* @codeCoverageIgnore
*/
final class Background extends FilterAbstract
{
const NAME = 'background';

/**
* @var string
*/
private $color;

/**
* @var string
*/
private $transparency;

/**
* @var string
*/
private $position;

/**
* @var Size
*/
private $size;

/**
* @param string|null $color background color HEX value
* @param string|null $transparency possible values 0..100
* @param string|null $position position of the input image on the newly created background image. Valid values: topleft, top, topright, left, center, right, bottomleft, bottom, and bottomright
* @param Size $size
*/
public function __construct(
string $color = null,
string $transparency = null,
string $position = null,
Size $size
) {
$this->color = $color;
$this->transparency = $transparency;
$this->position = $position;
$this->size = $size;
}

public function getColor(): ?string
{
return $this->color;
}

public function getTransparency(): ?string
{
return $this->transparency;
}

public function getPosition(): ?string
{
return $this->position;
}

public function getSize(): Size
{
return $this->size;
}
}
49 changes: 49 additions & 0 deletions Config/Filter/Type/Crop.php
@@ -0,0 +1,49 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Config\Filter\Type;

use Liip\ImagineBundle\Config\Filter\Argument\Point;
use Liip\ImagineBundle\Config\Filter\Argument\Size;

/**
* @codeCoverageIgnore
*/
final class Crop extends FilterAbstract
{
const NAME = 'crop';

/**
* @var Point
*/
private $startPoint;

/**
* @var Size
*/
private $size;

public function __construct(Point $startPoint, Size $size)
{
$this->startPoint = $startPoint;
$this->size = $size;
}

public function getStartPoint(): Point
{
return $this->startPoint;
}

public function getSize(): Size
{
return $this->size;
}
}
52 changes: 52 additions & 0 deletions Config/Filter/Type/Downscale.php
@@ -0,0 +1,52 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Config\Filter\Type;

use Liip\ImagineBundle\Config\Filter\Argument\Size;

/**
* @codeCoverageIgnore
*/
final class Downscale extends FilterAbstract
{
const NAME = 'downscale';

/**
* @var Size
*/
private $max;

/**
* @var float
*/
private $by;

/**
* @param Size|null $max
* @param float|null $by sets the "ratio multiple" which initiates a proportional scale operation computed by multiplying all image sides by this value
*/
public function __construct(Size $max = null, float $by = null)
{
$this->max = $max;
$this->by = $by;
}

public function getMax(): ?Size
{
return $this->max;
}

public function getBy(): ?float
{
return $this->by;
}
}
29 changes: 29 additions & 0 deletions Config/Filter/Type/FilterAbstract.php
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Config\Filter\Type;

use Liip\ImagineBundle\Config\FilterInterface;

/**
* @codeCoverageIgnore
*/
abstract class FilterAbstract implements FilterInterface
{
public function getName(): string
{
if (!defined('static::NAME')) {
throw new \Exception('Constant NAME is not defined on subclass '.get_class($this));
}

return static::NAME;
}
}
38 changes: 38 additions & 0 deletions Config/Filter/Type/Flip.php
@@ -0,0 +1,38 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Config\Filter\Type;

/**
* @codeCoverageIgnore
*/
final class Flip extends FilterAbstract
{
const NAME = 'flip';

/**
* @var string
*/
private $axis;

/**
* @param string $axis possible values are: "x", "horizontal", "y", or "vertical"
*/
public function __construct(string $axis)
{
$this->axis = $axis;
}

public function getAxis(): string
{
return $this->axis;
}
}

0 comments on commit 687e902

Please sign in to comment.