Stream::setLanguage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
cc 1
eloc 2
nc 1
nop 1
rs 10
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
19
use Kadet\Xmpp\Xml\XmlElement;
20
21
/**
22
 * Class describing root element of stream.
23
 * It doesn't store any references to it's children, only children can refer that class, so they can be garbage
24
 * collected when needed. It's used mainly for storing default namespace for stanzas.
25
 *
26
 * @package Kadet\Xmpp\Stream
27
 *
28
 * @property string $xmlns    Default namespace for stanzas
29
 * @property string $language Stream language
30
 * @property string $version  Stream version
31
 * @property string $to       Server vhost
32
 */
33
class Stream extends XmlElement
34
{
35
    /**
36
     * Stream constructor
37
     *
38
     * @param array  $options {
39
     *     @var mixed    $content    Content of element
40
     *     @var string   $xmlns      Namespace of stream elements
41
     *     @var array    $attributes Stream attributes
42
     * }
43
     */
44
    public function __construct(array $options)
45
    {
46
        parent::__construct('stream:stream', 'http://etherx.jabber.org/streams', $options);
47
    }
48
49
    //region Default Namespace
50
    public function setXmlns($uri)
51
    {
52
        $this->setNamespace($uri, null);
53
    }
54
55
    public function getXmlns()
56
    {
57
        return $this->getNamespace(null);
58
    }
59
    //endregion
60
61
    public function setInnerXml($value)
62
    {
63
        return false;
64
    }
65
66
    public function setContent($value)
67
    {
68
        return false;
69
    }
70
71
    public function appendChild($element)
72
    {
73
        if ($element instanceof XmlElement) {
74
            $element->parent = $this;
75
        }
76
77
        return null;
78
    }
79
80
    /**
81
     * @return string
82
     */
83
    public function getLanguage(): string
84
    {
85
        return $this->getAttribute('xml:lang');
86
    }
87
88
    /**
89
     * @param string $language
90
     */
91
    public function setLanguage(string $language)
92
    {
93
        $this->setAttribute('xml:lang', $language);
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getVersion(): string
100
    {
101
        return $this->getAttribute('version');
102
    }
103
104
    /**
105
     * @param string $version
106
     */
107
    public function setVersion(string $version)
108
    {
109
        $this->setAttribute('version', $version);
110
    }
111
112
    #region To
113
    /**
114
     * @return string
115
     */
116
    public function getTo(): string
117
    {
118
        return $this->getAttribute('to');
119
    }
120
121
    /**
122
     * @param string $to
123
     */
124
    public function setTo(string $to)
125
    {
126
        $this->setAttribute('to', $to);
127
    }
128
    #endregion
129
}
130