triadev /
Leopard
| Conditions | 1 |
| Paths | 1 |
| Total Lines | 4 |
| Code Lines | 2 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 3 |
| CRAP Score | 1 |
| Changes | 0 | ||
| Metric | Value |
|---|---|
| cc | 1 |
| eloc | 2 |
| nc | 1 |
| nop | 4 |
| dl | 0 |
| loc | 4 |
| ccs | 3 |
| cts | 3 |
| cp | 1 |
| crap | 1 |
| rs | 10 |
| c | 0 |
| b | 0 |
| f | 0 |
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | namespace Triadev\Leopard\Business\Dsl\Aggregation; |
||
|
0 ignored issues
–
show
|
|||
| 3 | |||
| 4 | use ONGR\ElasticsearchDSL\Aggregation\Metric\AvgAggregation; |
||
| 5 | use ONGR\ElasticsearchDSL\Aggregation\Metric\CardinalityAggregation; |
||
| 6 | use ONGR\ElasticsearchDSL\Aggregation\Metric\ExtendedStatsAggregation; |
||
| 7 | use ONGR\ElasticsearchDSL\Aggregation\Metric\GeoBoundsAggregation; |
||
| 8 | use ONGR\ElasticsearchDSL\Aggregation\Metric\GeoCentroidAggregation; |
||
| 9 | use ONGR\ElasticsearchDSL\Aggregation\Metric\MaxAggregation; |
||
| 10 | use ONGR\ElasticsearchDSL\Aggregation\Metric\MinAggregation; |
||
| 11 | use ONGR\ElasticsearchDSL\Aggregation\Metric\StatsAggregation; |
||
| 12 | use ONGR\ElasticsearchDSL\Aggregation\Metric\SumAggregation; |
||
| 13 | use ONGR\ElasticsearchDSL\Aggregation\Metric\TopHitsAggregation; |
||
| 14 | use ONGR\ElasticsearchDSL\Aggregation\Metric\ValueCountAggregation; |
||
| 15 | use ONGR\ElasticsearchDSL\BuilderInterface; |
||
| 16 | |||
| 17 | class Metric extends Aggs |
||
|
0 ignored issues
–
show
|
|||
| 18 | { |
||
|
0 ignored issues
–
show
|
|||
| 19 | /** |
||
| 20 | * Avg |
||
| 21 | * |
||
| 22 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 23 | * @param string|null $field |
||
|
0 ignored issues
–
show
|
|||
| 24 | * @param string|null $script |
||
|
0 ignored issues
–
show
|
|||
| 25 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 26 | */ |
||
| 27 | 2 | public function avg(string $name, ?string $field = null, ?string $script = null) : Metric |
|
|
0 ignored issues
–
show
|
|||
| 28 | { |
||
| 29 | 2 | $this->addAggregation(new AvgAggregation($name, $field, $script)); |
|
| 30 | 2 | return $this; |
|
| 31 | } |
||
|
0 ignored issues
–
show
|
|||
| 32 | |||
| 33 | /** |
||
| 34 | * Cardinality |
||
| 35 | * |
||
| 36 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 37 | * @param string $field |
||
|
0 ignored issues
–
show
|
|||
| 38 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 39 | */ |
||
| 40 | 1 | public function cardinality(string $name, string $field) : Metric |
|
| 41 | { |
||
| 42 | 1 | $cardinality = new CardinalityAggregation($name); |
|
| 43 | 1 | $cardinality->setField($field); |
|
| 44 | |||
| 45 | 1 | $this->addAggregation($cardinality); |
|
| 46 | 1 | return $this; |
|
| 47 | } |
||
|
0 ignored issues
–
show
|
|||
| 48 | |||
| 49 | /** |
||
| 50 | * Extended stats |
||
| 51 | * |
||
| 52 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 53 | * @param string $field |
||
|
0 ignored issues
–
show
|
|||
| 54 | * @param int|null $sigma |
||
|
0 ignored issues
–
show
|
|||
| 55 | * @param string|null $script |
||
|
0 ignored issues
–
show
|
|||
| 56 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 57 | */ |
||
| 58 | 1 | public function extendedStats(string $name, string $field, ?int $sigma = null, ?string $script = null) : Metric |
|
|
0 ignored issues
–
show
|
|||
| 59 | { |
||
| 60 | 1 | $this->addAggregation(new ExtendedStatsAggregation($name, $field, $sigma, $script)); |
|
| 61 | 1 | return $this; |
|
| 62 | } |
||
|
0 ignored issues
–
show
|
|||
| 63 | |||
| 64 | /** |
||
| 65 | * Geo bounds |
||
| 66 | * |
||
| 67 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 68 | * @param string|null $field |
||
|
0 ignored issues
–
show
|
|||
| 69 | * @param bool $wrapLongitude |
||
|
0 ignored issues
–
show
|
|||
| 70 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 71 | */ |
||
| 72 | 1 | public function geoBounds(string $name, ?string $field = null, bool $wrapLongitude = true) : Metric |
|
|
0 ignored issues
–
show
|
|||
| 73 | { |
||
| 74 | 1 | $this->addAggregation(new GeoBoundsAggregation($name, $field, $wrapLongitude)); |
|
| 75 | 1 | return $this; |
|
| 76 | } |
||
|
0 ignored issues
–
show
|
|||
| 77 | |||
| 78 | /** |
||
| 79 | * Geo centroid |
||
| 80 | * |
||
| 81 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 82 | * @param string|null $field |
||
|
0 ignored issues
–
show
|
|||
| 83 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 84 | */ |
||
| 85 | 1 | public function geoCentroid(string $name, ?string $field = null) : Metric |
|
|
0 ignored issues
–
show
|
|||
| 86 | { |
||
| 87 | 1 | $this->addAggregation(new GeoCentroidAggregation($name, $field)); |
|
| 88 | 1 | return $this; |
|
| 89 | } |
||
|
0 ignored issues
–
show
|
|||
| 90 | |||
| 91 | /** |
||
| 92 | * Max |
||
| 93 | * |
||
| 94 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 95 | * @param string|null $field |
||
|
0 ignored issues
–
show
|
|||
| 96 | * @param string|null $script |
||
|
0 ignored issues
–
show
|
|||
| 97 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 98 | */ |
||
| 99 | 1 | public function max(string $name, ?string $field = null, ?string $script = null) : Metric |
|
|
0 ignored issues
–
show
|
|||
| 100 | { |
||
| 101 | 1 | $this->addAggregation(new MaxAggregation($name, $field, $script)); |
|
| 102 | 1 | return $this; |
|
| 103 | } |
||
|
0 ignored issues
–
show
|
|||
| 104 | |||
| 105 | /** |
||
| 106 | * Min |
||
| 107 | * |
||
| 108 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 109 | * @param string|null $field |
||
|
0 ignored issues
–
show
|
|||
| 110 | * @param string|null $script |
||
|
0 ignored issues
–
show
|
|||
| 111 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 112 | */ |
||
| 113 | 1 | public function min(string $name, ?string $field = null, ?string $script = null): Metric |
|
|
0 ignored issues
–
show
|
|||
| 114 | { |
||
| 115 | 1 | $this->addAggregation(new MinAggregation($name, $field, $script)); |
|
| 116 | 1 | return $this; |
|
| 117 | } |
||
|
0 ignored issues
–
show
|
|||
| 118 | |||
| 119 | /** |
||
| 120 | * Stats |
||
| 121 | * |
||
| 122 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 123 | * @param string|null $field |
||
|
0 ignored issues
–
show
|
|||
| 124 | * @param string|null $script |
||
|
0 ignored issues
–
show
|
|||
| 125 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 126 | */ |
||
| 127 | 1 | public function stats(string $name, ?string $field = null, ?string $script = null): Metric |
|
|
0 ignored issues
–
show
|
|||
| 128 | { |
||
| 129 | 1 | $this->addAggregation(new StatsAggregation($name, $field, $script)); |
|
| 130 | 1 | return $this; |
|
| 131 | } |
||
|
0 ignored issues
–
show
|
|||
| 132 | |||
| 133 | /** |
||
| 134 | * Sum |
||
| 135 | * |
||
| 136 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 137 | * @param string|null $field |
||
|
0 ignored issues
–
show
|
|||
| 138 | * @param string|null $script |
||
|
0 ignored issues
–
show
|
|||
| 139 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 140 | */ |
||
| 141 | 1 | public function sum(string $name, ?string $field = null, ?string $script = null): Metric |
|
|
0 ignored issues
–
show
|
|||
| 142 | { |
||
| 143 | 1 | $this->addAggregation(new SumAggregation($name, $field, $script)); |
|
| 144 | 1 | return $this; |
|
| 145 | } |
||
|
0 ignored issues
–
show
|
|||
| 146 | |||
| 147 | /** |
||
| 148 | * Top hits |
||
| 149 | * |
||
| 150 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 151 | * @param int|null $size |
||
|
0 ignored issues
–
show
|
|||
| 152 | * @param int|null $from |
||
|
0 ignored issues
–
show
|
|||
| 153 | * @param BuilderInterface|null $sort |
||
|
0 ignored issues
–
show
|
|||
| 154 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 155 | */ |
||
| 156 | 1 | public function topHits(string $name, ?int $size = null, ?int $from = null, ?BuilderInterface $sort = null) : Metric |
|
|
0 ignored issues
–
show
|
|||
| 157 | { |
||
| 158 | 1 | $this->addAggregation(new TopHitsAggregation($name, $size, $from, $sort)); |
|
| 159 | 1 | return $this; |
|
| 160 | } |
||
|
0 ignored issues
–
show
|
|||
| 161 | |||
| 162 | /** |
||
| 163 | * Value count |
||
| 164 | * |
||
| 165 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 166 | * @param string|null $field |
||
|
0 ignored issues
–
show
|
|||
| 167 | * @param string|null $script |
||
|
0 ignored issues
–
show
|
|||
| 168 | * @return Metric |
||
|
0 ignored issues
–
show
|
|||
| 169 | */ |
||
| 170 | 1 | public function valueCount(string $name, ?string $field = null, ?string $script = null): Metric |
|
|
0 ignored issues
–
show
|
|||
| 171 | { |
||
| 172 | 1 | $this->addAggregation(new ValueCountAggregation($name, $field, $script)); |
|
| 173 | 1 | return $this; |
|
| 174 | } |
||
|
0 ignored issues
–
show
|
|||
| 175 | } |
||
|
0 ignored issues
–
show
|
|||
| 176 |