43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\Entities;
|
|
|
|
use Domain\Models\ValueObjects\Entities\ShopId;
|
|
use Shared\DDD\Entity;
|
|
|
|
/** @implements \Shared\DDD\Entity<\Domain\Models\ValueObjects\Entities\ShopId> */
|
|
final readonly class Shop implements Entity
|
|
{
|
|
public function __construct(
|
|
public ShopId $id,
|
|
public string $name,
|
|
public string $address,
|
|
public string $postcode,
|
|
public string $city,
|
|
public ?string $phone = null,
|
|
public ?string $latitude = null,
|
|
public ?string $longitude = null,
|
|
public bool $isDefault = false
|
|
) {
|
|
if (trim($name) === '') {
|
|
throw new \DomainException('name cannot be empty');
|
|
}
|
|
if (trim($address) === '') {
|
|
throw new \DomainException('address cannot be empty');
|
|
}
|
|
if (trim($postcode) === '') {
|
|
throw new \DomainException('postcode cannot be empty');
|
|
}
|
|
if (trim($city) === '') {
|
|
throw new \DomainException('city cannot be empty');
|
|
}
|
|
}
|
|
|
|
#[\Override]
|
|
public function id(): ShopId
|
|
{
|
|
return $this->id;
|
|
}
|
|
}
|