1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 04:08:14 +01:00
intervention_image/src/ModifierStack.php
Oliver Vogel 2dbfb53bf8
Update code for phpstan level 6 (#1342)
* Update phpstan checks to level 6
* Add more details doc blocks to meet phpstan level 6
* Fix bug in building decoder chain
* Fix type hints
2024-05-02 11:03:18 +02:00

50 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace Intervention\Image;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
class ModifierStack implements ModifierInterface
{
/**
* Create new modifier stack object with an array of modifier objects
*
* @param array<ModifierInterface> $modifiers
* @return void
*/
public function __construct(protected array $modifiers)
{
}
/**
* Apply all modifiers in stack to the given image
*
* @param ImageInterface $image
* @return ImageInterface
*/
public function apply(ImageInterface $image): ImageInterface
{
foreach ($this->modifiers as $modifier) {
$modifier->apply($image);
}
return $image;
}
/**
* Append new modifier to the stack
*
* @param ModifierInterface $modifier
* @return ModifierStack
*/
public function push(ModifierInterface $modifier): self
{
$this->modifiers[] = $modifier;
return $this;
}
}