Skip to content

Commit 7e06221

Browse files
authored
Feature/Add is method to Identifier contract. (#10)
- Now it is possible to use `is()` method to check if two identifiers are the same.
1 parent e13ed5a commit 7e06221

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Domain/Contracts/Identifier.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,13 @@ interface Identifier
2020
* @return string
2121
*/
2222
public function value(): string;
23+
24+
/**
25+
* Check if the given identifier is the same than the current one.
26+
*
27+
* @param Identifier $other
28+
*
29+
* @return bool
30+
*/
31+
public function is(Identifier $other): bool;
2332
}

src/Domain/ValueObjects/UUIDValue.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ public static function random(): self
7272
return new static(self::RANDOM);
7373
}
7474

75+
/**
76+
* Check if the given identifier is the same than the current one.
77+
*
78+
* @param Identifier $other
79+
*
80+
* @return bool
81+
*/
82+
public function is(Identifier $other): bool
83+
{
84+
return $this->equals($other);
85+
}
86+
7587
/**
7688
* To string method.
7789
*

0 commit comments

Comments
 (0)