HtmlResponse::getHttpResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace CodeCloud\Bundle\ShopifyBundle\Api\Response;
3
4
use Psr\Http\Message\ResponseInterface as PsrResponse;
5
6
class HtmlResponse implements ResponseInterface
7
{
8
    /**
9
     * @var PsrResponse
10
     */
11
    private $response;
12
13
    /**
14
     * @param PsrResponse $response
15
     */
16
    public function __construct(PsrResponse $response)
17
    {
18
        $this->response = $response;
19
    }
20
21
    /**
22
     * @return PsrResponse
23
     */
24
    public function getHttpResponse()
25
    {
26
        return $this->response;
27
    }
28
29
    /**
30
     * @param null $item
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $item is correct as it would always require null to be passed?
Loading history...
31
     * @param null $default
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $default is correct as it would always require null to be passed?
Loading history...
32
     * @return mixed
33
     */
34
    public function get($item = null, $default = null)
35
    {
36
        return $this->response->getBody()->getContents();
37
    }
38
39
    /**
40
     * @return bool
41
     */
42
    public function successful()
43
    {
44
        return preg_match('/^2[\d]{2,}/', $this->getHttpResponse()->getStatusCode());
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match('/^2[\...nse()->getStatusCode()) returns the type integer which is incompatible with the documented return type boolean.
Loading history...
45
    }
46
}
47