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

Category   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 33
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
eloc 13
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getDomain() 0 2 1
A getIdentifier() 0 2 1
A setDomain() 0 2 1
A setIdentifier() 0 2 1
A appendToXml() 0 4 2
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
?>