Completed
Push — 1.x ( 257780...f31d1d )
by Mikaël
42:33 queued 33:38
created

MinExclusiveRule::applyRule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 2
Metric Value
c 2
b 1
f 2
dl 0
loc 10
ccs 0
cts 10
cp 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 3
crap 2
1
<?php
2
3
namespace WsdlToPhp\PackageGenerator\File\Validation;
4
5
class MinExclusiveRule extends AbstractRule
6
{
7
    /**
8
     * @see \WsdlToPhp\PackageGenerator\File\Validation\AbstractValidation::addRule()
9
     * @param string $parameterName
10
     * @param mixed $value
11
     * @param bool $itemType
12
     * @return MinExclusiveRule
13
     */
14
    public function applyRule($parameterName, $value, $itemType = false)
15
    {
16
        $this
17
            ->getMethod()
18
                ->addChild('// validation for constraint: minExclusive')
19
                ->addChild(sprintf('if ($%s < %d) {', $parameterName, $value))
20
                    ->addChild($this->getMethod()->getIndentedString(sprintf('throw new \InvalidArgumentException(sprintf(\'Invalid value, the value must be superior to %d\, "%%s" given\', %s), __LINE__);', $value, $parameterName), 1))
21
                ->addChild('}');
22
        return $this;
23
    }
24
}
25