Skip to content

Commit 434f8e3

Browse files
author
Art Kurbakov
committed
Ran code lint
1 parent 46f9d7a commit 434f8e3

9 files changed

Lines changed: 113 additions & 126 deletions

File tree

src/Yasumi/Provider/USA/NYSE.php

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
*
88
* The easy PHP Library for calculating holidays.
99
*
10-
* Copyright (c) 2025 Magic Web Group
10+
* Copyright (c) 2015 - 2025 AzuyaLabs
1111
*
1212
* For the full copyright and license information, please view the LICENSE
1313
* file that was distributed with this source code.
1414
*
15+
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
1516
* @author Art Kurbakov <admin at mgwebgroup dot com>
1617
*/
1718

18-
// This file in addition to regular holidays observed by US stock exchanges,
19+
// This file in addition to regular holidays observed by
20+
// the New York Stock Exchange (NYSE),
1921
// includes full day special closure events due to:
2022
// weather, national emergencies and presidential proclamations.
2123
// All closure events are included from year 2000.
2224

2325
namespace Yasumi\Provider\USA;
2426

25-
use Yasumi\Provider\USA;
2627
use Yasumi\Holiday;
27-
use DateTime;
28-
use DateTimeZone;
28+
use Yasumi\Provider\USA;
2929

3030
class NYSE extends USA
3131
{
@@ -36,68 +36,72 @@ class NYSE extends USA
3636
*/
3737
public function initialize(): void
3838
{
39-
$this->timezone = 'America/New_York';
39+
$this->timezone = 'America/New_York';
4040

41-
// Add exhange-specific holidays
41+
// Add exhange-specific holidays
4242
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
4343
$this->calculateMartinLutherKingday();
4444
$this->calculateWashingtonsBirthday();
4545
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale));
4646
$this->calculateMemorialDay();
47-
if (2021 < $this->year)
48-
$this->calculateJuneteenth();
47+
if (2021 < $this->year) {
48+
$this->calculateJuneteenth();
49+
}
4950
$this->calculateIndependenceDay();
5051
$this->calculateLabourDay();
5152
$this->calculateThanksgivingDay();
5253
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
5354

5455
$this->calculateSubstituteHolidays();
55-
56-
// Add other full-day closure events
57-
$this->addWeatherEvents();
58-
$this->addEmergencies();
59-
$this->addProclamations();
60-
}
61-
62-
private function addWeatherEvents()
63-
{
64-
if (2012 == $this->year) {
65-
$this->addHoliday(new Holiday('hurricaneSandy1', [], new DateTime('2012-10-29', new DateTimeZone($this->timezone))));
66-
$this->addHoliday(new Holiday('hurricaneSandy2', [], new DateTime('2012-10-30', new DateTimeZone($this->timezone))));
67-
}
68-
}
69-
70-
private function addEmergencies()
71-
{
72-
if (2001 == $this->year) {
73-
$this->addHoliday(new Holiday('groundZero1', [], new DateTime('2001-09-11', new DateTimeZone($this->timezone))));
74-
$this->addHoliday(new Holiday('groundZero2', [], new DateTime('2001-09-12', new DateTimeZone($this->timezone))));
75-
$this->addHoliday(new Holiday('groundZero3', [], new DateTime('2001-09-13', new DateTimeZone($this->timezone))));
76-
$this->addHoliday(new Holiday('groundZero4', [], new DateTime('2001-09-14', new DateTimeZone($this->timezone))));
77-
}
78-
}
7956

80-
private function addProclamations()
81-
{
82-
if (2004 == $this->year)
83-
$this->addHoliday(new Holiday('ReaganMourning', [], new DateTime('2004-06-11', new DateTimeZone($this->timezone))));
84-
if (2007 == $this->year)
85-
$this->addHoliday(new Holiday('GRFordMourning', [], new DateTime('2007-01-02', new DateTimeZone($this->timezone))));
86-
if (2018 == $this->year)
87-
$this->addHoliday(new Holiday('HWBushMourning', [], new DateTime('2018-12-05', new DateTimeZone($this->timezone))));
88-
if (2025 == $this->year)
89-
$this->addHoliday(new Holiday('CarterMourning', [], new DateTime('2025-01-09', new DateTimeZone($this->timezone))));
90-
}
57+
// Add other full-day closure events
58+
$this->addWeatherEvents();
59+
$this->addEmergencies();
60+
$this->addProclamations();
61+
}
9162

9263
public function getSources(): array
9364
{
9465
return [
95-
'https://www.nyse.com/trader-update/history#11507',
96-
'https://s3.amazonaws.com/armstrongeconomics-wp/2013/07/NYSE-Closings.pdf',
97-
'https://ir.theice.com/press/news-details/2018/New-York-Stock-Exchange-to-Honor-President-George-H-W-Bush/default.aspx',
98-
'https://ir.theice.com/press/news-details/2024/The-New-York-Stock-Exchange-Will-Close-Markets-on-January-9-to-Honor-the-Passing-of-Former-President-Jimmy-Carter-on-National-Day-of-Mourning/default.aspx',
99-
'https://www.thecorporatecounsel.net/blog/2021/10/nyse-makes-juneteenth-a-new-market-holiday.html',
66+
'https://www.nyse.com/trader-update/history#11507',
67+
'https://s3.amazonaws.com/armstrongeconomics-wp/2013/07/NYSE-Closings.pdf',
68+
'https://ir.theice.com/press/news-details/2018/New-York-Stock-Exchange-to-Honor-President-George-H-W-Bush/default.aspx',
69+
'https://ir.theice.com/press/news-details/2024/The-New-York-Stock-Exchange-Will-Close-Markets-on-January-9-to-Honor-the-Passing-of-Former-President-Jimmy-Carter-on-National-Day-of-Mourning/default.aspx',
70+
'https://www.thecorporatecounsel.net/blog/2021/10/nyse-makes-juneteenth-a-new-market-holiday.html',
10071
];
10172
}
102-
}
10373

74+
private function addWeatherEvents()
75+
{
76+
if (2012 == $this->year) {
77+
$this->addHoliday(new Holiday('hurricaneSandy1', [], new \DateTime('2012-10-29', new \DateTimeZone($this->timezone))));
78+
$this->addHoliday(new Holiday('hurricaneSandy2', [], new \DateTime('2012-10-30', new \DateTimeZone($this->timezone))));
79+
}
80+
}
81+
82+
private function addEmergencies()
83+
{
84+
if (2001 == $this->year) {
85+
$this->addHoliday(new Holiday('groundZero1', [], new \DateTime('2001-09-11', new \DateTimeZone($this->timezone))));
86+
$this->addHoliday(new Holiday('groundZero2', [], new \DateTime('2001-09-12', new \DateTimeZone($this->timezone))));
87+
$this->addHoliday(new Holiday('groundZero3', [], new \DateTime('2001-09-13', new \DateTimeZone($this->timezone))));
88+
$this->addHoliday(new Holiday('groundZero4', [], new \DateTime('2001-09-14', new \DateTimeZone($this->timezone))));
89+
}
90+
}
91+
92+
private function addProclamations()
93+
{
94+
if (2004 == $this->year) {
95+
$this->addHoliday(new Holiday('ReaganMourning', [], new \DateTime('2004-06-11', new \DateTimeZone($this->timezone))));
96+
}
97+
if (2007 == $this->year) {
98+
$this->addHoliday(new Holiday('GRFordMourning', [], new \DateTime('2007-01-02', new \DateTimeZone($this->timezone))));
99+
}
100+
if (2018 == $this->year) {
101+
$this->addHoliday(new Holiday('HWBushMourning', [], new \DateTime('2018-12-05', new \DateTimeZone($this->timezone))));
102+
}
103+
if (2025 == $this->year) {
104+
$this->addHoliday(new Holiday('CarterMourning', [], new \DateTime('2025-01-09', new \DateTimeZone($this->timezone))));
105+
}
106+
}
107+
}

tests/USA/NYSE/CarterMourningTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@
77
*
88
* The easy PHP Library for calculating holidays.
99
*
10-
* Copyright (c) 2025 Magic Web Group
10+
* Copyright (c) 2015 - 2025 AzuyaLabs
1111
*
1212
* For the full copyright and license information, please view the LICENSE
1313
* file that was distributed with this source code.
1414
*
15+
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
1516
* @author Art Kurbakov <admin at mgwebgroup dot com>
1617
*/
1718

1819
namespace Yasumi\tests\USA\NYSE;
1920

20-
use Yasumi\Holiday;
21-
use Yasumi\tests\HolidayTestCase;
2221
use Yasumi\tests\USA\USABaseTestCase;
23-
use DateTime;
24-
use DateTimeZone;
2522

2623
/**
2724
* Class to test day of closure of NYSE due to Jimmy Carter mourning proclamation
@@ -49,7 +46,7 @@ public function testCarterMourning(): void
4946
self::REGION,
5047
'CarterMourning',
5148
self::OBSERVED_YEAR,
52-
new DateTime("2025-01-09", new DateTimeZone(self::TIMEZONE))
49+
new \DateTime('2025-01-09', new \DateTimeZone(self::TIMEZONE))
5350
);
5451
}
5552

@@ -61,7 +58,7 @@ public function testCarterMourning(): void
6158
public function testCarterMourningBefore2025(): void
6259
{
6360
$this->assertNotHoliday(
64-
self::REGION,
61+
self::REGION,
6562
'CarterMourning',
6663
self::OBSERVED_YEAR - 1
6764
);
@@ -75,7 +72,7 @@ public function testCarterMourningBefore2025(): void
7572
public function testCarterMourningAfter2025(): void
7673
{
7774
$this->assertNotHoliday(
78-
self::REGION,
75+
self::REGION,
7976
'CarterMourning',
8077
self::OBSERVED_YEAR + 1
8178
);

tests/USA/NYSE/GRFordMourningTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@
77
*
88
* The easy PHP Library for calculating holidays.
99
*
10-
* Copyright (c) 2025 Magic Web Group
10+
* Copyright (c) 2015 - 2025 AzuyaLabs
1111
*
1212
* For the full copyright and license information, please view the LICENSE
1313
* file that was distributed with this source code.
1414
*
15+
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
1516
* @author Art Kurbakov <admin at mgwebgroup dot com>
1617
*/
1718

1819
namespace Yasumi\tests\USA\NYSE;
1920

20-
use Yasumi\Holiday;
21-
use Yasumi\tests\HolidayTestCase;
2221
use Yasumi\tests\USA\USABaseTestCase;
23-
use DateTime;
24-
use DateTimeZone;
2522

2623
/**
2724
* Class to test day of closure of NYSE due to G.R. Ford Mourning proclamation
@@ -49,7 +46,7 @@ public function testGRFordMourning(): void
4946
self::REGION,
5047
'GRFordMourning',
5148
self::OBSERVED_YEAR,
52-
new DateTime("2007-01-02", new DateTimeZone(self::TIMEZONE))
49+
new \DateTime('2007-01-02', new \DateTimeZone(self::TIMEZONE))
5350
);
5451
}
5552

@@ -61,7 +58,7 @@ public function testGRFordMourning(): void
6158
public function testGRFordMourningBefore2007(): void
6259
{
6360
$this->assertNotHoliday(
64-
self::REGION,
61+
self::REGION,
6562
'GRFordMourning',
6663
self::OBSERVED_YEAR - 1
6764
);
@@ -75,7 +72,7 @@ public function testGRFordMourningBefore2007(): void
7572
public function testGRFordMourningAfter2007(): void
7673
{
7774
$this->assertNotHoliday(
78-
self::REGION,
75+
self::REGION,
7976
'GRFordMourning',
8077
self::OBSERVED_YEAR + 1
8178
);

tests/USA/NYSE/GroundZeroTest.php

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@
77
*
88
* The easy PHP Library for calculating holidays.
99
*
10-
* Copyright (c) 2025 Magic Web Group
10+
* Copyright (c) 2015 - 2025 AzuyaLabs
1111
*
1212
* For the full copyright and license information, please view the LICENSE
1313
* file that was distributed with this source code.
1414
*
15+
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
1516
* @author Art Kurbakov <admin at mgwebgroup dot com>
1617
*/
1718

1819
namespace Yasumi\tests\USA\NYSE;
1920

20-
use Yasumi\Holiday;
21-
use Yasumi\tests\HolidayTestCase;
2221
use Yasumi\tests\USA\USABaseTestCase;
23-
use DateTime;
24-
use DateTimeZone;
2522

2623
/**
2724
* Class to test 4 days of closure of NYSE due to September 11th attacks
@@ -49,90 +46,90 @@ public function testGroundZero(): void
4946
self::REGION,
5047
'groundZero1',
5148
self::OBSERVED_YEAR,
52-
new DateTime("2001-09-11", new DateTimeZone(self::TIMEZONE))
49+
new \DateTime('2001-09-11', new \DateTimeZone(self::TIMEZONE))
5350
);
5451

5552
$this->assertHoliday(
5653
self::REGION,
5754
'groundZero2',
5855
self::OBSERVED_YEAR,
59-
new DateTime("2001-09-12", new DateTimeZone(self::TIMEZONE))
56+
new \DateTime('2001-09-12', new \DateTimeZone(self::TIMEZONE))
6057
);
6158

6259
$this->assertHoliday(
6360
self::REGION,
6461
'groundZero3',
6562
self::OBSERVED_YEAR,
66-
new DateTime("2001-09-13", new DateTimeZone(self::TIMEZONE))
63+
new \DateTime('2001-09-13', new \DateTimeZone(self::TIMEZONE))
6764
);
6865

6966
$this->assertHoliday(
7067
self::REGION,
7168
'groundZero4',
7269
self::OBSERVED_YEAR,
73-
new DateTime("2001-09-14", new DateTimeZone(self::TIMEZONE))
70+
new \DateTime('2001-09-14', new \DateTimeZone(self::TIMEZONE))
7471
);
7572
}
7673

7774
/**
78-
* Tests years before 2001
75+
* Tests years before 2001
7976
*
8077
* @throws \Exception
8178
*/
8279
public function testGroundZeroBefore2001(): void
8380
{
8481
$this->assertNotHoliday(
85-
self::REGION,
82+
self::REGION,
8683
'groundZero1',
8784
self::OBSERVED_YEAR - 1
8885
);
8986

9087
$this->assertNotHoliday(
91-
self::REGION,
88+
self::REGION,
9289
'groundZero2',
9390
self::OBSERVED_YEAR - 1
9491
);
9592

9693
$this->assertNotHoliday(
97-
self::REGION,
94+
self::REGION,
9895
'groundZero3',
9996
self::OBSERVED_YEAR - 1
10097
);
10198

10299
$this->assertNotHoliday(
103-
self::REGION,
100+
self::REGION,
104101
'groundZero4',
105102
self::OBSERVED_YEAR - 1
106103
);
107104
}
108105

109106
/**
110-
* Tests years after 2001
107+
* Tests years after 2001
111108
*
112109
* @throws \Exception
113110
*/
114111
public function testGroundZeroAfter2001(): void
115112
{
116113
$this->assertNotHoliday(
117-
self::REGION,
114+
self::REGION,
118115
'groundZero1',
119116
self::OBSERVED_YEAR + 1
120117
);
121118

122119
$this->assertNotHoliday(
123-
self::REGION,
120+
self::REGION,
124121
'groundZero2',
125122
self::OBSERVED_YEAR + 1
126123
);
127124

128125
$this->assertNotHoliday(
129-
self::REGION,
126+
self::REGION,
130127
'groundZero3',
131128
self::OBSERVED_YEAR + 1
132129
);
133130

134131
$this->assertNotHoliday(
135-
self::REGION,
132+
self::REGION,
136133
'groundZero4',
137134
self::OBSERVED_YEAR + 1
138135
);

0 commit comments

Comments
 (0)