Completed
Push — master ( b09ecd...ff3168 )
by Jakub
02:47
created

GenericElement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 44
ccs 12
cts 12
cp 1
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setValue() 0 2 1
A appendToXml() 0 5 2
A getValue() 0 2 1
A getName() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Rss;
5
6
/**
7
 * GenericElement
8
 *
9
 * @author Jakub Konečný
10
 * @internal
11
 * @property-read string $name
12
 * @property mixed $value
13
 */
14 1
final class GenericElement implements IXmlConvertible {
15 1
  use \Nette\SmartObject;
16
17
  /**
18
   * @var string
19
   */
20
  private $name;
21
22
  /**
23
   * @var mixed
24
   */
25
  private $value;
26
27
  /**
28
   * @param mixed $value
29
   */
30
  public function __construct(string $name, $value) {
31 1
    $this->name = $name;
0 ignored issues
show
Bug introduced by
The property name is declared read-only in Nexendrie\Rss\GenericElement.
Loading history...
32 1
    $this->value = $value;
33 1
  }
34
35
  public function getName(): string {
36 1
    return $this->name;
37
  }
38
39
  /**
40
   * @return mixed
41
   */
42
  public function getValue() {
43 1
    return $this->value;
44
  }
45
46
  /**
47
   * @param mixed $value
48
   */
49
  public function setValue($value): void {
50 1
    $this->value = $value;
51 1
  }
52
53
  public function appendToXml(\SimpleXMLElement &$parent): void {
54 1
    if(empty($this->value)) {
55 1
      return;
56
    }
57 1
    $parent->{$this->name} = $this->value;
58 1
  }
59
}
60
?>