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

Merge branch 'PTPS|Function_7' into 'main'

Ptps|function 7

See merge request !17
parents 5e4177ba 8c2f59a9
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?php

namespace App\Actions;

use DateTimeImmutable;

class DiffDaysAction
{
    /**
     * Вернет кол-во дней между датами
     * @param DateTimeImmutable $dateStart дата начала
     * @param DateTimeImmutable $dateEnd дата окончания
     * @return int
     * */
    public static function count(
        DateTimeImmutable $dateStart,
        DateTimeImmutable $dateEnd
    ): int {
        return (int) $dateStart->diff($dateEnd)->format('%a');
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@ namespace App\TestData;

class TestData
{
    public const START_DATE = "13.04.2024";
    public const END_DATE = "13.04.2025";

    public const YEAR = 2024;

    public const PRICE_COUNT_ARRAY = [
+8 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

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


use App\Actions\DiffDaysAction;
use App\Actions\CountFriday13;
use App\Actions\HowDaysToNYAction;
use App\Actions\SortPriceAction;
@@ -10,6 +10,13 @@ use App\Actions\IdSearchAction;
use App\Actions\PrepareMenuAction;
use App\TestData\TestData;

echo 'DiffDaysAction <br>'
var_dump(DiffDaysAction::count(
    new DateTimeImmutable(TestData::START_DATE),
    new DateTimeImmutable(TestData::END_DATE)
));
echo '<hr>'

echo 'HowDaysToNYAction: <br>';
echo "Дней до нового года (в днях): ". HowDaysToNYAction::count(new DateTimeImmutable());
echo '<hr>';