Commit 4d8e2b2c authored by Akex's avatar Akex
Browse files

add func acc to task | add test data

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

class TestData
{

    public const START_DATE = "13.04.2024";
    public const END_DATE = "13.04.2025";
}
+5 −1
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@

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

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

var_dump(DiffDaysAction::count(
    new DateTimeImmutable(TestData::START_DATE),
    new DateTimeImmutable(TestData::END_DATE)
));