SkipHoursCollection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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