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

EasterFactory::itemFromDomElement()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 2
nc 2
nop 1
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