Skip to content

Commit 170eed1

Browse files
committed
[mongodb] Do not use deprecated classes.
1 parent c5b2e11 commit 170eed1

12 files changed

+78
-78
lines changed

pkg/mongodb/MongodbConnectionFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace Enqueue\Mongodb;
66

7-
use Interop\Queue\PsrConnectionFactory;
8-
use Interop\Queue\PsrContext;
7+
use Interop\Queue\ConnectionFactory;
8+
use Interop\Queue\Context;
99
use MongoDB\Client;
1010

11-
class MongodbConnectionFactory implements PsrConnectionFactory
11+
class MongodbConnectionFactory implements ConnectionFactory
1212
{
1313
/**
1414
* @var array
@@ -54,7 +54,7 @@ public function __construct($config = 'mongodb:')
5454
/**
5555
* @return MongodbContext
5656
*/
57-
public function createContext(): PsrContext
57+
public function createContext(): Context
5858
{
5959
$client = new Client($this->config['dsn']);
6060

pkg/mongodb/MongodbConsumer.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace Enqueue\Mongodb;
66

7-
use Interop\Queue\InvalidMessageException;
8-
use Interop\Queue\PsrConsumer;
9-
use Interop\Queue\PsrMessage;
10-
use Interop\Queue\PsrQueue;
7+
use Interop\Queue\Consumer;
8+
use Interop\Queue\Exception\InvalidMessageException;
9+
use Interop\Queue\Message;
10+
use Interop\Queue\Queue;
1111

12-
class MongodbConsumer implements PsrConsumer
12+
class MongodbConsumer implements Consumer
1313
{
1414
/**
1515
* @var MongodbContext
@@ -53,15 +53,15 @@ public function getPollingInterval(): int
5353
/**
5454
* @return MongodbDestination
5555
*/
56-
public function getQueue(): PsrQueue
56+
public function getQueue(): Queue
5757
{
5858
return $this->queue;
5959
}
6060

6161
/**
6262
* @return MongodbMessage
6363
*/
64-
public function receive(int $timeout = 0): ?PsrMessage
64+
public function receive(int $timeout = 0): ?Message
6565
{
6666
$timeout /= 1000;
6767
$startAt = microtime(true);
@@ -88,23 +88,23 @@ public function receive(int $timeout = 0): ?PsrMessage
8888
/**
8989
* @return MongodbMessage
9090
*/
91-
public function receiveNoWait(): ?PsrMessage
91+
public function receiveNoWait(): ?Message
9292
{
9393
return $this->receiveMessage();
9494
}
9595

9696
/**
9797
* @param MongodbMessage $message
9898
*/
99-
public function acknowledge(PsrMessage $message): void
99+
public function acknowledge(Message $message): void
100100
{
101101
// does nothing
102102
}
103103

104104
/**
105105
* @param MongodbMessage $message
106106
*/
107-
public function reject(PsrMessage $message, bool $requeue = false): void
107+
public function reject(Message $message, bool $requeue = false): void
108108
{
109109
InvalidMessageException::assertMessageInstanceOf($message, MongodbMessage::class);
110110

pkg/mongodb/MongodbContext.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
namespace Enqueue\Mongodb;
66

7-
use Interop\Queue\InvalidDestinationException;
8-
use Interop\Queue\PsrConsumer;
9-
use Interop\Queue\PsrContext;
10-
use Interop\Queue\PsrDestination;
11-
use Interop\Queue\PsrMessage;
12-
use Interop\Queue\PsrProducer;
13-
use Interop\Queue\PsrQueue;
14-
use Interop\Queue\PsrSubscriptionConsumer;
15-
use Interop\Queue\PsrTopic;
16-
use Interop\Queue\SubscriptionConsumerNotSupportedException;
17-
use Interop\Queue\TemporaryQueueNotSupportedException;
7+
use Interop\Queue\Consumer;
8+
use Interop\Queue\Context;
9+
use Interop\Queue\Destination;
10+
use Interop\Queue\Exception\InvalidDestinationException;
11+
use Interop\Queue\Exception\SubscriptionConsumerNotSupportedException;
12+
use Interop\Queue\Exception\TemporaryQueueNotSupportedException;
13+
use Interop\Queue\Message;
14+
use Interop\Queue\Producer;
15+
use Interop\Queue\Queue;
16+
use Interop\Queue\SubscriptionConsumer;
17+
use Interop\Queue\Topic;
1818
use MongoDB\Client;
1919
use MongoDB\Collection;
2020

21-
class MongodbContext implements PsrContext
21+
class MongodbContext implements Context
2222
{
2323
/**
2424
* @var array
@@ -44,7 +44,7 @@ public function __construct($client, array $config = [])
4444
/**
4545
* @return MongodbMessage
4646
*/
47-
public function createMessage(string $body = '', array $properties = [], array $headers = []): PsrMessage
47+
public function createMessage(string $body = '', array $properties = [], array $headers = []): Message
4848
{
4949
$message = new MongodbMessage();
5050
$message->setBody($body);
@@ -57,28 +57,28 @@ public function createMessage(string $body = '', array $properties = [], array $
5757
/**
5858
* @return MongodbDestination
5959
*/
60-
public function createTopic(string $name): PsrTopic
60+
public function createTopic(string $name): Topic
6161
{
6262
return new MongodbDestination($name);
6363
}
6464

6565
/**
6666
* @return MongodbDestination
6767
*/
68-
public function createQueue(string $queueName): PsrQueue
68+
public function createQueue(string $queueName): Queue
6969
{
7070
return new MongodbDestination($queueName);
7171
}
7272

73-
public function createTemporaryQueue(): PsrQueue
73+
public function createTemporaryQueue(): Queue
7474
{
7575
throw TemporaryQueueNotSupportedException::providerDoestNotSupportIt();
7676
}
7777

7878
/**
7979
* @return MongodbProducer
8080
*/
81-
public function createProducer(): PsrProducer
81+
public function createProducer(): Producer
8282
{
8383
return new MongodbProducer($this);
8484
}
@@ -88,7 +88,7 @@ public function createProducer(): PsrProducer
8888
*
8989
* @return MongodbConsumer
9090
*/
91-
public function createConsumer(PsrDestination $destination): PsrConsumer
91+
public function createConsumer(Destination $destination): Consumer
9292
{
9393
InvalidDestinationException::assertDestinationInstanceOf($destination, MongodbDestination::class);
9494

@@ -105,15 +105,15 @@ public function close(): void
105105
{
106106
}
107107

108-
public function createSubscriptionConsumer(): PsrSubscriptionConsumer
108+
public function createSubscriptionConsumer(): SubscriptionConsumer
109109
{
110110
throw SubscriptionConsumerNotSupportedException::providerDoestNotSupportIt();
111111
}
112112

113113
/**
114114
* @param MongodbDestination $queue
115115
*/
116-
public function purgeQueue(PsrQueue $queue): void
116+
public function purgeQueue(Queue $queue): void
117117
{
118118
$this->getCollection()->deleteMany([
119119
'queue' => $queue->getQueueName(),

pkg/mongodb/MongodbDestination.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Enqueue\Mongodb;
66

7-
use Interop\Queue\PsrQueue;
8-
use Interop\Queue\PsrTopic;
7+
use Interop\Queue\Queue;
8+
use Interop\Queue\Topic;
99

10-
class MongodbDestination implements PsrTopic, PsrQueue
10+
class MongodbDestination implements Topic, Queue
1111
{
1212
/**
1313
* @var string

pkg/mongodb/MongodbMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Enqueue\Mongodb;
66

7-
use Interop\Queue\PsrMessage;
7+
use Interop\Queue\Message;
88

9-
class MongodbMessage implements PsrMessage
9+
class MongodbMessage implements Message
1010
{
1111
/**
1212
* @var string

pkg/mongodb/MongodbProducer.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace Enqueue\Mongodb;
66

7-
use Interop\Queue\Exception;
8-
use Interop\Queue\InvalidDestinationException;
9-
use Interop\Queue\InvalidMessageException;
10-
use Interop\Queue\PsrDestination;
11-
use Interop\Queue\PsrMessage;
12-
use Interop\Queue\PsrProducer;
13-
14-
class MongodbProducer implements PsrProducer
7+
use Interop\Queue\Destination;
8+
use Interop\Queue\Exception\Exception;
9+
use Interop\Queue\Exception\InvalidDestinationException;
10+
use Interop\Queue\Exception\InvalidMessageException;
11+
use Interop\Queue\Message;
12+
use Interop\Queue\Producer;
13+
14+
class MongodbProducer implements Producer
1515
{
1616
/**
1717
* @var int|null
@@ -42,7 +42,7 @@ public function __construct(MongodbContext $context)
4242
* @param MongodbDestination $destination
4343
* @param MongodbMessage $message
4444
*/
45-
public function send(PsrDestination $destination, PsrMessage $message): void
45+
public function send(Destination $destination, Message $message): void
4646
{
4747
InvalidDestinationException::assertDestinationInstanceOf($destination, MongodbDestination::class);
4848
InvalidMessageException::assertMessageInstanceOf($message, MongodbMessage::class);
@@ -117,7 +117,7 @@ public function send(PsrDestination $destination, PsrMessage $message): void
117117
/**
118118
* @return self
119119
*/
120-
public function setDeliveryDelay(int $deliveryDelay = null): PsrProducer
120+
public function setDeliveryDelay(int $deliveryDelay = null): Producer
121121
{
122122
$this->deliveryDelay = $deliveryDelay;
123123

@@ -132,7 +132,7 @@ public function getDeliveryDelay(): ?int
132132
/**
133133
* @return self
134134
*/
135-
public function setPriority(int $priority = null): PsrProducer
135+
public function setPriority(int $priority = null): Producer
136136
{
137137
$this->priority = $priority;
138138

@@ -147,7 +147,7 @@ public function getPriority(): ?int
147147
/**
148148
* @return self
149149
*/
150-
public function setTimeToLive(int $timeToLive = null): PsrProducer
150+
public function setTimeToLive(int $timeToLive = null): Producer
151151
{
152152
$this->timeToLive = $timeToLive;
153153

pkg/mongodb/Tests/MongodbConnectionFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Enqueue\Mongodb\MongodbConnectionFactory;
66
use Enqueue\Mongodb\MongodbContext;
77
use Enqueue\Test\ClassExtensionTrait;
8-
use Interop\Queue\PsrConnectionFactory;
8+
use Interop\Queue\ConnectionFactory;
99

1010
/**
1111
* @group mongodb
@@ -16,7 +16,7 @@ class MongodbConnectionFactoryTest extends \PHPUnit_Framework_TestCase
1616

1717
public function testShouldImplementConnectionFactoryInterface()
1818
{
19-
$this->assertClassImplements(PsrConnectionFactory::class, MongodbConnectionFactory::class);
19+
$this->assertClassImplements(ConnectionFactory::class, MongodbConnectionFactory::class);
2020
}
2121

2222
public function testCouldBeConstructedWithEmptyConfiguration()

pkg/mongodb/Tests/MongodbConsumerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
use Enqueue\Mongodb\MongodbMessage;
99
use Enqueue\Mongodb\MongodbProducer;
1010
use Enqueue\Test\ClassExtensionTrait;
11-
use Interop\Queue\InvalidMessageException;
12-
use Interop\Queue\PsrConsumer;
13-
use Interop\Queue\PsrMessage;
11+
use Interop\Queue\Consumer;
12+
use Interop\Queue\Exception\InvalidMessageException;
13+
use Interop\Queue\Message;
1414

1515
/**
1616
* @group mongodb
@@ -21,7 +21,7 @@ class MongodbConsumerTest extends \PHPUnit_Framework_TestCase
2121

2222
public function testShouldImplementConsumerInterface()
2323
{
24-
$this->assertClassImplements(PsrConsumer::class, MongodbConsumer::class);
24+
$this->assertClassImplements(Consumer::class, MongodbConsumer::class);
2525
}
2626

2727
public function testCouldBeConstructedWithRequiredArguments()
@@ -128,7 +128,7 @@ private function createContextMock()
128128
}
129129
}
130130

131-
class InvalidMessage implements PsrMessage
131+
class InvalidMessage implements Message
132132
{
133133
public function getBody(): string
134134
{

pkg/mongodb/Tests/MongodbContextTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
use Enqueue\Mongodb\MongodbMessage;
99
use Enqueue\Mongodb\MongodbProducer;
1010
use Enqueue\Test\ClassExtensionTrait;
11-
use Interop\Queue\InvalidDestinationException;
12-
use Interop\Queue\PsrContext;
13-
use Interop\Queue\PsrDestination;
14-
use Interop\Queue\TemporaryQueueNotSupportedException;
11+
use Interop\Queue\Context;
12+
use Interop\Queue\Destination;
13+
use Interop\Queue\Exception\InvalidDestinationException;
14+
use Interop\Queue\Exception\TemporaryQueueNotSupportedException;
1515
use MongoDB\Client;
1616

1717
/**
@@ -23,7 +23,7 @@ class MongodbContextTest extends \PHPUnit_Framework_TestCase
2323

2424
public function testShouldImplementContextInterface()
2525
{
26-
$this->assertClassImplements(PsrContext::class, MongodbContext::class);
26+
$this->assertClassImplements(Context::class, MongodbContext::class);
2727
}
2828

2929
public function testCouldBeConstructedWithRequiredArguments()
@@ -164,6 +164,6 @@ private function createClientMock()
164164
}
165165
}
166166

167-
class NotSupportedDestination2 implements PsrDestination
167+
class NotSupportedDestination2 implements Destination
168168
{
169169
}

pkg/mongodb/Tests/MongodbDestinationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use Enqueue\Mongodb\MongodbDestination;
66
use Enqueue\Test\ClassExtensionTrait;
7-
use Interop\Queue\PsrDestination;
8-
use Interop\Queue\PsrQueue;
9-
use Interop\Queue\PsrTopic;
7+
use Interop\Queue\Destination;
8+
use Interop\Queue\Queue;
9+
use Interop\Queue\Topic;
1010

1111
/**
1212
* @group mongodb
@@ -17,17 +17,17 @@ class MongodbDestinationTest extends \PHPUnit_Framework_TestCase
1717

1818
public function testShouldImplementDestinationInterface()
1919
{
20-
$this->assertClassImplements(PsrDestination::class, MongodbDestination::class);
20+
$this->assertClassImplements(Destination::class, MongodbDestination::class);
2121
}
2222

2323
public function testShouldImplementTopicInterface()
2424
{
25-
$this->assertClassImplements(PsrTopic::class, MongodbDestination::class);
25+
$this->assertClassImplements(Topic::class, MongodbDestination::class);
2626
}
2727

2828
public function testShouldImplementQueueInterface()
2929
{
30-
$this->assertClassImplements(PsrQueue::class, MongodbDestination::class);
30+
$this->assertClassImplements(Queue::class, MongodbDestination::class);
3131
}
3232

3333
public function testShouldReturnTopicAndQueuePreviouslySetInConstructor()

0 commit comments

Comments
 (0)