. */ declare(strict_types=1); namespace FireflyIII\Rules; use Illuminate\Contracts\Validation\Rule; /** * Class ValidRecurrenceRepetitionType */ class ValidRecurrenceRepetitionType implements Rule { /** * Get the validation error message. * * @return string */ public function message(): string { return (string)trans('validation.valid_recurrence_rep_type'); } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function passes($attribute, $value): bool { $value = (string)$value; if ('daily' === $value) { return true; } //monthly,17 //ndom,3,7 if (\in_array(substr($value, 0, 6), ['yearly', 'weekly'])) { return true; } if (0 === strpos($value, 'monthly')) { return true; } if (0 === strpos($value, 'ndom')) { return true; } return false; } }