TinyPngService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 19
rs 10
ccs 6
cts 8
cp 0.75

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getApiKey() 0 4 1
A minimize() 0 5 1
1
<?php
2
3
namespace TinyPngBundle\Service;
4
5
use Pimcore\Model\Asset;
6
use function Tinify\fromFile;
7
use function Tinify\setKey;
8
use TinyPngBundle\Helper\AssetHelper;
9
10
/**
11
 * Class TinyPngService
12
 * @package TinyPngBundle\Service
13
 */
14
class TinyPngService
15
{
16
    /**
17
     * @param Asset $image
18
     */
19 2
    public function minimize(Asset $image)
20
    {
21 2
        setKey($this->getApiKey());
22 2
        $source = fromFile($image->getFileSystemPath());
23
        $source->toFile($image->getFileSystemPath());
24
    }
25
26
    /**
27
     * @return string
28
     */
29 2
    private function getApiKey() : string
30
    {
31 2
        $config = AssetHelper::getConfig();
32 2
        return $config['config']['apiKey'] ?? '';
33
    }
34
}
35