Completed
Push — master ( eddec1...1fdb05 )
by Nicolas
03:17
created

Block   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 2
c 4
b 0
f 1
lcom 0
cbo 3
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 0 15 2
1
<?php namespace Modules\Block\Entities;
2
3
use Dimsav\Translatable\Translatable;
4
use Illuminate\Database\Eloquent\Model;
5
use Laracasts\Presenter\PresentableTrait;
6
7
class Block extends Model
8
{
9
    use Translatable, PresentableTrait;
10
11
    protected $presenter = 'Modules\Block\Presenters\BlockPresenter';
12
    protected $table = 'block__blocks';
13
    public $translatedAttributes = ['online', 'body'];
14
    protected $fillable = ['name', 'online', 'body'];
15
    protected $casts = [
16
        'online' => 'bool',
17
    ];
18
19
    public function __call($method, $parameters)
20
    {
21
        #i: Convert array to dot notation
22
        $config = implode('.', ['asgard.block.config.relations', $method]);
23
24
        #i: Relation method resolver
25
        if (config()->has($config)) {
26
            $function = config()->get($config);
27
28
            return $function($this);
29
        }
30
31
        #i: No relation found, return the call to parent (Eloquent) to handle it.
32
        return parent::__call($method, $parameters);
33
    }
34
}
35