SkipHoursCollection   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A appendToXml() 0 4 1
A __construct() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Rss;
5
6
/**
7
 * SkipHoursCollection
8
 *
9
 * @author Jakub Konečný
10
 * @internal
11
 */
12 1
final class SkipHoursCollection implements IXmlConvertible {
13
  private array $hours = [];
14
15
  /**
16
   * @param int[] $hours
17
   */
18
  public function __construct(array $hours) {
19 1
    array_walk($hours, function(int &$value): void {
20 1
      $value = (string) $value;
21 1
    });
22
    /** @var string[] $hours */
23 1
    $hours = array_unique($hours);
24 1
    $this->hours = $hours;
25 1
  }
26
27
  public function appendToXml(\SimpleXMLElement &$parent): void {
28 1
    $element = $parent->addChild("skipHours");
29 1
    array_walk($this->hours, function(string $value) use ($element): void {
30 1
      $element->addChild("hour", $value);
31 1
    });
32 1
  }
33
}
34
?>