Passed
Branch master (1abd51)
by Mathijs
10:46
created

ExchangeArgument::getArgumentName()   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 mcorten87\rabbitmq_api\objects;
4
5
class ExchangeArgument extends BaseObject
6
{
7
    /**
8
     * @var integer
9
     * If messages to this exchange cannot otherwise be routed, send them to the alternate exchange named here.
10
     */
11
    const ALTERNATE_EXCHAGE = 'alternate-exchange';
12
13
14
    private $argumentName;
15
16
    /**
17
     * @return String
18
     */
19
    public function getArgumentName()
20
    {
21
        return $this->argumentName;
22
    }
23
24
    public function __construct(String $argument, string $value)
25
    {
26
        $this->argumentName = $argument;
27
28
        parent::__construct($value);
29
    }
30
31
    public function validate($value) : bool
32
    {
33
        if (empty($this->getArgumentName())) {
34
            return false;
35
        }
36
37
38
        switch ($this->argumentName) {
39
            case self::ALTERNATE_EXCHAGE:
40
                return true;
41
42
            default :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a DEFAULT statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in the default statement.

switch ($expr) {
    default : //wrong
        doSomething();
        break;
}

switch ($expr) {
    default: //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
43
                throw new \RuntimeException('Argument not supported');
44
        }
45
    }
46
}
47