ResolverApi
in package
Private helper which treats an API as a callable function.
Table of Contents
Properties
- $url : array<string|int, mixed>
Methods
- __construct() : mixed
- Class constructor.
- __invoke() : mixed
- Fire an API call.
- createPlaceholders() : array<string|int, mixed>
- Create placeholders.
- interpolate() : mixed
- Recursively interpolate values.
Properties
$url
private
array<string|int, mixed>
$url
- string scheme
- string host
- string path
- string query (optional)
Methods
__construct()
Class constructor.
public
__construct(array<string|int, mixed> $url) : mixed
Parameters
- $url : array<string|int, mixed>
-
Parsed URL (e.g. "api3://EntityName/action?foo=bar").
Tags
__invoke()
Fire an API call.
public
__invoke() : mixed
createPlaceholders()
Create placeholders.
protected
createPlaceholders(string $prefix, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $prefix : string
- $args : array<string|int, mixed>
-
Positional arguments.
Return values
array<string|int, mixed> —Named placeholders based on the positional arguments (e.g. "@1" => "firstValue").
interpolate()
Recursively interpolate values.
protected
interpolate(array<string|int, mixed> &$array, array<string|int, mixed> $replacements) : mixed
$params = array('foo' => '@1');
$this->interpolate($params, array('@1'=> $object))
assert $data['foo'] == $object;
Parameters
- $array : array<string|int, mixed>
-
Array which may or many not contain a mix of tokens.
- $replacements : array<string|int, mixed>
-
A list of tokens to substitute.