src/Utilities/Reflection.php
private static function getPropertyValueByGetter($source, string $property): array
    {
        $value = null;
        $valueFound = false;

        $reflectionObject = new \ReflectionObject($source);
        $property = Inflector::classify($property);

        $gettersPrefixes = [
            'get',
            'has',
            'is',
        ];

        foreach ($gettersPrefixes as $prefix) {
            $getter = sprintf('%s%s', $prefix, $property);

            if ($reflectionObject->hasMethod($getter)) {
                $method = new \ReflectionMethod($source, $getter);

                /*
                 * Getter is not accessible publicly?
                 * I have to skip it, to avoid an error like this:
                 *
                 * Call to protected method My\ExtraClass::getExtraProperty() from context 'My\ExtraClass'
                 */
                if ($method->isProtected() || $method->isPrivate()) {
                    continue;
                }

                $value = $source->{$getter}();
                $valueFound = true;

                break;
            }
        }

        return [
            $value,
            $valueFound,
        ];
    }
private static function getPropertyValueByGetter($source, string $property): array
    {
        $value = null;
        $valueFound = false;

        $reflectionObject = new \ReflectionObject($source);
        $property = Inflector::classify($property);

        $gettersPrefixes = [
            'get',
            'has',
            'is',
        ];

        foreach ($gettersPrefixes as $prefix) {
            $getter = sprintf('%s%s', $prefix, $property);

            if ($reflectionObject->hasMethod($getter)) {
                $method = new \ReflectionMethod($source, $getter);

                /*
                 * Getter is not accessible publicly?
                 * I have to skip it, to avoid an error like this:
                 *
                 * Call to protected method My\ExtraClass::getExtraProperty() from context 'My\ExtraClass'
                 */
                if ($method->isProtected() || $method->isPrivate()) {
                    continue;
                }

                $value = $source->{$getter}();
                $valueFound = true;

                break;
            }
        }

        return [
            $value,
            $valueFound,
        ];
    }
private static function getPropertyValueByGetter ( $ source , string $ property ) : array { $ value = null ; $ valueFound = false ; $ reflectionObject = new \ ReflectionObject ( $ source ) ; $ property = Inflector :: classify ( $ property ) ; $ gettersPrefixes = [ 'get' , 'has' , 'is' , ] ; foreach ( $ gettersPrefixes as $ prefix ) { $ getter = sprintf ( '%s%s' , $ prefix , $ property ) ; if ( $ reflectionObject -> hasMethod ( $ getter ) ) { $ method = new \ ReflectionMethod ( $ source , $ getter ) ; /*
                 * Getter is not accessible publicly?
                 * I have to skip it, to avoid an error like this:
                 *
                 * Call to protected method My\ExtraClass::getExtraProperty() from context 'My\ExtraClass'
                 */ if ( $ method -> isProtected ( ) || $ method -> isPrivate ( ) ) { continue ; } $ value = $ source -> { $ getter } ( ) ; $ valueFound = true ; break ; } } return [ $ value , $ valueFound , ] ; }
Returns value of given property using getter of the property

An array with 2 elements is returned:
- value of given property
- information if the value was found (because null may be returned)

@param mixed  $source   Object that should contains given property
@param string $property Name of the property that contains a value
@return array
Returns value of given property using getter of the property