Completed
Push — next ( ba018c...5105e3 )
by Mathias
10:34
created

Response   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getXml() 0 9 3
1
<?php
2
/**
3
 * YAWIK Stackoverflow API
4
 *
5
 * @filesource
6
 * @license    MIT
7
 * @copyright  2016 - 2017 Cross Solution <http://cross-solution.de>
8
 */
9
10
/** */
11
namespace StackoverflowApi\Client;
12
13
use Zend\Http\Response as ZfResponse;
14
15
/**
16
 * Stackoverflow response.
17
 *
18
 * Provide a method to extract the xml response body.
19
 *
20
 * @author Mathias Gelhausen <[email protected]>
21
 * @since  0.1.0
22
 */
23
class Response extends ZfResponse
24
{
25
26
    /**
27
     * The xml tree.
28
     *
29
     * @var \SimpleXMLElement|false
30
     */
31
    protected $xml;
32
33
    /**
34
     * Generate a xml tree from the response body when possible.
35
     *
36
     * @return false|\SimpleXMLElement
37
     */
38
    public function getXml()
39
    {
40
        if (!$this->xml) {
41
            $body      = $this->getBody();
42
            $this->xml = 0 === strpos($body, '<?xml') ? new \SimpleXMLElement($body) : false;
43
        }
44
45
        return $this->xml;
46
    }
47
}