Completed
Push — master ( 44a965...c00981 )
by Nassif
02:43
created

Presentable::present()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 9.7333
c 0
b 0
f 0
cc 4
nc 4
nop 0
crap 4
1
<?php
2
3
namespace Tequilarapido\Presenter;
4
5
trait Presentable
6
{
7
    /**
8
     * View presenter instance.
9
     *
10
     * @var mixed
11
     */
12
    protected $presenterInstance;
13
14
    /**
15
     * Prepare a new or cached presenter instance.
16
     *
17
     * @return mixed
18
     * @throws PresenterException
19
     */
20 4
    public function present()
21
    {
22 4
        if (! $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...
23 1
            throw new PresenterException('Please set the $presenter property to your presenter fully qualified class name.');
24
        }
25
26 3
        if (! 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...
27 1
            throw new PresenterException('The presenter class ['.$this->presenter.'] does not exist.');
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...
28
        }
29
30 2
        if (! $this->presenterInstance) {
31 2
            $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...
32
        }
33
34 2
        return $this->presenterInstance;
35
    }
36
}
37