Completed
Branch 09branch (31301e)
by Anton
02:42
created

CompileException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromTwig() 0 8 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
namespace Spiral\Views\Engines\Twig\Exceptions;
10
11
/**
12
 * Provides ability to clarify syntax error location.
13
 */
14
class CompileException extends \Spiral\Views\Exceptions\CompileException
15
{
16
    /**
17
     * Clarify twig syntax exception.
18
     *
19
     * @param \Twig_Error_Syntax $error
20
     *
21
     * @return self
22
     */
23
    public static function fromTwig(\Twig_Error_Syntax $error): CompileException
24
    {
25
        $exception = new static($error->getMessage(), $error->getCode(), $error);
26
        $exception->file = $error->getSourceContext()->getPath();
27
        $exception->line = $error->getTemplateLine();
28
29
        return $exception;
30
    }
31
}