Completed
Push — master ( 03d8b8...64d4be )
by Denis
05:05
created

File::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * JBZoo Assets
4
 *
5
 * This file is part of the JBZoo CCK package.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package   Assets
10
 * @license   MIT
11
 * @copyright Copyright (C) JBZoo.com,  All rights reserved.
12
 * @link      https://github.com/JBZoo/Assets
13
 * @author    Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace JBZoo\Assets\Asset;
17
18
use JBZoo\Utils\Url;
19
20
/**
21
 * Class File
22
 * @package JBZoo\Assets\Asset
23
 */
24
abstract class File extends Asset
25
{
26
    /**
27
     * @var string
28
     */
29
    protected $_type = null;
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function load(array $filters = [])
35
    {
36
        return [$this->_type, $this->_findSource()];
37
    }
38
39
    /**
40
     * Find source in variants.
41
     *
42
     * @return array
43
     */
44
    protected function _findSource()
45
    {
46
        $path = $this->_manager->getPath();
47
        if ($path->isVirtual($this->_source)) {
48
            return $path->get($this->_source);
49
        }
50
51
        if (Url::isAbsolute($this->_source)) {
52
            return $this->_source;
53
        }
54
55
        $fullPath = $path->get('root:' . $this->_source);
56
57
        return $fullPath;
58
    }
59
}
60