Skip to content

Commit 8d02fb7

Browse files
committed
refactor: clean up code formatting and comments in grammar and pivot table traits
1 parent d7ef97d commit 8d02fb7

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/Query/Grammar.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ public function _buildInnerHits($innerQuery)
548548
$innerHits['from'] = $innerQuery->offset;
549549
}
550550
if ($size = $innerQuery->getSetLimit()) {
551-
# TODO: David should we handle this diffrently?
552-
# Nested queries have a hard limit of 100 for inner_hits size
551+
// TODO: David should we handle this diffrently?
552+
// Nested queries have a hard limit of 100 for inner_hits size
553553
$innerHits['size'] = min($size, 100);
554554
}
555555

Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types=1);
44

5-
namespace PDPhilip\Elasticsearch\Relations\Traits;
5+
namespace PDPhilip\Elasticsearch\Relations\Traits;
66

7-
use BackedEnum;
8-
9-
trait InteractsWithPivotTable
10-
{
7+
use BackedEnum;
118

9+
trait InteractsWithPivotTable
10+
{
1211
/** {@inheritdoc} */
1312
protected function formatRecordsList(array $records)
1413
{
15-
return collect($records)->mapWithKeys(function ($attributes, $id) {
16-
if (! is_array($attributes)) {
17-
[$id, $attributes] = [$attributes, []];
18-
}
19-
20-
if ($id instanceof BackedEnum) {
21-
$id = $id->value;
22-
}
23-
24-
// We have to convert all Key Ids to string values to keep it consistent in Elastic.
25-
return [(string) $id => $attributes];
26-
})->all();
14+
return collect($records)->mapWithKeys(function ($attributes, $id) {
15+
if (! is_array($attributes)) {
16+
[$id, $attributes] = [$attributes, []];
17+
}
18+
19+
if ($id instanceof BackedEnum) {
20+
$id = $id->value;
21+
}
22+
23+
// We have to convert all Key Ids to string values to keep it consistent in Elastic.
24+
return [(string) $id => $attributes];
25+
})->all();
2726
}
2827

2928
/** {@inheritdoc} */
3029
protected function parseIds($value)
3130
{
32-
// We have to convert all Key Ids to string values to keep it consistent in Elastic.
33-
return collect(parent::parseIds($value))->mapWithKeys(function ($value, $key) {
34-
return [(string) $key => $value];
35-
})->all();
31+
// We have to convert all Key Ids to string values to keep it consistent in Elastic.
32+
return collect(parent::parseIds($value))->mapWithKeys(function ($value, $key) {
33+
return [(string) $key => $value];
34+
})->all();
3635
}
37-
38-
}
36+
}

0 commit comments

Comments
 (0)