33namespace PE \Nodes ;
44
55use PE \Exceptions \EncoderNodeChildException ;
6+ use PE \Nodes \Children \NodeChildGetter ;
7+ use PE \Nodes \Children \NodeChildSetter ;
68
79class EncoderNodeChild extends EncoderNodeVariable {
810
11+ /**
12+ * @var string
13+ */
914 private $ childNodeName ;
15+
16+ /**
17+ * @var NodeChildSetter Setter of the child objects
18+ */
19+ private $ setter ;
20+
21+ /**
22+ * @var NodeChildGetter Setter of the child objects
23+ */
24+ private $ getter ;
25+
1026 private $ isArray = true ;
1127 private $ setAfterChildren = true ;
1228 private $ setAfterAttributes = true ;
@@ -26,6 +42,32 @@ public function getChildNodeName() {
2642 return $ this ->childNodeName ;
2743 }
2844
45+ /**
46+ * @param NodeChildSetter $setter
47+ */
48+ public function setter (NodeChildSetter $ setter ) {
49+ $ this ->setter = $ setter ;
50+ }
51+ /**
52+ * @return NodeChildSetter
53+ */
54+ public function getSetter () {
55+ return $ this ->setter ;
56+ }
57+
58+ /**
59+ * @param NodeChildGetter $getter
60+ */
61+ public function getter (NodeChildGetter $ getter ) {
62+ $ this ->getter = $ getter ;
63+ }
64+ /**
65+ * @return NodeChildGetter
66+ */
67+ public function getGetter () {
68+ return $ this ->getter ;
69+ }
70+
2971 // @todo Figure out if this feature is still necessary. Because if you use a single node, can't we simply assume it isn't an array?
3072 public function isArray ($ bool = null ) {
3173 if ($ bool !== null ) {
@@ -56,13 +98,13 @@ public function setAfterAttributes($bool = null) {
5698 * @return bool Returns true if the action succeeded and false when it couldn't find the child
5799 */
58100 public function addChildrenToObject ($ target , $ values ) {
59- $ methodName = $ this ->getSetterMethod ();
101+ $ methodName = $ this ->getSetter ()-> getMethod ();
60102 if ($ methodName === null ) {
61103 throw new EncoderNodeChildException (sprintf ('Setter method (%s) for class "%s" does not exist ' , $ this ->getChildNodeName (), get_class ($ target )));
62104 }
63105 else if (method_exists ($ target , $ methodName )) {
64106 foreach ($ values as $ value ) {
65- $ target ->$ methodName ($ this -> processValue ( $ value) );
107+ $ target ->$ methodName ($ value );
66108 }
67109 }
68110 else {
0 commit comments