Psecio\PropAuth\Enforcer::executeTests PHP Method

executeTests() public method

Execute the tests on the policy to ensure they match/pass
public executeTests ( array $tests, string $type, string $propertyValue, array $addl ) : boolean
$tests array A set of Check instances to evaluate
$type string Type of tests to evaluate with
$propertyValue string Value to evaluate against
$addl array Additional values to pass through to the test
return boolean Pass/fail status of the evaluation (if exception not thrown)
    public function executeTests($tests, $type, $propertyValue, $addl)
    {
        $valueType = gettype($propertyValue);
        // Ensure all of the things in our policy are true
        foreach ($tests as $test) {
            // First check for a custom "tester"
            $typeNs = __NAMESPACE__ . '\\Test\\Test' . ucwords(strtolower($type));
            if (!class_exists($typeNs)) {
                $typeNs = __NAMESPACE__ . '\\Test\\Test' . ucwords(strtolower($valueType));
            }
            if (class_exists($typeNs)) {
                $testInstance = new $typeNs($test, $addl);
                if ($testInstance->evaluate($propertyValue) === false) {
                    return false;
                }
            } else {
                throw new \InvalidArgumentException('Test type "' . $valueType . '" does not exist.');
            }
        }
        return true;
    }