Completed
Push — master ( a2b906...d5b295 )
by Peter
03:27
created

Queue::__construct()   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 2
1
<?php
2
3
namespace PeterColes\Cluster\Queues;
4
5
use PeterColes\Cluster\Contracts\Factory;
6
use PeterColes\Cluster\Contracts\QueueAdapterInterface;
7
use PeterColes\Cluster\Contracts\HttpClientInterface;
8
9
class Queue extends Factory
10
{
11
    /**
12
     * Constructor - receive server adapter, adapter api authentication and http client details.
13
     * Initialise the http client and make it available for use by the server adapter.
14
     *
15
     * @param QueueAdapterInterface $adapter
16
     * @param HttpClientInterface $client
17
     */
18
    public function __construct(QueueAdapterInterface $adapter, HttpClientInterface $client = null)
19
    {
20
        $this->init($adapter, $client);
21
    }
22
23
    /**
24
     * Receives the name of a queue and returns the number of jobs in that queue.
25
     *
26
     * @param string $queue
27
     * @return integer
28
     */
29
    public function count($queue)
30
    {
31
        return $this->adapter->count($queue);
32
    }
33
34
    /**
35
     * Empty a named queue.
36
     *
37
     * @param string $queue
38
     * @return void
39
     */
40
    public function clear($queue)
41
    {
42
        $this->adapter->clear($queue);
43
    }
44
}
45