CzechRepublic   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 189
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 51
c 0
b 0
f 0
dl 0
loc 189
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A calculateRenewalOfCzechIndependenceDay() 0 10 1
A initialize() 0 18 1
A calculateStruggleForFreedomAndDemocracyDay() 0 10 1
A calculateCzechStatehoodDay() 0 10 1
A calculateIndependentCzechoslovakStateDay() 0 6 1
A calculateSaintsCyrilAndMethodiusDay() 0 10 1
A calculateJanHusDay() 0 7 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the Yasumi package.
4
 *
5
 * Copyright (c) 2015 - 2020 AzuyaLabs
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author Sacha Telgenhof <[email protected]>
11
 */
12
13
namespace Yasumi\Provider;
14
15
use DateTime;
16
use Yasumi\Exception\InvalidDateException;
17
use Yasumi\Exception\UnknownLocaleException;
18
use Yasumi\Holiday;
19
20
/**
21
 * Provider for all holidays in Czech republic.
22
 *
23
 * Class CzechRepublic
24
 * @package Yasumi\Provider
25
 * @author  Dennis Fridrich <[email protected]>
26
 */
27
class CzechRepublic extends AbstractProvider
28
{
29
    use CommonHolidays, ChristianHolidays;
30
31
    /**
32
     * Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
33
     * country or sub-region.
34
     */
35
    public const ID = 'CZ';
36
37
    /**
38
     * Initialize holidays for the Czech Republic.
39
     *
40
     * @throws InvalidDateException
41
     * @throws \InvalidArgumentException
42
     * @throws UnknownLocaleException
43
     * @throws \Exception
44
     */
45
    public function initialize(): void
46
    {
47
        $this->timezone = 'Europe/Prague';
48
49
        $this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
50
        $this->calculateRenewalOfCzechIndependenceDay();
51
        $this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale));
52
        $this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
53
        $this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale));
54
        $this->addHoliday($this->victoryInEuropeDay($this->year, $this->timezone, $this->locale));
55
        $this->calculateSaintsCyrilAndMethodiusDay();
56
        $this->calculateJanHusDay();
57
        $this->calculateCzechStatehoodDay();
58
        $this->calculateIndependentCzechoslovakStateDay();
59
        $this->calculateStruggleForFreedomAndDemocracyDay();
60
        $this->addHoliday($this->christmasEve($this->year, $this->timezone, $this->locale));
61
        $this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
62
        $this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));
63
    }
64
65
    /**
66
     * Day of renewal of independent Czech state
67
     *
68
     * @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
69
     *
70
     * @throws InvalidDateException
71
     * @throws \InvalidArgumentException
72
     * @throws UnknownLocaleException
73
     * @throws \Exception
74
     */
75
    private function calculateRenewalOfCzechIndependenceDay(): void
76
    {
77
        $this->addHoliday(new Holiday(
78
            'czechRenewalOfIndependentStateDay',
79
            [
80
                'cs' => 'Den obnovy samostatného českého státu',
81
                'en' => 'Day of renewal of the independent Czech state',
82
            ],
83
            new DateTime($this->year . '-01-01', new \DateTimeZone($this->timezone)),
84
            $this->locale
85
        ));
86
    }
87
88
    /**
89
     * Saints Cyril and Methodius Day
90
     *
91
     * Saints Cyril and Methodius were two Byzantine Christian theologians and Christian missionaries who were brothers.
92
     * Through their work they influenced the cultural development of all Slavs, for which they received the title
93
     * "Apostles to the Slavs". They are credited with devising the Glagolitic alphabet, the first alphabet used
94
     * to transcribe Old Church Slavonic.
95
     *
96
     * After their deaths, their pupils continued their missionary work among other Slavs. Both brothers are venerated
97
     * in the Orthodox Church as saints with the title of "equal-to-apostles". In 1880, Pope Leo XIII introduced their
98
     * feast into the calendar of the Roman Catholic Church. In 1980, Pope John Paul II declared them co-patron saints
99
     * of Europe, together with Benedict of Nursia.
100
     *
101
     * @see https://en.wikipedia.org/wiki/Saints_Cyril_and_Methodius
102
     * @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
103
     *
104
     * @throws InvalidDateException
105
     * @throws \InvalidArgumentException
106
     * @throws UnknownLocaleException
107
     * @throws \Exception
108
     */
109
    private function calculateSaintsCyrilAndMethodiusDay(): void
110
    {
111
        $this->addHoliday(new Holiday(
112
            'saintsCyrilAndMethodiusDay',
113
            [
114
                'cs' => 'Den slovanských věrozvěstů Cyrila a Metoděje',
115
                'en' => 'Saints Cyril and Methodius Day',
116
            ],
117
            new DateTime($this->year . '-07-5', new \DateTimeZone($this->timezone)),
118
            $this->locale
119
        ));
120
    }
121
122
    /**
123
     * Jan Hus Day
124
     *
125
     * Jan Hus, often referred to in English as John Hus or John Huss, was a Czech priest, philosopher, early Christian
126
     * reformer and Master at Charles University in Prague. After John Wycliffe, the theorist of ecclesiastical
127
     * Reformation, Hus is considered the first Church reformer, as he lived before Luther, Calvin and Zwingli.
128
     *
129
     * @see https://en.wikipedia.org/wiki/Jan_Hus
130
     * @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
131
     *
132
     * @throws InvalidDateException
133
     * @throws \InvalidArgumentException
134
     * @throws UnknownLocaleException
135
     * @throws \Exception
136
     */
137
    private function calculateJanHusDay(): void
138
    {
139
        $this->addHoliday(new Holiday(
140
            'janHusDay',
141
            ['cs' => 'Den upálení mistra Jana Husa', 'en' => 'Jan Hus Day'],
142
            new DateTime($this->year . '-07-6', new \DateTimeZone($this->timezone)),
143
            $this->locale
144
        ));
145
    }
146
147
    /**
148
     * St. Wenceslas Day (Czech Statehood Day)
149
     *
150
     * Wenceslaus I, Wenceslas I, or Vaclav the Good was the duke of Bohemia from 921 until his assassination in 935,
151
     * in a plot by his brother, Boleslav the Cruel.
152
     *
153
     * His martyrdom, and the popularity of several biographies, quickly gave rise to a reputation for heroic goodness,
154
     * resulting in his being elevated to sainthood, posthumously declared king, and seen as the patron saint
155
     * of the Czech state. He is the subject of "Good King Wenceslas", a Saint Stephen's Day carol.
156
     *
157
     * @see https://en.wikipedia.org/wiki/Wenceslaus_I,_Duke_of_Bohemia
158
     * @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
159
     *
160
     * @throws InvalidDateException
161
     * @throws \InvalidArgumentException
162
     * @throws UnknownLocaleException
163
     * @throws \Exception
164
     */
165
    private function calculateCzechStatehoodDay(): void
166
    {
167
        $this->addHoliday(new Holiday(
168
            'czechStateHoodDay',
169
            [
170
                'cs' => 'Den české státnosti',
171
                'en' => 'St. Wenceslas Day (Czech Statehood Day)',
172
            ],
173
            new DateTime($this->year . '-09-28', new \DateTimeZone($this->timezone)),
174
            $this->locale
175
        ));
176
    }
177
178
    /**
179
     * Independent Czechoslovak State Day
180
     *
181
     * @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
182
     *
183
     * @throws InvalidDateException
184
     * @throws \InvalidArgumentException
185
     * @throws UnknownLocaleException
186
     * @throws \Exception
187
     */
188
    private function calculateIndependentCzechoslovakStateDay(): void
189
    {
190
        $this->addHoliday(new Holiday('independentCzechoslovakStateDay', [
191
            'cs' => 'Den vzniku samostatného československého státu',
192
            'en' => 'Independent Czechoslovak State Day',
193
        ], new DateTime($this->year . '-10-28', new \DateTimeZone($this->timezone)), $this->locale));
194
    }
195
196
    /**
197
     * Struggle for Freedom and Democracy Day
198
     *
199
     * @see https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic
200
     *
201
     * @throws InvalidDateException
202
     * @throws \InvalidArgumentException
203
     * @throws UnknownLocaleException
204
     * @throws \Exception
205
     */
206
    private function calculateStruggleForFreedomAndDemocracyDay(): void
207
    {
208
        $this->addHoliday(new Holiday(
209
            'struggleForFreedomAndDemocracyDay',
210
            [
211
                'cs' => 'Den boje za svobodu a demokracii',
212
                'en' => 'Struggle for Freedom and Democracy Day',
213
            ],
214
            new DateTime($this->year . '-11-17', new \DateTimeZone($this->timezone)),
215
            $this->locale
216
        ));
217
    }
218
}
219