Passed
Push — master ( 2d5d29...0740c8 )
by ReliQ
04:50 queued 13s
created

ParsingFailed::getFailedFile()   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 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliqArts\Docweaver\Exception;
6
7
use ReliqArts\Docweaver\Contract\Exception as ExceptionContract;
8
9
final class ParsingFailed extends Exception
10
{
11
    private const CODE = 1004;
12
13
    /**
14
     * @var null|string
15
     */
16
    private ?string $failedFile;
17
18
    /**
19
     * @param ExceptionContract $previous
20
     */
21
    public static function forFile(string $file, ExceptionContract $previous = null): ExceptionContract
22
    {
23
        $message = sprintf('Failed to parse file `%s`.', $file);
24
        $self = new self($message, self::CODE, $previous);
25
        $self->failedFile = $file;
26
27
        return $self;
28
    }
29
30
    /**
31
     * Get the file which parsing failed for.
32
     */
33
    public function getFailedFile(): ?string
34
    {
35
        return $this->failedFile;
36
    }
37
}
38