| Total Complexity | 5 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Nord\Lumen\Elasticsearch\Search\Query\Joining; |
||
| 13 | class NestedQuery extends AbstractQuery |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | private $path; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @inheritdoc |
||
| 22 | * @throws InvalidArgument |
||
| 23 | */ |
||
| 24 | public function toArray() |
||
| 25 | { |
||
| 26 | $query = $this->getQuery(); |
||
| 27 | |||
| 28 | if ($query === null) { |
||
| 29 | throw new InvalidArgument('Query must be set'); |
||
| 30 | } |
||
| 31 | |||
| 32 | $nested = [ |
||
| 33 | 'path' => $this->getPath(), |
||
| 34 | 'query' => $query->toArray(), |
||
| 35 | ]; |
||
| 36 | |||
| 37 | $scoreMode = $this->getScoreMode(); |
||
| 38 | if (null !== $scoreMode) { |
||
| 39 | $nested['score_mode'] = $scoreMode; |
||
| 40 | } |
||
| 41 | |||
| 42 | return ['nested' => $nested]; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param string $path |
||
| 47 | * @return NestedQuery |
||
| 48 | */ |
||
| 49 | public function setPath($path) |
||
| 50 | { |
||
| 51 | $this->path = $path; |
||
| 52 | return $this; |
||
| 53 | } |
||
| 54 | |||
| 55 | |||
| 56 | /** |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | public function getPath() |
||
| 62 | } |
||
| 63 | } |
||
| 64 |