BaseResponse   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 11
dl 0
loc 43
rs 10
c 0
b 0
f 0

7 Methods

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