Commit 9421f2cd authored by Akex's avatar Akex
Browse files

add test data | add count func

parent 2a7f91b8
Loading
Loading
Loading
Loading
+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;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -8,5 +8,5 @@ namespace App\TestData;

class TestData
{

    public const YEAR = 2024;
}
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

require_once __DIR__ . '/../vendor/autoload.php';

use App\Actions /*placeholder for a class */;
use App\Actions\CountFriday13;
use App\TestData\TestData;

var_dump(CountFriday13::count(TestData::YEAR));