chore: Типы для параметров

This commit is contained in:
origami11@yandex.ru 2025-05-13 17:26:49 +03:00
parent 6ef65fc826
commit 36c81135f3
7 changed files with 55 additions and 95 deletions

View file

@ -9,12 +9,11 @@ use ctiso\Validator\Rule\AbstractRule,
class Code extends AbstractRule
{
public function getErrorMsg()
{
public function getErrorMsg(): string {
return "Неправильно указан персональный код";
}
function checkCode($code) {
function checkCode($code): bool {
foreach($code as $c) {
if (empty($c)) {
return false;
@ -23,7 +22,7 @@ class Code extends AbstractRule
return true;
}
public function isValid(Collection $container, $status = null)
public function isValid(Collection $container, $status = null): bool
{
if ($status == 'update') return true;
$name = $this->field;
@ -32,27 +31,27 @@ class Code extends AbstractRule
$count = count($_POST[$name . '_code_genre']);
for($n = 0; $n < $count; $n++) {
$code = [
$_POST[$name . '_code_genre'][$n],
$_POST[$name . '_code_f'][$n],
$_POST[$name . '_code_i'][$n],
$_POST[$name . '_code_o'][$n],
$_POST[$name . '_code_year'][$n],
$_POST[$name . '_code_month'][$n],
$_POST[$name . '_code_day'][$n]
$_POST[$name . '_code_genre'][$n],
$_POST[$name . '_code_f'][$n],
$_POST[$name . '_code_i'][$n],
$_POST[$name . '_code_o'][$n],
$_POST[$name . '_code_year'][$n],
$_POST[$name . '_code_month'][$n],
$_POST[$name . '_code_day'][$n]
];
if (!$this->checkCode($code)) {
return false;
}
}
return true;
} else {
} else {
$code = [
$_POST[$name . '_code_genre'],
$_POST[$name . '_code_f'],
$_POST[$name . '_code_i'],
$_POST[$name . '_code_o'],
$_POST[$name . '_code_year'],
$_POST[$name . '_code_month'],
$_POST[$name . '_code_genre'],
$_POST[$name . '_code_f'],
$_POST[$name . '_code_i'],
$_POST[$name . '_code_o'],
$_POST[$name . '_code_year'],
$_POST[$name . '_code_month'],
$_POST[$name . '_code_day']
];