Total Complexity | 16 |
Total Lines | 77 |
Duplicated Lines | 0 % |
Coverage | 93.75% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | trait ValidatesReferences |
||
8 | { |
||
9 | 7 | public function isBind(mixed $value): bool |
|
10 | { |
||
11 | 7 | if (is_string($value)) { |
|
12 | 6 | return true; |
|
13 | } |
||
14 | 1 | if (is_object($value)) { |
|
15 | return true; |
||
16 | } |
||
17 | |||
18 | 1 | return false; |
|
19 | } |
||
20 | |||
21 | 1 | public function isCollectionBind(mixed $value): bool |
|
28 | } |
||
29 | |||
30 | 28 | public function isVariable(mixed $value): bool |
|
31 | { |
||
32 | 28 | if (is_string($value) && preg_match('/^\$?[a-zA-Z_][a-zA-Z0-9_]*+$/', $value)) { |
|
33 | 28 | return true; |
|
34 | } |
||
35 | |||
36 | 5 | return false; |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param array<mixed> $registeredVariables |
||
41 | */ |
||
42 | 1 | public function isRegisteredVariable( |
|
43 | mixed $value, |
||
44 | array $registeredVariables = [] |
||
45 | ): bool { |
||
46 | 1 | return isset($registeredVariables[$value]); |
|
47 | } |
||
48 | |||
49 | 1 | public function isAttribute(mixed $value): bool |
|
50 | { |
||
51 | 1 | $pattern = '/^(@?[\d\w_]+|`@?[\d\w_]+`)(\[\`.+\`\]|\[[\d\w\*]*\])*' |
|
52 | . '(\.(\`.+\`|@?[\d\w]*)(\[\`.+\`\]|\[[\d\w\*]*\])*)*$/'; |
||
53 | if ( |
||
54 | 1 | is_string($value) && |
|
55 | 1 | preg_match($pattern, $value) |
|
56 | ) { |
||
57 | 1 | return true; |
|
58 | } |
||
59 | |||
60 | 1 | return false; |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param array<mixed> $registeredVariables |
||
65 | */ |
||
66 | 25 | public function isReference( |
|
84 | ); |
||
85 | } |
||
86 | } |
||
87 |