GuzzleReaderFactory::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Alchemy\Zippy\Resource\Reader\Guzzle;
4
5
use Alchemy\Zippy\Resource\Resource as ZippyResource;
6
use Alchemy\Zippy\Resource\ResourceReader;
7
use Alchemy\Zippy\Resource\ResourceReaderFactory;
8
use GuzzleHttp\Client;
9
use GuzzleHttp\ClientInterface;
10
11
class GuzzleReaderFactory implements ResourceReaderFactory
12
{
13
    /**
14
     * @var ClientInterface|null
15
     */
16
    private $client = null;
17
18
    public function __construct(ClientInterface $client = null)
19
    {
20
        $this->client = $client;
21
22
        if (! $this->client) {
23
            $this->client = new Client();
24
        }
25
    }
26
27
    /**
28
     * @param ZippyResource $resource
29
     * @param string        $context
30
     *
31
     * @return ResourceReader
32
     */
33
    public function getReader(ZippyResource $resource, $context)
34
    {
35
        return new GuzzleReader($resource, $this->client);
36
    }
37
}
38