Completed
Pull Request — master (#17)
by Nicolas
05:50
created

AbstractRabbitMQContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 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,
1 ignored issue
show
Coding Style introduced by
The visibility should be declared for property $api.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
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';
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
26
    
27
        $this->api = APIClient::factory(['host' => $this->host()]);
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
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