Submit
Path:
~
/
/
usr
/
local
/
psa
/
admin
/
plib
/
modules
/
wp-toolkit
/
vendor
/
cerbero
/
json-parser
/
src
/
Concerns
/
File Content:
GuzzleAware.php
<?php namespace WPToolkitDependenciesIsolationPrefix\Cerbero\JsonParser\Concerns; use WPToolkitDependenciesIsolationPrefix\Cerbero\JsonParser\Exceptions\GuzzleRequiredException; use WPToolkitDependenciesIsolationPrefix\GuzzleHttp\Client; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; /** * The Guzzle-aware trait. * */ trait GuzzleAware { /** * Abort if Guzzle is not loaded * * @return void * @throws GuzzleRequiredException */ protected function requireGuzzle() : void { if (!$this->guzzleIsInstalled()) { throw new GuzzleRequiredException(); } } /** * Determine whether Guzzle is installed * * @return bool */ protected function guzzleIsInstalled() : bool { return \class_exists(Client::class); } /** * Retrieve the JSON response of the given URL * * @param UriInterface|string $url * @return ResponseInterface */ protected function getJson(UriInterface|string $url) : ResponseInterface { return $this->guzzle()->get($url, ['headers' => ['Accept' => 'application/json', 'Content-Type' => 'application/json']]); } /** * Retrieve the Guzzle client * * @codeCoverageIgnore * @return Client */ protected function guzzle() : Client { return new Client(); } /** * Retrieve the JSON response of the given request * * @param RequestInterface $request * @return ResponseInterface */ protected function sendRequest(RequestInterface $request) : ResponseInterface { return $this->guzzle()->sendRequest($request); } }
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
DetectsEndpoints.php
534 bytes
0644
GuzzleAware.php
1741 bytes
0644
N4ST4R_ID | Naxtarrr