GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 7cfa91...64a2f2 )
by James
31:27 queued 21:57
created

IsTransferAccount::passes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 19
rs 9.9
cc 2
nc 2
nop 2
1
<?php
2
/**
3
 * IsTransferAccount.php
4
 * Copyright (c) 2019 [email protected]
5
 *
6
 * This file is part of Firefly III (https://github.com/firefly-iii).
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
namespace FireflyIII\Rules;
23
24
25
use FireflyIII\Models\TransactionType;
26
use FireflyIII\Validation\AccountValidator;
27
use Illuminate\Contracts\Validation\Rule;
28
use Log;
29
30
/**
31
 * Class IsTransferAccount
32
 */
33
class IsTransferAccount implements Rule
34
{
35
    /**
36
     * Get the validation error message.
37
     *
38
     * @return string|array
39
     */
40
    public function message(): string
41
    {
42
        return (string)trans('validation.not_transfer_account');
43
    }
44
45
    /**
46
     * Determine if the validation rule passes.
47
     *
48
     * @param string $attribute
49
     * @param mixed  $value
50
     *
51
     * @return bool
52
     */
53
    public function passes($attribute, $value): bool
54
    {
55
        Log::debug(sprintf('Now in %s(%s)', __METHOD__, $value));
56
        /** @var AccountValidator $validator */
57
        $validator = app(AccountValidator::class);
58
        $validator->setTransactionType(TransactionType::TRANSFER);
59
        $validator->setUser(auth()->user());
60
61
        $validAccount = $validator->validateSource(null, (string)$value);
62
        if (true === $validAccount) {
63
            Log::debug('Found account based on name. Return true.');
64
65
            // found by name, use repos to return.
66
            return true;
67
        }
68
        $validAccount = $validator->validateSource((int)$value, null);
69
        Log::debug(sprintf('Search by id (%d), result is %s.', (int)$value, var_export($validAccount, true)));
70
71
        return !(false === $validAccount);
72
    }
73
}