ClientFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createPiwikClient() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\PiwikBundle\Client;
13
14
use Core23\PiwikBundle\Connection\PiwikConnection;
15
use Http\Client\HttpClient;
16
use Http\Message\MessageFactory;
17
18
final class ClientFactory implements ClientFactoryInterface
19
{
20
    /**
21
     * @var HttpClient
22
     */
23
    private $client;
24
25
    /**
26
     * @var MessageFactory
27
     */
28
    private $messageFactory;
29
30
    /**
31
     * Initialize client.
32
     *
33
     * @param HttpClient     $client
34
     * @param MessageFactory $messageFactory
35
     */
36
    public function __construct(HttpClient $client, MessageFactory $messageFactory)
37
    {
38
        $this->client         = $client;
39
        $this->messageFactory = $messageFactory;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function createPiwikClient(string $host, string $token): ClientInterface
46
    {
47
        $connection = new PiwikConnection($this->client, $this->messageFactory, $host);
48
49
        return new Client($connection, $token);
50
    }
51
}
52