for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Gelf\Transport;
use Closure;
use Gelf\MessageInterface as Message;
use Throwable;
class RetryTransportWrapper implements TransportInterface
{
protected Closure $exceptionMatcher;
/**
* KeepAliveRetryTransportWrapper constructor.
*
* @param null|callable(Throwable):bool $exceptionMatcher
*/
public function __construct(
private TransportInterface $transport,
private int $maxRetries,
?callable $exceptionMatcher = null
) {
$this->exceptionMatcher = Closure::fromCallable($exceptionMatcher ?? fn (Throwable $_) => true);
$_
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
$this->exceptionMatcher = Closure::fromCallable($exceptionMatcher ?? fn (/** @scrutinizer ignore-unused */ Throwable $_) => true);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
}
public function getTransport(): TransportInterface
return $this->transport;
* @inheritDoc
public function send(Message $message): int
$tries = 0;
while (true) {
try {
$tries++;
return $this->transport->send($message);
} catch (Throwable $e) {
if ($this->maxRetries !== 0 && $tries > $this->maxRetries) {
throw $e;
if (!call_user_func($this->exceptionMatcher, $e)) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.