Skip to content

Commit 88d8918

Browse files
committed
Clean up + CS + PHPSTAN
1 parent a273914 commit 88d8918

23 files changed

+300
-391
lines changed

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
"issues": "https://github.com/Spameri/ElasticQuery/issues"
1212
},
1313
"require": {
14-
"php": ">=7.1",
15-
"elasticsearch/elasticsearch": "^6.0"
14+
"php": ">=7.1"
1615
},
1716
"require-dev": {
1817
"phpstan/phpstan-shim": "v0.10.3",
@@ -24,6 +23,8 @@
2423
}
2524
},
2625
"autoload-dev": {
27-
"Spameri\\": "tests"
26+
"psr-4": {
27+
"SpameriTests\\": "tests/SpameriTests"
28+
}
2829
}
2930
}

composer.lock

Lines changed: 5 additions & 255 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aggregation/AggregationCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ class AggregationCollection implements LeafAggregationInterface
1212
private $filter;
1313

1414
/**
15-
* @var \Spameri\ElasticQuery\Aggregation\LeafAggregationCollection
15+
* @var \Spameri\ElasticQuery\Aggregation\LeafAggregationCollection[]
1616
*/
1717
private $aggregations;
1818

1919

2020
public function __construct(
21-
?\Spameri\ElasticQuery\Filter\FilterCollection $filter,
22-
\Spameri\ElasticQuery\Aggregation\LeafAggregationCollection ... $aggregations
21+
?\Spameri\ElasticQuery\Filter\FilterCollection $filter = NULL
22+
, \Spameri\ElasticQuery\Aggregation\LeafAggregationCollection ... $aggregations
2323
)
2424
{
2525
if ( ! $filter) {

src/Aggregation/Histogram.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
namespace Spameri\ElasticQuery\Aggregation;
44

55

6+
/**
7+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html
8+
*/
69
class Histogram implements LeafAggregationInterface
710
{
811

@@ -18,8 +21,8 @@ class Histogram implements LeafAggregationInterface
1821

1922

2023
public function __construct(
21-
string $field,
22-
int $interval
24+
string $field
25+
, int $interval
2326
)
2427
{
2528
$this->field = $field;
@@ -42,4 +45,5 @@ public function toArray() : array
4245
],
4346
];
4447
}
48+
4549
}

src/Aggregation/LeafAggregationCollection.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Spameri\ElasticQuery\Aggregation;
44

55

6-
class LeafAggregationCollection implements LeafAggregationInterface
6+
class LeafAggregationCollection implements LeafAggregationInterface, \IteratorAggregate
77
{
88

99
/**
@@ -17,15 +17,15 @@ class LeafAggregationCollection implements LeafAggregationInterface
1717
private $filter;
1818

1919
/**
20-
* @var \Spameri\ElasticQuery\Aggregation\LeafAggregationInterface
20+
* @var \Spameri\ElasticQuery\Aggregation\LeafAggregationInterface[]
2121
*/
2222
private $aggregations;
2323

2424

2525
public function __construct(
26-
string $name,
27-
?\Spameri\ElasticQuery\Filter\FilterCollection $filter,
28-
\Spameri\ElasticQuery\Aggregation\LeafAggregationInterface ... $aggregations
26+
string $name
27+
, ?\Spameri\ElasticQuery\Filter\FilterCollection $filter
28+
, \Spameri\ElasticQuery\Aggregation\LeafAggregationInterface ... $aggregations
2929
)
3030
{
3131
if ( ! $filter) {
@@ -50,12 +50,18 @@ public function filter() : \Spameri\ElasticQuery\Filter\FilterCollection
5050
}
5151

5252

53+
public function getIterator() : \ArrayIterator
54+
{
55+
return new \ArrayIterator($this->aggregations);
56+
}
57+
58+
5359
public function toArray() : array
5460
{
5561
$array = [];
5662

5763
foreach ($this->aggregations as $aggregation) {
58-
if ($aggregation instanceof LeafAggregationCollection) {
64+
if ($aggregation instanceof \Spameri\ElasticQuery\Aggregation\LeafAggregationCollection) {
5965
$array[$this->key()]['aggs'] = $aggregation->toArray();
6066

6167
} else {

0 commit comments

Comments
 (0)