Image::getThumb()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 10
1
<?php
2
/**
3
 * Licensed under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License.
5
 * You may obtain a copy of the License at
6
 *
7
 * @license http://www.apache.org/licenses/LICENSE-2.0
8
 *
9
 * Unless required by applicable law or agreed to in writing, software
10
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 * See the License for the specific language governing permissions and
13
 * limitations under the License.
14
 *
15
 * @author Alexander Zakharov <[email protected]>
16
 * @link http://rootlocal.ru
17
 * @copyright Copyright © 2018 rootlocal.ru
18
 */
19
20
namespace image;
21
22
use image\components\Thumb;
23
use yii\base\Component;
24
use yii\helpers\ArrayHelper;
25
26
/**
27
 * Class Image
28
 * @package image
29
 * @property Thumb $thumb
30
 */
31
class Image extends Component
32
{
33
34
    /**
35
     * default driver: GD, Imagick
36
     * @var  string
37
     */
38
    public $driver;
39
40
    /**
41
     * The File path to the Watermark File
42
     * @var string
43
     */
44
    public $watermarkFile;
45
46
    /**
47
     * @param array $config
48
     * @return Thumb
49
     */
50
    public function getThumb($config)
51
    {
52
        $componentConfig = [
53
            'driver' => $this->driver,
54
            'watermarkFile' => $this->watermarkFile,
55
        ];
56
57
        $config = ArrayHelper::merge($componentConfig, $config);
58
59
        return Thumb::getInstance($config);
60
    }
61
62
}