ClientFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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