Completed
Push — master ( 055d28...d800b5 )
by Scott
04:53
created

GreaterThan::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 GreaterThan 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 318
    public function id()
12
    {
13 318
        return '>';
14
    }
15
16 4
    public function run(array $args)
17
    {
18 4
        $this->expectArguments('>', [['Number']], $args);
19 4
        $last = $args[0];
20 4
        array_shift($args);
21 4
        foreach ($args as $number) {
22 4
            if (!$this->isDesmondType('Number', $number)) {
23 1
                throw new ArgumentException('">" expects arguments to be numbers.');
24
            }
25 4
            if ($number->value() >= $last->value()) {
26 1
                return $this->newReturnType('False');
27
            }
28 3
            $last = $number;
29
        }
30 2
        return $this->newReturnType('True');
31
    }
32
}
33