Presenter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 43
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAttribute() 0 4 1
A __get() 0 8 2
1
<?php
2
3
namespace Tequilarapido\Presenter;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
abstract class Presenter
8
{
9
    /**
10
     * Model.
11
     *
12
     * @var Model
13
     */
14
    protected $model;
15
16
    /**
17
     * @param $model
18
     */
19 2
    public function __construct($model)
20
    {
21 2
        $this->model = $model;
22 2
    }
23
24
    /**
25
     * Get model attribute.
26
     *
27
     * @param $key
28
     * @return mixed
29
     */
30 1
    public function getAttribute($key)
31
    {
32 1
        return $this->model->getAttribute($key);
33
    }
34
35
    /**
36
     * Allow for property-style retrieval.
37
     *
38
     * @param $property
39
     * @return mixed
40
     */
41 1
    public function __get($property)
42
    {
43 1
        if (method_exists($this, $property)) {
44 1
            return $this->{$property}();
45
        }
46
47 1
        return $this->model->{$property};
48
    }
49
}
50