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

GreaterThanEqualTo::id()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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