Passed
Pull Request — main (#22)
by
unknown
04:00 queued 01:57
created

QualityFilter::apply()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Conlect\ImageIIIF\Filters;
4
5
use Intervention\Image\Interfaces\ImageInterface;
6
use Intervention\Image\Interfaces\ModifierInterface;
7
8
class QualityFilter implements ModifierInterface
9
{
10
    private $quality;
11
12
    /**
13
     * Creates new instance of filter
14
     *
15
     */
16
    public function __construct($quality)
17
    {
18
        $this->quality = $quality;
19
    }
20
21
    /**
22
     * Applies filter effects to given image
23
     *
24
     * @param  ImageInterface $image
25
     *
26
     * @return  ImageInterface
27
     */
28
    public function apply(ImageInterface $image): ImageInterface
29
    {
30
        if ($this->quality === 'gray') {
31
            return $image->greyscale();
32
        }
33
34
        return $image;
35
    }
36
}
37