@@ -42,7 +42,7 @@ public static function from(mixed $value): Row
42
42
});
43
43
}
44
44
45
- private function __construct (private readonly array |object $ record )
45
+ private function __construct (private readonly array |object $ row )
46
46
{
47
47
}
48
48
@@ -51,7 +51,7 @@ private function __construct(private readonly array|object $record)
51
51
*
52
52
* @throws ReflectionException
53
53
* @throws QueryException If the value can not be retrieved
54
- *@see Row::select()
54
+ * @see Row::select()
55
55
*
56
56
*/
57
57
public function value (string |int $ key ): mixed
@@ -74,8 +74,8 @@ public function value(string|int $key): mixed
74
74
public function select (string |int ...$ key ): array
75
75
{
76
76
return match (true ) {
77
- is_object ($ this ->record ) => self ::getObjectPropertyValue ($ this ->record , ...$ key ),
78
- default => self ::getArrayEntry ($ this ->record , ...$ key ),
77
+ is_object ($ this ->row ) => self ::getObjectPropertyValue ($ this ->row , ...$ key ),
78
+ default => self ::getArrayEntry ($ this ->row , ...$ key ),
79
79
};
80
80
}
81
81
@@ -84,26 +84,26 @@ public function select(string|int ...$key): array
84
84
*
85
85
* @return non-empty-array<array-key, mixed>
86
86
*/
87
- private function getArrayEntry (array $ value , string |int ...$ keys ): array
87
+ private function getArrayEntry (array $ row , string |int ...$ keys ): array
88
88
{
89
89
$ res = [];
90
- $ arrValues = array_values ($ value );
90
+ $ arrValues = array_values ($ row );
91
91
foreach ($ keys as $ key ) {
92
92
if (array_key_exists ($ key , $ res )) {
93
93
continue ;
94
94
}
95
95
$ offset = $ key ;
96
96
if (is_int ($ offset )) {
97
- if (!array_is_list ($ value )) {
98
- $ value = $ arrValues ;
97
+ if (!array_is_list ($ row )) {
98
+ $ row = $ arrValues ;
99
99
}
100
100
101
101
if ($ offset < 0 ) {
102
- $ offset += count ($ value );
102
+ $ offset += count ($ row );
103
103
}
104
104
}
105
105
106
- $ res [$ key ] = array_key_exists ($ offset , $ value ) ? $ value [$ offset ] : throw QueryException::dueToUnknownColumn ($ key , $ value );
106
+ $ res [$ key ] = array_key_exists ($ offset , $ row ) ? $ row [$ offset ] : throw QueryException::dueToUnknownColumn ($ key , $ row );
107
107
}
108
108
109
109
return [] !== $ res ? $ res : throw QueryException::dueToMissingColumn ();
@@ -115,21 +115,21 @@ private function getArrayEntry(array $value, string|int ...$keys): array
115
115
*
116
116
* @return non-empty-array<array-key, mixed>
117
117
*/
118
- private static function getObjectPropertyValue (object $ value , string |int ...$ keys ): array
118
+ private static function getObjectPropertyValue (object $ row , string |int ...$ keys ): array
119
119
{
120
120
$ res = [];
121
- $ refl = new ReflectionObject ($ value );
121
+ $ object = new ReflectionObject ($ row );
122
122
foreach ($ keys as $ key ) {
123
123
if (array_key_exists ($ key , $ res )) {
124
124
continue ;
125
125
}
126
126
127
127
if (is_int ($ key )) {
128
- throw QueryException::dueToUnknownColumn ($ key , $ value );
128
+ throw QueryException::dueToUnknownColumn ($ key , $ row );
129
129
}
130
130
131
- if ($ refl ->hasProperty ($ key ) && $ refl ->getProperty ($ key )->isPublic ()) {
132
- $ res [$ key ] = $ refl ->getProperty ($ key )->getValue ($ value );
131
+ if ($ object ->hasProperty ($ key ) && $ object ->getProperty ($ key )->isPublic ()) {
132
+ $ res [$ key ] = $ object ->getProperty ($ key )->getValue ($ row );
133
133
continue ;
134
134
}
135
135
@@ -139,26 +139,26 @@ private static function getObjectPropertyValue(object $value, string|int ...$key
139
139
}
140
140
$ methodNameList [] = self ::camelCase ($ key , 'get ' );
141
141
foreach ($ methodNameList as $ methodName ) {
142
- if ($ refl ->hasMethod ($ methodName )
143
- && $ refl ->getMethod ($ methodName )->isPublic ()
144
- && 1 > $ refl ->getMethod ($ methodName )->getNumberOfRequiredParameters ()
142
+ if ($ object ->hasMethod ($ methodName )
143
+ && $ object ->getMethod ($ methodName )->isPublic ()
144
+ && 1 > $ object ->getMethod ($ methodName )->getNumberOfRequiredParameters ()
145
145
) {
146
- $ res [$ key ] = $ refl ->getMethod ($ methodName )->invoke ($ value );
146
+ $ res [$ key ] = $ object ->getMethod ($ methodName )->invoke ($ row );
147
147
continue 2 ;
148
148
}
149
149
}
150
150
151
- if (method_exists ($ value , '__call ' )) {
152
- $ res [$ key ] = $ refl ->getMethod ('__call ' )->invoke ($ value , $ methodNameList [1 ]);
151
+ if (method_exists ($ row , '__call ' )) {
152
+ $ res [$ key ] = $ object ->getMethod ('__call ' )->invoke ($ row , $ methodNameList [1 ]);
153
153
continue ;
154
154
}
155
155
156
- if ($ value instanceof ArrayAccess && $ value ->offsetExists ($ key )) {
157
- $ res [$ key ] = $ value ->offsetGet ($ key );
156
+ if ($ row instanceof ArrayAccess && $ row ->offsetExists ($ key )) {
157
+ $ res [$ key ] = $ row ->offsetGet ($ key );
158
158
continue ;
159
159
}
160
160
161
- throw QueryException::dueToUnknownColumn ($ key , $ value );
161
+ throw QueryException::dueToUnknownColumn ($ key , $ row );
162
162
}
163
163
164
164
return [] !== $ res ? $ res : throw QueryException::dueToMissingColumn ();
0 commit comments