QueueableTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 52
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
queue() 0 1 ?
A setQueueId() 0 17 3
A queueId() 0 4 1
1
<?php
2
3
namespace Charcoal\Queue;
4
5
use InvalidArgumentException;
6
7
/**
8
 * Full implementation, as a Trait, of the `QueueableInterface`.
9
 */
10
trait QueueableTrait
11
{
12
    /**
13
     * The queue ID.
14
     *
15
     * @var mixed $queueId
16
     */
17
    private $queueId;
18
19
    /**
20
     * Set the queue's ID.
21
     *
22
     * @param string|null $id The unique queue identifier.
23
     * @throws InvalidArgumentException If the ID isn't a string.
24
     * @return self
25
     */
26
    public function setQueueId($id)
27
    {
28
        if ($id === null) {
29
            $this->queueId = null;
30
            return $this;
31
        }
32
33
        if (!is_string($id)) {
34
            throw new InvalidArgumentException(
35
                'Queue ID must be a string'
36
            );
37
        }
38
39
        $this->queueId = $id;
40
41
        return $this;
42
    }
43
44
    /**
45
     * Get the queue's ID.
46
     *
47
     * @return string|null $queueId
48
     */
49
    public function queueId()
50
    {
51
        return $this->queueId;
52
    }
53
54
    /**
55
     * Set the date/time to process the queue.
56
     *
57
     * @param mixed $ts A date/time to initiate the queue processing.
58
     * @return mixed
59
     */
60
    abstract public function queue($ts = null);
61
}
62