1 | <?php declare(strict_types=1); |
||
2 | |||
3 | namespace Igni\Storage\Id; |
||
4 | |||
5 | use Igni\Storage\Exception\MappingException; |
||
6 | use Igni\Util\UuidGenerator; |
||
7 | use InvalidArgumentException; |
||
8 | |||
9 | class Uuid extends GenericId |
||
10 | { |
||
11 | private $long; |
||
12 | |||
13 | 9 | public function __construct(string $value = null) |
|
14 | { |
||
15 | 9 | if ($value === null) { |
|
16 | 6 | $value = UuidGenerator::generate(); |
|
17 | 6 | $this->long = $value; |
|
18 | 6 | return parent::__construct(UuidGenerator::toShort($value)); |
|
0 ignored issues
–
show
|
|||
19 | } |
||
20 | |||
21 | 3 | $uuid = (string) $value; |
|
22 | 3 | $short = (string) $value; |
|
23 | |||
24 | try { |
||
25 | 3 | if (!UuidGenerator::validate($uuid)) { |
|
26 | 3 | $uuid = UuidGenerator::fromShort($uuid); |
|
27 | } else { |
||
28 | 2 | $short = UuidGenerator::toShort($short); |
|
29 | } |
||
30 | 1 | } catch (InvalidArgumentException $exception) { |
|
31 | 1 | throw MappingException::forInvalidUuid($value); |
|
32 | } |
||
33 | |||
34 | 2 | if (!UuidGenerator::validate($uuid)) { |
|
35 | 1 | throw MappingException::forInvalidUuid($value); |
|
36 | } |
||
37 | |||
38 | 1 | $this->long = $uuid; |
|
39 | 1 | parent::__construct($short); |
|
40 | 1 | } |
|
41 | |||
42 | 2 | public function getShort(): string |
|
43 | { |
||
44 | 2 | return $this->getValue(); |
|
45 | } |
||
46 | |||
47 | 2 | public function getLong(): string |
|
48 | { |
||
49 | 2 | return $this->long; |
|
50 | } |
||
51 | } |
||
52 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.