mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-23 07:56:12 +01:00
TASK: Refactor code to use guards and decrease indentation
This commit is contained in:
parent
5d5af73705
commit
140dea3cbb
3 changed files with 33 additions and 24 deletions
|
@ -99,11 +99,13 @@ class Facet implements FacetInterface
|
|||
*/
|
||||
protected function initOptions()
|
||||
{
|
||||
if ($this->options === null) {
|
||||
$this->options = [];
|
||||
foreach ($this->buckets as $bucket) {
|
||||
$this->options[$bucket['key']] = new FacetOption($bucket);
|
||||
}
|
||||
if (is_array($this->options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->options = [];
|
||||
foreach ($this->buckets as $bucket) {
|
||||
$this->options[$bucket['key']] = new FacetOption($bucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,11 +115,13 @@ class SearchResult implements SearchResultInterface
|
|||
*/
|
||||
protected function initResults()
|
||||
{
|
||||
if ($this->results === null) {
|
||||
$this->results = [];
|
||||
foreach ($this->result->getResults() as $result) {
|
||||
$this->results[] = new ResultItem($result->getData(), $result->getParam('_type'));
|
||||
}
|
||||
if (is_array($this->results)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->results = [];
|
||||
foreach ($this->result->getResults() as $result) {
|
||||
$this->results[] = new ResultItem($result->getData(), $result->getParam('_type'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,16 +130,18 @@ class SearchResult implements SearchResultInterface
|
|||
*/
|
||||
protected function initFacets()
|
||||
{
|
||||
if ($this->facets === null) {
|
||||
$this->facets = [];
|
||||
if ($this->result->hasAggregations()) {
|
||||
foreach ($this->result->getAggregations() as $aggregationName => $aggregation) {
|
||||
$this->facets[$aggregationName] = $this->objectManager->get(
|
||||
Facet::class,
|
||||
$aggregationName,
|
||||
$aggregation
|
||||
);
|
||||
}
|
||||
if (is_array($this->facets)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->facets = [];
|
||||
if ($this->result->hasAggregations()) {
|
||||
foreach ($this->result->getAggregations() as $aggregationName => $aggregation) {
|
||||
$this->facets[$aggregationName] = $this->objectManager->get(
|
||||
Facet::class,
|
||||
$aggregationName,
|
||||
$aggregation
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,10 +79,13 @@ class SearchResult implements SearchResultInterface
|
|||
*/
|
||||
protected function initResults()
|
||||
{
|
||||
if ($this->results === null) {
|
||||
foreach ($this->resultItems as $item) {
|
||||
$this->results[] = new ResultItem($item['data'], $item['type']);
|
||||
}
|
||||
if (is_array($this->results)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->results = [];
|
||||
foreach ($this->resultItems as $item) {
|
||||
$this->results[] = new ResultItem($item['data'], $item['type']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue