Presentable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 24
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A present() 0 12 4
1
<?php
2
3
namespace Laracodes\Presenter\Traits;
4
5
use Laracodes\Presenter\Exceptions\PresenterException;
6
7
trait Presentable
8
{
9
    /**
10
     * @var \Laracodes\Presenter\Presenter
11
     */
12
    protected $presenterInstance;
13
14
    /**
15
     * @return mixed
16
     * @throws PresenterException
17
     */
18
    public function present()
19
    {
20
        if (is_object($this->presenterInstance)) {
21
            return $this->presenterInstance;
22
        }
23
24
        if (property_exists($this, 'presenter') && class_exists($this->presenter)) {
25
            return $this->presenterInstance = new $this->presenter($this);
26
        }
27
28
        throw new PresenterException('Property $presenter was not set correctly in ' . get_class($this));
29
    }
30
}
31