Passed
Pull Request — master (#69)
by Dave
02:21
created

DiffParseException::getDetails()   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
/**
4
 * Static Analysis Results Baseliner (sarb).
5
 *
6
 * (c) Dave Liddament
7
 *
8
 * For the full copyright and licence information please view the LICENSE file distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Domain\HistoryAnalyser\UnifiedDiffParser\internal;
14
15
use Exception;
16
17
class DiffParseException extends Exception
18
{
19
    public const END_OF_FILE = '<EOF>';
20
21
    public static function missingRenameTo(string $line): self
22
    {
23
        return new self('NO_RENAME_TO', $line);
24
    }
25
26
    public static function missingNewFileName(string $line): self
27
    {
28
        return new self('NO_NEW_FILE_NAME', $line);
29
    }
30
31
    public static function invalidRangeInformation(string $rangeInformation): self
32
    {
33
        return new self('RANGE_INFORMATION_PARSE_ERROR', $rangeInformation);
34
    }
35
36
    /**
37
     * @var string
38
     */
39
    private $reason;
40
41
    /**
42
     * @var string
43
     */
44
    private $details;
45
46
    public function __construct(string $reason, string $details)
47
    {
48
        parent::__construct("$reason: $details");
49
        $this->reason = $reason;
50
        $this->details = $details;
51
    }
52
53
    public function getReason(): string
54
    {
55
        return $this->reason;
56
    }
57
58
    public function getDetails(): string
59
    {
60
        return $this->details;
61
    }
62
}
63