Completed
Push — develop ( 505115...81a6ce )
by Mikaël
44:58
created

MinExclusiveRule::applyRule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
crap 1
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 24
    public function applyRule($parameterName, $value, $itemType = false)
15
    {
16 24
        $this->getMethod()
17 24
            ->addChild('// validation for constraint: minExclusive')
18 24
            ->addChild(sprintf('if ($%s <= %d) {', $parameterName, $value))
19 24
            ->addChild($this->getMethod()->getIndentedString(sprintf('throw new \InvalidArgumentException(sprintf(\'Invalid value, the value must be strictly superior to %d, "%%s" given\', $%s), __LINE__);', $value, $parameterName), 1))
20 24
            ->addChild('}');
21 24
        return $this;
22
    }
23
}
24