Completed
Branch dbal-improvement (06db1a)
by Anton
03:59
created

Aliaser::importable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\Stempler\Importers;
9
10
use Spiral\Stempler\ImporterInterface;
11
12
/**
13
 * {@inheritdoc}
14
 *
15
 * Simple aliased based import, declared relation between tag name and it's location. Element alias
16
 * must be located in "as" attribute caused import, location in "path" attribute (will be passed
17
 * thought Stempler->fetchLocation()).
18
 */
19
class Aliaser implements ImporterInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    private $alias = '';
25
26
    /**
27
     * @var mixed
28
     */
29
    private $path = null;
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function __construct($alias, $path)
35
    {
36
        $this->alias = $alias;
37
        $this->path = $path;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function importable($element, array $token)
44
    {
45
        return strtolower($element) == strtolower($this->alias);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function resolvePath($element, array $token)
52
    {
53
        return $this->path;
54
    }
55
}