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->SletTilmeldingerV2Result)) { |
51
|
|
|
if ($this->response->SletTilmeldingerV2Result) { |
52
|
|
|
throw new \Exception($this->response->SletTilmeldingerV2Result); |
53
|
|
|
} |
54
|
|
|
return $this->response->SletTilmeldingerV2Result; |
55
|
|
|
} elseif (!empty($this->response->HentNyeTilmeldingerV2Result)) { |
56
|
|
|
return $this->response->HentNyeTilmeldingerV2Result; |
57
|
|
|
} elseif (!empty($this->response->NyTilmelding2Result)) { |
58
|
|
|
return $this->response->NyTilmelding2Result; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
throw new \Exception('Not a known response type - You should write a Response class'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Checks whether the communication is OK |
66
|
|
|
* |
67
|
|
|
* @return boolean |
68
|
|
|
*/ |
69
|
|
|
public function isOk() |
70
|
|
|
{ |
71
|
|
|
return true; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Count how many results are being returned |
76
|
|
|
* |
77
|
|
|
* @return int |
78
|
|
|
*/ |
79
|
|
|
public function getCount() |
80
|
|
|
{ |
81
|
|
|
return 1; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|