Completed
Push — develop ( 38e5c7...79ed02 )
by Enea
09:42
created

Grantable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 3 1
A getFillable() 0 6 1
A serializeDate() 0 3 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 83
{
16
    public function __construct(array $attributes = [])
17 83
    {
18 83
        $this->setTable($this->getConfigTableName());
19 83
        parent::__construct($attributes);
20
    }
21
22
    abstract protected function getConfigTableName(): string;
23 83
24
    public function getFillable()
25
    {
26 83
        return [
27
            'secret_name',
28
            'display_name',
29
            'description'
30
        ];
31
    }
32 9
33
    protected function serializeDate(\DateTimeInterface $date): string
34 9
    {
35
        return Carbon::instance($date)->toDateTimeString();
36
    }
37
38
    public function __toString()
39
    {
40
        return $this->getAttribute('secret_name');
41
    }
42
}
43