Psecio\PropAuth\Enforcer::getPropertyValue PHP Method

getPropertyValue() public method

Type a few options to get the property value for evaluation
public getPropertyValue ( string $type, object $subject ) : mixed
$type string Type of check being performed
$subject object Object to get the property value from
return mixed Either the found property value or null if not found
    public function getPropertyValue($type, $subject)
    {
        $method = 'get' . ucwords(strtolower($type));
        $propertyValue = null;
        if ($type !== 'closure' && $type !== 'method' && (isset($subject->{$type}) && $subject->{$type} !== null)) {
            $propertyValue = $subject->{$type};
        } elseif (method_exists($subject, $method)) {
            $propertyValue = $subject->{$method}();
        } elseif (method_exists($subject, 'getProperty')) {
            $propertyValue = $subject->getProperty($type);
        }
        return $propertyValue;
    }