File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -313,7 +313,9 @@ public function __unserialize(array $data): void
313313 public static function parse (self |string |int |null $ rut ): static
314314 {
315315 // No need to parse a Rut that is already a Rut object.
316- return $ rut instanceof static ? $ rut : new static (...static ::split ($ rut ));
316+ return $ rut instanceof static
317+ ? new static ($ rut ->num , $ rut ->vd )
318+ : new static (...static ::split ($ rut ));
317319 }
318320
319321 /**
Original file line number Diff line number Diff line change @@ -266,6 +266,16 @@ public function test_rut_serializes_to_raw_string(): void
266266 static ::assertTrue ($ rut ->isEqual (unserialize ($ serialized )));
267267 }
268268
269+ public function test_parses_instance_creating_new_instance (): void
270+ {
271+ $ first = new Rut (99637702 , 4 );
272+
273+ $ second = Rut::parse ($ first );
274+
275+ static ::assertEquals ($ first , $ second );
276+ static ::assertNotSame ($ first , $ second );
277+ }
278+
269279 public function test_parses_string (): void
270280 {
271281 $ rut = Rut::parse ('996377024 ' );
You can’t perform that action at this time.
0 commit comments