Passed
Branch master (6b4ceb)
by Jan
01:47
created
source/PurePhpGoogleAdsCsvGenerator.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@
 block discarded – undo
249 249
      * @return array
250 250
      */
251 251
     private function _prepareRow($array){
252
-       return array_merge($this->_blankRow, $array);
252
+        return array_merge($this->_blankRow, $array);
253 253
     }
254 254
 
255 255
     /**
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      *
139 139
      * @param $filename
140 140
      */
141
-    public function setFileName($filename){
141
+    public function setFileName($filename) {
142 142
         $this->_fileName = $filename;
143 143
     }
144 144
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      *
148 148
      * @return string
149 149
      */
150
-    public function getFileName(){
150
+    public function getFileName() {
151 151
         return $this->_fileName;
152 152
     }
153 153
 
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
         /**
163 163
          * Generate filename if needed
164 164
          */
165
-        if($fileName === null){
165
+        if ($fileName === null) {
166 166
             $this->setFileName('ads.csv');
167 167
         }
168
-        else{
168
+        else {
169 169
             $this->setFileName($fileName);
170 170
         }
171 171
 
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
     /**
194 194
      * Open CSV file
195 195
      */
196
-    public function openFile(){
196
+    public function openFile() {
197 197
         try {
198 198
             $this->_filePointer = fopen($this->_fileName, "w");
199 199
         }
200
-        catch (\Exception $e){
200
+        catch (\Exception $e) {
201 201
             die('File cannot be opened: ' . $e->getMessage());
202 202
         }
203 203
 
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
     /**
211 211
      * Close CSV file if is opened
212 212
      */
213
-    public function closeFile(){
214
-        if(is_resource($this->_filePointer) === true){
213
+    public function closeFile() {
214
+        if (is_resource($this->_filePointer) === true) {
215 215
             fclose($this->_filePointer);
216 216
         }
217 217
     }
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
     /**
220 220
      * Write Raw SV row
221 221
      */
222
-    private function _writeRawRow($array, $delimiter = "\t", $enclosure = null){
223
-        if($enclosure == null){
222
+    private function _writeRawRow($array, $delimiter = "\t", $enclosure = null) {
223
+        if ($enclosure == null) {
224 224
             $enclosure = chr(0);
225 225
         }
226 226
         fputcsv($this->_filePointer, $array, $delimiter, $enclosure);
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @return array
233 233
      */
234
-    private function _generateBlankRow(){
234
+    private function _generateBlankRow() {
235 235
 
236 236
         $blankRow = array();
237
-        foreach ($this->_fileHeader as $value){
237
+        foreach ($this->_fileHeader as $value) {
238 238
 
239 239
             $blankRow[strtolower(str_replace(' ', '-', $value))] = '';
240 240
         }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      * @param $array
249 249
      * @return array
250 250
      */
251
-    private function _prepareRow($array){
251
+    private function _prepareRow($array) {
252 252
        return array_merge($this->_blankRow, $array);
253 253
     }
254 254
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      *
258 258
      * @param $array
259 259
      */
260
-    private function _writeRow($array, $delimiter = "\t", $enclosure = null){
260
+    private function _writeRow($array, $delimiter = "\t", $enclosure = null) {
261 261
         $this->_writeRawRow($this->_prepareRow($array), $delimiter, $enclosure);
262 262
     }
263 263
 
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
      * Write campaign data
266 266
      * @param array $config
267 267
      */
268
-    public function writeCampaign( $data = array (
268
+    public function writeCampaign($data = array(
269 269
         'campaign' => 'Campaign',
270 270
         'campaign-type' => 'Search',
271 271
         'campaign-daily-budget' => '100.00',
272 272
         'networks' => 'Search;Google Search;Search Partners',
273 273
         'campaign-status' => 'active'
274
-    )){
274
+    )) {
275 275
 
276 276
         $this->_writeRow($data);
277 277
     }
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      *
282 282
      * @param array $data
283 283
      */
284
-    public function writeAdGroup( $data = array (
284
+    public function writeAdGroup($data = array(
285 285
         'campaign' => 'Campaign',
286 286
         'ad-group' => 'Ad Group',
287 287
         'max-cpc' => '1',
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @param array $data
300 300
      */
301
-    public function writeKeyword( $data = array (
301
+    public function writeKeyword($data = array(
302 302
         'campaign' => 'Campaign',
303 303
         'ad-group' => 'Ad Group',
304 304
         'keyword' => 'Keyword',
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      *
316 316
      * @param array $data
317 317
      */
318
-    public function writeAd( $data = array (
318
+    public function writeAd($data = array(
319 319
         'campaign' => 'Campaign',
320 320
         'ad-group' => 'Ad Group',
321 321
         'description-line-1' => 'Description line 1',
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      *
337 337
      * @param array $data
338 338
      */
339
-    public function writeAge( $data = array (
339
+    public function writeAge($data = array(
340 340
         'campaign' => 'Campaign',
341 341
         'ad-group' => 'Ad Group',
342 342
         'age' => 'Unknown',
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
      *
353 353
      * @param array $data
354 354
      */
355
-    public function writeGender( $data = array (
355
+    public function writeGender($data = array(
356 356
         'campaign' => 'Campaign',
357 357
         'ad-group' => 'Ad Group',
358 358
         'gender' => 'Unknown',
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
      *
369 369
      * @param array $data
370 370
      */
371
-    public function writeAllAges( $data = array (
371
+    public function writeAllAges($data = array(
372 372
         'campaign' => 'Campaign',
373 373
         'ad-group' => 'Ad Group',
374 374
         'status' => 'Active',
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
      *
386 386
      * @param array $data
387 387
      */
388
-    public function writeAllGenders( $data = array (
388
+    public function writeAllGenders($data = array(
389 389
         'campaign' => 'Campaign',
390 390
         'ad-group' => 'Ad Group',
391 391
         'status' => 'Active',
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -164,8 +164,7 @@  discard block
 block discarded – undo
164 164
          */
165 165
         if($fileName === null){
166 166
             $this->setFileName('ads.csv');
167
-        }
168
-        else{
167
+        } else{
169 168
             $this->setFileName($fileName);
170 169
         }
171 170
 
@@ -196,8 +195,7 @@  discard block
 block discarded – undo
196 195
     public function openFile(){
197 196
         try {
198 197
             $this->_filePointer = fopen($this->_fileName, "w");
199
-        }
200
-        catch (\Exception $e){
198
+        } catch (\Exception $e){
201 199
             die('File cannot be opened: ' . $e->getMessage());
202 200
         }
203 201
 
Please login to merge, or discard this patch.
example.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 /**
68 68
  * Write Age
69 69
  */
70
-$adWriter->writeAge( [
70
+$adWriter->writeAge([
71 71
     'campaign' => 'Campaign',
72 72
     'ad-group' => 'Ad Group',
73 73
     'age' => 'Unknown'
Please login to merge, or discard this patch.