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

ClassManifestErrorHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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