Completed
Push — master ( f93ccb...d2e371 )
by Alessandro
03:39
created

Factory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 91.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 41
ccs 11
cts 12
cp 0.9167
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B createPublisher() 0 27 3
1
<?php
2
3
namespace Facile\CrossbarHTTPPublisherBundle\Publisher;
4
5
use GuzzleHttp\Client as GuzzleClient;
6
7
/**
8
 * Class Factory
9
 * @package Facile\CrossbarHTTPPublisherBundle\Publisher
10
 */
11
class Factory
12
{
13
    /**
14
     * @param string $protocol
15
     * @param string $host
16
     * @param int $port
17
     * @param string $path
18
     * @param string $key
19
     * @param string $secret
20
     * @param bool|string $hostname
21
     * @param bool $ignoreSsl
22
     * @return Publisher
23
     */
24 2
    public function createPublisher($protocol, $host, $port, $path, $key, $secret, $hostname, $ignoreSsl)
25
    {
26 2
        $config = array();
27
28 2
        $config['base_url'] = sprintf(
29 2
            '%s://%s:%s%s',
30
            $protocol,
31
            $host,
32
            $port,
33
            $path
34
        );
35 2
        $config['base_uri'] = $config['base_url']; // Guzzle 6 compat
36
37 2
        $config['defaults']['headers']['Content-Type'] = 'application/json';
38
39 2
        if (null !== $hostname) {
40
            $config['defaults']['headers']['Host'] = $hostname;
41
        }
42
43 2
        if ($ignoreSsl) {
44 2
            $config['defaults']['verify'] = false;
45
        }
46
47 2
        $guzzleClient = new GuzzleClient($config);
48
49 2
        return new Publisher($guzzleClient, $key, $secret);
50
    }
51
}
52