Completed
Push — main ( d12b31...3b4b71 )
by Andreas
24s queued 12s
created

EasterFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A itemFromDomElement() 0 10 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\Easter;
16
17
class EasterFactory implements ItemFromDomElementCreator
18
{
19
	public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface
20
	{
21
		if ($element->nodeName !== 'easter') {
22
			return null;
23
		}
24
25
		return new Easter(
26
			$element->textContent,
27
			$element->getAttribute('free') === "true",
28
			(int) $element->getAttribute('offset')
29
		);
30
	}
31
}
32