ImageHelper::getUrl()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * @link https://github.com/yiimaker/yii2-banner
4
 * @copyright Copyright (c) 2017 Yii Maker
5
 * @license BSD 3-Clause License
6
 */
7
8
namespace ymaker\banner\common\helpers;
9
10
use Yii;
11
use ymaker\banner\common\components\FileManagerInterface;
12
13
/**
14
 * Helper for banner images.
15
 *
16
 * @author Vladimir Kuprienko <[email protected]>
17
 * @since 1.0
18
 */
19
class ImageHelper
20
{
21
    /**
22
     * @var FileManagerInterface
23
     */
24
    private static $_fileManager;
25
26
27
    /**
28
     * Returns URL to image.
29
     *
30
     * @param string $fileName
31
     * @return string
32
     */
33
    public static function getUrl($fileName)
34
    {
35
        if (self::$_fileManager === null) {
36
            self::$_fileManager = Yii::$container->get(FileManagerInterface::class);
37
        }
38
        return self::$_fileManager->getImageUrl($fileName);
39
    }
40
}
41