22 lines
597 B
PHP
22 lines
597 B
PHP
<?php
|
|
|
|
namespace App\Domain\Location\Model;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
class Address
|
|
{
|
|
public function __construct(
|
|
public readonly string $addressLine,
|
|
public readonly City $city,
|
|
) {
|
|
if (strlen($addressLine) >= 100) {
|
|
throw new InvalidArgumentException('Address line cannot be longer than 100 characters');
|
|
}
|
|
}
|
|
|
|
public static function create(string $addressLine, string $city, string $countryAlpha2, ?string $zipCode = null): self
|
|
{
|
|
return new self($addressLine, City::create($city, $countryAlpha2, $zipCode));
|
|
}
|
|
} |