Presentable::present()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.2
cc 4
eloc 6
nc 3
nop 0
1
<?php
2
3
namespace Displore\Presenters;
4
5
trait Presentable
6
{
7
    /**
8
     * Hold the presenter instance.
9
     *
10
     * @var object
11
     */
12
    protected $presenterInstance;
13
14
    /**
15
     * Return a new or cached presenter instance.
16
     *
17
     * @throws \Exception
18
     *
19
     * @return object
20
     */
21
    public function present()
22
    {
23
        if ( ! $this->presenter or ! class_exists($this->presenter)) {
0 ignored issues
show
Bug introduced by
The property presenter does not seem to exist. Did you mean presenterInstance?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
24
            throw new \Exception('Please set the $presenter property in your model.');
25
        }
26
27
        if ( ! $this->presenterInstance) {
28
            $this->presenterInstance = new $this->presenter($this);
0 ignored issues
show
Bug introduced by
The property presenter does not seem to exist. Did you mean presenterInstance?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
29
        }
30
31
        return $this->presenterInstance;
32
    }
33
}
34