HandlerAwareTrait::getHandler()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
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 SessionHandlerInterface;
18
use Phossa2\Session\Handler\FileHandler;
19
use Phossa2\Session\Interfaces\HandlerAwareInterface;
20
21
/**
22
 * HandlerAwareTrait
23
 *
24
 * Implemetation of HandlerAwareInterface
25
 *
26
 * @package Phossa2\Session
27
 * @author  Hong Zhang <[email protected]>
28
 * @see     HandlerAwareInterface
29
 * @version 2.1.0
30
 * @since   2.1.0 added
31
 */
32
trait HandlerAwareTrait
33
{
34
    /**
35
     * @var    SessionHandlerInterface
36
     * @access protected
37
     */
38
    protected $handler;
39
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public function setHandler(SessionHandlerInterface $handler = null)
44
    {
45
        $this->handler = $handler;
46
        return $this;
47
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52
    public function getHandler()/*# : SessionHandlerInterface */
53
    {
54
        if (null === $this->handler) {
55
            $this->handler = new FileHandler();
56
        }
57
        return $this->handler;
58
    }
59
}
60