1+ <?php
2+ namespace Makasim \PhpFpm ;
3+ 4+ use hollodotme \FastCGI \Client ;
5+ use Interop \Queue \ConnectionFactory ;
6+ use Interop \Queue \Consumer ;
7+ use Interop \Queue \Context ;
8+ use Interop \Queue \Destination ;
9+ use Interop \Queue \Exception \PurgeQueueNotSupportedException ;
10+ use Interop \Queue \Exception \SubscriptionConsumerNotSupportedException ;
11+ use Interop \Queue \Exception \TemporaryQueueNotSupportedException ;
12+ use Interop \Queue \Message ;
13+ use Interop \Queue \Producer ;
14+ use Interop \Queue \Queue ;
15+ use Interop \Queue \SubscriptionConsumer ;
16+ use Interop \Queue \Topic ;
17+ 18+ class PhpFpmContext implements Context
19+ {
20+ /**
21+ * @var Client
22+ */
23+ private $ cgiClient ;
24+ 25+ public function __construct (Client $ cgiClient )
26+ {
27+ $ this ->cgiClient = $ cgiClient ;
28+ }
29+ 30+ public function createMessage (string $ body = '' , array $ properties = [], array $ headers = []): Message
31+ {
32+ return new PhpFpmMessage ($ body , $ properties , $ headers );
33+ }
34+ 35+ public function createTopic (string $ topicName ): Topic
36+ {
37+ return new PhpFpmDestination ($ topicName );
38+ }
39+ 40+ public function createQueue (string $ queueName ): Queue
41+ {
42+ return new PhpFpmDestination ($ queueName );
43+ }
44+ 45+ public function createProducer (): Producer
46+ {
47+ return new PhpFpmProducer ($ this ->cgiClient );
48+ }
49+ 50+ public function createConsumer (Destination $ destination ): Consumer
51+ {
52+ return new PhpFpmConsumer ($ destination );
53+ }
54+ 55+ public function close (): void
56+ {
57+ }
58+ 59+ public function createTemporaryQueue (): Queue
60+ {
61+ throw TemporaryQueueNotSupportedException::providerDoestNotSupportIt ();
62+ }
63+ 64+ public function createSubscriptionConsumer (): SubscriptionConsumer
65+ {
66+ throw SubscriptionConsumerNotSupportedException::providerDoestNotSupportIt ();
67+ }
68+ 69+ public function purgeQueue (Queue $ queue ): void
70+ {
71+ throw PurgeQueueNotSupportedException::providerDoestNotSupportIt ();
72+ }
73+ }
0 commit comments