Skip to content

Commit

Permalink
Merge pull request #94 from iRaziul/master
Browse files Browse the repository at this point in the history
Update CurrencyRule.php
  • Loading branch information
denisdulici committed Mar 19, 2024
2 parents 03519bc + db84244 commit 444216a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Rules/CurrencyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
namespace Akaunting\Money\Rules;

use Akaunting\Money\Currency;
use Illuminate\Contracts\Validation\Rule;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;

class CurrencyRule implements Rule
class CurrencyRule implements ValidationRule

Check failure on line 9 in src/Rules/CurrencyRule.php

View workflow job for this annotation

GitHub Actions / psalm

UndefinedClass

src/Rules/CurrencyRule.php:9:31: UndefinedClass: Class, interface or enum named Illuminate\Contracts\Validation\ValidationRule does not exist (see https://psalm.dev/019)
{
public function passes($attribute, $value): bool
public function validate(string $attribute, mixed $value, Closure $fail): void
{
return is_string($value) && key_exists(strtoupper($value), Currency::getCurrencies());
if (! $this->passes($value)) {
$fail('money.invalid-currency')->translate();
}
}

public function message()
protected function passes($value): bool
{
/** @var string */
return trans('money.invalid-currency');
return is_string($value) && array_key_exists(strtoupper($value), Currency::getCurrencies());
}
}

0 comments on commit 444216a

Please sign in to comment.