1414
1515class Attributesimplements Arrayable
1616{
17- private const RELATION_MARKER ='relations: ' ;
17+ private const string RELATION_MARKER ='relations: ' ;
18+ private const string DYNAMIC_COUNT_MARKER ='* ' ;
1819private array $ params ;
1920private array $ attributes = [];
2021/** @var array<self> */
@@ -97,7 +98,7 @@ private function parseParameters(array $params): void
9798$ attributes = [];
9899$ relations = [];
99100foreach ($ paramsas $ key =>$ data ) {
100- if (str_starts_with ($ key ,self ::RELATION_MARKER )) {
101+ if (str_starts_with (( string ) $ key ,self ::RELATION_MARKER )) {
101102$ ex =explode (': ' ,$ key );
102103if (!isset ($ ex [1 ])) {
103104throw new InvalidArgumentException ('Relation is empty ' );
@@ -106,9 +107,9 @@ private function parseParameters(array $params): void
106107$ relName =$ ex [1 ];
107108$ count =1 ;
108109if (isset ($ ex [2 ])) {
109- $ count = (int )$ ex [2 ];
110+ $ count =$ ex [ 2 ] === self :: DYNAMIC_COUNT_MARKER ? count ( $ data ) : (int )$ ex [2 ];
110111 }
111- $ attrs =$ params [ $ key ] ;
112+ $ attrs =$ data ;
112113
113114$ relations [$ relName ] =new self ($ attrs ,$ relName ,$ count );
114115 }else {