SimpleSAML_Configuration::getEndpointPrioritizedByBinding PHP Method

getEndpointPrioritizedByBinding() public method

Find an endpoint of the given type, using a list of supported bindings as a way to prioritize.
public getEndpointPrioritizedByBinding ( string $endpointType, array $bindings, mixed $default = self::REQUIRED_OPTION ) : array | null
$endpointType string The endpoint type.
$bindings array Sorted array of acceptable bindings.
$default mixed The default value to return if no matching endpoint is found. If no default is provided, an exception will be thrown.
return array | null The default endpoint, or null if no acceptable endpoints are used.
    public function getEndpointPrioritizedByBinding($endpointType, array $bindings, $default = self::REQUIRED_OPTION)
    {
        assert('is_string($endpointType)');
        $endpoints = $this->getEndpoints($endpointType);
        foreach ($bindings as $binding) {
            foreach ($endpoints as $ep) {
                if ($ep['Binding'] === $binding) {
                    return $ep;
                }
            }
        }
        if ($default === self::REQUIRED_OPTION) {
            $loc = $this->location . '[' . var_export($endpointType, true) . ']:';
            throw new Exception($loc . 'Could not find a supported ' . $endpointType . ' endpoint.');
        }
        return $default;
    }