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