HasApp::getApp()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
/**
4
 * @author Jared King <[email protected]>
5
 *
6
 * @link http://jaredtking.com
7
 *
8
 * @copyright 2015 Jared King
9
 * @license MIT
10
 */
11
12
namespace Infuse;
13
14
trait HasApp
15
{
16
    /**
17
     * @var Application
18
     */
19
    protected $app;
20
21
    /**
22
     * Sets the application instance.
23
     *
24
     * @param Application $app container
25
     *
26
     * @return self
27
     */
28
    public function setApp(Application $app)
29
    {
30
        $this->app = $app;
31
32
        return $this;
33
    }
34
35
    /**
36
     * Gets the application instance.
37
     *
38
     * @return Application
39
     */
40
    public function getApp()
41
    {
42
        if (!$this->app) {
43
            return Application::getDefault();
44
        }
45
46
        return $this->app;
47
    }
48
}
49