Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| DurationDto | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | namespace Apie\Serializer\Dto; |
| 3 | |
| 4 | use Apie\Core\Dto\DtoInterface; |
| 5 | use Apie\Serializer\Exceptions\ValidationException; |
| 6 | use InvalidArgumentException; |
| 7 | |
| 8 | final class DurationDto implements DtoInterface |
| 9 | { |
| 10 | public function __construct( |
| 11 | public int $seconds, |
| 12 | public int $nanoseconds, |
| 13 | public bool $negative |
| 14 | ) { |
| 15 | if ($seconds < 0 || $seconds > 9223372035) { |
| 16 | throw ValidationException::createFromArray([ |
| 17 | 'seconds' => new InvalidArgumentException('Seconds should be between 0 and 9223372035') |
| 18 | ]); |
| 19 | } |
| 20 | if ($nanoseconds < 0 || $nanoseconds > 999999999) { |
| 21 | throw ValidationException::createFromArray([ |
| 22 | 'seconds' => new InvalidArgumentException('Nanoseconds should be between 0 and 999999999, got: ' . $nanoseconds) |
| 23 | ]); |
| 24 | } |
| 25 | } |
| 26 | } |