Grantable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 2
b 0
f 0
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A getFillable() 0 6 1
A serializeDate() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Created on 11/02/18 by enea dhack.
7
 */
8
9
namespace Enea\Authorization\Models;
10
11
use Carbon\Carbon;
12
use Illuminate\Database\Eloquent\Model;
13
14
abstract class Grantable extends Model
15
{
16 83
    public function __construct(array $attributes = [])
17
    {
18 83
        $this->setTable($this->getConfigTableName());
19 83
        parent::__construct($attributes);
20 83
    }
21
22
    abstract protected function getConfigTableName(): string;
23
24 83
    public function getFillable()
25
    {
26
        return [
27 83
            'secret_name',
28
            'display_name',
29
            'description'
30
        ];
31
    }
32
33 9
    public function __toString()
34
    {
35 9
        return $this->getAttribute('secret_name');
36
    }
37
38 2
    protected function serializeDate(\DateTimeInterface $date): string
39
    {
40 2
        return Carbon::instance($date)->toDateTimeString();
41
    }
42
}
43