HasApp   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setApp() 0 6 1
A getApp() 0 8 2
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