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.
Completed
Pull Request — master (#85)
by Seb
03:12
created

PushSubscription::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace NotificationChannels\WebPush;
4
5
use Illuminate\Support\Facades\Config;
6
use Illuminate\Database\Eloquent\Model;
7
8
class PushSubscription extends Model
9
{
10
    /**
11
     * The attributes that are mass assignable.
12
     *
13
     * @var array
14
     */
15
    protected $fillable = [
16
        'endpoint',
17
        'public_key',
18
        'auth_token',
19
    ];
20
21 13
    public function __construct(array $attributes = [])
22
    {
23 13
        if (!isset($this->table)) {
24 13
            $this->setTable(config('webpush.db_table'));
25
        }
26
27 13
        parent::__construct($attributes);
28 13
    }
29
30
    /**
31
     * Get the connection name for the push subscriptions.
32
     *
33
     * @return string
34
     */
35 13
    public function getConnectionName()
36
    {
37 13
        $connName = config('webpush.db_connection');
38 13
        return $connName ?: config('database.default');
39
    }
40
41
    /**
42
     * Get the user that owns the subscription.
43
     *
44
     * @return \Illuminate\Contracts\Auth\Authenticatable
45
     */
46 1
    public function user()
47
    {
48 1
        return $this->belongsTo(Config::get('auth.providers.users.model'));
49
    }
50
51
    /**
52
     * Find a subscription by the given endpint.
53
     *
54
     * @param  string $endpoint
55
     * @return static|null
56
     */
57 8
    public static function findByEndpoint($endpoint)
58
    {
59 8
        return static::where('endpoint', $endpoint)->first();
60
    }
61
}
62