Passed
Push — faster-cleartable ( 79c2b5 )
by Sam
07:37
created

ClassManifestErrorHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handleError() 0 5 1
1
<?php
2
namespace SilverStripe\Core\Manifest;
3
4
use PhpParser\Error;
5
use PhpParser\ErrorHandler;
6
7
/**
8
9
 * Error handler which throws, but retains the original path context.
10
 * For parsing errors, this is essential information to identify the issue.
11
 */
12
class ClassManifestErrorHandler implements ErrorHandler
13
{
14
    /**
15
     * @var String
16
     */
17
    protected $pathname;
18
19
    /**
20
     * @param String $pathname
21
     */
22
    public function __construct($pathname)
23
    {
24
        $this->pathname = $pathname;
25
    }
26
27
    public function handleError(Error $error)
28
    {
29
        $newMessage = sprintf('%s in %s', $error->getRawMessage(), $this->pathname);
30
        $error->setRawMessage($newMessage);
31
        throw $error;
32
    }
33
}
34