PushSubscription   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 34
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A findByEndpoint() 0 4 1
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
    /**
22
     * Get the user that owns the subscription.
23
     *
24
     * @return \Illuminate\Contracts\Auth\Authenticatable
25
     */
26
    public function user()
27
    {
28
        return $this->belongsTo(Config::get('auth.providers.users.model'));
29
    }
30
31
    /**
32
     * Find a subscription by the given endpint.
33
     *
34
     * @param  string $endpoint
35
     * @return static|null
36
     */
37
    public static function findByEndpoint($endpoint)
38
    {
39
        return static::where('endpoint', $endpoint)->first();
40
    }
41
}
42