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

CompileException::fromTwig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
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
}