-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathStubAdapter.php
More file actions
56 lines (45 loc) · 1.25 KB
/
Copy pathStubAdapter.php
File metadata and controls
56 lines (45 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace Yiisoft\Queue\Stubs;
use BackedEnum;
use Yiisoft\Queue\Adapter\AdapterInterface;
use Yiisoft\Queue\ChannelNormalizer;
use Yiisoft\Queue\JobStatus;
use Yiisoft\Queue\Message\MessageInterface;
use Yiisoft\Queue\Provider\QueueProviderInterface;
/**
* Stub adapter that does nothing. Job status is always "done".
*/
final class StubAdapter implements AdapterInterface
{
private string $channel;
public function __construct(
string|BackedEnum $channel = QueueProviderInterface::DEFAULT_CHANNEL
) {
$this->channel = ChannelNormalizer::normalize($channel);
}
public function runExisting(callable $handlerCallback): void
{
}
public function status(int|string $id): JobStatus
{
return JobStatus::DONE;
}
public function push(MessageInterface $message): MessageInterface
{
return $message;
}
public function subscribe(callable $handlerCallback): void
{
}
public function withChannel(string|BackedEnum $channel): AdapterInterface
{
$new = clone $this;
$new->channel = ChannelNormalizer::normalize($channel);
return $new;
}
public function getChannel(): string
{
return $this->channel;
}
}