• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NIT-Administrative-Systems / SysDev-EventHub-PHP-SDK / 7803610125

06 Feb 2024 05:22PM UTC coverage: 83.74% (-2.0%) from 85.714%
7803610125

push

github

nie7321
Remove composer.lock

Not useful for a library to have one

103 of 123 relevant lines covered (83.74%)

42.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Guzzle/RetryClient.php
1
<?php
2

3
namespace Northwestern\SysDev\SOA\EventHub\Guzzle;
4

5
use GuzzleHttp\Client;
6
use GuzzleHttp\HandlerStack;
7
use GuzzleHttp\Handler\CurlHandler;
8
use GuzzleHttp\Exception\ConnectException;
9
use GuzzleHttp\Exception\RequestException;
10
use GuzzleHttp\Psr7\Request as Psr7Request;
11
use GuzzleHttp\Psr7\Response as Psr7Response;
12

13
class RetryClient
14
{
15
    const MAX_RETRIES = 3;
16
    protected $client;
17

18
    public static function make()
19
    {
20
        $factory = new self();
×
21

22
        return $factory->getClient();
×
23
    } // end make
24

25
    public function __construct()
26
    {
27
        $this->client = $this->createHttpClient();
×
28
    } // end __construct
29

30
    public function getClient()
31
    {
32
        return $this->client;
×
33
    } // end getClient
34

35
    protected function createHttpClient()
36
    {
37
        $stack = HandlerStack::create(new CurlHandler());
×
38
        $stack->push(\GuzzleHttp\Middleware::retry($this->createRetryHandler()));
×
39
        $client = new Client([
×
40
            'handler' => $stack,
×
41
        ]);
×
42

43
        return $client;
×
44
    } // end createHttpClient
45

46
    protected function createRetryHandler()
47
    {
48
        return function ($retries, Psr7Request $request, Psr7Response $response = null, RequestException $exception = null) {
×
49
            if ($retries >= self::MAX_RETRIES) {
×
50
                return false;
×
51
            }
52

53
            return $this->isConnectError($exception);
×
54
        };
×
55
    } // end createRetryHandler
56

57
    protected function isConnectError(RequestException $exception = null)
58
    {
59
        return $exception instanceof ConnectException;
×
60
    } // end isConnectError
61

62
} // end RetryClient
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc