2017-04-13 13:47:59 -05:00
|
|
|
<?php
|
2021-01-29 11:50:35 -06:00
|
|
|
/*
|
|
|
|
* IsDuplicateTransaction.php
|
|
|
|
* Copyright (c) 2021 james@firefly-iii.org
|
|
|
|
*
|
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-12-21 22:35:06 -06:00
|
|
|
declare(strict_types=1);
|
2017-04-13 13:47:59 -05:00
|
|
|
|
2020-11-08 07:13:21 -06:00
|
|
|
namespace FireflyIII\Rules;
|
2021-09-18 03:26:12 -05:00
|
|
|
|
2023-10-29 11:41:14 -05:00
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
2017-04-13 13:47:59 -05:00
|
|
|
|
2017-12-17 07:30:53 -06:00
|
|
|
/**
|
2023-10-29 11:41:14 -05:00
|
|
|
* TODO not sure where this is used.
|
|
|
|
*
|
2020-11-08 07:13:21 -06:00
|
|
|
* Class IsDuplicateTransaction
|
2017-12-17 07:30:53 -06:00
|
|
|
*/
|
2023-10-29 11:41:14 -05:00
|
|
|
class IsDuplicateTransaction implements ValidationRule
|
2017-04-13 13:47:59 -05:00
|
|
|
{
|
2020-11-08 07:13:21 -06:00
|
|
|
private string $value;
|
|
|
|
|
2023-12-20 23:06:23 -06:00
|
|
|
/**
|
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
|
|
|
*/
|
2023-12-20 12:35:52 -06:00
|
|
|
public function validate(string $attribute, mixed $value, \Closure $fail): void
|
2020-11-08 07:13:21 -06:00
|
|
|
{
|
2021-03-21 03:15:40 -05:00
|
|
|
$this->value = $value;
|
|
|
|
|
2023-10-29 11:41:14 -05:00
|
|
|
$fail($this->value);
|
2020-11-08 07:13:21 -06:00
|
|
|
}
|
2020-12-21 22:35:06 -06:00
|
|
|
}
|