Completed
Push — master ( 2fc7ef...2c7029 )
by Vladimir
07:48
created

TwigError::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Templating\Twig;
9
10
use allejo\stakx\Templating\TemplateErrorInterface;
11
12
class TwigError extends \Exception implements TemplateErrorInterface
13
{
14
    private $error;
15
    private $content;
16
    private $relativeFilePath;
17
    private $name;
18
19
    public function __construct(\Twig_Error $error)
20
    {
21
        $this->error = $error;
22
        $this->message = $error->getRawMessage();
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function getTemplateLine()
29
    {
30
        return $this->error->getTemplateLine();
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function setTemplateLine($lineNumber)
37
    {
38
        $this->error->setTemplateLine($lineNumber);
39
40
        return $this;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getContent()
47
    {
48
        return $this->content;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function setContent($content)
55
    {
56
        $this->content = $content;
57
58
        return $this;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function getName()
65
    {
66
        return $this->name;
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function setName($name)
73
    {
74
        $this->name = $name;
75
76
        return $this;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function getRelativeFilePath()
83
    {
84
        return $this->relativeFilePath;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function setRelativeFilePath($filePath)
91
    {
92
        $this->relativeFilePath = $filePath;
93
94
        return $this;
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function buildException()
101
    {
102
        $this->error->setSourceContext(new \Twig_Source(
103
            $this->content,
104
            $this->name,
105
            $this->relativeFilePath
106
        ));
107
    }
108
}
109