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 5
5
namespace Longman \LaravelLodash \Testing ;
6
6
7
7
use InvalidArgumentException ;
8
+ use Longman \LaravelLodash \Support \Str ;
8
9
9
10
use function array_shift ;
11
+ use function call_user_func_array ;
10
12
use function explode ;
13
+ use function get_called_class ;
11
14
use function is_callable ;
15
+ use function lcfirst ;
16
+ use function property_exists ;
12
17
use function str_contains ;
13
18
use function str_starts_with ;
14
19
use function trim ;
15
20
16
21
abstract class DataStructuresProvider
17
22
{
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
+
18
37
protected static function includeNestedRelations (array &$ item , array $ relations ): void
19
38
{
20
39
if (empty ($ relations )) {
You can’t perform that action at this time.
0 commit comments