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 ( ebbbe1...4650a2 )
by James
08:48
created

Rule::setDescriptionAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Rule.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\Models;
24
25
use Illuminate\Database\Eloquent\Model;
26
use Illuminate\Database\Eloquent\SoftDeletes;
27
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
28
29
/**
30
 * Class Rule.
31
 */
32
class Rule extends Model
33
{
34
    use SoftDeletes;
35
36
    /**
37
     * The attributes that should be casted to native types.
38
     *
39
     * @var array
40
     */
41
    protected $casts
42
        = [
43
            'created_at'      => 'datetime',
44
            'updated_at'      => 'datetime',
45
            'deleted_at'      => 'datetime',
46
            'active'          => 'boolean',
47
            'order'           => 'int',
48
            'stop_processing' => 'boolean',
49
        ];
50
51
    /**
52
     * @param string $value
53
     *
54
     * @return Rule
55
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
56
     */
57
    public static function routeBinder(string $value): Rule
58
    {
59
        if (auth()->check()) {
60
            $ruleId = (int)$value;
61
            $rule   = auth()->user()->rules()->find($ruleId);
62
            if (null !== $rule) {
63
                return $rule;
64
            }
65
        }
66
        throw new NotFoundHttpException;
67
    }
68
69
    /**
70
     * @codeCoverageIgnore
71
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
72
     */
73
    public function ruleActions()
74
    {
75
        return $this->hasMany('FireflyIII\Models\RuleAction');
76
    }
77
78
    /**
79
     * @codeCoverageIgnore
80
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
81
     */
82
    public function ruleGroup()
83
    {
84
        return $this->belongsTo('FireflyIII\Models\RuleGroup');
85
    }
86
87
    /**
88
     * @codeCoverageIgnore
89
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
90
     */
91
    public function ruleTriggers()
92
    {
93
        return $this->hasMany('FireflyIII\Models\RuleTrigger');
94
    }
95
96
    /**
97
     * @param $value
98
     */
99
    public function setDescriptionAttribute($value)
100
    {
101
        $this->attributes['description'] = e($value);
102
    }
103
104
    /**
105
     * @codeCoverageIgnore
106
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
107
     */
108
    public function user()
109
    {
110
        return $this->belongsTo('FireflyIII\User');
111
    }
112
}
113