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

Stopper::importable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6667
cc 2
eloc 4
nc 2
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
 * Declares to templater that element must be treated as html tag, not Node include. Stop keyword
14
 * must be located in
15
 * "stop" attribute of tag caused import.
16
 */
17
class Stopper implements ImporterInterface
18
{
19
    /**
20
     * Html tag name.
21
     *
22
     * @var string
23
     */
24
    protected $element = '';
25
26
    /**
27
     * @param string $element
28
     */
29
    public function __construct($element)
30
    {
31
        $this->element = $element;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function importable($element, array $token)
38
    {
39
        if ($this->element == '*') {
40
            //To disable every lower level importer, you can still define more importers after that
41
            return true;
42
        }
43
44
        return strtolower($element) == strtolower($this->element);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function resolvePath($element, array $token)
51
    {
52
        return null;
53
    }
54
}