Passed
Push — master ( e9f6a4...7ddfc7 )
by Jakub
01:51
created

Category::appendToXml()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
eloc 3
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Rss;
5
6
/**
7
 * Category
8
 *
9
 * @author Jakub Konečný
10
 * @property string $identifier
11
 * @property string $domain
12
 */
13 1
final class Category implements IXmlConvertible {
14 1
  use \Nette\SmartObject;
15
16
  /** @var string */
17
  protected $identifier;
18
  /** @var string */
19
  protected $domain;
20
21
  public function __construct(string $identifier, string $domain = "") {
22 1
    $this->identifier = $identifier;
23 1
    $this->domain = $domain;
24 1
  }
25
26
  public function getIdentifier(): string {
27 1
    return $this->identifier;
28
  }
29
30
  public function setIdentifier(string $identifier): void {
31 1
    $this->identifier = $identifier;
32 1
  }
33
34
  public function getDomain(): string {
35 1
    return $this->domain;
36
  }
37
38
  public function setDomain(string $domain): void {
39 1
    $this->domain = $domain;
40 1
  }
41
42
  public function appendToXml(\SimpleXMLElement &$parent): void {
43 1
    $categoryElement = $parent->addChild("category", $this->identifier);
44 1
    if($this->domain !== "") {
45 1
      $categoryElement->addAttribute("domain", $this->domain);
46
    }
47 1
  }
48
}
49
?>