| Conditions | 5 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | 74 | public function setId(string $id = null) |
|
| 38 | { |
||
| 39 | 74 | $uuid = null; |
|
| 40 | 74 | if ($id === null || $id === '') { |
|
| 41 | 47 | $uuid = Uuid::uuid4(); |
|
| 42 | } else { |
||
| 43 | 61 | if (Uuid::isValid($id)) { |
|
| 44 | 60 | $uuid = Uuid::fromString($id); |
|
| 45 | } else { |
||
| 46 | 1 | throw new InvalidUuidStringException('Invalid string'); |
|
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | 73 | if ($uuid->getVersion() !== Uuid::uuid4()->getVersion()) { |
|
| 51 | 1 | throw new InvalidUuidStringException('Not supported version: '.$uuid->getVersion()); |
|
| 52 | } |
||
| 53 | |||
| 54 | 72 | $this->id = $uuid; |
|
| 55 | 72 | } |
|
| 56 | } |
||
| 57 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.