PagedSearchResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFacets() 0 6 2
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Response;
7
8
use GuzzleHttp\Message\ResponseInterface;
9
use Commercetools\Core\Model\Common\Context;
10
use Commercetools\Core\Model\Product\FacetResultCollection;
11
use Commercetools\Core\Request\ClientRequestInterface;
12
13
/**
14
 * @package Commercetools\Core\Response
15
 */
16
class PagedSearchResponse extends PagedQueryResponse
17
{
18
    const FACETS = 'facets';
19
20
    /**
21
     * @var FacetResultCollection
22
     */
23
    protected $facets;
24
25
    /**
26
     * @return FacetResultCollection
27
     */
28 10
    public function getFacets()
29
    {
30 10
        if (is_null($this->facets)) {
31 10
            $this->facets = FacetResultCollection::fromArray($this->getResponseKey(static::FACETS), $this->getContext());
0 ignored issues
show
Bug introduced by
It seems like $this->getResponseKey(static::FACETS) can also be of type null; however, parameter $data of Commercetools\Core\Model...lizeObject::fromArray() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
            $this->facets = FacetResultCollection::fromArray(/** @scrutinizer ignore-type */ $this->getResponseKey(static::FACETS), $this->getContext());
Loading history...
32
        }
33 10
        return $this->facets;
34
    }
35
}
36