File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,25 @@ public function getFieldValues($key)
6060 return $ values ;
6161 }
6262
63+ /**
64+ * Returns a hashmap of all variable assignments in the given $key
65+ *
66+ * @param string $key
67+ * @return array
68+ * @uses self::getFieldValues()
69+ */
70+ public function getFieldVariables ($ key )
71+ {
72+ $ variables = array ();
73+
74+ foreach ($ this ->getFieldValues ($ key ) as $ value ) {
75+ $ temp = explode ('= ' , $ value , 2 );
76+ $ variables [$ temp [0 ]] = $ temp [1 ];
77+ }
78+
79+ return $ variables ;
80+ }
81+
6382 public function toJson ()
6483 {
6584 return json_encode ($ this ->getFields ());
Original file line number Diff line number Diff line change @@ -91,5 +91,8 @@ public function testOneFieldMultipleKeyValues()
9191
9292 $ this ->assertEquals ('first=on ' , $ action ->getFieldValue ('Variables ' ));
9393 $ this ->assertEquals (array ('first=on ' , 'second=off ' ), $ action ->getFieldValues ('Variables ' ));
94+
95+ $ this ->assertEquals (array ('first ' => 'on ' , 'second ' => 'off ' ), $ action ->getFieldVariables ('Variables ' ));
96+ $ this ->assertEquals (array (), $ action ->getFieldVariables ('unknown ' ));
9497 }
9598}
You can’t perform that action at this time.
0 commit comments