| @@ 204-224 (lines=21) @@ | ||
| 201 | * @param string $propertyName |
|
| 202 | * @return string|NULL |
|
| 203 | */ |
|
| 204 | protected function detectAccessor($subject, $propertyName) |
|
| 205 | { |
|
| 206 | if (is_array($subject) || ($subject instanceof \ArrayAccess && $subject->offsetExists($propertyName))) { |
|
| 207 | return self::ACCESSOR_ARRAY; |
|
| 208 | } |
|
| 209 | if (is_object($subject)) { |
|
| 210 | $upperCasePropertyName = ucfirst($propertyName); |
|
| 211 | $getter = 'get' . $upperCasePropertyName; |
|
| 212 | if (method_exists($subject, $getter)) { |
|
| 213 | return self::ACCESSOR_GETTER; |
|
| 214 | } |
|
| 215 | if ($this->isExtractableThroughAsserter($subject, $propertyName)) { |
|
| 216 | return self::ACCESSOR_ASSERTER; |
|
| 217 | } |
|
| 218 | if (property_exists($subject, $propertyName)) { |
|
| 219 | return self::ACCESSOR_PUBLICPROPERTY; |
|
| 220 | } |
|
| 221 | } |
|
| 222 | ||
| 223 | return null; |
|
| 224 | } |
|
| 225 | ||
| 226 | /** |
|
| 227 | * Tests whether a property can be extracted through `is*` or `has*` methods. |
|
| @@ 403-423 (lines=21) @@ | ||
| 400 | * @param string $propertyName |
|
| 401 | * @return string|NULL |
|
| 402 | */ |
|
| 403 | protected function detectAccessor($subject, $propertyName) |
|
| 404 | { |
|
| 405 | if (is_array($subject) || ($subject instanceof \ArrayAccess && $subject->offsetExists($propertyName))) { |
|
| 406 | return self::ACCESSOR_ARRAY; |
|
| 407 | } |
|
| 408 | if (is_object($subject)) { |
|
| 409 | $upperCasePropertyName = ucfirst($propertyName); |
|
| 410 | $getter = 'get' . $upperCasePropertyName; |
|
| 411 | if (method_exists($subject, $getter)) { |
|
| 412 | return self::ACCESSOR_GETTER; |
|
| 413 | } |
|
| 414 | if ($this->isExtractableThroughAsserter($subject, $propertyName)) { |
|
| 415 | return self::ACCESSOR_ASSERTER; |
|
| 416 | } |
|
| 417 | if (property_exists($subject, $propertyName)) { |
|
| 418 | return self::ACCESSOR_PUBLICPROPERTY; |
|
| 419 | } |
|
| 420 | } |
|
| 421 | ||
| 422 | return null; |
|
| 423 | } |
|
| 424 | ||
| 425 | /** |
|
| 426 | * Tests whether a property can be extracted through `is*` or `has*` methods. |
|