Completed
Push — master ( 939cef...4aee11 )
by Kacper
03:59
created

Stream::setVersion()   A

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
 * @internal
34
 */
35
class Stream extends XmlElement
36
{
37
    /**
38
     * Stream constructor
39
     *
40
     * @param array  $options {
41
     *     @var mixed    $content    Content of element
42
     *     @var string   $xmlns      Namespace of stream elements
43
     *     @var array    $attributes Stream attributes
44
     * }
45
     */
46
    public function __construct(array $options)
47
    {
48
        parent::__construct('stream:stream', 'http://etherx.jabber.org/streams', $options);
49
    }
50
51
    //region Default Namespace
52
    public function setXmlns($uri)
53
    {
54
        $this->setNamespace($uri, null);
55
    }
56
57
    public function getXmlns()
58
    {
59
        return $this->getNamespace(null);
60
    }
61
    //endregion
62
63
    public function setInnerXml($value)
64
    {
65
        return false;
66
    }
67
68
    public function setContent($value)
69
    {
70
        return false;
71
    }
72
73
    public function appendChild($element)
74
    {
75
        if ($element instanceof XmlElement) {
76
            $element->parent = $this;
77
        }
78
79
        return null;
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getLanguage(): string
86
    {
87
        return $this->getAttribute('xml:language');
88
    }
89
90
    /**
91
     * @param string $language
92
     */
93
    public function setLanguage(string $language)
94
    {
95
        $this->setAttribute('xml:language', $language);
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function getVersion(): string
102
    {
103
        return $this->getAttribute('version');
104
    }
105
106
    /**
107
     * @param string $version
108
     */
109
    public function setVersion(string $version)
110
    {
111
        $this->setAttribute('version', $version);
112
    }
113
114
    #region To
115
    /**
116
     * @return string
117
     */
118
    public function getTo(): string
119
    {
120
        return $this->getAttribute('to');
121
    }
122
123
    /**
124
     * @param string $to
125
     */
126
    public function setTo(string $to)
127
    {
128
        $this->setAttribute('to', $to);
129
    }
130
    #endregion
131
}
132