1 | <?php |
||
15 | abstract class RuleAbstract |
||
16 | { |
||
17 | const NODE_NAME = 'node'; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $nodeName; |
||
23 | |||
24 | /** |
||
25 | * @param string $nodeName |
||
26 | */ |
||
27 | 92 | public function __construct($nodeName = null) |
|
31 | |||
32 | /** |
||
33 | * @return string |
||
34 | */ |
||
35 | 53 | public function getNodeName() |
|
39 | |||
40 | /** |
||
41 | * @param \DOMElement $element |
||
42 | * @param string $name |
||
43 | * @return string|null |
||
44 | */ |
||
45 | 8 | public function getAttributeValue(\DOMElement $element, $name) |
|
53 | |||
54 | /** |
||
55 | * @param \DOMElement $element |
||
56 | * @param string $name |
||
57 | * @return string|null |
||
58 | */ |
||
59 | 3 | public function getChildValue(\DOMElement $element, $name) |
|
68 | |||
69 | /** |
||
70 | * adds the accurate DomElement content according to the node's property |
||
71 | * |
||
72 | * @param \DomDocument $document |
||
73 | * @param \DOMElement $rootElement |
||
74 | * @param NodeInterface $node |
||
75 | */ |
||
76 | 23 | public function apply(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void |
|
82 | |||
83 | /** |
||
84 | * Sets the accurate $item property according to the DomElement content |
||
85 | * |
||
86 | * @param NodeInterface $node |
||
87 | * @param \DOMElement $element |
||
88 | * @return mixed |
||
89 | */ |
||
90 | abstract public function setProperty(NodeInterface $node, \DOMElement $element); |
||
91 | |||
92 | /** |
||
93 | * Tells if the node contains the expected value |
||
94 | * |
||
95 | * @param NodeInterface $node |
||
96 | * @return bool |
||
97 | */ |
||
98 | abstract protected function hasValue(NodeInterface $node) : bool; |
||
99 | |||
100 | /** |
||
101 | * Creates and adds the element(s) to the docuement's rootElement |
||
102 | * |
||
103 | * @param \DomDocument $document |
||
104 | * @param \DOMElement $rootElement |
||
105 | * @param NodeInterface $node |
||
106 | */ |
||
107 | abstract protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void; |
||
108 | } |
||
109 |