From 7e062218e391725dcd4ffb735a440aee125ea9d3 Mon Sep 17 00:00:00 2001 From: Unay Santisteban Date: Fri, 15 Jan 2021 16:35:11 +0100 Subject: [PATCH] Feature/Add is method to Identifier contract. (#10) - Now it is possible to use `is()` method to check if two identifiers are the same. --- src/Domain/Contracts/Identifier.php | 9 +++++++++ src/Domain/ValueObjects/UUIDValue.php | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Domain/Contracts/Identifier.php b/src/Domain/Contracts/Identifier.php index 73ba2e4..02f9286 100644 --- a/src/Domain/Contracts/Identifier.php +++ b/src/Domain/Contracts/Identifier.php @@ -20,4 +20,13 @@ interface Identifier * @return string */ public function value(): string; + + /** + * Check if the given identifier is the same than the current one. + * + * @param Identifier $other + * + * @return bool + */ + public function is(Identifier $other): bool; } diff --git a/src/Domain/ValueObjects/UUIDValue.php b/src/Domain/ValueObjects/UUIDValue.php index 72a9fe3..91b1a98 100644 --- a/src/Domain/ValueObjects/UUIDValue.php +++ b/src/Domain/ValueObjects/UUIDValue.php @@ -72,6 +72,18 @@ public static function random(): self return new static(self::RANDOM); } + /** + * Check if the given identifier is the same than the current one. + * + * @param Identifier $other + * + * @return bool + */ + public function is(Identifier $other): bool + { + return $this->equals($other); + } + /** * To string method. *