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) {
|
||||
if (is_array($this->options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->options = [];
|
||||
foreach ($this->buckets as $bucket) {
|
||||
$this->options[$bucket['key']] = new FacetOption($bucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,20 +115,25 @@ class SearchResult implements SearchResultInterface
|
|||
*/
|
||||
protected function initResults()
|
||||
{
|
||||
if ($this->results === null) {
|
||||
if (is_array($this->results)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->results = [];
|
||||
foreach ($this->result->getResults() as $result) {
|
||||
$this->results[] = new ResultItem($result->getData(), $result->getParam('_type'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function initFacets()
|
||||
{
|
||||
if ($this->facets === null) {
|
||||
if (is_array($this->facets)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->facets = [];
|
||||
if ($this->result->hasAggregations()) {
|
||||
foreach ($this->result->getAggregations() as $aggregationName => $aggregation) {
|
||||
|
@ -140,7 +145,6 @@ class SearchResult implements SearchResultInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Countable - Interface
|
||||
|
|
|
@ -79,12 +79,15 @@ class SearchResult implements SearchResultInterface
|
|||
*/
|
||||
protected function initResults()
|
||||
{
|
||||
if ($this->results === null) {
|
||||
if (is_array($this->results)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->results = [];
|
||||
foreach ($this->resultItems as $item) {
|
||||
$this->results[] = new ResultItem($item['data'], $item['type']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
|
Loading…
Reference in a new issue