Features   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getStartTls() 0 4 1
A getMechanisms() 0 6 1
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\Stream\Features\StartTls;
19
use Kadet\Xmpp\Utils\Accessors;
20
use Kadet\Xmpp\Xml\XmlElement;
21
use Kadet\Xmpp\Xml\XmlStream;
22
use Kadet\Xmpp\Utils\filter;
23
24
/**
25
 * Class Features
26
 * @package Kadet\Xmpp\Stream
27
 *
28
 * @property-read false|StartTls $startTls
29
 * @property-read string[]       $mechanisms
30
 */
31
class Features extends XmlElement
32
{
33
    use Accessors;
34
35
    /**
36
     * XmlElement constructor
37
     *
38
     * @param array $features
39
     */
40
    public function __construct(array $features = [])
41
    {
42
        parent::__construct('stream:features', XmlStream::NAMESPACE_URI, [ 'content' => $features ]);
43
    }
44
45
    /**
46
     * @return false|StartTls
47
     */
48
    public function getStartTls()
49
    {
50
        return $this->get(StartTls::class);
51
    }
52
53
    public function getMechanisms()
54
    {
55
        return array_map(function (XmlElement $element) {
56
            return $element->innerXml;
57
        }, $this->get(filter\element\name('mechanisms'))->children ?? []);
58
    }
59
}
60