Skip to content

Commit e03d2be

Browse files
committed
Coding standard
1 parent 46e92ac commit e03d2be

25 files changed

+169
-149
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ install:
4242

4343
script:
4444
- if [ "$PHPSTAN" = "1" ]; then vendor/bin/phpstan analyse -l 7 -c phpstan.neon src tests; fi
45-
- if [ "$CODING_STANDARD" = "1" ]; then vendor/bin/phpcs --standard=vendor/spameri/coding-standard/src/ruleset.xml --cache=$HOME/phpcs-cache/.phpcs-cache src tests; fi
45+
- if [ "$CODING_STANDARD" = "1" ]; then vendor/bin/phpcs --standard=ruleset.xml --cache=$HOME/phpcs-cache/.phpcs-cache src tests; fi
4646
- if [ "$RUN_TESTS" = "1" ]; then vendor/bin/tester $COVERAGE -s -c ./tests/php.ini ./tests; fi

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"ext-json": "*"
1616
},
1717
"require-dev": {
18-
"phpstan/phpstan-shim": "v0.10.3",
18+
"phpstan/phpstan-shim": "v0.11.4",
1919
"nette/tester": "v2.1.0",
2020
"elasticsearch/elasticsearch": "^6.1",
2121
"guzzlehttp/guzzle": "^6.3",

ruleset.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" ?>
2+
<ruleset name="Spameri\ElasticQuery">
3+
<rule ref="./vendor/spameri/coding-standard/src/ruleset.xml"/>
4+
5+
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
6+
<properties>
7+
<property name="rootNamespaces" type="array">
8+
<element key="src" value="Spameri\ElasticQuery"/>
9+
</property>
10+
</properties>
11+
</rule>
12+
13+
</ruleset>

src/Aggregation/AggregationCollection.php

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

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

@@ -33,7 +33,7 @@ public function __construct(
3333

3434
public function key() : string
3535
{
36-
return '';
36+
return 'top-aggs-collection';
3737
}
3838

3939

@@ -76,7 +76,7 @@ public function toArray() : array
7676
$array = [];
7777

7878
foreach ($this->aggregations as $aggregation) {
79-
$array = $array + $aggregation->toArray();
79+
$array += $aggregation->toArray();
8080
}
8181

8282
return $array;

src/Aggregation/LeafAggregationCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class LeafAggregationCollection implements LeafAggregationInterface, \IteratorAg
1717
private $filter;
1818

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

src/Aggregation/RangeValueCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class RangeValueCollection implements \IteratorAggregate
77
{
88

99
/**
10-
* @var \Spameri\ElasticQuery\Aggregation\RangeValue[]
10+
* @var array<\Spameri\ElasticQuery\Aggregation\RangeValue>
1111
*/
1212
private $collection;
1313

src/Collection/AbstractCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ abstract class AbstractCollection implements CollectionInterface
77
{
88

99
/**
10-
* @var \Spameri\ElasticQuery\Entity\EntityInterface[]
10+
* @var array<\Spameri\ElasticQuery\Entity\EntityInterface>
1111
*/
1212
protected $collection;
1313

src/ElasticQuery.php

Lines changed: 117 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,117 @@
1-
<?php declare(strict_types=1);
2-
3-
namespace Spameri\ElasticQuery;
4-
5-
6-
class ElasticQuery implements \Spameri\ElasticQuery\Entity\ArrayInterface
7-
{
8-
9-
/**
10-
* @var \Spameri\ElasticQuery\Query\QueryCollection
11-
*/
12-
private $query;
13-
14-
/**
15-
* @var \Spameri\ElasticQuery\Filter\FilterCollection
16-
*/
17-
private $filter;
18-
19-
/**
20-
* @var \Spameri\ElasticQuery\Options\SortCollection
21-
*/
22-
private $sort;
23-
24-
/**
25-
* @var \Spameri\ElasticQuery\Aggregation\AggregationCollection
26-
*/
27-
private $aggregation;
28-
29-
/**
30-
* @var \Spameri\ElasticQuery\Options
31-
*/
32-
private $options;
33-
34-
35-
public function __construct(
36-
?\Spameri\ElasticQuery\Query\QueryCollection $query = NULL
37-
, ?\Spameri\ElasticQuery\Filter\FilterCollection $filter = NULL
38-
, ?\Spameri\ElasticQuery\Options\SortCollection $sort = NULL
39-
, ?\Spameri\ElasticQuery\Aggregation\AggregationCollection $aggregation = NULL
40-
, ?Options $options = NULL
41-
)
42-
{
43-
if ( ! $query) {
44-
$query = new \Spameri\ElasticQuery\Query\QueryCollection();
45-
}
46-
if ( ! $filter) {
47-
$filter = new \Spameri\ElasticQuery\Filter\FilterCollection();
48-
}
49-
if ( ! $sort) {
50-
$sort = new \Spameri\ElasticQuery\Options\SortCollection();
51-
}
52-
if ( ! $aggregation) {
53-
$aggregation = new \Spameri\ElasticQuery\Aggregation\AggregationCollection();
54-
}
55-
if ( ! $options) {
56-
$options = new Options();
57-
}
58-
$this->query = $query;
59-
$this->filter = $filter;
60-
$this->sort = $sort;
61-
$this->aggregation = $aggregation;
62-
$this->options = $options;
63-
}
64-
65-
66-
public function query() : \Spameri\ElasticQuery\Query\QueryCollection
67-
{
68-
return $this->query;
69-
}
70-
71-
72-
public function filter() : \Spameri\ElasticQuery\Filter\FilterCollection
73-
{
74-
return $this->filter;
75-
}
76-
77-
78-
public function aggregation() : \Spameri\ElasticQuery\Aggregation\AggregationCollection
79-
{
80-
return $this->aggregation;
81-
}
82-
83-
84-
public function options() : \Spameri\ElasticQuery\Options
85-
{
86-
return $this->options;
87-
}
88-
89-
90-
public function toArray() : array
91-
{
92-
$array = $this->options->toArray();
93-
94-
$queryArray = $this->query->toArray();
95-
if ($queryArray) {
96-
$array['query'] = $queryArray;
97-
}
98-
99-
$filterArray = $this->filter->toArray();
100-
if ($filterArray) {
101-
$array['filter'] = $filterArray;
102-
}
103-
104-
$sortArray = $this->sort->toArray();
105-
if ($sortArray) {
106-
$array['sort'] = $sortArray;
107-
}
108-
109-
$aggregation = $this->aggregation->toArray();
110-
if ($aggregation) {
111-
$array['aggs'] = $aggregation;
112-
}
113-
114-
return $array;
115-
}
116-
117-
}
1+
<?php declare(strict_types = 1);
2+
3+
namespace Spameri\ElasticQuery;
4+
5+
6+
class ElasticQuery implements \Spameri\ElasticQuery\Entity\ArrayInterface
7+
{
8+
9+
/**
10+
* @var \Spameri\ElasticQuery\Query\QueryCollection
11+
*/
12+
private $query;
13+
14+
/**
15+
* @var \Spameri\ElasticQuery\Filter\FilterCollection
16+
*/
17+
private $filter;
18+
19+
/**
20+
* @var \Spameri\ElasticQuery\Options\SortCollection
21+
*/
22+
private $sort;
23+
24+
/**
25+
* @var \Spameri\ElasticQuery\Aggregation\AggregationCollection
26+
*/
27+
private $aggregation;
28+
29+
/**
30+
* @var \Spameri\ElasticQuery\Options
31+
*/
32+
private $options;
33+
34+
35+
public function __construct(
36+
?\Spameri\ElasticQuery\Query\QueryCollection $query = NULL
37+
, ?\Spameri\ElasticQuery\Filter\FilterCollection $filter = NULL
38+
, ?\Spameri\ElasticQuery\Options\SortCollection $sort = NULL
39+
, ?\Spameri\ElasticQuery\Aggregation\AggregationCollection $aggregation = NULL
40+
, ?Options $options = NULL
41+
)
42+
{
43+
if ( ! $query) {
44+
$query = new \Spameri\ElasticQuery\Query\QueryCollection();
45+
}
46+
if ( ! $filter) {
47+
$filter = new \Spameri\ElasticQuery\Filter\FilterCollection();
48+
}
49+
if ( ! $sort) {
50+
$sort = new \Spameri\ElasticQuery\Options\SortCollection();
51+
}
52+
if ( ! $aggregation) {
53+
$aggregation = new \Spameri\ElasticQuery\Aggregation\AggregationCollection();
54+
}
55+
if ( ! $options) {
56+
$options = new Options();
57+
}
58+
$this->query = $query;
59+
$this->filter = $filter;
60+
$this->sort = $sort;
61+
$this->aggregation = $aggregation;
62+
$this->options = $options;
63+
}
64+
65+
66+
public function query() : \Spameri\ElasticQuery\Query\QueryCollection
67+
{
68+
return $this->query;
69+
}
70+
71+
72+
public function filter() : \Spameri\ElasticQuery\Filter\FilterCollection
73+
{
74+
return $this->filter;
75+
}
76+
77+
78+
public function aggregation() : \Spameri\ElasticQuery\Aggregation\AggregationCollection
79+
{
80+
return $this->aggregation;
81+
}
82+
83+
84+
public function options() : \Spameri\ElasticQuery\Options
85+
{
86+
return $this->options;
87+
}
88+
89+
90+
public function toArray() : array
91+
{
92+
$array = $this->options->toArray();
93+
94+
$queryArray = $this->query->toArray();
95+
if ($queryArray) {
96+
$array['query'] = $queryArray;
97+
}
98+
99+
$filterArray = $this->filter->toArray();
100+
if ($filterArray) {
101+
$array['filter'] = $filterArray;
102+
}
103+
104+
$sortArray = $this->sort->toArray();
105+
if ($sortArray) {
106+
$array['sort'] = $sortArray;
107+
}
108+
109+
$aggregation = $this->aggregation->toArray();
110+
if ($aggregation) {
111+
$array['aggs'] = $aggregation;
112+
}
113+
114+
return $array;
115+
}
116+
117+
}

src/Exception/AggregationNotFound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Spameri\ElasticQuery\Exception;
44

55

6-
class AggregationNotFound extends InvalidArgumentException
6+
class AggregationNotFound extends \InvalidArgumentException
77
{
88

99
}

src/Exception/BulkActionNotFound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Spameri\ElasticQuery\Exception;
44

55

6-
class BulkActionNotFound extends InvalidArgumentException
6+
class BulkActionNotFound extends \InvalidArgumentException
77
{
88

99
}

0 commit comments

Comments
 (0)