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

Stopper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A importable() 0 9 2
A resolvePath() 0 4 1
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
}