File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 55namespace Longman \LaravelLodash \Testing ;
66
77use InvalidArgumentException ;
8+ use Longman \LaravelLodash \Support \Str ;
89
910use function array_shift ;
11+ use function call_user_func_array ;
1012use function explode ;
13+ use function get_called_class ;
1114use function is_callable ;
15+ use function lcfirst ;
16+ use function property_exists ;
1217use function str_contains ;
1318use function str_starts_with ;
1419use function trim ;
1520
1621abstract class DataStructuresProvider
1722{
23+ public static function __callStatic (string $ name , array $ arguments ): mixed
24+ {
25+ $ property = lcfirst (Str::substr ($ name , 3 ));
26+ if (! property_exists (get_called_class (), $ property )) {
27+ throw new InvalidArgumentException ('Property " ' . $ property . '" does not exists ' );
28+ }
29+ $ structure = static ::$ $ property ;
30+
31+ $ parameters = [&$ structure , $ arguments [0 ] ?? []];
32+ call_user_func_array ([get_called_class (), 'includeNestedRelations ' ], $ parameters );
33+
34+ return $ structure ;
35+ }
36+
1837 protected static function includeNestedRelations (array &$ item , array $ relations ): void
1938 {
2039 if (empty ($ relations )) {
You can’t perform that action at this time.
0 commit comments