33namespace Enqueue \Gearman ;
44
55use Interop \Queue \InvalidDestinationException ;
6+ use Interop \Queue \PsrConsumer ;
67use Interop \Queue \PsrContext ;
78use Interop \Queue \PsrDestination ;
9+ use Interop \Queue \PsrMessage ;
10+ use Interop \Queue \PsrProducer ;
11+ use Interop \Queue \PsrQueue ;
12+ use Interop \Queue \PsrSubscriptionConsumer ;
13+ use Interop \Queue \PsrTopic ;
14+ use Interop \Queue \PurgeQueueNotSupportedException ;
15+ use Interop \Queue \SubscriptionConsumerNotSupportedException ;
16+ use Interop \Queue \TemporaryQueueNotSupportedException ;
817
918class GearmanContext implements PsrContext
1019{
@@ -23,68 +32,54 @@ class GearmanContext implements PsrContext
2332 */
2433 private $ config ;
2534
26- /**
27- * @param array $config
28- */
2935 public function __construct (array $ config )
3036 {
3137 $ this ->config = $ config ;
3238 }
3339
3440 /**
35- * {@inheritdoc}
36- *
3741 * @return GearmanMessage
3842 */
39- public function createMessage ($ body = '' , array $ properties = [], array $ headers = [])
43+ public function createMessage (string $ body = '' , array $ properties = [], array $ headers = []): PsrMessage
4044 {
4145 return new GearmanMessage ($ body , $ properties , $ headers );
4246 }
4347
4448 /**
45- * {@inheritdoc}
46- *
4749 * @return GearmanDestination
4850 */
49- public function createTopic ($ topicName )
51+ public function createTopic (string $ topicName ): PsrTopic
5052 {
5153 return new GearmanDestination ($ topicName );
5254 }
5355
5456 /**
55- * {@inheritdoc}
57+ * @return GearmanDestination
5658 */
57- public function createQueue ($ queueName )
59+ public function createQueue (string $ queueName ): PsrQueue
5860 {
5961 return new GearmanDestination ($ queueName );
6062 }
6163
62- /**
63- * {@inheritdoc}
64- */
65- public function createTemporaryQueue ()
64+ public function createTemporaryQueue (): PsrQueue
6665 {
67- throw new \ LogicException ( ' Not implemented ' );
66+ throw TemporaryQueueNotSupportedException :: providerDoestNotSupportIt ( );
6867 }
6968
7069 /**
71- * {@inheritdoc}
72- *
7370 * @return GearmanProducer
7471 */
75- public function createProducer ()
72+ public function createProducer (): PsrProducer
7673 {
7774 return new GearmanProducer ($ this ->getClient ());
7875 }
7976
8077 /**
81- * {@inheritdoc}
82- *
8378 * @param GearmanDestination $destination
8479 *
8580 * @return GearmanConsumer
8681 */
87- public function createConsumer (PsrDestination $ destination )
82+ public function createConsumer (PsrDestination $ destination ): PsrConsumer
8883 {
8984 InvalidDestinationException ::assertDestinationInstanceOf ($ destination , GearmanDestination::class);
9085
@@ -93,7 +88,7 @@ public function createConsumer(PsrDestination $destination)
9388 return $ consumer ;
9489 }
9590
96- public function close ()
91+ public function close (): void
9792 {
9893 $ this ->getClient ()->clearCallbacks ();
9994
@@ -102,10 +97,17 @@ public function close()
10297 }
10398 }
10499
105- /**
106- * @return \GearmanClient
107- */
108- public function getClient ()
100+ public function createSubscriptionConsumer (): PsrSubscriptionConsumer
101+ {
102+ throw SubscriptionConsumerNotSupportedException ::providerDoestNotSupportIt ();
103+ }
104+
105+ public function purgeQueue (PsrQueue $ queue ): void
106+ {
107+ throw PurgeQueueNotSupportedException ::providerDoestNotSupportIt ();
108+ }
109+
110+ public function getClient (): \GearmanClient
109111 {
110112 if (false == $ this ->client ) {
111113 $ this ->client = new \GearmanClient ();
@@ -115,10 +117,7 @@ public function getClient()
115117 return $ this ->client ;
116118 }
117119
118- /**
119- * @return \GearmanWorker
120- */
121- public function createWorker ()
120+ public function createWorker (): \GearmanWorker
122121 {
123122 $ worker = new \GearmanWorker ();
124123 $ worker ->addServer ($ this ->config ['host ' ], $ this ->config ['port ' ]);
0 commit comments