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

contributte / guzzlette / 4645098303

pending completion
4645098303

push

github

Milan Felix Ć ulc
Composer: allow nette/utils 4.x

128 of 150 relevant lines covered (85.33%)

0.85 hits per line

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

88.24
/src/ClientFactory.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Guzzlette;
4

5
use GuzzleHttp\Client;
6
use GuzzleHttp\HandlerStack;
7

8
class ClientFactory
9
{
10

11
        public const FORCE_REQUEST_COLLECTION = true;
12

13
        private SnapshotStack $snapshotStack;
14

15
        private bool $debug;
16

17
        public function __construct(SnapshotStack $snapshotStack, bool $debug = false)
1✔
18
        {
19
                $this->snapshotStack = $snapshotStack;
1✔
20
                $this->debug = $debug;
1✔
21
        }
1✔
22

23
        /**
24
         * @param mixed[] $config
25
         */
26
        public function createClient(array $config = []): Client
1✔
27
        {
28
                if ($this->debug) {
1✔
29
                        $handlerStack = $config['handler'] ?? null;
1✔
30
                        if (!($handlerStack instanceof HandlerStack)) {
1✔
31
                                $handlerStack = null;
×
32
                        }
33

34
                        $config['handler'] = $this->createHandlerStack($handlerStack);
1✔
35
                }
36

37
                return new Client($config);
1✔
38
        }
39

40
        private function createHandlerStack(?HandlerStack $handlerStack = null): HandlerStack
1✔
41
        {
42
                if ($handlerStack === null) {
1✔
43
                        $handlerStack = HandlerStack::create();
×
44
                }
45

46
                $handler = new GuzzleHandler($this->snapshotStack);
1✔
47
                $handlerStack->push($handler);
1✔
48

49
                return $handlerStack;
1✔
50
        }
51

52
}
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