-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathModifierStack.php
More file actions
44 lines (36 loc) · 934 Bytes
/
ModifierStack.php
File metadata and controls
44 lines (36 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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
*/
public function apply(ImageInterface $image): ImageInterface
{
foreach ($this->modifiers as $modifier) {
$modifier->apply($image);
}
return $image;
}
/**
* Append new modifier to the stack
*/
public function push(ModifierInterface $modifier): self
{
$this->modifiers[] = $modifier;
return $this;
}
}