ImagineDriver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ImageOptimizer;
6
7
use Imagine\Gd\Imagine;
8
use Imagine\Image\{Box, ImageInterface};
9
10
class ImagineDriver implements DriverInterface
11
{
12
    /**
13
     * @var Imagine $imagine
14
     */
15
    protected $imagine;
16
17
    public function __construct()
18
    {
19
        $this->imagine = new Imagine();
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25
    public function process(string $path, int $width, int $height, string $resizedFile): void
26
    {
27
        $this->imagine->open($path)
28
            ->thumbnail(new Box($width, $height), ImageInterface::THUMBNAIL_OUTBOUND)
29
            ->save($resizedFile)
30
            ->save($resizedFile . '.webp');
31
    }
32
}
33