Completed
Pull Request — master (#17)
by Nicolas
04:26 queued 01:13
created

AbstractRabbitMQContext::host()   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
use Behat\Behat\Context\Context;
4
use Puzzle\Configuration\Yaml;
5
use Gaufrette\Filesystem;
6
use Gaufrette\Adapter\Local;
7
use RabbitMQ\Management\APIClient;
8
use Puzzle\AMQP\Clients\Pecl;
9
10
abstract class AbstractRabbitMQContext implements Context
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    const
13
        TEXT_ROUTING_KEY = 'text.key',
14
        JSON_ROUTING_KEY = 'json.key';
15
    
16
    protected
17
        $api,
18
        $exchange,
19
        $client,
20
        $configuration;
21
    
22
    public function __construct($path)
23
    {
24
        $this->configuration = new Yaml(new Filesystem(new Local($path)));
25
        $this->exchange = 'puzzle';
26
    
27
        $this->api = APIClient::factory(['host' => $this->host()]);
28
        $this->client = new Pecl($this->configuration);
29
    }
30
    
31
    private function host()
32
    {
33
        return $this->configuration->readRequired('amqp/broker/host');
34
    }
35
    
36
    protected function vhost()
37
    {
38
        return $this->configuration->readRequired('amqp/broker/vhost');
39
    }
40
}
41