mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-11 17:34:09 +02:00
update deps & install rector
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace DesignPatterns\More\Repository\Domain;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* This is a perfect example of a value object that is identifiable by it's value alone and
|
||||
* is guaranteed to be valid each time an instance is created. Another important property of value objects
|
||||
@@ -11,12 +13,9 @@ namespace DesignPatterns\More\Repository\Domain;
|
||||
*/
|
||||
class PostId
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
private int $id;
|
||||
|
||||
public static function fromInt(int $id)
|
||||
public static function fromInt(int $id): PostId
|
||||
{
|
||||
self::ensureIsValid($id);
|
||||
|
||||
@@ -36,7 +35,7 @@ class PostId
|
||||
private static function ensureIsValid(int $id)
|
||||
{
|
||||
if ($id <= 0) {
|
||||
throw new \InvalidArgumentException('Invalid PostId given');
|
||||
throw new InvalidArgumentException('Invalid PostId given');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user