RelativeFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A itemFromDomElement() 0 12 2
1
<?php
2
3
/**
4
 * Copyright Andreas Heigl <[email protected]>
5
 *
6
 * Licenses under the MIT-license. For details see the included file LICENSE.md
7
 */
8
9
declare(strict_types=1);
10
11
namespace Org_Heigl\Holidaychecker\Factory;
12
13
use DOMElement;
14
use Org_Heigl\Holidaychecker\HolidayIteratorItemInterface;
15
use Org_Heigl\Holidaychecker\IteratorItem\Relative;
16
17
class RelativeFactory implements ItemFromDomElementCreator
18
{
19
	public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface
20
	{
21
		if ($element->nodeName !== 'relative') {
22
			return null;
23
		}
24
25
		return new Relative(
26
			$element->textContent,
27
			$element->getAttribute('free') === "true",
28
			(int) $element->getAttribute('day'),
29
			(int) $element->getAttribute('month'),
30
			$element->getAttribute('relation')
31
		);
32
	}
33
}
34