ExchangeArgument::validate()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 3
nop 1
crap 4
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 6
    public function getArgumentName()
20
    {
21 6
        return $this->argumentName;
22
    }
23
24 6
    public function __construct(String $argument, string $value)
25
    {
26 6
        $this->argumentName = $argument;
27
28 6
        parent::__construct($value);
29 3
    }
30
31 6
    public function validate($value) : bool
32
    {
33 6
        if (empty($this->getArgumentName()) || empty($value)) {
34 2
            return false;
35
        }
36
37
38 4
        switch ($this->argumentName) {
39 4
            case self::ALTERNATE_EXCHAGE:
40 3
                return true;
41
42
            default:
43 1
                return false;
44
        }
45
    }
46
}
47