Skip to content

Commit

Permalink
Feature/Add is method to Identifier contract. (#10)
Browse files Browse the repository at this point in the history
- Now it is possible to use `is()` method to check if two identifiers are the same.
  • Loading branch information
othercodes authored Jan 15, 2021
1 parent e13ed5a commit 7e06221
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Domain/Contracts/Identifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
12 changes: 12 additions & 0 deletions src/Domain/ValueObjects/UUIDValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 7e06221

Please sign in to comment.