DriverAwareTrait::getDriver()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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