Skip to content

Commit ead3aad

Browse files
committed
reformat code
1 parent 0f8f09b commit ead3aad

File tree

89 files changed

+1272
-1196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1272
-1196
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
bootstrap: vendor/autoload.php
3939
configuration: phpunit.xml.dist
4040
php_extensions: xdebug
41-
args: tests --coverage-clover ./coverage.xml
41+
args: --coverage-clover ./coverage.xml
4242

4343
- name: Upload to Codecov
4444
uses: codecov/codecov-action@v3

src/Aggregation/AbstractAggregation.php

+34-34
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ abstract class AbstractAggregation implements NamedBuilderInterface
3131

3232
private ?BuilderBag $aggregations = null;
3333

34-
/**
35-
* Abstract supportsNesting method.
36-
*
37-
* @return bool
38-
*/
39-
abstract protected function supportsNesting(): bool;
40-
41-
/**
42-
* @return array|\stdClass
43-
*/
44-
abstract public function getArray(): array|\stdClass;
45-
4634
/**
4735
* Inner aggregations container init.
4836
*
@@ -53,6 +41,14 @@ public function __construct(string $name)
5341
$this->setName($name);
5442
}
5543

44+
/**
45+
* @return string
46+
*/
47+
public function getField()
48+
{
49+
return $this->field;
50+
}
51+
5652
/**
5753
* @param string $field
5854
*
@@ -65,14 +61,6 @@ public function setField($field)
6561
return $this;
6662
}
6763

68-
/**
69-
* @return string
70-
*/
71-
public function getField()
72-
{
73-
return $this->field;
74-
}
75-
7664
/**
7765
* Adds a sub-aggregation.
7866
*
@@ -86,29 +74,25 @@ public function addAggregation(AbstractAggregation $abstractAggregation)
8674
}
8775

8876
$this->aggregations->add($abstractAggregation);
89-
77+
9078
return $this;
9179
}
9280

9381
/**
94-
* Returns all sub aggregations.
82+
* Creates BuilderBag new instance.
9583
*
96-
* @return BuilderBag[]|NamedBuilderInterface[]
84+
* @return BuilderBag
9785
*/
98-
public function getAggregations()
86+
private function createBuilderBag()
9987
{
100-
if ($this->aggregations instanceof BuilderBag) {
101-
return $this->aggregations->all();
102-
} else {
103-
return [];
104-
}
88+
return new BuilderBag();
10589
}
10690

10791
/**
10892
* Returns sub aggregation.
10993
* @param string $name Aggregation name to return.
11094
*
111-
* @return AbstractAggregation|NamedBuilderInterface|null
95+
* @return \ONGR\ElasticsearchDSL\BuilderInterface
11296
*/
11397
public function getAggregation($name)
11498
{
@@ -140,6 +124,18 @@ public function toArray(): array|\stdClass
140124
return $result;
141125
}
142126

127+
/**
128+
* @return array|\stdClass
129+
*/
130+
abstract public function getArray(): array|\stdClass;
131+
132+
/**
133+
* Abstract supportsNesting method.
134+
*
135+
* @return bool
136+
*/
137+
abstract protected function supportsNesting(): bool;
138+
143139
/**
144140
* Process all nested aggregations.
145141
*
@@ -157,12 +153,16 @@ protected function collectNestedAggregations()
157153
}
158154

159155
/**
160-
* Creates BuilderBag new instance.
156+
* Returns all sub aggregations.
161157
*
162-
* @return BuilderBag
158+
* @return BuilderBag[]|NamedBuilderInterface[]
163159
*/
164-
private function createBuilderBag()
160+
public function getAggregations(): array
165161
{
166-
return new BuilderBag();
162+
if ($this->aggregations instanceof BuilderBag) {
163+
return $this->aggregations->all();
164+
} else {
165+
return [];
166+
}
167167
}
168168
}

src/Aggregation/Bucketing/AdjacencyMatrixAggregation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class AdjacencyMatrixAggregation extends AbstractAggregation
3030
* @var BuilderInterface[]
3131
*/
3232
private array $filters = [
33-
self::FILTERS => []
33+
self::FILTERS => [],
3434
];
3535

3636
/**
3737
* Inner aggregations container init.
3838
*
39-
* @param string $name
39+
* @param string $name
4040
* @param BuilderInterface[] $filters
4141
*/
4242
public function __construct(string $name, array $filters = [])

src/Aggregation/Bucketing/AutoDateHistogramAggregation.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
1515
use ONGR\ElasticsearchDSL\Aggregation\Type\BucketingTrait;
16-
use ONGR\ElasticsearchDSL\BuilderInterface;
1716

1817
/**
1918
* Class representing AutoDateHistogramAggregation.
@@ -29,7 +28,7 @@ class AutoDateHistogramAggregation extends AbstractAggregation
2928
*
3029
* @param string $name
3130
* @param string $field
32-
* @param int $buckets
31+
* @param int $buckets
3332
* @param string $format
3433
*/
3534
public function __construct(string $name, $field, $buckets = null, $format = null)

src/Aggregation/Bucketing/ChildrenAggregation.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ public function __construct(string $name, ?string $children = null)
3232
$this->setChildren($children);
3333
}
3434

35-
public function setChildren(?string $children): static
36-
{
37-
$this->children = $children;
38-
39-
return $this;
40-
}
41-
42-
public function getChildren(): ?string
43-
{
44-
return $this->children;
45-
}
46-
4735
/**
4836
* {@inheritdoc}
4937
*/
@@ -63,4 +51,16 @@ public function getArray(): array|\stdClass
6351

6452
return ['type' => $this->getChildren()];
6553
}
54+
55+
public function getChildren(): ?string
56+
{
57+
return $this->children;
58+
}
59+
60+
public function setChildren(?string $children): static
61+
{
62+
$this->children = $children;
63+
64+
return $this;
65+
}
6666
}

src/Aggregation/Bucketing/CompositeAggregation.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function addSource(AbstractAggregation $agg): static
5454
$array = is_array($array) ? array_merge($array, $agg->getParameters()) : $array;
5555

5656
$this->sources[] = [
57-
$agg->getName() => [ $agg->getType() => $array ]
57+
$agg->getName() => [$agg->getType() => $array],
5858
];
5959

6060
return $this;
@@ -88,16 +88,21 @@ public function getType(): string
8888
return 'composite';
8989
}
9090

91+
public function getSize(): ?int
92+
{
93+
return $this->size;
94+
}
95+
9196
public function setSize(int $size): static
9297
{
9398
$this->size = $size;
9499

95100
return $this;
96101
}
97102

98-
public function getSize(): ?int
103+
public function getAfter(): ?array
99104
{
100-
return $this->size;
105+
return $this->after;
101106
}
102107

103108
public function setAfter(array $after): static
@@ -106,9 +111,4 @@ public function setAfter(array $after): static
106111

107112
return $this;
108113
}
109-
110-
public function getAfter(): ?array
111-
{
112-
return $this->after;
113-
}
114114
}

src/Aggregation/Bucketing/DateHistogramAggregation.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ public function __construct(string $name, ?string $field = null, ?string $interv
3838
$this->setFormat($format);
3939
}
4040

41-
public function getInterval(): ?string
42-
{
43-
return $this->interval;
44-
}
45-
46-
public function setInterval(?string $interval): static
47-
{
48-
$this->interval = $interval;
49-
50-
return $this;
51-
}
52-
5341
public function setFormat(?string $format): static
5442
{
5543
$this->format = $format;
@@ -85,4 +73,16 @@ public function getArray(): array|\stdClass
8573

8674
return $out;
8775
}
76+
77+
public function getInterval(): ?string
78+
{
79+
return $this->interval;
80+
}
81+
82+
public function setInterval(?string $interval): static
83+
{
84+
$this->interval = $interval;
85+
86+
return $this;
87+
}
8888
}

src/Aggregation/Bucketing/DateRangeAggregation.php

+17-12
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ class DateRangeAggregation extends AbstractAggregation
2727
private array $ranges = [];
2828
private bool $keyed = false;
2929

30-
public function __construct(string $name, ?string $field = null, ?string $format = null, array $ranges = [], bool $keyed = false)
31-
{
30+
public function __construct(
31+
string $name,
32+
?string $field = null,
33+
?string $format = null,
34+
array $ranges = [],
35+
bool $keyed = false
36+
) {
3237
parent::__construct($name);
3338

3439
$this->setField($field);
@@ -54,16 +59,6 @@ public function setKeyed(bool $keyed): static
5459
return $this;
5560
}
5661

57-
public function getFormat(): ?string
58-
{
59-
return $this->format;
60-
}
61-
62-
public function setFormat(?string $format): void
63-
{
64-
$this->format = $format;
65-
}
66-
6762
/**
6863
* Add range to aggregation.
6964
*
@@ -112,6 +107,16 @@ public function getArray(): array|\stdClass
112107
throw new \LogicException('Date range aggregation must have field, format set and range added.');
113108
}
114109

110+
public function getFormat(): ?string
111+
{
112+
return $this->format;
113+
}
114+
115+
public function setFormat(?string $format): void
116+
{
117+
$this->format = $format;
118+
}
119+
115120
/**
116121
* {@inheritdoc}
117122
*/

src/Aggregation/Bucketing/DiversifiedSamplerAggregation.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,6 @@ public function __construct(string $name, $field = null, $shardSize = null)
4444
$this->setShardSize($shardSize);
4545
}
4646

47-
/**
48-
* @return mixed
49-
*/
50-
public function getShardSize()
51-
{
52-
return $this->shardSize;
53-
}
54-
55-
/**
56-
* @return $this
57-
*/
58-
public function setShardSize(mixed $shardSize)
59-
{
60-
$this->shardSize = $shardSize;
61-
62-
return $this;
63-
}
64-
6547
/**
6648
* @inheritdoc
6749
*/
@@ -82,4 +64,22 @@ public function getArray(): array|\stdClass
8264
]
8365
);
8466
}
67+
68+
/**
69+
* @return mixed
70+
*/
71+
public function getShardSize()
72+
{
73+
return $this->shardSize;
74+
}
75+
76+
/**
77+
* @return $this
78+
*/
79+
public function setShardSize(mixed $shardSize)
80+
{
81+
$this->shardSize = $shardSize;
82+
83+
return $this;
84+
}
8585
}

0 commit comments

Comments
 (0)