44
55namespace TinyBlocks \Country ;
66
7- use TinyBlocks \Country \Internal \AlphaCode ;
87use TinyBlocks \Country \Internal \Exceptions \InvalidAlphaCode ;
98use TinyBlocks \Country \Internal \Exceptions \InvalidAlphaCodeImplementation ;
109use TinyBlocks \Country \Internal \Name ;
1110use TinyBlocks \Vo \ValueObject ;
1211use TinyBlocks \Vo \ValueObjectBehavior ;
1312
14- final class Country implements ValueObject
13+ final readonly class Country implements ValueObject
1514{
1615 use ValueObjectBehavior;
1716
18- private const ALPHA2_CODE_LENGTH = 2 ;
19-
2017 private function __construct (public string $ name , public Alpha2Code $ alpha2 , public Alpha3Code $ alpha3 )
2118 {
2219 }
2320
24- public static function from (AlphaCode $ alphaCode , string | null $ name = null ): Country
21+ public static function from (AlphaCode $ alphaCode , ? string $ name = null ): Country
2522 {
2623 $ name = empty ($ name )
2724 ? Name::fromAlphaCode (alphaCode: $ alphaCode )->value
@@ -38,9 +35,9 @@ public static function from(AlphaCode $alphaCode, string|null $name = null): Cou
3835 throw new InvalidAlphaCodeImplementation (class: $ alphaCode ::class);
3936 }
4037
41- public static function fromString (string $ alphaCode , string | null $ name = null ): Country
38+ public static function fromString (string $ alphaCode , ? string $ name = null ): Country
4239 {
43- $ alphaCodeFrom = strlen ($ alphaCode ) === self :: ALPHA2_CODE_LENGTH
40+ $ alphaCodeFrom = strlen ($ alphaCode ) === Alpha2Code:: CODE_LENGTH
4441 ? Alpha2Code::tryFrom (value: $ alphaCode )
4542 : Alpha3Code::tryFrom (value: $ alphaCode );
4643
0 commit comments