Skip to content

Commit 06f0175

Browse files
authored
Refactor: snake_case to camelCase variables (#1288)
1 parent fe7954d commit 06f0175

6 files changed

Lines changed: 55 additions & 55 deletions

File tree

src/ColumnsSummary.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ public function setRenderer(callable $renderer): self
112112
public function setFormat(
113113
string $key,
114114
int $decimals = 0,
115-
string $dec_point = '.',
116-
string $thousands_sep = ' '
115+
string $decPoint = '.',
116+
string $thousandsSep = ' '
117117
): self
118118
{
119-
$this->format[$key] = [$decimals, $dec_point, $thousands_sep];
119+
$this->format[$key] = [$decimals, $decPoint, $thousandsSep];
120120

121121
return $this;
122122
}

src/DataSource/ArrayDataSource.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public function sort(Sorting $sorting): IDataSource
117117

118118
foreach ($this->data as $item) {
119119
$value = is_object($item) ? $item->$column : $item[$column]; // @phpstan-ignore-line
120-
$sort_by = $value instanceof DateTimeInterface ? $value->format('Y-m-d H:i:s') : (string) $value;
120+
$sortBy = $value instanceof DateTimeInterface ? $value->format('Y-m-d H:i:s') : (string) $value;
121121

122-
$data[$sort_by][] = $item;
122+
$data[$sortBy][] = $item;
123123
}
124124

125125
if ($order === 'ASC') {
@@ -177,12 +177,12 @@ protected function applyFilter(mixed $row, Filter $filter): mixed
177177

178178
$words = $filter instanceof FilterText && $filter->hasSplitWordsSearch() === false ? [$value] : explode(' ', $value);
179179

180-
$row_value = strtolower(Strings::toAscii((string) $row[$column]));
180+
$rowValue = strtolower(Strings::toAscii((string) $row[$column]));
181181

182182
$found = [];
183183

184184
foreach ($words as $word) {
185-
if (str_contains($row_value, strtolower(Strings::toAscii($word)))) {
185+
if (str_contains($rowValue, strtolower(Strings::toAscii($word)))) {
186186
if ($filter instanceof FilterText && !$filter->hasConjunctionSearch()) {
187187
return $row;
188188
} else {
@@ -233,22 +233,22 @@ protected function applyFilterDateRange(mixed $row, FilterDateRange $filter): bo
233233
$format = $filter->getPhpFormat();
234234
$condition = $filter->getCondition();
235235
$values = $condition[$filter->getColumn()];
236-
$row_value = $row[$filter->getColumn()];
236+
$rowValue = $row[$filter->getColumn()];
237237

238238
if ($values['from'] !== null && $values['from'] !== '') {
239239
try {
240-
$date_from = DateTimeHelper::tryConvertToDate($values['from'], [$format]);
241-
$date_from->setTime(0, 0, 0);
240+
$dateFrom = DateTimeHelper::tryConvertToDate($values['from'], [$format]);
241+
$dateFrom->setTime(0, 0, 0);
242242
} catch (DatagridDateTimeHelperException) {
243243
return false;
244244
}
245245

246-
if (!($row_value instanceof DateTime)) {
246+
if (!($rowValue instanceof DateTime)) {
247247
/**
248248
* Try to convert string to DateTime object
249249
*/
250250
try {
251-
$row_value = DateTimeHelper::tryConvertToDate($row_value);
251+
$rowValue = DateTimeHelper::tryConvertToDate($rowValue);
252252
} catch (DatagridDateTimeHelperException) {
253253
/**
254254
* Otherwise just return raw string
@@ -257,25 +257,25 @@ protected function applyFilterDateRange(mixed $row, FilterDateRange $filter): bo
257257
}
258258
}
259259

260-
if ($row_value->getTimestamp() < $date_from->getTimestamp()) {
260+
if ($rowValue->getTimestamp() < $dateFrom->getTimestamp()) {
261261
return false;
262262
}
263263
}
264264

265265
if ($values['to'] !== null && $values['to'] !== '') {
266266
try {
267-
$date_to = DateTimeHelper::tryConvertToDate($values['to'], [$format]);
268-
$date_to->setTime(23, 59, 59);
267+
$dateTo = DateTimeHelper::tryConvertToDate($values['to'], [$format]);
268+
$dateTo->setTime(23, 59, 59);
269269
} catch (DatagridDateTimeHelperException) {
270270
return false;
271271
}
272272

273-
if (!($row_value instanceof DateTime)) {
273+
if (!($rowValue instanceof DateTime)) {
274274
/**
275275
* Try to convert string to DateTime object
276276
*/
277277
try {
278-
$row_value = DateTimeHelper::tryConvertToDate($row_value);
278+
$rowValue = DateTimeHelper::tryConvertToDate($rowValue);
279279
} catch (DatagridDateTimeHelperException) {
280280
/**
281281
* Otherwise just return raw string
@@ -284,7 +284,7 @@ protected function applyFilterDateRange(mixed $row, FilterDateRange $filter): bo
284284
}
285285
}
286286

287-
if ($row_value->getTimestamp() > $date_to->getTimestamp()) {
287+
if ($rowValue->getTimestamp() > $dateTo->getTimestamp()) {
288288
return false;
289289
}
290290
}
@@ -301,20 +301,20 @@ protected function applyFilterDate(mixed $row, FilterDate $filter): bool
301301
$condition = $filter->getCondition();
302302

303303
foreach ($condition as $column => $value) {
304-
$row_value = $row[$column];
304+
$rowValue = $row[$column];
305305

306306
try {
307307
$date = DateTimeHelper::tryConvertToDateTime($value, [$format]);
308308
} catch (DatagridDateTimeHelperException) {
309309
return false;
310310
}
311311

312-
if (!($row_value instanceof DateTime)) {
312+
if (!($rowValue instanceof DateTime)) {
313313
/**
314314
* Try to convert string to DateTime object
315315
*/
316316
try {
317-
$row_value = DateTimeHelper::tryConvertToDateTime($row_value);
317+
$rowValue = DateTimeHelper::tryConvertToDateTime($rowValue);
318318
} catch (DatagridDateTimeHelperException) {
319319
/**
320320
* Otherwise just return raw string
@@ -323,7 +323,7 @@ protected function applyFilterDate(mixed $row, FilterDate $filter): bool
323323
}
324324
}
325325

326-
return $row_value->format($format) === $date->format($format);
326+
return $rowValue->format($format) === $date->format($format);
327327
}
328328

329329
return false;

src/DataSource/NextrasDataSource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ protected function applyFilterDate(FilterDate $filter): void
120120
foreach ($filter->getCondition() as $column => $value) {
121121
try {
122122
$date = DateTimeHelper::tryConvertToDateTime($value, [$filter->getPhpFormat()]);
123-
$date_end = clone $date;
123+
$dateEnd = clone $date;
124124

125125
$this->dataSource = $this->dataSource->findBy([
126126
$this->prepareColumn($column) . '>=' => $date->setTime(0, 0, 0),
127-
$this->prepareColumn($column) . '<=' => $date_end->setTime(23, 59, 59),
127+
$this->prepareColumn($column) . '<=' => $dateEnd->setTime(23, 59, 59),
128128
]);
129129
} catch (DatagridDateTimeHelperException) {
130130
// ignore the invalid filter value

src/Datagrid.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,9 @@ public function setStrictStorageFilterValues(bool $strictStorageFilterValues = t
10381038
********************************************************************************/
10391039
public function isFilterActive(): bool
10401040
{
1041-
$is_filter = ArraysHelper::testTruthy($this->filter);
1041+
$isFilter = ArraysHelper::testTruthy($this->filter);
10421042

1043-
return $is_filter || $this->forceFilterActive;
1043+
return $isFilter || $this->forceFilterActive;
10441044
}
10451045

10461046
public function isFilterDefault(): bool
@@ -1151,16 +1151,16 @@ public function createComponentFilter(): Form
11511151
/**
11521152
* InlineEdit part
11531153
*/
1154-
$inline_edit_container = $form->addContainer('inline_edit');
1154+
$inlineEditContainer = $form->addContainer('inline_edit');
11551155

11561156
if ($this->inlineEdit instanceof InlineEdit) {
1157-
$inline_edit_container->addSubmit('submit', 'contributte_datagrid.save')
1158-
->setValidationScope([$inline_edit_container]);
1159-
$inline_edit_container->addSubmit('cancel', 'contributte_datagrid.cancel')
1157+
$inlineEditContainer->addSubmit('submit', 'contributte_datagrid.save')
1158+
->setValidationScope([$inlineEditContainer]);
1159+
$inlineEditContainer->addSubmit('cancel', 'contributte_datagrid.cancel')
11601160
->setValidationScope(null);
11611161

1162-
$this->inlineEdit->onControlAdd($inline_edit_container);
1163-
$this->inlineEdit->onControlAfterAdd($inline_edit_container);
1162+
$this->inlineEdit->onControlAdd($inlineEditContainer);
1163+
$this->inlineEdit->onControlAfterAdd($inlineEditContainer);
11641164
}
11651165

11661166
/**
@@ -1827,15 +1827,15 @@ public function sendNonEmptyFiltersInPayload(array $filters): void
18271827
return;
18281828
}
18291829

1830-
$non_empty_filters = [];
1830+
$nonEmptyFilters = [];
18311831

18321832
foreach ($filters as $filter) {
18331833
if ($filter->isValueSet()) {
1834-
$non_empty_filters[] = $filter->getKey();
1834+
$nonEmptyFilters[] = $filter->getKey();
18351835
}
18361836
}
18371837

1838-
$this->getPresenterInstance()->payload->non_empty_filters = $non_empty_filters;
1838+
$this->getPresenterInstance()->payload->non_empty_filters = $nonEmptyFilters;
18391839
}
18401840

18411841
public function handleExport(mixed $id): void
@@ -2287,16 +2287,16 @@ public function getTranslator(): Translator
22872287
*/
22882288
public function setColumnsOrder(array $order): self
22892289
{
2290-
$new_order = [];
2290+
$newOrder = [];
22912291

22922292
foreach ($order as $key) {
22932293
if (isset($this->columns[$key])) {
2294-
$new_order[$key] = $this->columns[$key];
2294+
$newOrder[$key] = $this->columns[$key];
22952295
}
22962296
}
22972297

2298-
if (count($new_order) === count($this->columns)) {
2299-
$this->columns = $new_order;
2298+
if (count($newOrder) === count($this->columns)) {
2299+
$this->columns = $newOrder;
23002300
} else {
23012301
throw new DatagridException('When changing columns order, you have to specify all columns');
23022302
}
@@ -2742,23 +2742,23 @@ public function getColumns(): array
27422742
$this->getParentComponent();
27432743

27442744
if (! (bool) $this->getStorageData('_grid_hidden_columns_manipulated', false)) {
2745-
$columns_to_hide = [];
2745+
$columnsToHide = [];
27462746

27472747
foreach ($this->columns as $key => $column) {
27482748
if ($column->getDefaultHide()) {
2749-
$columns_to_hide[] = $key;
2749+
$columnsToHide[] = $key;
27502750
}
27512751
}
27522752

2753-
if ($columns_to_hide !== []) {
2754-
$this->saveStorageData('_grid_hidden_columns', $columns_to_hide);
2753+
if ($columnsToHide !== []) {
2754+
$this->saveStorageData('_grid_hidden_columns', $columnsToHide);
27552755
$this->saveStorageData('_grid_hidden_columns_manipulated', true);
27562756
}
27572757
}
27582758

2759-
$hidden_columns = $this->getStorageData('_grid_hidden_columns', []);
2759+
$hiddenColumns = $this->getStorageData('_grid_hidden_columns', []);
27602760

2761-
foreach ($hidden_columns ?? [] as $column) {
2761+
foreach ($hiddenColumns ?? [] as $column) {
27622762
if (isset($this->columns[$column])) {
27632763
$this->columnsVisibility[$column] = [
27642764
'visible' => false,

src/Filter/FilterRange.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ public function addToFormContainer(Container $container): void
3838
$placeholders = $this->getPlaceholders();
3939

4040
if ($placeholders !== []) {
41-
$text_from = reset($placeholders);
41+
$textFrom = reset($placeholders);
4242

43-
if ($text_from) {
44-
$from->setHtmlAttribute('placeholder', $text_from);
43+
if ($textFrom) {
44+
$from->setHtmlAttribute('placeholder', $textFrom);
4545
}
4646

47-
$text_to = end($placeholders);
47+
$textTo = end($placeholders);
4848

49-
if ($text_to && ($text_to !== $text_from)) {
50-
$to->setHtmlAttribute('placeholder', $text_to);
49+
if ($textTo && ($textTo !== $textFrom)) {
50+
$to->setHtmlAttribute('placeholder', $textTo);
5151
}
5252
}
5353
}

src/GroupAction/GroupActionCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function addToFormContainer(Container $container): void
2929
$form = $container->lookup(Form::class);
3030
$lookupPath = $container->lookupPath();
3131
$translator = $form->getTranslator();
32-
$main_options = [];
32+
$mainOptions = [];
3333

3434
if ($translator === null) {
3535
throw new UnexpectedValueException();
@@ -61,11 +61,11 @@ public function addToFormContainer(Container $container): void
6161
*/
6262
foreach ($this->groupActions as $id => $action) {
6363
if (! $action instanceof GroupButtonAction) {
64-
$main_options[$id] = $action->getTitle();
64+
$mainOptions[$id] = $action->getTitle();
6565
}
6666
}
6767

68-
$groupActionSelect = $container->addSelect('group_action', '', $main_options)
68+
$groupActionSelect = $container->addSelect('group_action', '', $mainOptions)
6969
->setPrompt('contributte_datagrid.choose');
7070

7171
/**
@@ -118,7 +118,7 @@ public function addToFormContainer(Container $container): void
118118
}
119119
}
120120

121-
if ($main_options !== []) {
121+
if ($mainOptions !== []) {
122122
foreach (array_keys($this->groupActions) as $id) {
123123
$groupActionSelect->addCondition(Form::Equal, $id)
124124
->toggle($lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);

0 commit comments

Comments
 (0)