URLExtractor
in package
implements
ClientInterface
A client that follows redirects until it reaches a non-30x response, e.g. to extract shortened URLs
The given HTTP client needs to be set up accordingly:
- CURLOPT_FOLLOWLOCATION must be set to false so that we can intercept the 30x responses
- CURLOPT_MAXREDIRS should be set to a value > 1
Table of Contents
Interfaces
- ClientInterface
Properties
- $http : ClientInterface
- $requestFactory : RequestFactoryInterface
- $responses : array<string|int, ResponseInterface>
Methods
- __construct() : mixed
- URLExtractor constructor.
- extract() : string|null
- extract the given URL and return the last valid location header
- getResponses() : array<string|int, ResponseInterface>
- sendRequest() : ResponseInterface
Properties
$http
protected
ClientInterface
$http
$requestFactory
protected
RequestFactoryInterface
$requestFactory
$responses
protected
array<string|int, ResponseInterface>
$responses
= []
Methods
__construct()
URLExtractor constructor.
public
__construct(ClientInterface $http, RequestFactoryInterface $requestFactory) : mixed
Parameters
- $http : ClientInterface
- $requestFactory : RequestFactoryInterface
extract()
extract the given URL and return the last valid location header
public
extract(UriInterface|string $shortURL) : string|null
Parameters
- $shortURL : UriInterface|string
Return values
string|nullgetResponses()
public
getResponses() : array<string|int, ResponseInterface>
Return values
array<string|int, ResponseInterface>sendRequest()
public
sendRequest(RequestInterface $request) : ResponseInterface
Parameters
- $request : RequestInterface