| Total Complexity | 8 |
| Total Lines | 103 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class ErrorDoc |
||
| 10 | { |
||
| 11 | /** @var string */ |
||
| 12 | private $title; |
||
| 13 | /** @var string */ |
||
| 14 | private $identifier; |
||
| 15 | /** @var int */ |
||
| 16 | private $code; |
||
| 17 | /** @var string|null */ |
||
| 18 | private $message; |
||
| 19 | /** @var null|TypeDoc */ |
||
| 20 | private $dataDoc = null; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param string $title |
||
| 24 | * @param int $code |
||
| 25 | * @param string|null $message |
||
| 26 | * @param TypeDoc|null $dataDoc |
||
| 27 | * @param string|null $identifier |
||
| 28 | */ |
||
| 29 | public function __construct( |
||
| 30 | string $title, |
||
| 31 | int $code, |
||
| 32 | string $message = null, |
||
| 33 | TypeDoc $dataDoc = null, |
||
| 34 | string $identifier = null |
||
| 35 | ) { |
||
| 36 | $this->title = $title; |
||
| 37 | $this->code = $code; |
||
| 38 | $this->message = $message; |
||
| 39 | $this->dataDoc = $dataDoc; |
||
| 40 | $this->setIdentifier($identifier ?? $title.((string)$code)); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param string $identifier |
||
| 45 | * |
||
| 46 | * @return ErrorDoc |
||
| 47 | */ |
||
| 48 | public function setIdentifier(string $identifier) : ErrorDoc |
||
| 49 | { |
||
| 50 | // Sanitize Identifier => remove space and slashes |
||
| 51 | $this->identifier = strtr( |
||
| 52 | ucwords(strtr( |
||
| 53 | $identifier, |
||
| 54 | ['_' => ' ', '/' => ' ', '.' => '_ ', '\\' => '_ '] |
||
| 55 | )), |
||
| 56 | [' ' => ''] |
||
| 57 | ); |
||
| 58 | |||
| 59 | return $this; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param TypeDoc $dataDoc |
||
| 64 | * |
||
| 65 | * @return ErrorDoc |
||
| 66 | */ |
||
| 67 | public function setDataDoc(TypeDoc $dataDoc) : ErrorDoc |
||
| 68 | { |
||
| 69 | $this->dataDoc = $dataDoc; |
||
| 70 | |||
| 71 | return $this; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return string |
||
| 76 | */ |
||
| 77 | public function getTitle() : string |
||
| 78 | { |
||
| 79 | return $this->title; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @return int |
||
| 84 | */ |
||
| 85 | public function getCode() : int |
||
| 86 | { |
||
| 87 | return $this->code; |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @return null|string |
||
| 92 | */ |
||
| 93 | public function getMessage() |
||
| 94 | { |
||
| 95 | return $this->message; |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @return TypeDoc|null |
||
| 100 | */ |
||
| 101 | public function getDataDoc() |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @return string |
||
| 108 | */ |
||
| 109 | public function getIdentifier() : string |
||
| 112 | } |
||
| 113 | } |
||
| 114 |