Invoice   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 11
c 0
b 0
f 0
dl 0
loc 43
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A owner() 0 7 2
A user() 0 3 1
1
<?php
2
/**
3
 * This file implements Invoice.
4
 *
5
 * @author    Bilal Gultekin <[email protected]>
6
 * @author    Justin Hartman <[email protected]>
7
 * @copyright 2019 22 Digital
8
 * @license   MIT
9
 * @since     v0.1
10
 */
11
12
namespace TwentyTwoDigital\CashierFastspring;
13
14
use Illuminate\Database\Eloquent\Model;
15
16
/**
17
 * This class describes an invoice.
18
 *
19
 * {@inheritdoc}
20
 */
21
class Invoice extends Model
22
{
23
    /**
24
     * The attributes that are not mass assignable.
25
     *
26
     * @var array
27
     */
28
    protected $guarded = [];
29
30
    /**
31
     * The attributes that should be mutated to dates.
32
     *
33
     * @var array
34
     */
35
    protected $dates = [
36
        'created_at',
37
        'updated_at',
38
        'subscription_period_start_date',
39
        'subscription_period_end_date',
40
    ];
41
42
    /**
43
     * Get the user that owns the invoice.
44
     *
45
     * @return self
46
     */
47 1
    public function user()
48
    {
49 1
        return $this->owner();
50
    }
51
52
    /**
53
     * Get the model related to the invoice.
54
     *
55
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
56
     */
57 1
    public function owner()
58
    {
59 1
        $model = getenv('FASTSPRING_MODEL') ?: config('services.fastspring.model', 'App\\User');
60
61 1
        $model = new $model();
62
63 1
        return $this->belongsTo(get_class($model), $model->getForeignKey());
64
    }
65
}
66