Completed
Push — master ( 676136...b5d1cf )
by Mathieu
02:39
created

AbstractWatermarkEffect::setGravity()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Charcoal\Image\Effect;
4
5
use \InvalidArgumentException;
6
7
use \Charcoal\Image\AbstractEffect;
8
use \Charcoal\Image\ImageInterface;
9
use \Charcoal\Image\Effect\LayerEffectInterface;
10
use \Charcoal\Image\Effect\LayerEffectTrait;
11
12
/**
13
 * Composite a watermark on top of the image.
14
 */
15
abstract class AbstractWatermarkEffect extends AbstractEffect implements LayerEffectInterface
16
{
17
    use LayerEffectTrait;
18
19
    /**
20
     * The watermark image source (path or Image).
21
     * @var string|ImageInterface $watermark
22
     */
23
    private $watermark;
24
25
    /**
26
     * @param string|ImageInterface $watermark The watermark (path or Image).
27
     * @throws InvalidArgumentException If the watermark value is not a string or an Image.
28
     * @return AbstractMaskEffect Chainable
29
     */
30
    public function setWatermark($watermark)
31
    {
32
        if (is_string($watermark) || ($watermark instanceof ImageInterface)) {
33
            $this->watermark = $watermark;
34
            return $this;
35
        } else {
36
            throw new InvalidArgumentException(
37
                'Watermark must be a string'
38
            );
39
        }
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function watermark()
46
    {
47
        return $this->watermark;
48
    }
49
}
50