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

Enclosure   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 45
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
eloc 18
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A appendToXml() 0 5 1
A __construct() 0 4 1
A setType() 0 2 1
A getType() 0 2 1
A getUrl() 0 2 1
A setUrl() 0 2 1
A getLength() 0 2 1
A setLength() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Rss;
5
6
/**
7
 * Enclosure
8
 *
9
 * @author Jakub Konečný
10
 * @property string $url
11
 * @property int $length
12
 * @property string $type
13
 */
14 1
final class Enclosure implements IXmlConvertible {
15 1
  use \Nette\SmartObject;
16
17
  /** @var string */
18
  protected $url;
19
  /** @var int */
20
  protected $length;
21
  /** @var string */
22
  protected $type;
23
24
  public function __construct(string $url, int $length, string $type) {
25 1
    $this->url = $url;
26 1
    $this->length = $length;
27 1
    $this->type = $type;
28 1
  }
29
30
  public function getUrl(): string {
31 1
    return $this->url;
32
  }
33
34
  public function setUrl(string $url): void {
35 1
    $this->url = $url;
36 1
  }
37
38
  public function getLength(): int {
39 1
    return $this->length;
40
  }
41
42
  public function setLength(int $length): void {
43 1
    $this->length = $length;
44 1
  }
45
46
  public function getType(): string {
47 1
    return $this->type;
48
  }
49
50
  public function setType(string $type): void {
51 1
    $this->type = $type;
52 1
  }
53
54
  public function appendToXml(\SimpleXMLElement &$parent): void {
55 1
    $enclosureElement = $parent->addChild("enclosure");
56 1
    $enclosureElement->addAttribute("url", $this->url);
57 1
    $enclosureElement->addAttribute("length", (string) $this->length);
58 1
    $enclosureElement->addAttribute("type", $this->type);
59 1
  }
60
}
61
?>