Completed
Pull Request — master (#17)
by Nicolas
03:21
created

AbstractRabbitMQContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A host() 0 4 1
A vhost() 0 4 1
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