FossabotCommander
class FossabotCommander implements FossabotCommander, LoggerAwareInterface (View source)
Main class to invoke a given \Brandon14\FossabotCommander\Contracts\FossabotCommand instance.
Traits
Constants
private FOSSABOT_API_VERSION |
Fossabot API version. |
private FOSSABOT_API_ROUTE |
Fossabot API route. |
private FOSSABOT_CONTEXT_ROUTE |
Fossabot context route. |
private FOSSABOT_VALIDATE_ROUTE |
Fossabot validate route. |
private FOSSABOT_API_BASE_URL |
Fossabot API base URL. |
Methods
Constructs a new FossabotCommander class.
Get \Psr\Http\Client\ClientInterface instance.
Set a new \Psr\Http\Client\ClientInterface instance.
Get \Psr\Http\Message\RequestFactoryInterface instance.
Set a new \Psr\Http\Message\RequestFactoryInterface instance.
Get \Psr\Log\LoggerInterface instance.
Fluent setter for setting a new \Psr\Log\LoggerInterface instance.
Enable logging. Will throw an \Brandon14\FossabotCommander\Contracts\Exceptions\NoValidLoggerProvidedException when enabling this without providing a valid \Psr\Log\LoggerInterface instance.
Disables logging for the \Brandon14\FossabotCommander\Contracts\FossabotCommander instance.
Sets whether to log or not for the \Brandon14\FossabotCommander\Contracts\FossabotCommander instance.
Gets the configured logging setting.
Will execute a given \Brandon14\FossabotCommander\Contracts\FossabotCommand instance. If this method throws a \Brandon14\FossabotCommander\Contracts\Exceptions\CannotValidateRequestException, then it was unable to verify that the request came from Fossabot, and should be treated as a critical error.
{@inheritDoc}
Gets general class information used for providing additional logging context.
Details
__construct(ClientInterface $httpClient, RequestFactoryInterface $requestFactory, LoggerInterface|null $logger = null, bool $logging = false)
Constructs a new FossabotCommander class.
ClientInterface
getHttpClient()
Get \Psr\Http\Client\ClientInterface instance.
FossabotCommander
setHttpClient(ClientInterface $httpClient)
Set a new \Psr\Http\Client\ClientInterface instance.
RequestFactoryInterface
getRequestFactory()
Get \Psr\Http\Message\RequestFactoryInterface instance.
FossabotCommander
setRequestFactory(RequestFactoryInterface $requestFactory)
Set a new \Psr\Http\Message\RequestFactoryInterface instance.
LoggerInterface|null
getLogger()
Get \Psr\Log\LoggerInterface instance.
FossabotCommander
setLog(LoggerInterface|null $logger)
Fluent setter for setting a new \Psr\Log\LoggerInterface instance.
FossabotCommander
enableLogging()
Enable logging. Will throw an \Brandon14\FossabotCommander\Contracts\Exceptions\NoValidLoggerProvidedException when enabling this without providing a valid \Psr\Log\LoggerInterface instance.
FossabotCommander
disableLogging()
Disables logging for the \Brandon14\FossabotCommander\Contracts\FossabotCommander instance.
FossabotCommander
setLogging(bool $logging)
Sets whether to log or not for the \Brandon14\FossabotCommander\Contracts\FossabotCommander instance.
If enabling, and no valid PSR logging is provided, it will throw an exception.
bool
getLogging()
Gets the configured logging setting.
string
runCommand(FossabotCommand|callable $command, string $customApiToken, bool $getContext = true)
Will execute a given \Brandon14\FossabotCommander\Contracts\FossabotCommand instance. If this method throws a \Brandon14\FossabotCommander\Contracts\Exceptions\CannotValidateRequestException, then it was unable to verify that the request came from Fossabot, and should be treated as a critical error.
If this method throws a \Brandon14\FossabotCommander\Contracts\Exceptions\RateLimitException then that means that Fossabot's API is throttling your requests, and you should check the rate limit parameters available in the exception to determine how to handle it.
To get the $customApiToken, you can obtain it from the Fossabot request header 'x-fossabot-customapitoken'.
void
log($level, $message, array $context = [])
{@inheritDoc}
array
getLoggingContext()
Gets general class information used for providing additional logging context.