Various code cleanup.

This commit is contained in:
James Cole
2021-04-06 18:48:02 +02:00
parent fe06a1f7a0
commit cb746200fa
14 changed files with 38 additions and 33 deletions

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Rules;
use Carbon\Carbon;
use Carbon\Exceptions\InvalidDateException;
use Exception;
use Illuminate\Contracts\Validation\Rule;
use Log;
@@ -65,7 +64,7 @@ class IsDateOrTime implements Rule
// probably a date format.
try {
Carbon::createFromFormat('Y-m-d', $value);
} catch (InvalidDateException | Exception $e) {
} catch (InvalidDateException $e) {
Log::error(sprintf('"%s" is not a valid date: %s', $value, $e->getMessage()));
return false;
@@ -76,7 +75,7 @@ class IsDateOrTime implements Rule
// is an atom string, I hope?
try {
Carbon::parse($value);
} catch (InvalidDateException | Exception $e) {
} catch (InvalidDateException $e) {
Log::error(sprintf('"%s" is not a valid date or time: %s', $value, $e->getMessage()));
return false;

View File

@@ -110,7 +110,7 @@ class IsValidAttachmentModel implements Rule
Transaction::class => 'validateTransaction',
TransactionJournal::class => 'validateJournal',
];
if (!isset($methods[$this->model])) {
if (!array_key_exists($this->model, $methods)) {
Log::error(sprintf('Cannot validate model "%s" in %s.', $this->model, __METHOD__));
return false;