Error::getKind()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Nucleus - XMPP Library for PHP
4
 *
5
 * Copyright (C) 2016, Some rights reserved.
6
 *
7
 * @author Kacper "Kadet" Donat <[email protected]>
8
 *
9
 * Contact with author:
10
 * Xmpp: [email protected]
11
 * E-mail: [email protected]
12
 *
13
 * From Kadet with love.
14
 */
15
16
namespace Kadet\Xmpp\Stream;
17
18
use Kadet\Xmpp\Utils\Accessors;
19
use Kadet\Xmpp\Xml\XmlElement;
20
21
/**
22
 * Class Error
23
 * @package Kadet\Xmpp\Stream
24
 *
25
 * @property-read string $kind Stream error defined condition
26
 * @property-read string $text Stream error text description
27
 *
28
 * @see http://xmpp.org/rfcs/rfc6120.html#streams-error-syntax
29
 */
30
class Error extends XmlElement
31
{
32
    use Accessors;
33
34
    public function getKind()
35
    {
36
        return $this->query("./xmpp:*")->with('xmpp', 'urn:ietf:params:xml:ns:xmpp-streams')->query()->current()->localName;
37
    }
38
39
    public function getText()
40
    {
41
        if ($text = $this->query(".//xmpp:text")->with('xmpp', 'urn:ietf:params:xml:ns:xmpp-streams')->query()->current()) {
42
            return $text;
43
        }
44
45
        return null;
46
    }
47
}
48