TypeSafeQueue::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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;
13
14
class TypeSafeQueue implements Queue
15
{
16
    /**
17
     * @var Queue
18
     */
19
    private $queue;
20
21 11
    public function __construct(Queue $queue)
22
    {
23 11
        $this->queue = $queue;
24 11
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 8
    public function push($item, $eta = null)
30
    {
31 8
        $item = base64_encode(serialize($item));
32
33 8
        $this->queue->push($item, $eta);
34 8
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    public function pop()
40
    {
41 1
        $item = $this->queue->pop();
42
43 1
        return unserialize(base64_decode($item));
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function count()
50
    {
51 1
        return $this->queue->count();
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    public function clear()
58
    {
59 1
        $this->queue->clear();
60 1
    }
61
}
62