Commit 5e4177ba authored by Nikita Chernykh's avatar Nikita Chernykh
Browse files

Merge branch 'PTPS|Function_6' into 'main'

Ptps|function 6

See merge request !16
parents b3eaade0 a4ec8443
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;
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ namespace App\TestData;

class TestData
{
    public const YEAR = 2024;

    public const PRICE_COUNT_ARRAY = [
        [
            'price' => 4,
+6 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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>';