Completed
Push — master ( 9003e7...f2c4d3 )
by ReliQ
04:59
created

ParsingFailed   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A forFile() 0 8 1
A getFailedFile() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliQArts\Docweaver\Exceptions;
6
7
use ReliQArts\Docweaver\Contracts\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 $failedFile;
17
18
    /**
19
     * @param string            $file
20
     * @param ExceptionContract $previous
0 ignored issues
show
Documentation introduced by
Should the type for parameter $previous not be null|ExceptionContract?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
21
     *
22
     * @return ExceptionContract
23
     */
24
    public static function forFile(string $file, ExceptionContract $previous = null): ExceptionContract
25
    {
26
        $message = sprintf('Failed to parse file `%s`.', $file);
27
        $self = new self($message, self::CODE, $previous);
28
        $self->failedFile = $file;
29
30
        return $self;
31
    }
32
33
    /**
34
     * Get the file which parsing failed for.
35
     *
36
     * @return null|string
37
     */
38
    public function getFailedFile(): ?string
39
    {
40
        return $this->failedFile;
41
    }
42
}
43