1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Brazanation\Documents\Sped; |
4
|
|
|
|
5
|
|
|
use Brazanation\Documents\Sped\Exception\InvalidEmissionType; |
6
|
|
|
|
7
|
|
|
class EmissionType |
8
|
|
|
{ |
9
|
|
|
const NORMAL = 1; |
10
|
|
|
|
11
|
|
|
const CONTINGENCY_ON_SAFETY_FORM = 2; |
12
|
|
|
|
13
|
|
|
const CONTINGENCY_SCAN = 3; |
14
|
|
|
|
15
|
|
|
const CONTINGENCY_DPEC = 4; |
16
|
|
|
|
17
|
|
|
const CONTINGENCY_ON_SAFETY_FORM_FSDA = 5; |
18
|
|
|
|
19
|
|
|
const CONTINGENCY_SVCAN = 6; |
20
|
|
|
|
21
|
|
|
const CONTINGENCY_SVCRS = 7; |
22
|
|
|
|
23
|
|
|
private $type; |
24
|
|
|
|
25
|
|
|
private $allowed = [ |
26
|
|
|
EmissionType::CONTINGENCY_DPEC, |
27
|
|
|
EmissionType::CONTINGENCY_ON_SAFETY_FORM, |
28
|
|
|
EmissionType::CONTINGENCY_ON_SAFETY_FORM_FSDA, |
29
|
|
|
EmissionType::CONTINGENCY_SCAN, |
30
|
|
|
EmissionType::CONTINGENCY_SVCAN, |
31
|
|
|
EmissionType::CONTINGENCY_SVCRS, |
32
|
|
|
EmissionType::NORMAL, |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Model constructor. |
37
|
|
|
* |
38
|
|
|
* @param int $type |
39
|
|
|
*/ |
40
|
29 |
|
public function __construct(int $type) |
41
|
|
|
{ |
42
|
29 |
|
$this->validate($type); |
43
|
29 |
|
$this->type = $type; |
44
|
|
|
} |
45
|
|
|
|
46
|
29 |
|
private function validate(int $type) |
47
|
|
|
{ |
48
|
29 |
|
if (!in_array($type, $this->allowed)) { |
49
|
|
|
throw InvalidEmissionType::notAllowed($type); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
4 |
|
public static function normal() : EmissionType |
54
|
|
|
{ |
55
|
4 |
|
return new self(self::NORMAL); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public static function contingencyDpec() : EmissionType |
59
|
|
|
{ |
60
|
|
|
return new self(self::CONTINGENCY_DPEC); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public static function contingencySVCRS() : EmissionType |
64
|
|
|
{ |
65
|
|
|
return new self(self::CONTINGENCY_SVCRS); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public static function contingencySVCAN() : EmissionType |
69
|
|
|
{ |
70
|
|
|
return new self(self::CONTINGENCY_SVCAN); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public static function contingencySCAN() : EmissionType |
74
|
|
|
{ |
75
|
|
|
return new self(self::CONTINGENCY_SCAN); |
76
|
|
|
} |
77
|
|
|
|
78
|
1 |
|
public static function contingencyOnSafetyForm() : EmissionType |
79
|
|
|
{ |
80
|
1 |
|
return new self(self::CONTINGENCY_ON_SAFETY_FORM); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public static function contingencyOnSafetyFormFSDA() : EmissionType |
84
|
|
|
{ |
85
|
|
|
return new self(self::CONTINGENCY_ON_SAFETY_FORM_FSDA); |
86
|
|
|
} |
87
|
|
|
|
88
|
5 |
|
public function __toString() : string |
89
|
|
|
{ |
90
|
5 |
|
return "{$this->type}"; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|