GenericElement::appendToXml()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 2
eloc 4
c 2
b 1
f 1
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
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
?>