Completed
Pull Request — master (#47)
by Ghazi
01:26
created

BaseResponse   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 62
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getRawXml() 0 4 1
A getReturnCode() 0 4 1
A getMessageKey() 0 4 1
A getMessage() 0 4 1
A success() 0 4 1
A failed() 0 4 1
1
<?php
2
/**
3
 * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
4
 *
5
 * Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below).
6
 *
7
 * This program is free software; you can redistribute it and/or modify it under the
8
 * terms of the GNU Lesser General Public License as published by the Free Software
9
 * Foundation; either version 3.0 of the License, or (at your option) any later
10
 * version.
11
 *
12
 * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License along
17
 * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
namespace BigBlueButton\Responses;
20
21
/**
22
 * Class BaseResponse
23
 * @package BigBlueButton\Responses
24
 */
25
abstract class BaseResponse
26
{
27
    const SUCCESS = 'SUCCESS';
28
    const FAILED  = 'FAILED';
29
30
    /**
31
     * @var \SimpleXMLElement
32
     */
33
    protected $rawXml;
34
35
    /**
36
     * BaseResponse constructor.
37
     *
38
     * @param \SimpleXMLElement $xml
39
     */
40
    public function __construct(\SimpleXMLElement $xml)
41
    {
42
        $this->rawXml = $xml;
43
    }
44
45
    /**
46
     * @return \SimpleXMLElement
47
     */
48
    public function getRawXml()
49
    {
50
        return $this->rawXml;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getReturnCode()
57
    {
58
        return $this->rawXml->returncode->__toString();
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getMessageKey()
65
    {
66
        return $this->rawXml->messageKey->__toString();
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getMessage()
73
    {
74
        return $this->rawXml->message->__toString();
75
    }
76
77
    public function success()
78
    {
79
        return $this->getReturnCode() === self::SUCCESS;
80
    }
81
82
    public function failed()
83
    {
84
        return $this->getReturnCode() === self::FAILED;
85
    }
86
}
87