Skip to content

Commit 0d5483b

Browse files
authored
Merge pull request #5 from Spameri/version-one
Version one
2 parents 04295e5 + b7ea62e commit 0d5483b

File tree

219 files changed

+2905
-1100
lines changed

Some content is hidden

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

219 files changed

+2905
-1100
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
php: [ 7.4 ]
13-
elastic: [ 7.12.1, 6.8.15, 5.6.16 ]
12+
php: [ 7.4, 8.1 ]
13+
elastic: [ 7.17.0 ]
1414

1515
steps:
1616
- uses: actions/checkout@v2
@@ -33,14 +33,14 @@ jobs:
3333
- name: Composer
3434
run: make composer
3535

36-
- if: matrix.php == '7.4' && matrix.elastic == '7.12.1'
36+
- if: matrix.php == '8.1' && matrix.elastic == '7.17.0'
3737
name: Coding standard
3838
run: make cs
3939

40-
- if: matrix.php == '7.4' && matrix.elastic == '7.12.1'
40+
- if: matrix.php == '8.1' && matrix.elastic == '7.17.0'
4141
name: PHPStan
4242
run: make phpstan
4343

44-
- if: matrix.php == '7.4'
44+
- if: matrix.php == '8.1'
4545
name: Tests
4646
run: make tests

.travis.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
.PHONY: composer
22
.PHONY: phpstan
33
.PHONY: cs
4+
.PHONY: cs-local
5+
.PHONY: cbf
46
.PHONY: tests
57
.PHONY: coverage
68

9+
710
composer:
811
composer update --no-interaction --no-suggest --no-progress --prefer-dist --prefer-stable
912

1013
phpstan:
1114
vendor/bin/phpstan analyse -l 7 -c phpstan.neon src tests
1215

1316
cs:
14-
vendor/bin/phpcs --standard=ruleset.xml --cache=$HOME/phpcs-cache/.phpcs-cache src tests
17+
vendor/bin/phpcs --standard=ruleset.xml --cache=.phpcs-cache src tests/SpameriTests
18+
19+
cs-local:
20+
vendor/bin/phpcs --standard=ruleset.xml src tests/SpameriTests
21+
22+
cbf:
23+
vendor/bin/phpcbf --standard=ruleset.xml src tests/SpameriTests
1524

1625
tests:
17-
vendor/bin/tester -s -p php --colors 1 -C tests
26+
vendor/bin/tester -s -p php --colors 1 -C -j 1 tests
1827

1928
coverage:
2029
vendor/bin/tester -s -p php --colors 1 -C --coverage ./coverage.html --coverage-src ./src tests

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# ElasticQuery
22
Elastic documentation converted to php objects for easy using.
33

4-
[![Build Status](https://travis-ci.org/Spameri/ElasticQuery.svg?branch=master)](https://travis-ci.org/Spameri/ElasticQuery)
5-
64
Installation
75
------------
86

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
"issues": "https://github.com/Spameri/ElasticQuery/issues"
1212
},
1313
"require": {
14-
"php": ">=7.1",
14+
"php": ">=7.4",
1515
"ext-json": "*"
1616
},
1717
"require-dev": {
18-
"phpstan/phpstan": "v0.12.37",
18+
"ext-curl": "*",
19+
"phpstan/phpstan": "^1.4.6",
1920
"nette/tester": "v2.3.1",
2021
"elasticsearch/elasticsearch": "^7",
2122
"guzzlehttp/guzzle": "^6.3",

doc/01-usage.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Using with [ElasticSearch/ElasticSearch](https://github.com/elastic/elasticsearch-php)
22
First we need to prepare query for what we want to search.
3+
34
```php
45
$query = new \Spameri\ElasticQuery\ElasticQuery();
56
$query->query()->must()->add(
6-
new \Spameri\ElasticQuery\Query\Match(
7+
new \Spameri\ElasticQuery\Query\ElasticMatch(
78
'name',
89
'Avengers'
910
)

phpstan.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
parameters:
22
ignoreErrors:
3-
- "#Call to function array_key_exists\\(\\) with string and array<int, mixed> will always evaluate to false#"
3+
- "#Call to function array_key_exists\\(\\) with string and array<int, string> will always evaluate to false#"
4+
5+
checkMissingIterableValueType: false
6+
checkGenericClassInNonGenericObjectType: false

ruleset.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<properties>
77
<property name="rootNamespaces" type="array">
88
<element key="src" value="Spameri\ElasticQuery"/>
9+
<element key="tests/SpameriTests" value="SpameriTests"/>
910
</property>
1011
</properties>
1112
</rule>

src/Aggregation/AggregationCollection.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,47 +31,47 @@ public function __construct(
3131
}
3232

3333

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

3939

40-
public function filter() : \Spameri\ElasticQuery\Filter\FilterCollection
40+
public function filter(): \Spameri\ElasticQuery\Filter\FilterCollection
4141
{
4242
return $this->filter;
4343
}
4444

4545

4646
public function add(
4747
LeafAggregationCollection $leafAggregation
48-
) : void
48+
): void
4949
{
5050
$this->aggregations[$leafAggregation->key()] = $leafAggregation;
5151
}
5252

5353

54-
public function keys() : array
54+
public function keys(): array
5555
{
5656
return \array_map('\strval', \array_keys($this->aggregations));
5757
}
5858

5959

6060
public function isKey(
6161
string $key
62-
) : bool
62+
): bool
6363
{
6464
return \array_key_exists($key, \array_map('\strval', \array_keys($this->aggregations)));
6565
}
6666

6767

68-
public function count() : int
68+
public function count(): int
6969
{
7070
return \count($this->aggregations);
7171
}
7272

7373

74-
public function toArray() : array
74+
public function toArray(): array
7575
{
7676
$array = [];
7777

src/Aggregation/Avg.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Spameri\ElasticQuery\Aggregation;
4+
5+
/**
6+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
7+
*/
8+
class Avg implements \Spameri\ElasticQuery\Aggregation\LeafAggregationInterface
9+
{
10+
11+
private string $field;
12+
13+
14+
public function __construct(
15+
string $field
16+
)
17+
{
18+
$this->field = $field;
19+
}
20+
21+
22+
public function key(): string
23+
{
24+
return 'avg_' . $this->field;
25+
}
26+
27+
28+
public function toArray(): array
29+
{
30+
return [
31+
'avg' => [
32+
'field' => $this->field,
33+
],
34+
];
35+
}
36+
37+
}

0 commit comments

Comments
 (0)