Completed
Pull Request — master (#69)
by Vladimir
05:36
created

AssetEngineManager::getFoldersToWatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\AssetEngine;
9
10
use __;
11
use allejo\stakx\Exception\UnsupportedAssetEngineException;
12
13
class AssetEngineManager
14
{
15
    private $enginesByExtension = [];
16
    private $foldersToWatch = [];
17
    private $engines;
18
19
    public function addAssetEngines(/* iterable */ $assetEngines)
20
    {
21
        foreach ($assetEngines as $assetEngine)
22
        {
23
            $this->addAssetEngine($assetEngine);
24
        }
25
    }
26
27
    public function addAssetEngine(AssetEngine $assetEngine)
28
    {
29
        $extensions = $assetEngine->getExtensions();
30
31
        $e = $this->engines[] = $assetEngine;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $e. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
32
33
        foreach ($extensions as $extension)
34
        {
35
            $this->enginesByExtension[$extension] = $e;
36
        }
37
38
        $this->foldersToWatch[$assetEngine->getFolder()] = $e;
39
    }
40
41
    public function getEngineByExtension($extension)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
42
    {
43
        if (isset($this->enginesByExtension[$extension]))
44
        {
45
            return $this->enginesByExtension[$extension];
46
        }
47
48
        throw new UnsupportedAssetEngineException($extension, 'There is no support to handle this asset type.');
49
    }
50
51
    public function getFoldersToWatch()
52
    {
53
        return $this->foldersToWatch;
54
    }
55
}
56