Completed
Push — master ( eaa08c...d2fe44 )
by Mikaël
656:34 queued 656:28
created

MinInclusiveRule   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A applyRule() 0 9 1
1
<?php
2
3
namespace WsdlToPhp\PackageGenerator\File\Validation;
4
5
class MinInclusiveRule 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 MinInclusiveRule
13
     */
14
    public function applyRule($parameterName, $value, $itemType = false)
15
    {
16
        $this->getMethod()
17
            ->addChild('// validation for constraint: minInclusive')
18
            ->addChild(sprintf('if ($%s < %d) {', $parameterName, $value))
19
            ->addChild($this->getMethod()->getIndentedString(sprintf('throw new \InvalidArgumentException(sprintf(\'Invalid value, the value must be superior or equal to %d\, "%%s" given\', $%s), __LINE__);', $value, $parameterName), 1))
20
            ->addChild('}');
21
        return $this;
22
    }
23
}
24