GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#302)
by Nikolay
02:13
created

SyncFactory::count()   A

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
namespace Bernard\QueueFactory;
4
5
use Bernard\Queue\SyncQueue;
6
use Bernard\QueueFactory;
7
use Bernard\Router;
8
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9
10
/**
11
 * Knows how to create queues and retrieve them from the used driver.
12
 * Every queue it creates is saved locally.
13
 *
14
 * @package Bernard
15
 */
16
class SyncFactory implements QueueFactory
17
{
18
    /**
19
     * @var array
20
     */
21
    protected $queues;
22
23
    /**
24
     * @var EventDispatcherInterface
25
     */
26
    protected $dispatcher;
27
28
    /**
29
     * @var Router
30
     */
31
    protected $router;
32
33
    /**
34
     * SyncFactory constructor.
35
     * @param EventDispatcherInterface $dispatcher
36
     * @param Router $router
37
     */
38
    public function __construct(EventDispatcherInterface $dispatcher, Router $router)
39
    {
40
        $this->queues = [];
41
        $this->dispatcher = $dispatcher;
42
        $this->router = $router;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function create($queueName)
49
    {
50
        if (!$this->exists($queueName)) {
51
            $this->queues[$queueName] = new SyncQueue($queueName, $this->dispatcher, $this->router);
52
        }
53
54
        return $this->queues[$queueName];
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function all()
61
    {
62
        return $this->queues;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function count()
69
    {
70
        return count($this->queues);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function exists($queueName)
77
    {
78
        return isset($this->queues[$queueName]);
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function remove($queueName)
85
    {
86
        if ($this->exists($queueName)) {
87
            $this->queues[$queueName]->close();
88
89
            unset($this->queues[$queueName]);
90
        }
91
    }
92
}
93