XmlConvertibleObject   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 2
b 0
f 0
dl 0
loc 36
ccs 6
cts 6
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getXmlProperties() 0 3 1
A __set() 0 3 1
A __get() 0 3 1
1
<?php
2
3
namespace Horat1us;
4
5
/**
6
 * Class XmlConvertibleObject
7
 * @package Horat1us
8
 */
9
class XmlConvertibleObject implements XmlConvertibleInterface
10
{
11
    use XmlConvertible {
12
        getXmlProperties as protected traitXmlProperties;
13
    }
14
15
    private array $xmlProperties = [];
16
17
    /**
18
     * XmlConvertibleObject constructor.
19
     * @param string $xmlElementName
20
     * @param array $xmlChildren
21
     */
22
    public function __construct(?string $xmlElementName = null, array $xmlChildren = null)
23
    {
24
        $this->xmlElementName = $xmlElementName;
25
        $this->xmlChildren = $xmlChildren;
26
    }
27 19
28
    /**
29 19
     * @param array|null $properties
30 19
     * @return array
31 19
     */
32
    public function getXmlProperties(?array $properties = null): array
33
    {
34
        return $this->traitXmlProperties($properties ?? array_keys($this->xmlProperties));
35
    }
36
37 14
    public function __get(string $name)
38
    {
39 14
        return $this->xmlProperties[$name] ?? null;
40
    }
41
42
    public function __set(string $name, $value): void
43
    {
44
        $this->xmlProperties[$name] = $value;
45
    }
46
}
47