Passed
Push — master ( 7912aa...646bd0 )
by Tobias
02:37
created
src/WrkLst/DocxMustache/DocxMustache.php 3 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -100,6 +100,9 @@  discard block
 block discarded – undo
100 100
             ->extractTo($this->storagePath($this->local_path), array($file), \Chumper\Zipper\Zipper::WHITELIST);
101 101
     }
102 102
 
103
+    /**
104
+     * @param string $file
105
+     */
103 106
     protected function ReadOpenXmlFile($file, $type="file")
104 107
     {
105 108
         $this->exctractOpenXmlFile($file);
@@ -127,6 +130,10 @@  discard block
 block discarded – undo
127 130
 
128 131
     }
129 132
 
133
+    /**
134
+     * @param string $file
135
+     * @param string|false $folder
136
+     */
130 137
     protected function SaveOpenXmlFile($file,$folder,$content)
131 138
     {
132 139
         \Storage::disk($this->storageDisk)
@@ -214,6 +221,9 @@  discard block
 block discarded – undo
214 221
         }
215 222
     }
216 223
 
224
+    /**
225
+     * @param \SimpleXMLElement $main_file
226
+     */
217 227
     protected function FetchReplaceableImages(&$main_file, $ns)
218 228
     {
219 229
         //set up basic arrays to keep track of imgs
@@ -317,6 +327,9 @@  discard block
 block discarded – undo
317 327
         return false;
318 328
     }
319 329
 
330
+    /**
331
+     * @param string $data
332
+     */
320 333
     protected function ResampleImage($imgs, $k, $data)
321 334
     {
322 335
         \Storage::disk($this->storageDisk)->put($this->local_path.'word/media/'.$imgs[$k]['img_file_src'], $data);
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
             ->extractTo($this->storagePath($this->local_path), array($file), \Chumper\Zipper\Zipper::WHITELIST);
101 101
     }
102 102
 
103
-    protected function ReadOpenXmlFile($file, $type="file")
103
+    protected function ReadOpenXmlFile($file, $type = "file")
104 104
     {
105 105
         $this->exctractOpenXmlFile($file);
106 106
 
107
-        if($type=="file")
107
+        if ($type == "file")
108 108
         {
109 109
             if ($file_contents = \Storage::disk($this->storageDisk)->get($this->local_path.$file))
110 110
             {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             }
116 116
         } else
117 117
         {
118
-            if($xml_object = simplexml_load_file($this->storagePath($this->local_path.$file)))
118
+            if ($xml_object = simplexml_load_file($this->storagePath($this->local_path.$file)))
119 119
             {
120 120
                 return $xml_object;
121 121
             }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
     }
129 129
 
130
-    protected function SaveOpenXmlFile($file,$folder,$content)
130
+    protected function SaveOpenXmlFile($file, $folder, $content)
131 131
     {
132 132
         \Storage::disk($this->storageDisk)
133 133
             ->put($this->local_path.$file, $content);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $this->log('Analyze Template');
142 142
         //get the main document out of the docx archive
143
-        $this->word_doc = ReadOpenXmlFile('word/document.xml','file');
143
+        $this->word_doc = ReadOpenXmlFile('word/document.xml', 'file');
144 144
 
145 145
         $this->log('Merge Data into Template');
146 146
         $this->word_doc = $this->MustacheRender($this->items, $this->word_doc);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
         $this->log('Compact Template with Data');
152 152
 
153
-        $this->SaveOpenXmlFile('word/document.xml','word',$this->word_doc);
153
+        $this->SaveOpenXmlFile('word/document.xml', 'word', $this->word_doc);
154 154
         $this->zipper->close();
155 155
     }
156 156
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
     protected function MustacheRender($items, $mustache_template, $clean_tags = true)
171 171
     {
172
-        if($clean_tags)
172
+        if ($clean_tags)
173 173
             $mustache_template = $this->MustacheTagCleaner($mustache_template);
174 174
 
175 175
         $m = new \Mustache_Engine(array('escape' => function($value) {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
     protected function AddContentType($imageCt = "jpeg")
185 185
     {
186
-        $ct_file = $this->ReadOpenXmlFile('[Content_Types].xml','object');
186
+        $ct_file = $this->ReadOpenXmlFile('[Content_Types].xml', 'object');
187 187
 
188 188
         //check if content type for jpg has been set
189 189
         $i = 0;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
             if ($ct_file_xml = $ct_file->asXML())
208 208
             {
209
-                $this->SaveOpenXmlFile('[Content_Types].xml',false,$ct_file_xml);
209
+                $this->SaveOpenXmlFile('[Content_Types].xml', false, $ct_file_xml);
210 210
             } else
211 211
             {
212 212
                 throw new Exception('Cannot generate xml for [Content_Types].xml.');
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
         foreach ($imgs as $k=>$img)
362 362
         {
363 363
             //get file type of img and test it against supported imgs
364
-            if($imgageData = $this->GetImageFromUrl($img['url']))
364
+            if ($imgageData = $this->GetImageFromUrl($img['url']))
365 365
             {
366 366
                 $imgs[$k]['img_file_src'] = str_replace("wrklstId", "wrklst_image", $img['id']).$allowed_imgs[$imgageData['mime']];
367 367
                 $imgs[$k]['img_file_dest'] = str_replace("wrklstId", "wrklst_image", $img['id']).'.jpeg';
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
         $imgs = $replaceableImage['imgs'];
418 418
         $imgs_replaced = $replaceableImage['imgs_replaced'];
419 419
 
420
-        $rels_file = $this->ReadOpenXmlFile('word/_rels/document.xml.rels','object');
420
+        $rels_file = $this->ReadOpenXmlFile('word/_rels/document.xml.rels', 'object');
421 421
 
422 422
         $this->RemoveReplaceImages($imgs_replaced, $rels_file);
423 423
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 
429 429
         if ($rels_file_xml = $rels_file->asXML())
430 430
         {
431
-            $this->SaveOpenXmlFile('word/_rels/document.xml.rels','word/_rels',$rels_file_xml);
431
+            $this->SaveOpenXmlFile('word/_rels/document.xml.rels', 'word/_rels', $rels_file_xml);
432 432
         } else
433 433
         {
434 434
             throw new Exception('Cannot generate xml for word/_rels/document.xml.rels.');
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@  discard block
 block discarded – undo
60 60
     {
61 61
         //introduce logging method here to keep track of process
62 62
         // can be overwritten in extended class to log with custom preocess logger
63
-        if ($this->verbose)
64
-            Log::error($msg);
63
+        if ($this->verbose) {
64
+                    Log::error($msg);
65
+        }
65 66
     }
66 67
 
67 68
     public function cleanUpTmpDirs()
@@ -118,8 +119,7 @@  discard block
 block discarded – undo
118 119
             if($xml_object = simplexml_load_file($this->storagePath($this->local_path.$file)))
119 120
             {
120 121
                 return $xml_object;
121
-            }
122
-            else
122
+            } else
123 123
             {
124 124
                 throw new Exception('Cannot load XML Object from file '.$file);
125 125
             }
@@ -169,8 +169,9 @@  discard block
 block discarded – undo
169 169
 
170 170
     protected function MustacheRender($items, $mustache_template, $clean_tags = true)
171 171
     {
172
-        if($clean_tags)
173
-            $mustache_template = $this->MustacheTagCleaner($mustache_template);
172
+        if($clean_tags) {
173
+                    $mustache_template = $this->MustacheTagCleaner($mustache_template);
174
+        }
174 175
 
175 176
         $m = new \Mustache_Engine(array('escape' => function($value) {
176 177
             if (str_replace('*[[DONOTESCAPE]]*', '', $value) != $value) {
Please login to merge, or discard this patch.