PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Worksheet / CellIterator.php

CellIterator.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Worksheet/CellIterator.php

86 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Worksheet;
4
5 use Iterator as NativeIterator;
6 use TablePress\PhpOffice\PhpSpreadsheet\Cell\Cell;
7 use TablePress\PhpOffice\PhpSpreadsheet\Collection\Cells;
8
9 /**
10 * @template TKey
11 *
12 * @implements NativeIterator<TKey, Cell>
13 */
14 abstract class CellIterator implements NativeIterator
15 {
16 public const TREAT_NULL_VALUE_AS_EMPTY_CELL = 1;
17
18 public const TREAT_EMPTY_STRING_AS_EMPTY_CELL = 2;
19
20 public const IF_NOT_EXISTS_RETURN_NULL = false;
21
22 public const IF_NOT_EXISTS_CREATE_NEW = true;
23
24 /**
25 * Worksheet to iterate.
26 */
27 protected Worksheet $worksheet;
28
29 /**
30 * Cell Collection to iterate.
31 */
32 protected Cells $cellCollection;
33
34 /**
35 * Iterate only existing cells.
36 */
37 protected bool $onlyExistingCells = false;
38
39 /**
40 * If iterating all cells, and a cell doesn't exist, identifies whether a new cell should be created,
41 * or if the iterator should return a null value.
42 */
43 protected bool $ifNotExists = self::IF_NOT_EXISTS_CREATE_NEW;
44
45 /**
46 * Destructor.
47 */
48 public function __destruct()
49 {
50 unset($this->worksheet, $this->cellCollection);
51 }
52
53 public function getIfNotExists(): bool
54 {
55 return $this->ifNotExists;
56 }
57
58 public function setIfNotExists(bool $ifNotExists = self::IF_NOT_EXISTS_CREATE_NEW): void
59 {
60 $this->ifNotExists = $ifNotExists;
61 }
62
63 /**
64 * Get loop only existing cells.
65 */
66 public function getIterateOnlyExistingCells(): bool
67 {
68 return $this->onlyExistingCells;
69 }
70
71 /**
72 * Validate start/end values for 'IterateOnlyExistingCells' mode, and adjust if necessary.
73 */
74 abstract protected function adjustForExistingOnlyRange(): void;
75
76 /**
77 * Set the iterator to loop only existing cells.
78 */
79 public function setIterateOnlyExistingCells(bool $value): void
80 {
81 $this->onlyExistingCells = (bool) $value;
82
83 $this->adjustForExistingOnlyRange();
84 }
85 }
86