timiTao /
ValueObject
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace TimiTao\ValueObject\Beberlei\Nullable; |
||
| 6 | |||
| 7 | use DateTimeImmutable; |
||
| 8 | use Exception; |
||
| 9 | use TimiTao\ValueObject\Nullable\DateTime\TimestampValueObject as TimestampValueObjectInterface; |
||
| 10 | |||
| 11 | abstract class TimestampValueObject implements TimestampValueObjectInterface |
||
| 12 | { |
||
| 13 | private $value; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @throws Exception if value is invalid |
||
| 17 | */ |
||
| 18 | public function __construct(?DateTimeImmutable $value) |
||
| 19 | { |
||
| 20 | $this->guard($value); |
||
| 21 | $this->value = $value; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function getDateTime(): ?DateTimeImmutable |
||
| 25 | { |
||
| 26 | if ($this->value === null) { |
||
| 27 | return null; |
||
| 28 | } |
||
| 29 | return $this->value; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function equals(TimestampValueObjectInterface $other): bool |
||
| 33 | { |
||
| 34 | if (static::class !== get_class($other)) { |
||
| 35 | return false; |
||
| 36 | } |
||
| 37 | return $this->getValue() === $other->getValue(); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getValue(): ?int |
||
| 41 | { |
||
| 42 | return $this->value->getTimestamp(); |
||
|
0 ignored issues
–
show
|
|||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @throws Exception if value is invalid |
||
| 47 | */ |
||
| 48 | abstract protected function guard(?DateTimeImmutable $value): void; |
||
| 49 | } |
||
| 50 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.