|
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
|
|
|
* Holidays for Portugal. |
|
22
|
|
|
* |
|
23
|
|
|
* @link https://pt.wikipedia.org/wiki/Feriados_em_Portugal |
|
24
|
|
|
* |
|
25
|
|
|
* @package Yasumi\Provider |
|
26
|
|
|
*/ |
|
27
|
|
|
class Portugal 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 = 'PT'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Initialize holidays for Portugal. |
|
39
|
|
|
* |
|
40
|
|
|
* @throws InvalidDateException |
|
41
|
|
|
* @throws \InvalidArgumentException |
|
42
|
|
|
* @throws UnknownLocaleException |
|
43
|
|
|
* @throws \Exception |
|
44
|
|
|
*/ |
|
45
|
|
|
public function initialize(): void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->timezone = 'Europe/Lisbon'; |
|
48
|
|
|
|
|
49
|
|
|
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); |
|
50
|
|
|
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale)); |
|
51
|
|
|
$this->addHoliday($this->easter($this->year, $this->timezone, $this->locale)); |
|
52
|
|
|
$this->calculateCarnationRevolutionDay(); |
|
53
|
|
|
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale)); |
|
54
|
|
|
$this->calculateCorpusChristi(); |
|
55
|
|
|
$this->calculatePortugalDay(); |
|
56
|
|
|
$this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale)); |
|
57
|
|
|
$this->calculatePortugueseRepublicDay(); |
|
58
|
|
|
$this->calculateAllSaintsDay(); |
|
59
|
|
|
$this->calculateRestorationOfIndependenceDay(); |
|
60
|
|
|
$this->addHoliday($this->immaculateConception($this->year, $this->timezone, $this->locale)); |
|
61
|
|
|
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Carnation Revolution (25th of April 1974) / Revolução dos Cravos (25 de Abril 1974) |
|
66
|
|
|
* |
|
67
|
|
|
* The Carnation Revolution (Portuguese: Revolução dos Cravos), also referred to as the 25 April (Portuguese: 25 de |
|
68
|
|
|
* Abril), was initially a military coup in Lisbon, Portugal, on 25 April 1974 which overthrew the regime of the |
|
69
|
|
|
* Estado Novo. The revolution started as a military coup organized by the Armed Forces Movement (Portuguese: |
|
70
|
|
|
* Movimento das Forças Armadas, MFA) composed of military officers who opposed the regime, but the movement was |
|
71
|
|
|
* soon coupled with an unanticipated and popular campaign of civil resistance. This movement would lead to the |
|
72
|
|
|
* fall of the Estado Novo and the withdrawal of Portugal from its African colonies and East Timor. The name |
|
73
|
|
|
* "Carnation Revolution" comes from the fact that almost no shots were fired and when the population took to the |
|
74
|
|
|
* streets to celebrate the end of the dictatorship and war in the colonies, carnations were put into the muzzles |
|
75
|
|
|
* of rifles and on the uniforms of the army men. In Portugal, the 25th of April is a national holiday, known as |
|
76
|
|
|
* Freedom Day (Portuguese: Dia da Liberdade), to celebrate the event. |
|
77
|
|
|
* |
|
78
|
|
|
* @link https://en.wikipedia.org/wiki/Carnation_Revolution |
|
79
|
|
|
* |
|
80
|
|
|
* @throws InvalidDateException |
|
81
|
|
|
* @throws \InvalidArgumentException |
|
82
|
|
|
* @throws UnknownLocaleException |
|
83
|
|
|
* @throws \Exception |
|
84
|
|
|
*/ |
|
85
|
|
|
private function calculateCarnationRevolutionDay(): void |
|
86
|
|
|
{ |
|
87
|
|
|
if ($this->year >= 1974) { |
|
88
|
|
|
$this->addHoliday(new Holiday( |
|
89
|
|
|
'25thApril', |
|
90
|
|
|
['pt' => 'Dia da Liberdade'], |
|
91
|
|
|
new DateTime("$this->year-04-25", DateTimeZoneFactory::getDateTimeZone($this->timezone)), |
|
92
|
|
|
$this->locale, |
|
93
|
|
|
Holiday::TYPE_OFFICIAL |
|
94
|
|
|
)); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* In Portugal, between 2013 andd 2015 (inclusive) this holiday did not happen due to government deliberation. |
|
100
|
|
|
* It was restored in 2016. |
|
101
|
|
|
* |
|
102
|
|
|
* @throws InvalidDateException |
|
103
|
|
|
* @throws \InvalidArgumentException |
|
104
|
|
|
* @throws UnknownLocaleException |
|
105
|
|
|
* @throws \Exception |
|
106
|
|
|
*/ |
|
107
|
|
|
private function calculateCorpusChristi(): void |
|
108
|
|
|
{ |
|
109
|
|
|
if ($this->year <= 2012 || $this->year >= 2016) { |
|
110
|
|
|
$this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale)); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Day of Portugal, Camões and the Portuguese Communities / Dia de Portugal, de Camões e das Comunidades Portuguesas |
|
116
|
|
|
* |
|
117
|
|
|
* The Wikipedia article mentions that this holiday changed names during the Portuguese dictatorship that ran |
|
118
|
|
|
* between 1933 and 1974 (ended with the Carnation Revolution). This is the name that is currently standing. |
|
119
|
|
|
* |
|
120
|
|
|
* Portugal Day, officially Day of Portugal, Camões, and the Portuguese Communities (Portuguese: Dia de Portugal, |
|
121
|
|
|
* de Camões e das Comunidades Portuguesas), is Portugal's National Day celebrated annually on 10 June. Although |
|
122
|
|
|
* officially observed only in Portugal, Portuguese citizens and emigrants throughout the world celebrate this |
|
123
|
|
|
* holiday. The date commemorates the death of national literary icon Luís de Camões on 10 June 1580. |
|
124
|
|
|
* |
|
125
|
|
|
* @link https://en.wikipedia.org/wiki/Portugal_Day |
|
126
|
|
|
* |
|
127
|
|
|
* @throws InvalidDateException |
|
128
|
|
|
* @throws \InvalidArgumentException |
|
129
|
|
|
* @throws UnknownLocaleException |
|
130
|
|
|
* @throws \Exception |
|
131
|
|
|
*/ |
|
132
|
|
|
private function calculatePortugalDay(): void |
|
133
|
|
|
{ |
|
134
|
|
|
if ($this->year <= 1932 || $this->year >= 1974) { |
|
135
|
|
|
$this->addHoliday(new Holiday( |
|
136
|
|
|
'portugalDay', |
|
137
|
|
|
['pt' => 'Dia de Portugal'], |
|
138
|
|
|
new DateTime("$this->year-06-10", DateTimeZoneFactory::getDateTimeZone($this->timezone)), |
|
139
|
|
|
$this->locale |
|
140
|
|
|
)); |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Establishment of the Portuguese Republic / Implantação da República Portuguesa |
|
146
|
|
|
* |
|
147
|
|
|
* The establishment of the Portuguese Republic was the result of a coup d'état organised by the Portuguese |
|
148
|
|
|
* Republican Party which, on 5 October 1910, deposed the constitutional monarchy and established a republican |
|
149
|
|
|
* regime in Portugal. The subjugation of the country to British colonial interests, the royal family's |
|
150
|
|
|
* expenses, the power of the Church, the political and social instability, the system of alternating power of the |
|
151
|
|
|
* two political parties (Progressive and Regenerador), João Franco's dictatorship, an apparent inability to adapt |
|
152
|
|
|
* to modern times – all contributed to an unrelenting erosion of the Portuguese monarchy. The proponents of the |
|
153
|
|
|
* republic, particularly the Republican Party, found ways to take advantage of the situation. The Republican Party |
|
154
|
|
|
* presented itself as the only one that had a programme that was capable of returning to the country its lost |
|
155
|
|
|
* status and place Portugal on the way of progress. |
|
156
|
|
|
* |
|
157
|
|
|
* The holiday was revoked in 2013 due to government deliberation. It was restored in 2016. |
|
158
|
|
|
* |
|
159
|
|
|
* @link https://en.wikipedia.org/wiki/5_October_1910_revolution |
|
160
|
|
|
* |
|
161
|
|
|
* @throws InvalidDateException |
|
162
|
|
|
* @throws \InvalidArgumentException |
|
163
|
|
|
* @throws UnknownLocaleException |
|
164
|
|
|
* @throws \Exception |
|
165
|
|
|
*/ |
|
166
|
|
|
private function calculatePortugueseRepublicDay(): void |
|
167
|
|
|
{ |
|
168
|
|
|
if (($this->year >= 1910 && $this->year <= 2012) || $this->year >= 2016) { |
|
169
|
|
|
$this->addHoliday(new Holiday( |
|
170
|
|
|
'portugueseRepublic', |
|
171
|
|
|
['pt' => 'Implantação da República Portuguesa'], |
|
172
|
|
|
new DateTime("$this->year-10-05", DateTimeZoneFactory::getDateTimeZone($this->timezone)), |
|
173
|
|
|
$this->locale |
|
174
|
|
|
)); |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* In Portugal, between 2013 and 2015 (inclusive) this holiday did not happen due to government deliberation. |
|
180
|
|
|
* It was restored in 2016. |
|
181
|
|
|
* |
|
182
|
|
|
* @throws InvalidDateException |
|
183
|
|
|
* @throws \InvalidArgumentException |
|
184
|
|
|
* @throws UnknownLocaleException |
|
185
|
|
|
* @throws \Exception |
|
186
|
|
|
*/ |
|
187
|
|
|
private function calculateAllSaintsDay(): void |
|
188
|
|
|
{ |
|
189
|
|
|
if ($this->year <= 2012 || $this->year >= 2016) { |
|
190
|
|
|
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* Restoration of Independence / Reguesstauração da Independência |
|
196
|
|
|
* |
|
197
|
|
|
* There is no Wikipedia article referencing this holiday directly so we are using the War that motivated the |
|
198
|
|
|
* holiday instead until we can find something better. |
|
199
|
|
|
* |
|
200
|
|
|
* The Portuguese Restoration War (Portuguese: Guerra da Restauração; Spanish: Guerra de Restauración portuguesa) |
|
201
|
|
|
* was the name given by nineteenth-century 'romantic' historians to the war between Portugal and Spain that began |
|
202
|
|
|
* with the Portuguese revolution of 1640 and ended with the Treaty of Lisbon in 1668. The revolution of 1640 ended |
|
203
|
|
|
* the 60-year rule of Portugal by the Spanish Habsburgs. The period from 1640 to 1668 was marked by periodic |
|
204
|
|
|
* skirmishes between Portugal and Spain, as well as short episodes of more serious warfare, much of it occasioned |
|
205
|
|
|
* by Spanish and Portuguese entanglements with non-Iberian powers. Spain was involved in the Thirty Years' War |
|
206
|
|
|
* until 1648 and the Franco–Spanish War until 1659, while Portugal was involved in the Dutch–Portuguese War until |
|
207
|
|
|
* 1663. In the seventeenth century and afterwards, this period of sporadic conflict was simply known, in Portugal |
|
208
|
|
|
* and elsewhere, as the Acclamation War. The war established the House of Braganza as Portugal's new ruling |
|
209
|
|
|
* dynasty, replacing the House of Habsburg. This ended the so-called Iberian Union. |
|
210
|
|
|
* |
|
211
|
|
|
* The holiday was revoked in 2013 due to government deliberation. It was restored in 2016. |
|
212
|
|
|
* |
|
213
|
|
|
* @link https://pt.wikipedia.org/wiki/Restauração_da_Independência (portuguese link) |
|
214
|
|
|
* @link https://pt.wikipedia.org/wiki/Guerra_da_Restauração (english link) |
|
215
|
|
|
* |
|
216
|
|
|
* @throws InvalidDateException |
|
217
|
|
|
* @throws \InvalidArgumentException |
|
218
|
|
|
* @throws UnknownLocaleException |
|
219
|
|
|
* @throws \Exception |
|
220
|
|
|
*/ |
|
221
|
|
|
private function calculateRestorationOfIndependenceDay(): void |
|
222
|
|
|
{ |
|
223
|
|
|
// The Wikipedia article mentions that this has been a holiday since the second of half of the XIX century. |
|
224
|
|
|
if (($this->year >= 1850 && $this->year <= 2012) || $this->year >= 2016) { |
|
225
|
|
|
$this->addHoliday(new Holiday( |
|
226
|
|
|
'restorationOfIndependence', |
|
227
|
|
|
['pt' => 'Restauração da Independência'], |
|
228
|
|
|
new DateTime("$this->year-12-01", DateTimeZoneFactory::getDateTimeZone($this->timezone)), |
|
229
|
|
|
$this->locale, |
|
230
|
|
|
Holiday::TYPE_OFFICIAL |
|
231
|
|
|
)); |
|
232
|
|
|
} |
|
233
|
|
|
} |
|
234
|
|
|
} |
|
235
|
|
|
|