Completed
Branch full-rewrite (4754d3)
by Thibaud
03:13
created

GuzzleReaderFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
wmc 3
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getReader() 0 4 1
1
<?php
2
3
namespace Alchemy\Zippy\Adapter\Guzzle;
4
5
use Alchemy\Zippy\Adapter\Guzzle\GuzzleReader;
6
use Alchemy\Zippy\Resource\Resource;
7
use Alchemy\Zippy\Resource\ResourceReader;
8
use Alchemy\Zippy\Resource\ResourceReaderFactory;
9
use Alchemy\Zippy\Resource\ResourceUri;
10
use GuzzleHttp\Client;
11
use GuzzleHttp\ClientInterface;
12
13
class GuzzleReaderFactory implements ResourceReaderFactory
14
{
15
    /**
16
     * @var ClientInterface|null
17
     */
18
    private $client = null;
19
20
    public function __construct(ClientInterface $client = null)
21
    {
22
        $this->client = $client;
23
24
        if (! $this->client) {
25
            $this->client = new Client();
26
        }
27
    }
28
29
    /**
30
     * @param ResourceUri $resource
31
     * @return ResourceReader
32
     */
33
    public function getReader(ResourceUri $resource)
34
    {
35
        return new GuzzleReader($resource, $this->client);
36
    }
37
}
38