Total Complexity | 3 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class Expression implements ExpressionInterface { |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $string; |
||
20 | |||
21 | /** |
||
22 | * Converts a camelCase method call to an UPPER_SNAKE_CASE function call, |
||
23 | * with all arguments separated by spaces. |
||
24 | * |
||
25 | * `NAME(argument [argument...])` |
||
26 | * |
||
27 | * @param string $name |
||
28 | * @param array $arguments |
||
29 | * @return ExpressionInterface |
||
30 | */ |
||
31 | public static function __callStatic (string $name, array $arguments): ExpressionInterface { |
||
32 | $arguments = implode(' ', $arguments); |
||
33 | $name = strtoupper(preg_replace('/(?<!^)[A-Z]/', '_$0', $name)); |
||
34 | return new static("{$name}({$arguments})"); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param string $string |
||
39 | */ |
||
40 | public function __construct (string $string) { |
||
41 | $this->string = $string; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | */ |
||
47 | public function __toString () { |
||
49 | } |
||
50 | } |