| @@ -16,16 +16,16 @@ | ||
| 16 | 16 | |
| 17 | 17 | class EasterFactory implements ItemFromDomElementCreator | 
| 18 | 18 |  { | 
| 19 | - public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface | |
| 20 | -	{ | |
| 21 | -		if ($element->nodeName !== 'easter') { | |
| 22 | - return null; | |
| 23 | - } | |
| 19 | + public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface | |
| 20 | +    { | |
| 21 | +        if ($element->nodeName !== 'easter') { | |
| 22 | + return null; | |
| 23 | + } | |
| 24 | 24 | |
| 25 | - return new Easter( | |
| 26 | - $element->textContent, | |
| 27 | -			$element->getAttribute('free') === "true", | |
| 28 | -			(int) $element->getAttribute('offset') | |
| 29 | - ); | |
| 30 | - } | |
| 25 | + return new Easter( | |
| 26 | + $element->textContent, | |
| 27 | +            $element->getAttribute('free') === "true", | |
| 28 | +            (int) $element->getAttribute('offset') | |
| 29 | + ); | |
| 30 | + } | |
| 31 | 31 | } | 
| @@ -15,5 +15,5 @@ | ||
| 15 | 15 | |
| 16 | 16 | interface ItemFromDomElementCreator | 
| 17 | 17 |  { | 
| 18 | - public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface; | |
| 18 | + public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface; | |
| 19 | 19 | } | 
| @@ -16,18 +16,18 @@ | ||
| 16 | 16 | |
| 17 | 17 | class RelativeFactory implements ItemFromDomElementCreator | 
| 18 | 18 |  { | 
| 19 | - public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface | |
| 20 | -	{ | |
| 21 | -		if ($element->nodeName !== 'relative') { | |
| 22 | - return null; | |
| 23 | - } | |
| 19 | + public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface | |
| 20 | +    { | |
| 21 | +        if ($element->nodeName !== 'relative') { | |
| 22 | + return null; | |
| 23 | + } | |
| 24 | 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 | - } | |
| 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 | 33 | } | 
| @@ -15,5 +15,5 @@ | ||
| 15 | 15 | |
| 16 | 16 | interface DecorateFromDomElement | 
| 17 | 17 |  { | 
| 18 | - public function decorate(HolidayIteratorItemInterface $element, DOMElement $domElement): HolidayIteratorItemInterface; | |
| 18 | + public function decorate(HolidayIteratorItemInterface $element, DOMElement $domElement): HolidayIteratorItemInterface; | |
| 19 | 19 | } | 
| @@ -61,7 +61,7 @@ | ||
| 61 | 61 | return new SwapRule( | 
| 62 | 62 | $direction, | 
| 63 | 63 | GregorianWeekday::fromString($to), | 
| 64 | -			...array_map(function ($item) { | |
| 64 | +			...array_map(function($item) { | |
| 65 | 65 | return GregorianWeekday::fromString($item); | 
| 66 | 66 |  			}, explode(' ', $when)) | 
| 67 | 67 | ); | 
| @@ -22,57 +22,57 @@ | ||
| 22 | 22 | |
| 23 | 23 | final class SwapDecoratorFactory implements DecorateFromDomElement | 
| 24 | 24 |  { | 
| 25 | - public function decorate(HolidayIteratorItemInterface $element, DOMElement $domElement): HolidayIteratorItemInterface | |
| 26 | -	{ | |
| 27 | - $rules = $this->getRulesFromDomElement($domElement); | |
| 25 | + public function decorate(HolidayIteratorItemInterface $element, DOMElement $domElement): HolidayIteratorItemInterface | |
| 26 | +    { | |
| 27 | + $rules = $this->getRulesFromDomElement($domElement); | |
| 28 | 28 | |
| 29 | -		if ($rules === []) { | |
| 30 | - return $element; | |
| 31 | - } | |
| 29 | +        if ($rules === []) { | |
| 30 | + return $element; | |
| 31 | + } | |
| 32 | 32 | |
| 33 | - $day = CalendarDayFactory::createCalendarDay( | |
| 34 | -			(int) $domElement->getAttribute('day'), | |
| 35 | -			(int) $domElement->getAttribute('month'), | |
| 36 | -			($domElement->hasAttribute('calendar') ? $domElement->getAttribute('calendar') : 'gregorian') | |
| 37 | - ); | |
| 33 | + $day = CalendarDayFactory::createCalendarDay( | |
| 34 | +            (int) $domElement->getAttribute('day'), | |
| 35 | +            (int) $domElement->getAttribute('month'), | |
| 36 | +            ($domElement->hasAttribute('calendar') ? $domElement->getAttribute('calendar') : 'gregorian') | |
| 37 | + ); | |
| 38 | 38 | |
| 39 | -		if ($domElement->hasAttribute('year')) { | |
| 40 | -			$day->setYear((int) $domElement->getAttribute('year')); | |
| 41 | - } | |
| 39 | +        if ($domElement->hasAttribute('year')) { | |
| 40 | +            $day->setYear((int) $domElement->getAttribute('year')); | |
| 41 | + } | |
| 42 | 42 | |
| 43 | - return new SwapDecorator($element, $day, ...$rules); | |
| 44 | - } | |
| 43 | + return new SwapDecorator($element, $day, ...$rules); | |
| 44 | + } | |
| 45 | 45 | |
| 46 | - /** | |
| 47 | - * @return SwapRule[] | |
| 48 | - */ | |
| 49 | - private function getRulesFromDomElement(DOMElement $domElement): array | |
| 50 | -	{ | |
| 51 | - $attributes = [ | |
| 52 | - 'forward' => SwapDirection::forward(), | |
| 53 | - 'alternateforward' => SwapDirection::forward(), | |
| 54 | - 'rewind' => SwapDirection::rewind(), | |
| 55 | - 'alternaterewind' => SwapDirection::rewind(), | |
| 56 | - ]; | |
| 46 | + /** | |
| 47 | + * @return SwapRule[] | |
| 48 | + */ | |
| 49 | + private function getRulesFromDomElement(DOMElement $domElement): array | |
| 50 | +    { | |
| 51 | + $attributes = [ | |
| 52 | + 'forward' => SwapDirection::forward(), | |
| 53 | + 'alternateforward' => SwapDirection::forward(), | |
| 54 | + 'rewind' => SwapDirection::rewind(), | |
| 55 | + 'alternaterewind' => SwapDirection::rewind(), | |
| 56 | + ]; | |
| 57 | 57 | |
| 58 | - $rules = []; | |
| 59 | -		foreach ($attributes as $attribute => $direction) { | |
| 60 | -			if ($domElement->hasAttribute($attribute . 'to') && $domElement->hasAttribute($attribute . 'when')) { | |
| 61 | - $rules[] = $this->createRuleFrom($domElement->getAttribute($attribute . 'to'), $domElement->getAttribute($attribute . 'when'), $direction); | |
| 62 | - } | |
| 63 | - } | |
| 58 | + $rules = []; | |
| 59 | +        foreach ($attributes as $attribute => $direction) { | |
| 60 | +            if ($domElement->hasAttribute($attribute . 'to') && $domElement->hasAttribute($attribute . 'when')) { | |
| 61 | + $rules[] = $this->createRuleFrom($domElement->getAttribute($attribute . 'to'), $domElement->getAttribute($attribute . 'when'), $direction); | |
| 62 | + } | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - return $rules; | |
| 66 | - } | |
| 65 | + return $rules; | |
| 66 | + } | |
| 67 | 67 | |
| 68 | - private function createRuleFrom(string $to, string $when, SwapDirection $direction): SwapRule | |
| 69 | -	{ | |
| 70 | - return new SwapRule( | |
| 71 | - $direction, | |
| 72 | - GregorianWeekday::fromString($to), | |
| 73 | -			...array_map(function ($item) { | |
| 74 | - return GregorianWeekday::fromString($item); | |
| 75 | -			}, explode(' ', $when)) | |
| 76 | - ); | |
| 77 | - } | |
| 68 | + private function createRuleFrom(string $to, string $when, SwapDirection $direction): SwapRule | |
| 69 | +    { | |
| 70 | + return new SwapRule( | |
| 71 | + $direction, | |
| 72 | + GregorianWeekday::fromString($to), | |
| 73 | +            ...array_map(function ($item) { | |
| 74 | + return GregorianWeekday::fromString($item); | |
| 75 | +            }, explode(' ', $when)) | |
| 76 | + ); | |
| 77 | + } | |
| 78 | 78 | } | 
| @@ -15,131 +15,131 @@ | ||
| 15 | 15 | |
| 16 | 16 | class CalendarDay | 
| 17 | 17 |  { | 
| 18 | - /** @var int */ | |
| 19 | - private $day; | |
| 20 | - | |
| 21 | - /** @var int */ | |
| 22 | - private $month; | |
| 23 | - | |
| 24 | - /** @var int|null */ | |
| 25 | - private $year = null; | |
| 26 | - | |
| 27 | - /** @var IntlCalendar */ | |
| 28 | - private $calendar; | |
| 29 | - | |
| 30 | - public function __construct(int $day, int $month, IntlCalendar $calendar) | |
| 31 | -	{ | |
| 32 | - $this->day = $day; | |
| 33 | - $this->month = $month; | |
| 34 | - $this->calendar = $calendar; | |
| 35 | - $this->calendar->set(IntlCalendar::FIELD_DAY_OF_MONTH, $day); | |
| 36 | - $this->calendar->set(IntlCalendar::FIELD_MONTH, $month - 1); | |
| 37 | - $this->calendar->set(IntlCalendar::FIELD_HOUR_OF_DAY, 12); | |
| 38 | - $this->calendar->set(IntlCalendar::FIELD_MINUTE, 0); | |
| 39 | - $this->calendar->set(IntlCalendar::FIELD_SECOND, 0); | |
| 40 | - $this->calendar->set(IntlCalendar::FIELD_MILLISECOND, 0); | |
| 41 | - } | |
| 42 | - | |
| 43 | - public function setYear(int $year): void | |
| 44 | -	{ | |
| 45 | - $this->year = $year; | |
| 46 | - $this->calendar->set(IntlCalendar::FIELD_YEAR, $year); | |
| 47 | - } | |
| 48 | - | |
| 49 | - public function setGregorianYear(int $year): void | |
| 50 | -	{ | |
| 51 | -		$calendarYear = (int) $this->calendar->toDateTime()->format('Y'); | |
| 52 | - | |
| 53 | - $diff = $year - $calendarYear; | |
| 54 | - $realYear = $this->calendar->get(IntlCalendar::FIELD_YEAR); | |
| 55 | - | |
| 56 | - $this->year = $realYear + $diff; | |
| 57 | - $this->calendar->add(IntlCalendar::FIELD_YEAR, $diff); | |
| 58 | - } | |
| 59 | - | |
| 60 | - public function isSameDay(DateTimeInterface $dateTime): bool | |
| 61 | -	{ | |
| 62 | - $cal = clone $this->calendar; | |
| 63 | - $cal->setTime($dateTime->getTimestamp() * 1000); | |
| 64 | - | |
| 65 | - if (null !== $this->year && | |
| 66 | - $cal->get(IntlCalendar::FIELD_YEAR) !== $this->calendar->get(IntlCalendar::FIELD_YEAR) | |
| 67 | -		) { | |
| 68 | - return false; | |
| 69 | - } | |
| 70 | - | |
| 71 | -		if ($cal->get(IntlCalendar::FIELD_MONTH) !== $this->calendar->get(IntlCalendar::FIELD_MONTH)) { | |
| 72 | - return false; | |
| 73 | - } | |
| 74 | - | |
| 75 | - return $cal->get(IntlCalendar::FIELD_DAY_OF_MONTH) === $this->calendar->get(IntlCalendar::FIELD_DAY_OF_MONTH); | |
| 76 | - } | |
| 77 | - | |
| 78 | - public function getCalendar(): IntlCalendar | |
| 79 | -	{ | |
| 80 | - return clone $this->calendar; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public function hasYearSet(): bool | |
| 84 | -	{ | |
| 85 | - return null !== $this->year; | |
| 86 | - } | |
| 87 | - | |
| 88 | - public function isFollowUpDay(DateTimeInterface $dateTime, string $followUpDay): bool | |
| 89 | -	{ | |
| 90 | - return $this->isModifiedDate($dateTime, $followUpDay, 'next'); | |
| 91 | - } | |
| 92 | - | |
| 93 | - private function isModifiedDate(DateTimeInterface $dateTime, string $modifiedDay, string $direction): bool | |
| 94 | -	{ | |
| 95 | - $cal = clone $this->calendar; | |
| 96 | -		$cal = self::setGregorianYearForDate((int) $dateTime->format('Y'), $cal); | |
| 97 | - $day = $cal->toDateTime(); | |
| 98 | - $day->modify($direction . ' ' . $modifiedDay); | |
| 99 | - $cal->setTime($day->getTimestamp() * 1000); | |
| 100 | - $cal2 = clone $this->calendar; | |
| 101 | - $cal2->setTime($dateTime->getTimestamp() * 1000); | |
| 102 | - | |
| 103 | -		if (null !== $this->year && $cal->get(IntlCalendar::FIELD_YEAR) !== $cal2->get(IntlCalendar::FIELD_YEAR)) { | |
| 104 | - return false; | |
| 105 | - } | |
| 106 | - | |
| 107 | -		if ($cal->get(IntlCalendar::FIELD_MONTH) !== $cal2->get(IntlCalendar::FIELD_MONTH)) { | |
| 108 | - return false; | |
| 109 | - } | |
| 110 | - | |
| 111 | - return $cal->get(IntlCalendar::FIELD_DAY_OF_MONTH) === $cal2->get(IntlCalendar::FIELD_DAY_OF_MONTH); | |
| 112 | - } | |
| 113 | - | |
| 114 | - public static function setGregorianYearForDate(int $year, IntlCalendar $calendar): IntlCalendar | |
| 115 | -	{ | |
| 116 | - $datetime = $calendar->toDateTime(); | |
| 117 | -		$yearDiff = $year - (int) $datetime->format('Y'); | |
| 118 | - | |
| 119 | - $calendar->set(IntlCalendar::FIELD_YEAR, $calendar->get(IntlCalendar::FIELD_YEAR) + $yearDiff); | |
| 120 | -		if ($calendar->toDateTime()->format('Y') < $year) { | |
| 121 | - $calendar->set(IntlCalendar::FIELD_YEAR, $calendar->get(IntlCalendar::FIELD_YEAR) + 1); | |
| 122 | - } | |
| 123 | -		if ($calendar->toDateTime()->format('Y') > $year) { | |
| 124 | - $calendar->set(IntlCalendar::FIELD_YEAR, $calendar->get(IntlCalendar::FIELD_YEAR) - 1); | |
| 125 | - } | |
| 126 | - | |
| 127 | - return $calendar; | |
| 128 | - } | |
| 129 | - | |
| 130 | - public function getWeekdayForGregorianYear(int $year): int | |
| 131 | -	{ | |
| 132 | - $cal = $this->getDayForGregorianYear($year); | |
| 133 | - | |
| 134 | - return $cal->get(IntlCalendar::FIELD_DAY_OF_WEEK); | |
| 135 | - } | |
| 136 | - | |
| 137 | - private function getDayForGregorianYear(int $gregorianYear): IntlCalendar | |
| 138 | -	{ | |
| 139 | - $cal = clone $this->calendar; | |
| 140 | - $cal->set(IntlCalendar::FIELD_MONTH, $this->month - 1); | |
| 141 | - $cal->set(IntlCalendar::FIELD_DAY_OF_MONTH, $this->day); | |
| 142 | - | |
| 143 | - return self::setGregorianYearForDate($gregorianYear, $cal); | |
| 144 | - } | |
| 18 | + /** @var int */ | |
| 19 | + private $day; | |
| 20 | + | |
| 21 | + /** @var int */ | |
| 22 | + private $month; | |
| 23 | + | |
| 24 | + /** @var int|null */ | |
| 25 | + private $year = null; | |
| 26 | + | |
| 27 | + /** @var IntlCalendar */ | |
| 28 | + private $calendar; | |
| 29 | + | |
| 30 | + public function __construct(int $day, int $month, IntlCalendar $calendar) | |
| 31 | +    { | |
| 32 | + $this->day = $day; | |
| 33 | + $this->month = $month; | |
| 34 | + $this->calendar = $calendar; | |
| 35 | + $this->calendar->set(IntlCalendar::FIELD_DAY_OF_MONTH, $day); | |
| 36 | + $this->calendar->set(IntlCalendar::FIELD_MONTH, $month - 1); | |
| 37 | + $this->calendar->set(IntlCalendar::FIELD_HOUR_OF_DAY, 12); | |
| 38 | + $this->calendar->set(IntlCalendar::FIELD_MINUTE, 0); | |
| 39 | + $this->calendar->set(IntlCalendar::FIELD_SECOND, 0); | |
| 40 | + $this->calendar->set(IntlCalendar::FIELD_MILLISECOND, 0); | |
| 41 | + } | |
| 42 | + | |
| 43 | + public function setYear(int $year): void | |
| 44 | +    { | |
| 45 | + $this->year = $year; | |
| 46 | + $this->calendar->set(IntlCalendar::FIELD_YEAR, $year); | |
| 47 | + } | |
| 48 | + | |
| 49 | + public function setGregorianYear(int $year): void | |
| 50 | +    { | |
| 51 | +        $calendarYear = (int) $this->calendar->toDateTime()->format('Y'); | |
| 52 | + | |
| 53 | + $diff = $year - $calendarYear; | |
| 54 | + $realYear = $this->calendar->get(IntlCalendar::FIELD_YEAR); | |
| 55 | + | |
| 56 | + $this->year = $realYear + $diff; | |
| 57 | + $this->calendar->add(IntlCalendar::FIELD_YEAR, $diff); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public function isSameDay(DateTimeInterface $dateTime): bool | |
| 61 | +    { | |
| 62 | + $cal = clone $this->calendar; | |
| 63 | + $cal->setTime($dateTime->getTimestamp() * 1000); | |
| 64 | + | |
| 65 | + if (null !== $this->year && | |
| 66 | + $cal->get(IntlCalendar::FIELD_YEAR) !== $this->calendar->get(IntlCalendar::FIELD_YEAR) | |
| 67 | +        ) { | |
| 68 | + return false; | |
| 69 | + } | |
| 70 | + | |
| 71 | +        if ($cal->get(IntlCalendar::FIELD_MONTH) !== $this->calendar->get(IntlCalendar::FIELD_MONTH)) { | |
| 72 | + return false; | |
| 73 | + } | |
| 74 | + | |
| 75 | + return $cal->get(IntlCalendar::FIELD_DAY_OF_MONTH) === $this->calendar->get(IntlCalendar::FIELD_DAY_OF_MONTH); | |
| 76 | + } | |
| 77 | + | |
| 78 | + public function getCalendar(): IntlCalendar | |
| 79 | +    { | |
| 80 | + return clone $this->calendar; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public function hasYearSet(): bool | |
| 84 | +    { | |
| 85 | + return null !== $this->year; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public function isFollowUpDay(DateTimeInterface $dateTime, string $followUpDay): bool | |
| 89 | +    { | |
| 90 | + return $this->isModifiedDate($dateTime, $followUpDay, 'next'); | |
| 91 | + } | |
| 92 | + | |
| 93 | + private function isModifiedDate(DateTimeInterface $dateTime, string $modifiedDay, string $direction): bool | |
| 94 | +    { | |
| 95 | + $cal = clone $this->calendar; | |
| 96 | +        $cal = self::setGregorianYearForDate((int) $dateTime->format('Y'), $cal); | |
| 97 | + $day = $cal->toDateTime(); | |
| 98 | + $day->modify($direction . ' ' . $modifiedDay); | |
| 99 | + $cal->setTime($day->getTimestamp() * 1000); | |
| 100 | + $cal2 = clone $this->calendar; | |
| 101 | + $cal2->setTime($dateTime->getTimestamp() * 1000); | |
| 102 | + | |
| 103 | +        if (null !== $this->year && $cal->get(IntlCalendar::FIELD_YEAR) !== $cal2->get(IntlCalendar::FIELD_YEAR)) { | |
| 104 | + return false; | |
| 105 | + } | |
| 106 | + | |
| 107 | +        if ($cal->get(IntlCalendar::FIELD_MONTH) !== $cal2->get(IntlCalendar::FIELD_MONTH)) { | |
| 108 | + return false; | |
| 109 | + } | |
| 110 | + | |
| 111 | + return $cal->get(IntlCalendar::FIELD_DAY_OF_MONTH) === $cal2->get(IntlCalendar::FIELD_DAY_OF_MONTH); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public static function setGregorianYearForDate(int $year, IntlCalendar $calendar): IntlCalendar | |
| 115 | +    { | |
| 116 | + $datetime = $calendar->toDateTime(); | |
| 117 | +        $yearDiff = $year - (int) $datetime->format('Y'); | |
| 118 | + | |
| 119 | + $calendar->set(IntlCalendar::FIELD_YEAR, $calendar->get(IntlCalendar::FIELD_YEAR) + $yearDiff); | |
| 120 | +        if ($calendar->toDateTime()->format('Y') < $year) { | |
| 121 | + $calendar->set(IntlCalendar::FIELD_YEAR, $calendar->get(IntlCalendar::FIELD_YEAR) + 1); | |
| 122 | + } | |
| 123 | +        if ($calendar->toDateTime()->format('Y') > $year) { | |
| 124 | + $calendar->set(IntlCalendar::FIELD_YEAR, $calendar->get(IntlCalendar::FIELD_YEAR) - 1); | |
| 125 | + } | |
| 126 | + | |
| 127 | + return $calendar; | |
| 128 | + } | |
| 129 | + | |
| 130 | + public function getWeekdayForGregorianYear(int $year): int | |
| 131 | +    { | |
| 132 | + $cal = $this->getDayForGregorianYear($year); | |
| 133 | + | |
| 134 | + return $cal->get(IntlCalendar::FIELD_DAY_OF_WEEK); | |
| 135 | + } | |
| 136 | + | |
| 137 | + private function getDayForGregorianYear(int $gregorianYear): IntlCalendar | |
| 138 | +    { | |
| 139 | + $cal = clone $this->calendar; | |
| 140 | + $cal->set(IntlCalendar::FIELD_MONTH, $this->month - 1); | |
| 141 | + $cal->set(IntlCalendar::FIELD_DAY_OF_MONTH, $this->day); | |
| 142 | + | |
| 143 | + return self::setGregorianYearForDate($gregorianYear, $cal); | |
| 144 | + } | |
| 145 | 145 | } | 
| @@ -16,16 +16,16 @@ | ||
| 16 | 16 | |
| 17 | 17 | class EasterOrthodoxFactory implements ItemFromDomElementCreator | 
| 18 | 18 |  { | 
| 19 | - public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface | |
| 20 | -	{ | |
| 21 | -		if ($element->nodeName !== 'easterorthodox') { | |
| 22 | - return null; | |
| 23 | - } | |
| 19 | + public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface | |
| 20 | +    { | |
| 21 | +        if ($element->nodeName !== 'easterorthodox') { | |
| 22 | + return null; | |
| 23 | + } | |
| 24 | 24 | |
| 25 | - return new EasterOrthodox( | |
| 26 | - $element->textContent, | |
| 27 | -			$element->getAttribute('free') === "true", | |
| 28 | -			(int) $element->getAttribute('offset') | |
| 29 | - ); | |
| 30 | - } | |
| 25 | + return new EasterOrthodox( | |
| 26 | + $element->textContent, | |
| 27 | +            $element->getAttribute('free') === "true", | |
| 28 | +            (int) $element->getAttribute('offset') | |
| 29 | + ); | |
| 30 | + } | |
| 31 | 31 | } | 
| @@ -16,16 +16,16 @@ | ||
| 16 | 16 | |
| 17 | 17 | class ObservanceDecoratorFactory implements DecorateFromDomElement | 
| 18 | 18 |  { | 
| 19 | - public function decorate(HolidayIteratorItemInterface $element, DOMElement $domElement): HolidayIteratorItemInterface | |
| 20 | -	{ | |
| 21 | -		if (!$domElement->hasAttribute('firstobservance') && !$domElement->hasAttribute('lastobservance')) { | |
| 22 | - return $element; | |
| 23 | - } | |
| 19 | + public function decorate(HolidayIteratorItemInterface $element, DOMElement $domElement): HolidayIteratorItemInterface | |
| 20 | +    { | |
| 21 | +        if (!$domElement->hasAttribute('firstobservance') && !$domElement->hasAttribute('lastobservance')) { | |
| 22 | + return $element; | |
| 23 | + } | |
| 24 | 24 | |
| 25 | - return new ObservanceDecorator( | |
| 26 | - $element, | |
| 27 | -			$domElement->hasAttribute('firstobservance') ? (int) $domElement->getAttribute('firstobservance') : null, | |
| 28 | -			$domElement->hasAttribute('lastobservance') ? (int) $domElement->getAttribute('lastobservance') : null, | |
| 29 | - ); | |
| 30 | - } | |
| 25 | + return new ObservanceDecorator( | |
| 26 | + $element, | |
| 27 | +            $domElement->hasAttribute('firstobservance') ? (int) $domElement->getAttribute('firstobservance') : null, | |
| 28 | +            $domElement->hasAttribute('lastobservance') ? (int) $domElement->getAttribute('lastobservance') : null, | |
| 29 | + ); | |
| 30 | + } | |
| 31 | 31 | } | 
| @@ -17,28 +17,28 @@ | ||
| 17 | 17 | |
| 18 | 18 | class DateFactory implements ItemFromDomElementCreator | 
| 19 | 19 |  { | 
| 20 | - public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface | |
| 21 | -	{ | |
| 22 | -		if ($element->nodeName !== 'date') { | |
| 23 | - return null; | |
| 24 | - } | |
| 25 | - | |
| 26 | - $day = CalendarDayFactory::createCalendarDay( | |
| 27 | -			(int) $element->getAttribute('day'), | |
| 28 | -			(int) $element->getAttribute('month'), | |
| 29 | -			($element->hasAttribute('calendar') ? $element->getAttribute('calendar') : 'gregorian') | |
| 30 | - ); | |
| 31 | - | |
| 32 | -		if ($element->hasAttribute('year')) { | |
| 33 | -			$day->setYear((int) $element->getAttribute('year')); | |
| 34 | - } | |
| 35 | - | |
| 36 | - $date = new Date( | |
| 37 | - $element->textContent, | |
| 38 | -			$element->getAttribute('free') === "true", | |
| 39 | - $day, | |
| 40 | - ); | |
| 41 | - | |
| 42 | - return $date; | |
| 43 | - } | |
| 20 | + public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface | |
| 21 | +    { | |
| 22 | +        if ($element->nodeName !== 'date') { | |
| 23 | + return null; | |
| 24 | + } | |
| 25 | + | |
| 26 | + $day = CalendarDayFactory::createCalendarDay( | |
| 27 | +            (int) $element->getAttribute('day'), | |
| 28 | +            (int) $element->getAttribute('month'), | |
| 29 | +            ($element->hasAttribute('calendar') ? $element->getAttribute('calendar') : 'gregorian') | |
| 30 | + ); | |
| 31 | + | |
| 32 | +        if ($element->hasAttribute('year')) { | |
| 33 | +            $day->setYear((int) $element->getAttribute('year')); | |
| 34 | + } | |
| 35 | + | |
| 36 | + $date = new Date( | |
| 37 | + $element->textContent, | |
| 38 | +            $element->getAttribute('free') === "true", | |
| 39 | + $day, | |
| 40 | + ); | |
| 41 | + | |
| 42 | + return $date; | |
| 43 | + } | |
| 44 | 44 | } |