Skip to content
Snippets Groups Projects

make controller

Merged Александр Плохих requested to merge PTPS|Controller_6 into main
Files
3
+ 27
0
<?php
namespace App\Actions;
use DateTimeImmutable;
class CountFriday13Action
{
/**
* Вернет все пятницы 13 в году
* @param int $year год, в котором необходимо произвести расчет
* @return DateTimeImmutable[]
*/
public function act(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;
}
}
Loading