Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractQueue
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
6 / 6
6
100.00% covered (success)
100.00%
1 / 1
 setName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAdapter
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAdapter
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 adapter
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 work
n/a
0 / 0
n/a
0 / 0
0
 run
n/a
0 / 0
n/a
0 / 0
0
 clear
n/a
0 / 0
n/a
0 / 0
0
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@nolainteractive.com>
7 * @copyright  Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Queue;
15
16use Pop\Application;
17use Pop\Queue\Adapter\AdapterInterface;
18use Pop\Queue\Adapter\TaskAdapterInterface;
19use Pop\Queue\Process\AbstractJob;
20
21/**
22 * Abstract queue class
23 *
24 * @category   Pop
25 * @package    Pop\Queue
26 * @author     Nick Sagona, III <dev@nolainteractive.com>
27 * @copyright  Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
28 * @license    http://www.popphp.org/license     New BSD License
29 * @version    2.0.0
30 */
31abstract class AbstractQueue implements QueueInterface
32{
33
34    /**
35     * Queue name
36     * @var string
37     */
38    protected string $name;
39
40    /**
41     * Queue adapter
42     * @var AdapterInterface|TaskAdapterInterface
43     */
44    protected AdapterInterface|TaskAdapterInterface $adapter;
45
46    /**
47     * Set name
48     *
49     * @param  string $name
50     * @return AbstractQueue
51     */
52    public function setName(string $name): AbstractQueue
53    {
54        $this->name = $name;
55        return $this;
56    }
57
58    /**
59     * Get name
60     *
61     * @return string
62     */
63    public function getName(): string
64    {
65        return $this->name;
66    }
67
68    /**
69     * Has name
70     *
71     * @return bool
72     */
73    public function hasName(): bool
74    {
75        return $this->name;
76    }
77
78    /**
79     * Set adapter
80     *
81     * @param  AdapterInterface|TaskAdapterInterface $adapter
82     * @return Queue
83     */
84    public function setAdapter(AdapterInterface|TaskAdapterInterface $adapter): Queue
85    {
86        $this->adapter = $adapter;
87        return $this;
88    }
89
90    /**
91     * Get adapter
92     *
93     * @return AdapterInterface|TaskAdapterInterface
94     */
95    public function getAdapter(): AdapterInterface|TaskAdapterInterface
96    {
97        return $this->adapter;
98    }
99
100    /**
101     * Get adapter (alias)
102     *
103     * @return AdapterInterface|TaskAdapterInterface
104     */
105    public function adapter(): AdapterInterface|TaskAdapterInterface
106    {
107        return $this->adapter;
108    }
109
110    /**
111     * Work next job
112     *
113     * @param  ?Application $application
114     * @return ?AbstractJob
115     */
116    abstract public function work(?Application $application = null): ?AbstractJob;
117
118    /**
119     * Run schedule
120     *
121     * @param  ?Application $application
122     * @throws Exception|Process\Exception
123     * @return array
124     */
125    abstract public function run(?Application $application = null): array;
126
127    /**
128     * Clear queue
129     *
130     * @return AbstractQueue
131     */
132    abstract public function clear(): AbstractQueue;
133
134}