Completed
Branch 2.x (03096d)
by Julián
08:36
created

HandlerTrait::setConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/*
4
 * sessionware (https://github.com/juliangut/sessionware).
5
 * PSR7 session management middleware.
6
 *
7
 * @license BSD-3-Clause
8
 * @link https://github.com/juliangut/sessionware
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace Jgut\Sessionware\Handler;
15
16
use Jgut\Sessionware\Configuration;
17
18
/**
19
 * Session handler utility trait.
20
 */
21
trait HandlerTrait
22
{
23
    /**
24
     * @var Configuration
25
     */
26
    protected $configuration;
27
28
    /**
29
     * Set configuration.
30
     *
31
     * @param Configuration $configuration
32
     *
33
     * @return static
34
     */
35
    public function setConfiguration(Configuration $configuration)
36
    {
37
        $this->configuration = $configuration;
38
39
        return $this;
40
    }
41
42
    /**
43
     * Checks if configuration is set.
44
     *
45
     * @throws \RuntimeException
46
     */
47
    protected function testConfiguration()
48
    {
49
        if ($this->configuration === null) {
50
            throw new \RuntimeException('Configuration must be set prior to use');
51
        }
52
    }
53
}
54