HighchartsData::setGoogleSpreadsheetWorksheet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the highcharts-bundle package.
5
 *
6
 * (c) 2017 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\HighchartsBundle\API\Chart;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts data.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsData implements JsonSerializable {
26
27
    /**
28
     * Columns.
29
     *
30
     * @var array
31
     * @since 4.0
32
     */
33
    private $columns;
34
35
    /**
36
     * Complete.
37
     *
38
     * @var string
39
     * @since 4.0
40
     */
41
    private $complete;
42
43
    /**
44
     * Csv.
45
     *
46
     * @var string
47
     * @since 4.0
48
     */
49
    private $csv;
50
51
    /**
52
     * Date format.
53
     *
54
     * @var string
55
     * @since 4.0
56
     */
57
    private $dateFormat;
58
59
    /**
60
     * Decimal point.
61
     *
62
     * @var string
63
     * @since 4.1.0
64
     */
65
    private $decimalPoint = ".";
66
67
    /**
68
     * End column.
69
     *
70
     * @var integer
71
     * @since 4.0
72
     */
73
    private $endColumn;
74
75
    /**
76
     * End row.
77
     *
78
     * @var integer
79
     * @since 4.0.4
80
     */
81
    private $endRow;
82
83
    /**
84
     * First row as names.
85
     *
86
     * @var boolean
87
     * @since 4.1.0
88
     */
89
    private $firstRowAsNames = true;
90
91
    /**
92
     * Google spreadsheet key.
93
     *
94
     * @var string
95
     * @since 4.0
96
     */
97
    private $googleSpreadsheetKey;
98
99
    /**
100
     * Google spreadsheet worksheet.
101
     *
102
     * @var string
103
     * @since 4.0
104
     */
105
    private $googleSpreadsheetWorksheet;
106
107
    /**
108
     * Item delimiter.
109
     *
110
     * @var string
111
     * @since 4.0
112
     */
113
    private $itemDelimiter;
114
115
    /**
116
     * Line delimiter.
117
     *
118
     * @var string
119
     * @since 4.0
120
     */
121
    private $lineDelimiter = "\\n";
122
123
    /**
124
     * Parse date.
125
     *
126
     * @var string
127
     * @since 4.0
128
     */
129
    private $parseDate;
130
131
    /**
132
     * Parsed.
133
     *
134
     * @var string
135
     * @since 4.0
136
     */
137
    private $parsed;
138
139
    /**
140
     * Rows.
141
     *
142
     * @var array
143
     * @since 4.0
144
     */
145
    private $rows;
146
147
    /**
148
     * Series mapping.
149
     *
150
     * @var array
151
     * @since 4.0.4
152
     */
153
    private $seriesMapping;
154
155
    /**
156
     * Start column.
157
     *
158
     * @var integer
159
     * @since 4.0
160
     */
161
    private $startColumn = 0;
162
163
    /**
164
     * Start row.
165
     *
166
     * @var integer
167
     * @since 4.0
168
     */
169
    private $startRow = 0;
170
171
    /**
172
     * Switch rows and columns.
173
     *
174
     * @var boolean
175
     * @since 4.0
176
     */
177
    private $switchRowsAndColumns = false;
178
179
    /**
180
     * Table.
181
     *
182
     * @var string
183
     * @since 4.0
184
     */
185
    private $table;
186
187
    /**
188
     * Constructor.
189
     *
190
     * @param boolean $ignoreDefaultValues Ignore the default values.
191
     */
192
    public function __construct($ignoreDefaultValues = true) {
193
        if (true === $ignoreDefaultValues) {
194
            $this->clear();
195
        }
196
    }
197
198
    /**
199
     * Clear.
200
     *
201
     * @return void
202
     */
203
    public function clear() {
204
205
        // Clear the columns.
206
        $this->columns = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $columns.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
207
208
        // Clear the complete.
209
        $this->complete = null;
210
211
        // Clear the csv.
212
        $this->csv = null;
213
214
        // Clear the date format.
215
        $this->dateFormat = null;
216
217
        // Clear the decimal point.
218
        $this->decimalPoint = null;
219
220
        // Clear the end column.
221
        $this->endColumn = null;
222
223
        // Clear the end row.
224
        $this->endRow = null;
225
226
        // Clear the first row as names.
227
        $this->firstRowAsNames = null;
228
229
        // Clear the google spreadsheet key.
230
        $this->googleSpreadsheetKey = null;
231
232
        // Clear the google spreadsheet worksheet.
233
        $this->googleSpreadsheetWorksheet = null;
234
235
        // Clear the item delimiter.
236
        $this->itemDelimiter = null;
237
238
        // Clear the line delimiter.
239
        $this->lineDelimiter = null;
240
241
        // Clear the parse date.
242
        $this->parseDate = null;
243
244
        // Clear the parsed.
245
        $this->parsed = null;
246
247
        // Clear the rows.
248
        $this->rows = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $rows.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
249
250
        // Clear the series mapping.
251
        $this->seriesMapping = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $seriesMapping.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
252
253
        // Clear the start column.
254
        $this->startColumn = null;
255
256
        // Clear the start row.
257
        $this->startRow = null;
258
259
        // Clear the switch rows and columns.
260
        $this->switchRowsAndColumns = null;
261
262
        // Clear the table.
263
        $this->table = null;
264
    }
265
266
    /**
267
     * Get the columns.
268
     *
269
     * @return array Returns the columns.
270
     */
271
    public function getColumns() {
272
        return $this->columns;
273
    }
274
275
    /**
276
     * Get the complete.
277
     *
278
     * @return string Returns the complete.
279
     */
280
    public function getComplete() {
281
        return $this->complete;
282
    }
283
284
    /**
285
     * Get the csv.
286
     *
287
     * @return string Returns the csv.
288
     */
289
    public function getCsv() {
290
        return $this->csv;
291
    }
292
293
    /**
294
     * Get the date format.
295
     *
296
     * @return string Returns the date format.
297
     */
298
    public function getDateFormat() {
299
        return $this->dateFormat;
300
    }
301
302
    /**
303
     * Get the decimal point.
304
     *
305
     * @return string Returns the decimal point.
306
     */
307
    public function getDecimalPoint() {
308
        return $this->decimalPoint;
309
    }
310
311
    /**
312
     * Get the end column.
313
     *
314
     * @return integer Returns the end column.
315
     */
316
    public function getEndColumn() {
317
        return $this->endColumn;
318
    }
319
320
    /**
321
     * Get the end row.
322
     *
323
     * @return integer Returns the end row.
324
     */
325
    public function getEndRow() {
326
        return $this->endRow;
327
    }
328
329
    /**
330
     * Get the first row as names.
331
     *
332
     * @return boolean Returns the first row as names.
333
     */
334
    public function getFirstRowAsNames() {
335
        return $this->firstRowAsNames;
336
    }
337
338
    /**
339
     * Get the google spreadsheet key.
340
     *
341
     * @return string Returns the google spreadsheet key.
342
     */
343
    public function getGoogleSpreadsheetKey() {
344
        return $this->googleSpreadsheetKey;
345
    }
346
347
    /**
348
     * Get the google spreadsheet worksheet.
349
     *
350
     * @return string Returns the google spreadsheet worksheet.
351
     */
352
    public function getGoogleSpreadsheetWorksheet() {
353
        return $this->googleSpreadsheetWorksheet;
354
    }
355
356
    /**
357
     * Get the item delimiter.
358
     *
359
     * @return string Returns the item delimiter.
360
     */
361
    public function getItemDelimiter() {
362
        return $this->itemDelimiter;
363
    }
364
365
    /**
366
     * Get the line delimiter.
367
     *
368
     * @return string Returns the line delimiter.
369
     */
370
    public function getLineDelimiter() {
371
        return $this->lineDelimiter;
372
    }
373
374
    /**
375
     * Get the parse date.
376
     *
377
     * @return string Returns the parse date.
378
     */
379
    public function getParseDate() {
380
        return $this->parseDate;
381
    }
382
383
    /**
384
     * Get the parsed.
385
     *
386
     * @return string Returns the parsed.
387
     */
388
    public function getParsed() {
389
        return $this->parsed;
390
    }
391
392
    /**
393
     * Get the rows.
394
     *
395
     * @return array Returns the rows.
396
     */
397
    public function getRows() {
398
        return $this->rows;
399
    }
400
401
    /**
402
     * Get the series mapping.
403
     *
404
     * @return array Returns the series mapping.
405
     */
406
    public function getSeriesMapping() {
407
        return $this->seriesMapping;
408
    }
409
410
    /**
411
     * Get the start column.
412
     *
413
     * @return integer Returns the start column.
414
     */
415
    public function getStartColumn() {
416
        return $this->startColumn;
417
    }
418
419
    /**
420
     * Get the start row.
421
     *
422
     * @return integer Returns the start row.
423
     */
424
    public function getStartRow() {
425
        return $this->startRow;
426
    }
427
428
    /**
429
     * Get the switch rows and columns.
430
     *
431
     * @return boolean Returns the switch rows and columns.
432
     */
433
    public function getSwitchRowsAndColumns() {
434
        return $this->switchRowsAndColumns;
435
    }
436
437
    /**
438
     * Get the table.
439
     *
440
     * @return string Returns the table.
441
     */
442
    public function getTable() {
443
        return $this->table;
444
    }
445
446
    /**
447
     * Serialize this instance.
448
     *
449
     * @return array Returns an array representing this instance.
450
     */
451
    public function jsonSerialize() {
452
        return $this->toArray();
453
    }
454
455
    /**
456
     * Set the columns.
457
     *
458
     * @param array $columns The columns.
459
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
460
     */
461
    public function setColumns(array $columns = null) {
462
        $this->columns = $columns;
0 ignored issues
show
Documentation Bug introduced by
It seems like $columns can be null. However, the property $columns is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
463
        return $this;
464
    }
465
466
    /**
467
     * Set the complete.
468
     *
469
     * @param string $complete The complete.
470
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
471
     */
472
    public function setComplete($complete) {
473
        $this->complete = $complete;
474
        return $this;
475
    }
476
477
    /**
478
     * Set the csv.
479
     *
480
     * @param string $csv The csv.
481
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
482
     */
483
    public function setCsv($csv) {
484
        $this->csv = $csv;
485
        return $this;
486
    }
487
488
    /**
489
     * Set the date format.
490
     *
491
     * @param string $dateFormat The date format.
492
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
493
     */
494
    public function setDateFormat($dateFormat) {
495
        switch ($dateFormat) {
496
            case null:
497
            case "YYYY-mm-dd":
498
            case "dd/mm/YY":
499
            case "dd/mm/YYYY":
500
            case "dd/mm/YYYY":
501
            case "mm/dd/YY":
502
            case "mm/dd/YYYY":
503
            $this->dateFormat = $dateFormat;
504
            break;
505
        }
506
        return $this;
507
    }
508
509
    /**
510
     * Set the decimal point.
511
     *
512
     * @param string $decimalPoint The decimal point.
513
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
514
     */
515
    public function setDecimalPoint($decimalPoint) {
516
        $this->decimalPoint = $decimalPoint;
517
        return $this;
518
    }
519
520
    /**
521
     * Set the end column.
522
     *
523
     * @param integer $endColumn The end column.
524
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
525
     */
526
    public function setEndColumn($endColumn) {
527
        $this->endColumn = $endColumn;
528
        return $this;
529
    }
530
531
    /**
532
     * Set the end row.
533
     *
534
     * @param integer $endRow The end row.
535
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
536
     */
537
    public function setEndRow($endRow) {
538
        $this->endRow = $endRow;
539
        return $this;
540
    }
541
542
    /**
543
     * Set the first row as names.
544
     *
545
     * @param boolean $firstRowAsNames The first row as names.
546
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
547
     */
548
    public function setFirstRowAsNames($firstRowAsNames) {
549
        $this->firstRowAsNames = $firstRowAsNames;
550
        return $this;
551
    }
552
553
    /**
554
     * Set the google spreadsheet key.
555
     *
556
     * @param string $googleSpreadsheetKey The google spreadsheet key.
557
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
558
     */
559
    public function setGoogleSpreadsheetKey($googleSpreadsheetKey) {
560
        $this->googleSpreadsheetKey = $googleSpreadsheetKey;
561
        return $this;
562
    }
563
564
    /**
565
     * Set the google spreadsheet worksheet.
566
     *
567
     * @param string $googleSpreadsheetWorksheet The google spreadsheet worksheet.
568
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
569
     */
570
    public function setGoogleSpreadsheetWorksheet($googleSpreadsheetWorksheet) {
571
        $this->googleSpreadsheetWorksheet = $googleSpreadsheetWorksheet;
572
        return $this;
573
    }
574
575
    /**
576
     * Set the item delimiter.
577
     *
578
     * @param string $itemDelimiter The item delimiter.
579
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
580
     */
581
    public function setItemDelimiter($itemDelimiter) {
582
        $this->itemDelimiter = $itemDelimiter;
583
        return $this;
584
    }
585
586
    /**
587
     * Set the line delimiter.
588
     *
589
     * @param string $lineDelimiter The line delimiter.
590
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
591
     */
592
    public function setLineDelimiter($lineDelimiter) {
593
        $this->lineDelimiter = $lineDelimiter;
594
        return $this;
595
    }
596
597
    /**
598
     * Set the parse date.
599
     *
600
     * @param string $parseDate The parse date.
601
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
602
     */
603
    public function setParseDate($parseDate) {
604
        $this->parseDate = $parseDate;
605
        return $this;
606
    }
607
608
    /**
609
     * Set the parsed.
610
     *
611
     * @param string $parsed The parsed.
612
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
613
     */
614
    public function setParsed($parsed) {
615
        $this->parsed = $parsed;
616
        return $this;
617
    }
618
619
    /**
620
     * Set the rows.
621
     *
622
     * @param array $rows The rows.
623
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
624
     */
625
    public function setRows(array $rows = null) {
626
        $this->rows = $rows;
0 ignored issues
show
Documentation Bug introduced by
It seems like $rows can be null. However, the property $rows is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
627
        return $this;
628
    }
629
630
    /**
631
     * Set the series mapping.
632
     *
633
     * @param array $seriesMapping The series mapping.
634
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
635
     */
636
    public function setSeriesMapping(array $seriesMapping = null) {
637
        $this->seriesMapping = $seriesMapping;
0 ignored issues
show
Documentation Bug introduced by
It seems like $seriesMapping can be null. However, the property $seriesMapping is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
638
        return $this;
639
    }
640
641
    /**
642
     * Set the start column.
643
     *
644
     * @param integer $startColumn The start column.
645
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
646
     */
647
    public function setStartColumn($startColumn) {
648
        $this->startColumn = $startColumn;
649
        return $this;
650
    }
651
652
    /**
653
     * Set the start row.
654
     *
655
     * @param integer $startRow The start row.
656
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
657
     */
658
    public function setStartRow($startRow) {
659
        $this->startRow = $startRow;
660
        return $this;
661
    }
662
663
    /**
664
     * Set the switch rows and columns.
665
     *
666
     * @param boolean $switchRowsAndColumns The switch rows and columns.
667
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
668
     */
669
    public function setSwitchRowsAndColumns($switchRowsAndColumns) {
670
        $this->switchRowsAndColumns = $switchRowsAndColumns;
671
        return $this;
672
    }
673
674
    /**
675
     * Set the table.
676
     *
677
     * @param string $table The table.
678
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsData Returns the highcharts data.
679
     */
680
    public function setTable($table) {
681
        $this->table = $table;
682
        return $this;
683
    }
684
685
    /**
686
     * Convert into an array representing this instance.
687
     *
688
     * @return array Returns an array representing this instance.
689
     */
690
    public function toArray() {
691
692
        // Initialize the output.
693
        $output = [];
694
695
        // Set the columns.
696
        ArrayUtility::set($output, "columns", $this->columns, [null]);
697
698
        // Set the complete.
699
        ArrayUtility::set($output, "complete", $this->complete, [null]);
700
701
        // Set the csv.
702
        ArrayUtility::set($output, "csv", $this->csv, [null]);
703
704
        // Set the date format.
705
        ArrayUtility::set($output, "dateFormat", $this->dateFormat, [null]);
706
707
        // Set the decimal point.
708
        ArrayUtility::set($output, "decimalPoint", $this->decimalPoint, [null]);
709
710
        // Set the end column.
711
        ArrayUtility::set($output, "endColumn", $this->endColumn, [null]);
712
713
        // Set the end row.
714
        ArrayUtility::set($output, "endRow", $this->endRow, [null]);
715
716
        // Set the first row as names.
717
        ArrayUtility::set($output, "firstRowAsNames", $this->firstRowAsNames, [null]);
718
719
        // Set the google spreadsheet key.
720
        ArrayUtility::set($output, "googleSpreadsheetKey", $this->googleSpreadsheetKey, [null]);
721
722
        // Set the google spreadsheet worksheet.
723
        ArrayUtility::set($output, "googleSpreadsheetWorksheet", $this->googleSpreadsheetWorksheet, [null]);
724
725
        // Set the item delimiter.
726
        ArrayUtility::set($output, "itemDelimiter", $this->itemDelimiter, [null]);
727
728
        // Set the line delimiter.
729
        ArrayUtility::set($output, "lineDelimiter", $this->lineDelimiter, [null]);
730
731
        // Set the parse date.
732
        ArrayUtility::set($output, "parseDate", $this->parseDate, [null]);
733
734
        // Set the parsed.
735
        ArrayUtility::set($output, "parsed", $this->parsed, [null]);
736
737
        // Set the rows.
738
        ArrayUtility::set($output, "rows", $this->rows, [null]);
739
740
        // Set the series mapping.
741
        ArrayUtility::set($output, "seriesMapping", $this->seriesMapping, [null]);
742
743
        // Set the start column.
744
        ArrayUtility::set($output, "startColumn", $this->startColumn, [null]);
745
746
        // Set the start row.
747
        ArrayUtility::set($output, "startRow", $this->startRow, [null]);
748
749
        // Set the switch rows and columns.
750
        ArrayUtility::set($output, "switchRowsAndColumns", $this->switchRowsAndColumns, [null]);
751
752
        // Set the table.
753
        ArrayUtility::set($output, "table", $this->table, [null]);
754
755
        // Return the output.
756
        return $output;
757
    }
758
759
}
760