ApiClient   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 0
cbo 4
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A factory() 0 4 1
A __construct() 0 12 1
1
<?php
2
3
namespace Crummy\Phlack\Bridge\Guzzle;
4
5
use Guzzle\Common\Collection;
6
use Guzzle\Common\Event;
7
use Guzzle\Service\Client;
8
use Guzzle\Service\Description\ServiceDescription;
9
10
class ApiClient extends Client
11
{
12
    /**
13
     * @param array $config
14
     */
15 3
    public function __construct($config = [])
16
    {
17 3
        $config = Collection::fromConfig($config, [], ['token']);
18 3
        parent::__construct('', $config);
19
20 3
        $description = ServiceDescription::factory(__DIR__.'/Resources/slack_api.json');
21 3
        $this->setDescription($description);
22
23 3
        $this->getEventDispatcher()->addListener('command.before_prepare', function (Event $event) use ($config) {
24 1
            $event['command']['token'] = $config['token'];
25 3
        });
26 3
    }
27
28
    /**
29
     * @param array $config
30
     *
31
     * @return ApiClient
32
     */
33 1
    public static function factory($config = [])
34
    {
35 1
        return new self($config);
36
    }
37
}
38