Loading public/public/Actions/CountFriday13.php 0 → 100644 +27 −0 Original line number Diff line number Diff line <?php namespace App\Actions; use DateTimeImmutable; class CountFriday13 { /** * Вернет все пятницы 13 в году * @param int $year год, в котором необходимо произвести расчет * @return DateTimeImmutable[] */ public static function count(int $year): array { $AllFri13 = []; for ($i = 1; $i <= 12; $i++) { $next13 = (new DateTimeImmutable())->setDate($year, $i, 13); if ($next13->format("D") === "Fri") { $AllFri13[] = $next13; } } return $AllFri13; } } public/public/TestData/TestData.php +2 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ namespace App\TestData; class TestData { public const YEAR = 2024; public const PRICE_COUNT_ARRAY = [ [ 'price' => 4, Loading public/public/index.php +6 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ require_once __DIR__ . '/../vendor/autoload.php'; use App\Actions\CountFriday13; use App\Actions\HowDaysToNYAction; use App\Actions\SortPriceAction; use App\Actions\IdSearchAction; Loading @@ -23,3 +25,7 @@ echo '<hr>'; echo 'IdSearchAction: <br>'; var_dump(IdSearchAction::search(TestData::ARRAY_FOR_SEARCHING)); echo '<hr>'; echo 'CountFriday13: <br>'; var_dump(CountFriday13::count(TestData::YEAR)); echo '<hr>'; Loading
public/public/Actions/CountFriday13.php 0 → 100644 +27 −0 Original line number Diff line number Diff line <?php namespace App\Actions; use DateTimeImmutable; class CountFriday13 { /** * Вернет все пятницы 13 в году * @param int $year год, в котором необходимо произвести расчет * @return DateTimeImmutable[] */ public static function count(int $year): array { $AllFri13 = []; for ($i = 1; $i <= 12; $i++) { $next13 = (new DateTimeImmutable())->setDate($year, $i, 13); if ($next13->format("D") === "Fri") { $AllFri13[] = $next13; } } return $AllFri13; } }
public/public/TestData/TestData.php +2 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ namespace App\TestData; class TestData { public const YEAR = 2024; public const PRICE_COUNT_ARRAY = [ [ 'price' => 4, Loading
public/public/index.php +6 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ require_once __DIR__ . '/../vendor/autoload.php'; use App\Actions\CountFriday13; use App\Actions\HowDaysToNYAction; use App\Actions\SortPriceAction; use App\Actions\IdSearchAction; Loading @@ -23,3 +25,7 @@ echo '<hr>'; echo 'IdSearchAction: <br>'; var_dump(IdSearchAction::search(TestData::ARRAY_FOR_SEARCHING)); echo '<hr>'; echo 'CountFriday13: <br>'; var_dump(CountFriday13::count(TestData::YEAR)); echo '<hr>';