@@ -15,31 +15,36 @@ class PrestashopWebService extends PrestashopWebServiceLibrary
1515 * @return SimpleXMLElement
1616 * @throws PrestaShopWebserviceException
1717 */
18- public function getSchema ($ resource , $ schema = 'blank ' )
18+ public function getSchema ($ resource , $ schema = 'blank ' )
1919 {
2020 return $ this ->get (['resource ' => $ resource . "?schema= $ schema " ]);
2121 }
2222
2323 /**
24- * Fill the provided schema with an associative array data, also remove the useless XML nodes if the corresponding flag is true
24+ * Fill the provided schema with an associative array data, also remove the useless XML nodes if
25+ * the corresponding flag is true
2526 *
2627 * @param SimpleXMLElement $xmlSchema
2728 * @param array $data
2829 * @param bool $removeUselessNodes set true if you want to remove nodes that are not present in the data array
29- * @param array $removeSpecificNodes If $removeUselessNodes is false you may add here the first level nodes that you want to remove
30+ * @param array $removeSpecificNodes If $removeUselessNodes is false you may add here the first level nodes that
31+ * you want to remove
3032 * @return SimpleXMLElement
3133 */
32- public function fillSchema (SimpleXMLElement $ xmlSchema , $ data , $ removeUselessNodes = true , $ removeSpecificNodes =array ())
33- {
34+ public function fillSchema (
35+ SimpleXMLElement $ xmlSchema ,
36+ $ data ,
37+ $ removeUselessNodes = true ,
38+ $ removeSpecificNodes = array ()
39+ ) {
3440 $ resource = $ xmlSchema ->children ()->children ();
3541 foreach ($ data as $ key => $ value ) {
3642 $ this ->processNode ($ resource , $ key , $ value );
3743 }
3844 if ($ removeUselessNodes ) {
3945 $ this ->checkForUselessNodes ($ resource , $ data );
40- }
41- else {
42- $ this ->removeSpecificNodes ($ resource ,$ removeSpecificNodes );
46+ } else {
47+ $ this ->removeSpecificNodes ($ resource , $ removeSpecificNodes );
4348 }
4449 return $ xmlSchema ;
4550 }
@@ -80,13 +85,12 @@ private function fillLanguageNode($node, $data)
8085 */
8186 private function processNode (SimpleXMLElement $ node , $ dataKey , $ dataValue )
8287 {
83- if (is_int ($ dataKey )){
84- if ($ dataKey ===0 ){
88+ if (is_int ($ dataKey )) {
89+ if ($ dataKey ===0 ) {
8590 $ this ->emptyNode ($ node );
8691 }
87- $ this ->createNode ($ node ,$ dataValue );
88- }
89- elseif (property_exists ($ node ->$ dataKey , 'language ' )) {
92+ $ this ->createNode ($ node , $ dataValue );
93+ } elseif (property_exists ($ node ->$ dataKey , 'language ' )) {
9094 $ this ->fillLanguageNode ($ node ->$ dataKey , $ dataValue );
9195 } elseif (is_array ($ dataValue )) {
9296 foreach ($ dataValue as $ key => $ value ) {
@@ -134,17 +138,15 @@ private function removeSpecificNodes($resource, $removeSpecificNodes)
134138 private function createNode (SimpleXMLElement $ node , $ dataValue )
135139 {
136140 foreach ($ dataValue as $ key => $ value ) {
137- if (is_array ($ value )){
138- if (is_int ($ key )){
139- $ this ->createNode ($ node ,$ value );
140- }
141- else {
141+ if (is_array ($ value )) {
142+ if (is_int ($ key )) {
143+ $ this ->createNode ($ node , $ value );
144+ } else {
142145 $ childNode =$ node ->addChild ($ key );
143- $ this ->createNode ($ childNode ,$ value );
146+ $ this ->createNode ($ childNode , $ value );
144147 }
145- }
146- else {
147- $ node ->addChild ($ key ,$ value );
148+ } else {
149+ $ node ->addChild ($ key , $ value );
148150 }
149151 }
150152 }
@@ -162,4 +164,4 @@ private function emptyNode(SimpleXMLElement $node)
162164 unset($ node ->$ nodeName );
163165 }
164166 }
165- }
167+ }
0 commit comments