src/Utilities/Reflection.php
public static function getPropertyValue($source, $property, $force = false)
    {
        if (Regex::contains($property, '.')) {
            return self::getPropertyValueByPropertiesChain($source, $property, $force);
        }

        [
            $value,
            $valueFound,
        ] = self::getPropertyValueByReflectionProperty($source, $property);

        if (!$valueFound) {
            [
                $value,
                $valueFound,
            ] = self::getPropertyValueByParentClasses($source, $property);
        }

        if (!$valueFound && ($force || self::hasProperty($source, $property))) {
            [
                $value,
                $valueFound,
            ] = self::getPropertyValueByGetter($source, $property);
        }

        if (!$valueFound) {
            $byReflectionProperty = self::getPropertyValueByReflectionProperty($source, $property);
            $value = $byReflectionProperty[0];
        }

        return $value;
    }
public static function getPropertyValue($source, $property, $force = false)
    {
        if (Regex::contains($property, '.')) {
            return self::getPropertyValueByPropertiesChain($source, $property, $force);
        }

        [
            $value,
            $valueFound,
        ] = self::getPropertyValueByReflectionProperty($source, $property);

        if (!$valueFound) {
            [
                $value,
                $valueFound,
            ] = self::getPropertyValueByParentClasses($source, $property);
        }

        if (!$valueFound && ($force || self::hasProperty($source, $property))) {
            [
                $value,
                $valueFound,
            ] = self::getPropertyValueByGetter($source, $property);
        }

        if (!$valueFound) {
            $byReflectionProperty = self::getPropertyValueByReflectionProperty($source, $property);
            $value = $byReflectionProperty[0];
        }

        return $value;
    }
public static function getPropertyValue ( $ source , $ property , $ force = false ) { if ( Regex :: contains ( $ property , '.' ) ) { return self :: getPropertyValueByPropertiesChain ( $ source , $ property , $ force ) ; } [ $ value , $ valueFound , ] = self :: getPropertyValueByReflectionProperty ( $ source , $ property ) ; if ( ! $ valueFound ) { [ $ value , $ valueFound , ] = self :: getPropertyValueByParentClasses ( $ source , $ property ) ; } if ( ! $ valueFound && ( $ force || self :: hasProperty ( $ source , $ property ) ) ) { [ $ value , $ valueFound , ] = self :: getPropertyValueByGetter ( $ source , $ property ) ; } if ( ! $ valueFound ) { $ byReflectionProperty = self :: getPropertyValueByReflectionProperty ( $ source , $ property ) ; $ value = $ byReflectionProperty [ 0 ] ; } return $ value ; }
Returns value of given property

@param mixed  $source   Object that should contains given property
@param string $property Name of the property that contains a value. It may be also multiple properties
dot-separated, e.g. "invoice.user.email".
@param bool   $force    (optional) If is set to true, try to retrieve value even if the object doesn't have
property. Otherwise - not.
@return mixed
Returns value of given property