This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Nikaia\TranslationSheet\Sheet; |
||
4 | |||
5 | class TranslationsSheetCoordinates |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
6 | { |
||
7 | protected $headerRowsCount = 1; |
||
8 | |||
9 | protected $dataRowsCount = 0; |
||
10 | |||
11 | protected $columnsCount = 0; |
||
12 | |||
13 | protected $localesCount = 1; |
||
14 | |||
15 | protected $sheetId; |
||
16 | |||
17 | protected $sheetTitle; |
||
18 | |||
19 | 9 | private function __construct() |
|
20 | { |
||
21 | 9 | } |
|
22 | |||
23 | 4 | public function setSheetId($sheetId) |
|
24 | { |
||
25 | 4 | $this->sheetId = $sheetId; |
|
26 | |||
27 | 4 | return $this; |
|
28 | } |
||
29 | |||
30 | 4 | public function setSheetTitle($sheetTitle) |
|
31 | { |
||
32 | 4 | $this->sheetTitle = $sheetTitle; |
|
33 | |||
34 | 4 | return $this; |
|
35 | } |
||
36 | |||
37 | 6 | public static function emptySheet($columnsCount, $localesCount, $headerRowsCount) |
|
38 | { |
||
39 | 6 | $instance = new self; |
|
40 | |||
41 | 6 | $instance->headerRowsCount = $headerRowsCount; |
|
42 | 6 | $instance->dataRowsCount = 10; |
|
43 | 6 | $instance->columnsCount = $columnsCount; |
|
44 | 6 | $instance->localesCount = $localesCount; |
|
45 | |||
46 | 6 | return $instance; |
|
47 | } |
||
48 | |||
49 | 3 | public static function sheetWithData($dataRowsCount, $columnsCount, $localesCount, $headerRowsCount) |
|
50 | { |
||
51 | 3 | $instance = new self; |
|
52 | |||
53 | 3 | $instance->headerRowsCount = $headerRowsCount; |
|
54 | 3 | $instance->dataRowsCount = $dataRowsCount; |
|
55 | 3 | $instance->columnsCount = $columnsCount; |
|
56 | 3 | $instance->localesCount = $localesCount; |
|
57 | |||
58 | 3 | return $instance; |
|
59 | } |
||
60 | |||
61 | 1 | public function headerShortRange() |
|
62 | { |
||
63 | 1 | return $this->sheetTitle.'!A1:'.self::stringFromColumnIndex($this->getColumnsCount()).'1'; |
|
64 | } |
||
65 | |||
66 | 2 | View Code Duplication | public function headerRange() |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
67 | { |
||
68 | return [ |
||
69 | 2 | 'sheetId' => $this->sheetId, |
|
70 | 2 | 'startRowIndex' => 0, |
|
71 | 2 | 'endRowIndex' => 1, |
|
72 | 2 | 'startColumnIndex' => 0, |
|
73 | 2 | 'endColumnIndex' => $this->getColumnsCount(), |
|
74 | ]; |
||
75 | } |
||
76 | |||
77 | 2 | View Code Duplication | public function fullKeyColumnRange() |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
78 | { |
||
79 | return [ |
||
80 | 2 | 'sheetId' => $this->sheetId, |
|
81 | 2 | 'startRowIndex' => 1, |
|
82 | 2 | 'endRowIndex' => $this->getRowsCount(), |
|
83 | 2 | 'startColumnIndex' => 0, |
|
84 | 2 | 'endColumnIndex' => 1, |
|
85 | ]; |
||
86 | } |
||
87 | |||
88 | 2 | public function metaColumnsRange() |
|
89 | { |
||
90 | return [ |
||
91 | 2 | 'sheetId' => $this->sheetId, |
|
92 | 2 | 'startRowIndex' => 1, |
|
93 | 2 | 'endRowIndex' => $this->getRowsCount(), |
|
94 | 2 | 'startColumnIndex' => $this->getLocalesCount() + 1, |
|
95 | 2 | 'endColumnIndex' => $this->getColumnsCount(), |
|
96 | ]; |
||
97 | } |
||
98 | |||
99 | 3 | public function dataShortRange($firstRow = 2, $noLastRow = false) |
|
100 | { |
||
101 | 3 | $firstColumn = 'A'; |
|
102 | 3 | $lastColumn = self::stringFromColumnIndex($this->getColumnsCount()); |
|
103 | 3 | $lastRow = $this->getRowsCount(); |
|
104 | |||
105 | 3 | return $this->sheetTitle.'!'.$firstColumn.$firstRow.':'.$lastColumn.($noLastRow ? '' : $lastRow); |
|
106 | } |
||
107 | |||
108 | View Code Duplication | public function dataRange($endRow, $firstRow = 2) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
109 | { |
||
110 | return [ |
||
111 | 'sheetId' => $this->sheetId, |
||
112 | 'startRowIndex' => $firstRow, |
||
113 | 'endRowIndex' => $endRow, |
||
114 | 'startColumnIndex' => 0, |
||
115 | 'endColumnIndex' => $this->getColumnsCount(), |
||
116 | ]; |
||
117 | } |
||
118 | |||
119 | 4 | public function translationsRange($firstColumn = 1, $rowCount = null) |
|
120 | { |
||
121 | return [ |
||
122 | 4 | 'sheetId' => $this->sheetId, |
|
123 | 4 | 'startRowIndex' => 1, |
|
124 | 4 | 'endRowIndex' => $rowCount ?: $this->getRowsCount(), |
|
125 | 4 | 'startColumnIndex' => $firstColumn, |
|
126 | 4 | 'endColumnIndex' => $firstColumn + $this->getLocalesCount(), |
|
127 | ]; |
||
128 | } |
||
129 | |||
130 | 4 | public function getColumnsCount() |
|
131 | { |
||
132 | 4 | return $this->columnsCount; |
|
133 | } |
||
134 | |||
135 | 6 | public function getRowsCount() |
|
136 | { |
||
137 | 6 | return $this->dataRowsCount + $this->headerRowsCount; |
|
138 | } |
||
139 | |||
140 | 4 | public function getLocalesCount() |
|
141 | { |
||
142 | 4 | return $this->localesCount; |
|
143 | } |
||
144 | |||
145 | 2 | public function namespaceColumnIndex() |
|
146 | { |
||
147 | 2 | return $this->getLocalesCount() + 1; |
|
148 | } |
||
149 | |||
150 | 2 | public function groupColumnIndex() |
|
151 | { |
||
152 | 2 | return $this->getLocalesCount() + 2; |
|
153 | } |
||
154 | |||
155 | 2 | public function keyColumnIndex() |
|
156 | { |
||
157 | 2 | return $this->getLocalesCount() + 3; |
|
158 | } |
||
159 | |||
160 | 2 | public function sourceFileColumnIndex() |
|
161 | { |
||
162 | 2 | return $this->getLocalesCount() + 4; |
|
163 | } |
||
164 | |||
165 | /** |
||
166 | * String from column index. |
||
167 | * |
||
168 | * @see https://github.com/PHPOffice/PhpSpreadsheet/blob/master/src/PhpSpreadsheet/Cell/Coordinate.php Source of implementation. |
||
169 | * |
||
170 | * @license https://raw.githubusercontent.com/PHPOffice/PhpSpreadsheet/master/LICENSE LGPL (GNU LESSER GENERAL PUBLIC LICENSE) |
||
171 | * |
||
172 | * @param int $columnIndex Column index (A = 1) |
||
173 | * |
||
174 | * @return string |
||
175 | */ |
||
176 | 3 | public static function stringFromColumnIndex($columnIndex) |
|
177 | { |
||
178 | 3 | static $indexCache = []; |
|
179 | 3 | if (! isset($indexCache[$columnIndex])) { |
|
180 | 2 | $indexValue = $columnIndex; |
|
181 | 2 | $base26 = null; |
|
182 | do { |
||
183 | 2 | $characterValue = ($indexValue % 26) ?: 26; |
|
184 | 2 | $indexValue = ($indexValue - $characterValue) / 26; |
|
185 | 2 | $base26 = chr($characterValue + 64).($base26 ?: ''); |
|
186 | 2 | } while ($indexValue > 0); |
|
187 | 2 | $indexCache[$columnIndex] = $base26; |
|
188 | } |
||
189 | |||
190 | 3 | return $indexCache[$columnIndex]; |
|
191 | } |
||
192 | } |
||
193 |