Completed
Push — feature/issue-49 ( 9a3dca...dba810 )
by Mikaël
28:22
created

AbstractRule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 1
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace WsdlToPhp\PackageGenerator\File\Validation;
4
5
use WsdlToPhp\PhpGenerator\Element\PhpMethod;
6
use WsdlToPhp\PackageGenerator\Model\StructAttribute as StructAttributeModel;
7
use WsdlToPhp\PackageGenerator\File\AbstractModelFile;
8
9
abstract class AbstractRule
10
{
11
    /**
12
     * @var Rules
13
     */
14
    private $rules;
15
    /**
16
     * @param Rules $rules
17
     */
18 88
    public function __construct(Rules $rules)
19
    {
20 88
        $this->setRules($rules);
21 88
    }
22
    /**
23
     * This method has to add the validation rule to the method's body
24
     * @param string $parameterName
25
     * @param mixed $value
26
     * @param bool $itemType
27
     * @return AbstractValidation
28
     */
29
    abstract public function applyRule($parameterName, $value, $itemType = false);
30
    /**
31
     * @return Rules
32
     */
33 88
    public function getRules()
34
    {
35 88
        return $this->rules;
36
    }
37
    /**
38
     * @param Rules $rules
39
     */
40 88
    public function setRules(Rules $rules)
41
    {
42 88
        $this->rules = $rules;
43 88
        return $this;
44
    }
45
    /**
46
     * @return PhpMethod
47
     */
48 88
    public function getMethod()
49
    {
50 88
        return $this->getRules()->getMethod();
51
    }
52
    /**
53
     * @return AbstractModelFile
54
     */
55 72
    public function getFile()
56
    {
57 72
        return $this->getRules()->getFile();
58
    }
59
    /**
60
     * @return StructAttributeModel
61
     */
62 72
    public function getAttribute()
63
    {
64 72
        return $this->getRules()->getAttribute();
65
    }
66
}
67