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

StemplerException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getToken() 0 4 1
A setLocation() 0 5 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\Stempler\Exceptions;
9
10
use Spiral\Core\Exceptions\ExceptionInterface;
11
use Spiral\Core\Exceptions\RuntimeException;
12
13
/**
14
 * StemplerException has ability to specify context token which will can used to define location
15
 * of html code caused error.
16
 */
17
class StemplerException extends RuntimeException implements ExceptionInterface
18
{
19
    /**
20
     * @var array
21
     */
22
    private $token = [];
23
24
    /**
25
     * @param string     $message
26
     * @param array      $token
27
     * @param int        $code
28
     * @param \Exception $previous
29
     */
30
    public function __construct($message, array $token = [], $code = 0, \Exception $previous = null)
31
    {
32
        parent::__construct($message, $code, $previous);
33
        $this->token = $token;
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function getToken()
40
    {
41
        return $this->token;
42
    }
43
44
    /**
45
     * Set exception location.
46
     *
47
     * @param string $file
48
     * @param string $line
49
     */
50
    public function setLocation($file, $line)
51
    {
52
        $this->file = $file;
53
        $this->line = $line;
54
    }
55
}