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 ( 37b02e...ebbbe1 )
by James
08:59
created

app/TransactionRules/Triggers/TransactionType.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * TransactionType.php
4
 * Copyright (c) 2017 [email protected]
5
 *
6
 * This file is part of Firefly III.
7
 *
8
 * Firefly III is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * Firefly III 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 General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
declare(strict_types=1);
22
23
namespace FireflyIII\TransactionRules\Triggers;
24
25
use FireflyIII\Models\TransactionJournal;
26
use Log;
27
28
/**
29
 * Class TransactionType.
30
 */
31
final class TransactionType extends AbstractTrigger implements TriggerInterface
32
{
33
    /**
34
     * A trigger is said to "match anything", or match any given transaction,
35
     * when the trigger value is very vague or has no restrictions. Easy examples
36
     * are the "AmountMore"-trigger combined with an amount of 0: any given transaction
37
     * has an amount of more than zero! Other examples are all the "Description"-triggers
38
     * which have hard time handling empty trigger values such as "" or "*" (wild cards).
39
     *
40
     * If the user tries to create such a trigger, this method MUST return true so Firefly III
41
     * can stop the storing / updating the trigger. If the trigger is in any way restrictive
42
     * (even if it will still include 99.9% of the users transactions), this method MUST return
43
     * false.
44
     *
45
     * @param null $value
46
     *
47
     * @return bool
48
     */
49
    public static function willMatchEverything($value = null)
50
    {
51
        if (null !== $value) {
52
            return false;
53
        }
54
        Log::error(sprintf('Cannot use %s with a null value.', self::class));
55
56
        return true;
57
    }
58
59
    /**
60
     * Return true when transaction type is X
61
     *
62
     * @param TransactionJournal $journal
63
     *
64
     * @return bool
65
     */
66
    public function triggered(TransactionJournal $journal): bool
67
    {
68
        $type   = null !== $journal->transaction_type_type ? $journal->transaction_type_type : strtolower($journal->transactionType->type);
0 ignored issues
show
The property type does not seem to exist on FireflyIII\Models\TransactionType. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
69
        $search = strtolower($this->triggerValue);
70
71
        if ($type === $search) {
72
            Log::debug(sprintf('RuleTrigger TransactionType for journal #%d: "%s" is "%s". Return true', $journal->id, $type, $search));
73
74
            return true;
75
        }
76
77
        Log::debug(sprintf('RuleTrigger TransactionType for journal #%d: "%s" is NOT "%s". Return false', $journal->id, $type, $search));
78
79
        return false;
80
    }
81
}
82