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