StringChecker   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 2
dl 0
loc 37
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkStringArgument() 0 6 3
B checkStringArguments() 0 12 5
1
<?php
2
namespace Disque\Command\Argument;
3
4
trait StringChecker
5
{
6
    use ArrayChecker;
7
8
    /**
9
     * This command, with all its arguments, ready to be sent to Disque
10
     *
11
     * @param array $arguments Arguments
12
     * @param int $numberOfElements Number of elements that must be present in $arguments
13
     * @throws InvalidCommandArgumentException
14
     */
15
    protected function checkStringArgument(array $arguments, $numberOfElements = 1)
16
    {
17
        if (!$this->checkFixedArray($arguments, $numberOfElements) || !is_string($arguments[0])) {
18
            throw new InvalidCommandArgumentException($this, $arguments);
19
        }
20
    }
21
22
    /**
23
     * This command, with all its arguments, ready to be sent to Disque
24
     *
25
     * @param array $arguments Arguments
26
     * @throws InvalidCommandArgumentException
27
     */
28
    protected function checkStringArguments(array $arguments)
29
    {
30
        if (empty($arguments)) {
31
            throw new InvalidCommandArgumentException($this, $arguments);
32
        }
33
34
        foreach ($arguments as $argument) {
35
            if (!is_string($argument) || $argument === '') {
36
                throw new InvalidCommandArgumentException($this, $arguments);
37
            }
38
        }
39
    }
40
}