GenericElement   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 10
c 2
b 1
f 1
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A appendToXml() 0 6 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Rss;
5
6
/**
7
 * GenericElement
8
 *
9
 * @author Jakub Konečný
10
 */
11 1
final class GenericElement implements IXmlConvertible {
12
  use \Nette\SmartObject;
13
14
  public string $name;
15
16
  /**
17
   * @var mixed
18
   */
19
  public $value;
20
21
  /**
22
   * @param mixed $value
23
   */
24
  public function __construct(string $name, $value) {
25 1
    $this->name = $name;
26 1
    $this->value = $value;
27 1
  }
28
29
  public function appendToXml(\SimpleXMLElement &$parent): void {
30 1
    $value = (string) $this->value;
31 1
    if($value === "") {
32 1
      return;
33
    }
34 1
    $parent->{$this->name} = $value;
35 1
  }
36
}
37
?>