Completed
Pull Request — master (#9)
by Lars
02:45
created

Response::getBody()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 0
crap 20
1
<?php
2
/**
3
 * SDK to communicate with EDBBrugs
4
 *
5
 * PHP Version 5
6
 *
7
 * @category EDBBrugs
8
 * @package  EDBBrugs
9
 * @author   Lars Olesen <[email protected]>
10
 * @license  MIT Open Source License https://opensource.org/licenses/MIT
11
 * @version  GIT: <git_id>
12
 */
13
14
namespace EDBBrugs;
15
16
use EDBBrugs\ResponseInterface;
17
18
/**
19
 * Service Communicator with EDB-Brugs
20
 *
21
 * @category EDBBrugs
22
 * @package  EDBBrugs
23
 * @author   Lars Olesen <[email protected]>
24
 * @license  MIT Open Source License https://opensource.org/licenses/MIT
25
 * @version  GIT: <git_id>
26
 */
27
class Response implements ResponseInterface
28
{
29
    protected $response;
30
31
    /**
32
     * Constructor
33
     *
34
     * @param object $response     Actual response from SOAP
35
     */
36
    public function __construct($response)
37
    {
38
        $this->response = $response;
39
    }
40
41
    /**
42
     * Gets the body from the response
43
     *
44
     * @return mixed Soap result or throws Exception
45
     */
46
    public function getBody()
47
    {
48
        if (!empty($this->response->HentBehandledeTilmeldingerV2Result)) {
49
            return $this->response->HentBehandledeTilmeldingerV2Result;
50
        } elseif (!empty($this->response->HentNyeTilmeldingerV2Result)) {
51
            return $this->response->HentNyeTilmeldingerV2Result;
52
        } elseif (!empty($this->response->NyTilmelding2Result)) {
53
            return $this->response->NyTilmelding2Result;
54
        }
55
56
        throw new \Exception('Not a known response type - You should write a Response class');
57
    }
58
59
    /**
60
     * Checks whether the communication is OK
61
     *
62
     * @return boolean
63
     */
64
    public function isOk()
65
    {
66
        return true;
67
    }
68
69
    /**
70
     * Count how many results are being returned
71
     *
72
     * @return int
73
     */
74
    public function getCount()
75
    {
76
        return 1;
77
    }
78
}
79