Completed
Push — master ( d800b5...abd1e1 )
by Scott
07:53
created

GreaterThanEqualTo::run()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 11

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
dl 16
loc 16
ccs 11
cts 11
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 11
nc 4
nop 1
crap 4
1
<?php
2
namespace Desmond\functions\core;
3
use Desmond\functions\DesmondFunction;
4
use Desmond\ArgumentHelper;
5
use Desmond\exceptions\ArgumentException;
6
7 View Code Duplication
class GreaterThanEqualTo extends DesmondFunction
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    use ArgumentHelper;
10
11 328
    public function id()
12
    {
13 328
        return '>=';
14
    }
15
16 5
    public function run(array $args)
17
    {
18 5
        $this->expectArguments('>=', [['Number']], $args);
19 5
        $last = $args[0];
20 5
        array_shift($args);
21 5
        foreach ($args as $number) {
22 5
            if (!$this->isDesmondType('Number', $number)) {
23 1
                throw new ArgumentException('">=" expects arguments to be numbers.');
24
            }
25 5
            if ($number->value() > $last->value()) {
26 1
                return $this->newReturnType('False');
27
            }
28 4
            $last = $number;
29
        }
30 3
        return $this->newReturnType('True');
31
    }
32
}
33