Passed
Pull Request — master (#17)
by Nicolas
03:26
created

AbstractRabbitMQContext::vhost()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Puzzle\AMQP\Contexts;
4
5
use Behat\Behat\Context\Context;
6
use Puzzle\Configuration\Yaml;
7
use Gaufrette\Filesystem;
8
use Gaufrette\Adapter\Local;
9
use RabbitMQ\Management\APIClient;
10
use Puzzle\AMQP\Clients\Pecl;
11
12
abstract class AbstractRabbitMQContext implements Context
13
{
14
    const
15
        TEXT_ROUTING_KEY = 'text.key',
16
        JSON_ROUTING_KEY = 'json.key';
17
    
18
    protected
19
        $api,
20
        $exchange,
21
        $client,
22
        $configuration;
23
    
24
    public function __construct($path)
25
    {
26
        $this->configuration = new Yaml(new Filesystem(new Local($path)));
27
        $this->exchange = 'puzzle';
28
    
29
        $this->api = APIClient::factory(['host' => $this->host()]);
30
        $this->client = new Pecl($this->configuration);
31
    }
32
    
33
    private function host()
34
    {
35
        return $this->configuration->readRequired('amqp/broker/host');
36
    }
37
    
38
    protected function vhost()
39
    {
40
        return $this->configuration->readRequired('amqp/broker/vhost');
41
    }
42
}
43