Passed
Push — addCostaRica ( e3053a )
by Andreas
02:09
created
src/Factory/EasterFactory.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Factory/DateFollowupFactory.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,24 +18,24 @@
 block discarded – undo
18 18
 
19 19
 class DateFollowupFactory implements ItemFromDomElementCreator
20 20
 {
21
-	public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface
22
-	{
23
-		if ($element->nodeName !== 'dateFollowUp') {
24
-			return null;
25
-		}
21
+    public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface
22
+    {
23
+        if ($element->nodeName !== 'dateFollowUp') {
24
+            return null;
25
+        }
26 26
 
27
-		$day = CalendarDayFactory::createCalendarDay(
28
-			(int) $element->getAttribute('day'),
29
-			(int) $element->getAttribute('month'),
30
-			($element->hasAttribute('calendar') ? $element->getAttribute('calendar') : 'gregorian')
31
-		);
27
+        $day = CalendarDayFactory::createCalendarDay(
28
+            (int) $element->getAttribute('day'),
29
+            (int) $element->getAttribute('month'),
30
+            ($element->hasAttribute('calendar') ? $element->getAttribute('calendar') : 'gregorian')
31
+        );
32 32
 
33
-		return new DateFollowUp(
34
-			$element->textContent,
35
-			$element->getAttribute('free') === "true",
36
-			$day,
37
-			$element->getAttribute('followup'),
38
-			($element->hasAttribute('replaced') ? explode(' ', $element->getAttribute('replaced')) : [])
39
-		);
40
-	}
33
+        return new DateFollowUp(
34
+            $element->textContent,
35
+            $element->getAttribute('free') === "true",
36
+            $day,
37
+            $element->getAttribute('followup'),
38
+            ($element->hasAttribute('replaced') ? explode(' ', $element->getAttribute('replaced')) : [])
39
+        );
40
+    }
41 41
 }
Please login to merge, or discard this patch.
src/Factory/ItemFromDomElementCreator.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,5 +15,5 @@
 block discarded – undo
15 15
 
16 16
 interface ItemFromDomElementCreator
17 17
 {
18
-	public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface;
18
+    public function itemFromDomElement(DOMElement $element): ?HolidayIteratorItemInterface;
19 19
 }
Please login to merge, or discard this patch.
src/Factory/RelativeFactory.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Factory/DecorateFromDomElement.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,5 +15,5 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/SwapRule.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -12,35 +12,35 @@
 block discarded – undo
12 12
 
13 13
 class SwapRule
14 14
 {
15
-	private $swapDirection;
16
-
17
-	private $swapToDay;
18
-
19
-	/** @var GregorianWeekday[] */
20
-	private $swapWhenDay;
21
-
22
-	/**
23
-	 * @param GregorianWeekday[] $swapWhenGregorianDay
24
-	 */
25
-	public function __construct(SwapDirection $direction, GregorianWeekday $swapToGregorianDay, GregorianWeekday ...$swapWhenGregorianDay)
26
-	{
27
-		$this->swapDirection = $direction;
28
-		$this->swapToDay = $swapToGregorianDay;
29
-		$this->swapWhenDay = $swapWhenGregorianDay;
30
-	}
31
-
32
-	public function getDirection(): SwapDirection
33
-	{
34
-		return $this->swapDirection;
35
-	}
36
-
37
-	public function getSwapToDay(): GregorianWeekday
38
-	{
39
-		return $this->swapToDay;
40
-	}
41
-
42
-	public function getSwapWhenDays(): array
43
-	{
44
-		return $this->swapWhenDay;
45
-	}
15
+    private $swapDirection;
16
+
17
+    private $swapToDay;
18
+
19
+    /** @var GregorianWeekday[] */
20
+    private $swapWhenDay;
21
+
22
+    /**
23
+     * @param GregorianWeekday[] $swapWhenGregorianDay
24
+     */
25
+    public function __construct(SwapDirection $direction, GregorianWeekday $swapToGregorianDay, GregorianWeekday ...$swapWhenGregorianDay)
26
+    {
27
+        $this->swapDirection = $direction;
28
+        $this->swapToDay = $swapToGregorianDay;
29
+        $this->swapWhenDay = $swapWhenGregorianDay;
30
+    }
31
+
32
+    public function getDirection(): SwapDirection
33
+    {
34
+        return $this->swapDirection;
35
+    }
36
+
37
+    public function getSwapToDay(): GregorianWeekday
38
+    {
39
+        return $this->swapToDay;
40
+    }
41
+
42
+    public function getSwapWhenDays(): array
43
+    {
44
+        return $this->swapWhenDay;
45
+    }
46 46
 }
Please login to merge, or discard this patch.
src/CalendarDay.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -15,131 +15,131 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Factory/EasterOrthodoxFactory.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Factory/ObservanceDecoratorFactory.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.