| Total Complexity | 5 |
| Total Lines | 70 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 4 | ||
| Bugs | 1 | Features | 3 |
| 1 | <?php |
||
| 14 | class Status |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Set for a new message |
||
| 18 | */ |
||
| 19 | public const NEW = 'NEW'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Set for a message that is being processed |
||
| 23 | */ |
||
| 24 | public const IN_PROCESS = 'IN_PROCESS'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Set for a message for which an error occurred |
||
| 28 | */ |
||
| 29 | public const FAILURE = 'FAILURE'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Set for a message to be redelivered to the queue |
||
| 33 | */ |
||
| 34 | public const REDELIVERED = 'REDELIVERED'; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Set for a message if there is no processor or job |
||
| 38 | */ |
||
| 39 | public const UNDEFINED_HANDLER = 'UNDEFINED_HANDLER'; |
||
| 40 | |||
| 41 | /** @var string */ |
||
| 42 | private string $status; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Status constructor. |
||
| 46 | * @param string $value |
||
| 47 | */ |
||
| 48 | 44 | public function __construct(string $value) |
|
| 49 | { |
||
| 50 | 44 | if (in_array($value, self::getStatuses(), true) === false) { |
|
| 51 | 1 | throw new InvalidArgumentException(sprintf('"%s" is not a valid message status.', $value)); |
|
| 52 | } |
||
| 53 | |||
| 54 | 43 | $this->status = $value; |
|
| 55 | 43 | } |
|
| 56 | |||
| 57 | /** |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | 20 | public function __toString(): string |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @return string |
||
| 67 | */ |
||
| 68 | 4 | public function getValue(): string |
|
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @return array |
||
| 75 | */ |
||
| 76 | 44 | public static function getStatuses(): array |
|
| 87 |