protected function getPropertyValue($object, string $propertyName, $default = null)
    {
        if (!is_object($object)) {
            throw new InvalidArgumentException('The first argument should be an object');
        }

        if (!property_exists($object, $propertyName)) {
            return $default;
        }

        try {
            $reflectionProperty = new ReflectionProperty($object, $propertyName);
            $reflectionProperty->setAccessible(true);

            return $reflectionProperty->getValue($object);
        } catch (ReflectionException $e) {
            return $default;
        }
    }
protected function getPropertyValue($object, string $propertyName, $default = null)
    {
        if (!is_object($object)) {
            throw new InvalidArgumentException('The first argument should be an object');
        }

        if (!property_exists($object, $propertyName)) {
            return $default;
        }

        try {
            $reflectionProperty = new ReflectionProperty($object, $propertyName);
            $reflectionProperty->setAccessible(true);

            return $reflectionProperty->getValue($object);
        } catch (ReflectionException $e) {
            return $default;
        }
    }
protected function getPropertyValue ( $ object , string $ propertyName , $ default = null ) { if ( ! is_object ( $ object ) ) { throw new InvalidArgumentException ( 'The first argument should be an object' ) ; } if ( ! property_exists ( $ object , $ propertyName ) ) { return $ default ; } try { $ reflectionProperty = new ReflectionProperty ( $ object , $ propertyName ) ; $ reflectionProperty -> setAccessible ( true ) ; return $ reflectionProperty -> getValue ( $ object ) ; } catch ( ReflectionException $ e ) { return $ default ; } }
Gets the value of a property of an object.

@param object     $object
@param string     $propertyName
@param mixed|null $default

@return mixed
Gets the value of a property of an object .