Completed
Push — master ( 69c63f...51b5f1 )
by Thibaud
8s
created

GuzzleReaderFactory::getReader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Alchemy\Zippy\Resource\Reader\Guzzle;
4
5
use Alchemy\Zippy\Resource\Resource;
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 \Alchemy\Zippy\Resource\Resource $resource
29
     * @param string $context
30
     * @return ResourceReader
31
     */
32
    public function getReader(Resource $resource, $context)
33
    {
34
        return new GuzzleReader($resource, $this->client);
35
    }
36
}
37