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

Grantable::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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