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

GuzzleReaderFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 26
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\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