Persistence::createHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Phive Queue package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phive\Queue\Tests\Queue;
13
14
trait Persistence
15
{
16
    /**
17
     * @var \Phive\Queue\Tests\Handler\Handler
18
     */
19
    private static $handler;
20
21
    protected function setUp()
22
    {
23
        parent::setUp();
24
25
        self::getHandler()->clear();
26
    }
27
28
    /**
29
     * @return \Phive\Queue\Queue
30
     */
31
    public function createQueue()
32
    {
33
        return self::getHandler()->createQueue();
34
    }
35
36
    /**
37
     * Abstract static class functions are not supported since v5.2.
38
     *
39
     * @param array $config
40
     *
41
     * @return \Phive\Queue\Tests\Handler\Handler
42
     *
43
     * @throws \BadMethodCallException
44
     */
45
    public static function createHandler(array $config)
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
    {
47
        throw new \BadMethodCallException(
48
            sprintf('Method %s:%s is not implemented.', get_called_class(), __FUNCTION__)
49
        );
50
    }
51
52
    public static function getHandler()
53
    {
54
        if (!self::$handler) {
55
            self::$handler = static::createHandler($_ENV);
56
        }
57
58
        return self::$handler;
59
    }
60
61
    public static function setUpBeforeClass()
62
    {
63
        parent::setUpBeforeClass();
64
65
        self::getHandler()->reset();
66
    }
67
68
    public static function tearDownAfterClass()
69
    {
70
        parent::tearDownAfterClass();
71
72
        self::$handler = null;
73
    }
74
}
75