TinyPngService::getApiKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
cc 1
nc 1
nop 0
crap 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