SessionAwareTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setSession() 0 5 1
A getSession() 0 8 2
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Session
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Session\Traits;
16
17
use Phossa2\Session\Interfaces\SessionInterface;
18
use Phossa2\Session\Interfaces\SessionAwareInterface;
19
20
/**
21
 * SessionAwareTrait
22
 *
23
 * @package Phossa2\Session
24
 * @author  Hong Zhang <[email protected]>
25
 * @see     SessionAwareInterface
26
 * @version 2.1.0
27
 * @since   2.1.0 added
28
 */
29
trait SessionAwareTrait
30
{
31
    use DefaultSessionAwareTrait;
32
33
    /**
34
     * @var    SessionInterface
35
     * @access protected
36
     */
37
    protected $session;
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public function setSession(SessionInterface $session = null)
43
    {
44
        $this->session = $session;
45
        return $this;
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     */
51
    public function getSession()/*# : SessionInterface */
52
    {
53
        if (null === $this->session) {
54
            return static::getDefaultSession();
55
        } else {
56
            return $this->session;
57
        }
58
    }
59
}
60