diff --git a/.gitignore b/.gitignore
index 61dce41..3188835 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ template/.phpunit.result.cache
.env
template/.env
.idea/
+*.DS_Store
diff --git a/filters/all.js b/filters/all.js
index d795c9b..ea7a722 100644
--- a/filters/all.js
+++ b/filters/all.js
@@ -14,10 +14,10 @@ function toPHPType(str) {
case 'date':
return 'DateTime';
case 'time':
- return '\DateTime';
+ return '\\DateTime';
case 'dateTime':
case 'date-time':
- return '\DateTime';
+ return '\\DateTime';
case 'string':
case 'password':
case 'byte':
@@ -26,7 +26,7 @@ function toPHPType(str) {
case 'double':
return 'float';
default:
- return '\stdClass';
+ return '\\stdClass';
}
}
diff --git a/template/README.md b/template/README.md
index 576ea30..039d086 100644
--- a/template/README.md
+++ b/template/README.md
@@ -1,4 +1,4 @@
-# BrokerAPI
+# AsyncAPI
[//]: # "[![Latest Version on Packagist][ico-version]][link-packagist]"
@@ -13,7 +13,7 @@
[//]: # "[![Total Downloads][ico-downloads]][link-downloads]"
-BrokerAPI is a wrapper for Message-driven API's built on top of most used industry plugins such as [PHP AMQP lib](https://packagist.org/packages/php-amqplib/php-amqplib) for RabbitMQ.
+AsyncAPI is a wrapper for Message-driven API's built on top of most used industry plugins such as [PHP AMQP lib](https://packagist.org/packages/php-amqplib/php-amqplib) for RabbitMQ.
It is built for usage altogether with [AsyncAPI specs and generators](https://github.com/asyncapi/generator)
## Structure
@@ -46,12 +46,12 @@ Once you hvae the generator installed, you can try to generate code from any val
Refer to the examples folder for further details on PHP usage
``` bash
-$brokerAPI = new BrokerAPI();
+$brokerAPI = new AsyncAPI();
$factory = $brokerAPI->init();
-/** @var \{{ params.packageName }}\Applications\Producer $producer */
-$producer = $factory->createApplication(
- PRODUCER_KEY,
+/** @var \{{ params.packageName }}\Applications\Subscriber $subscriber */
+$subscriber = $factory->createApplication(
+ SUBSCRIBER_KEY,
[
BROKER_HOST_KEY => 'localhost',
BROKER_USER_KEY => 'guest',
@@ -68,7 +68,7 @@ $message = $factory->createMessage(
]
);
-$producer->requestExampleById($message);
+$subscriber->requestExampleById($message);
```
## Change log
@@ -92,17 +92,17 @@ If you discover any security related issues, please email ezublena@gmail.com ins
The MIT License (MIT). Please see [License File](../LICENSE.md) for more information.
-[ico-version]: https://img.shields.io/packagist/v/GA/BrokerAPI.svg?style=flat-square
+[ico-version]: https://img.shields.io/packagist/v/GA/AsyncAPI.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
-[ico-travis]: https://img.shields.io/travis/GA/BrokerAPI/master.svg?style=flat-square
-[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/GA/BrokerAPI.svg?style=flat-square
-[ico-code-quality]: https://img.shields.io/scrutinizer/g/GA/BrokerAPI.svg?style=flat-square
-[ico-downloads]: https://img.shields.io/packagist/dt/GA/BrokerAPI.svg?style=flat-square
-
-[link-packagist]: https://packagist.org/packages/GA/BrokerAPI
-[link-travis]: https://travis-ci.org/GA/BrokerAPI
-[link-scrutinizer]: https://scrutinizer-ci.com/g/GA/BrokerAPI/code-structure
-[link-code-quality]: https://scrutinizer-ci.com/g/GA/BrokerAPI
-[link-downloads]: https://packagist.org/packages/GA/BrokerAPI
+[ico-travis]: https://img.shields.io/travis/GA/AsyncAPI/master.svg?style=flat-square
+[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/GA/AsyncAPI.svg?style=flat-square
+[ico-code-quality]: https://img.shields.io/scrutinizer/g/GA/AsyncAPI.svg?style=flat-square
+[ico-downloads]: https://img.shields.io/packagist/dt/GA/AsyncAPI.svg?style=flat-square
+
+[link-packagist]: https://packagist.org/packages/GA/AsyncAPI
+[link-travis]: https://travis-ci.org/GA/AsyncAPI
+[link-scrutinizer]: https://scrutinizer-ci.com/g/GA/AsyncAPI/code-structure
+[link-code-quality]: https://scrutinizer-ci.com/g/GA/AsyncAPI
+[link-downloads]: https://packagist.org/packages/GA/AsyncAPI
[link-author]: https://github.com/emilianozublena
[link-contributors]: https://github.com/asyncapi/php-template/graphs/contributors
diff --git a/template/configs/consts.php b/template/configs/consts.php
index 28a2b19..798ef07 100644
--- a/template/configs/consts.php
+++ b/template/configs/consts.php
@@ -28,6 +28,6 @@
/** END OF PROTOCOL LITERALS */
/** APPLICATION LITERALS */
-const PRODUCER_KEY = 'producer';
-const CONSUMER_KEY = 'consumer';
+const SUBSCRIBER_KEY = 'subscriber';
+const PUBLISHER_KEY = 'publisher';
/** END OF APPLICATION LITERALS */
diff --git a/template/examples/basic/producer/index.php b/template/examples/basic/publisher/index.php
similarity index 77%
rename from template/examples/basic/producer/index.php
rename to template/examples/basic/publisher/index.php
index 98f8f2e..5a9c628 100644
--- a/template/examples/basic/producer/index.php
+++ b/template/examples/basic/publisher/index.php
@@ -4,12 +4,12 @@
use {{ params.packageName }};
use {{ params.packageName }}\Messages\Example;
-$brokerAPI = new BrokerAPI();
+$brokerAPI = new AsyncAPI();
$factory = $brokerAPI->init();
-/** @var \{{ params.packageName }}\Applications\Producer $producer */
-$producer = $factory->createApplication(
- PRODUCER_KEY,
+/** @var \{{ params.packageName }}\Applications\Publisher $publisher */
+$publisher = $factory->createApplication(
+ PUBLISHER_KEY,
[
BROKER_HOST_KEY => $_ENV[ENV_BROKER_HOST_KEY] ?? BROKER_HOST_DEFAULT,
BROKER_USER_KEY => $_ENV[ENV_BROKER_USER_KEY] ?? BROKER_USER_DEFAULT,
@@ -25,4 +25,4 @@
'id' => 1,
]
);
-$producer->requestExampleById($message);
+$publisher->requestExampleById($message);
diff --git a/template/examples/basic/consumer/Handlers/ExampleHandler.php b/template/examples/basic/subscriber/Handlers/ExampleHandler.php
similarity index 92%
rename from template/examples/basic/consumer/Handlers/ExampleHandler.php
rename to template/examples/basic/subscriber/Handlers/ExampleHandler.php
index e904177..3eedf26 100644
--- a/template/examples/basic/consumer/Handlers/ExampleHandler.php
+++ b/template/examples/basic/subscriber/Handlers/ExampleHandler.php
@@ -1,6 +1,6 @@
init();
-/** @var \{{ params.packageName }}\Applications\Consumer $consumer */
-$consumer = $factory->createApplication(
- CONSUMER_KEY,
+/** @var \{{ params.packageName }}\Applications\Subscriber $subscriber */
+$subscriber = $factory->createApplication(
+ SUBSCRIBER_KEY,
[
BROKER_HOST_KEY => $_ENV[ENV_BROKER_HOST_KEY] ?? BROKER_HOST_DEFAULT,
BROKER_USER_KEY => $_ENV[ENV_BROKER_USER_KEY] ?? BROKER_USER_DEFAULT,
@@ -18,5 +18,5 @@
BROKER_VIRTUAL_HOST_KEY => $_ENV[ENV_BROKER_VIRTUAL_HOST_KEY] ?? BROKER_VIRTUAL_HOST_DEFAULT,
]
);
-$handler = new \Examples\Basic\Consumer\Handlers\ExampleHandler();
-$consumer->retrieveExampleById($handler);
+$handler = new \Examples\Basic\Subscriber\Handlers\ExampleHandler();
+$subscriber->retrieveExampleById($handler);
diff --git a/template/examples/rpc/producer/index.php b/template/examples/rpc/publisher/index.php
similarity index 78%
rename from template/examples/rpc/producer/index.php
rename to template/examples/rpc/publisher/index.php
index 0e45fb6..8255729 100644
--- a/template/examples/rpc/producer/index.php
+++ b/template/examples/rpc/publisher/index.php
@@ -4,12 +4,12 @@
use {{ params.packageName }};
use {{ params.packageName }}\Messages\Example;
-$brokerAPI = new BrokerAPI();
+$brokerAPI = new AsyncAPI();
$factory = $brokerAPI->init();
-/** @var \{{ params.packageName }}\Applications\Producer $producer */
-$producer = $factory->createApplication(
- PRODUCER_KEY,
+/** @var \{{ params.packageName }}\Applications\Publisher $publisher */
+$publisher = $factory->createApplication(
+ PUBLISHER_KEY,
[
BROKER_HOST_KEY => $_ENV[ENV_BROKER_HOST_KEY] ?? BROKER_HOST_DEFAULT,
BROKER_USER_KEY => $_ENV[ENV_BROKER_USER_KEY] ?? BROKER_USER_DEFAULT,
@@ -26,5 +26,5 @@
]
);
/** @var \PhpAmqpLib\Message\AMQPMessage $return */
-$return = $producer->requestExampleByIdRPC($message);
+$return = $publisher->requestExampleByIdRPC($message);
print_r($return->getBody());
diff --git a/template/examples/rpc/consumer/Handlers/RPCExampleHandler.php b/template/examples/rpc/subscriber/Handlers/RPCExampleHandler.php
similarity index 96%
rename from template/examples/rpc/consumer/Handlers/RPCExampleHandler.php
rename to template/examples/rpc/subscriber/Handlers/RPCExampleHandler.php
index 9693948..3ae8443 100644
--- a/template/examples/rpc/consumer/Handlers/RPCExampleHandler.php
+++ b/template/examples/rpc/subscriber/Handlers/RPCExampleHandler.php
@@ -1,6 +1,6 @@
init();
-/** @var \{{ params.packageName }}\Applications\Consumer $consumer */
-$consumer = $factory->createApplication(
- CONSUMER_KEY,
+/** @var \{{ params.packageName }}\Applications\Subscriber $subscriber */
+$subscriber = $factory->createApplication(
+ SUBSCRIBER_KEY,
[
BROKER_HOST_KEY => $_ENV[ENV_BROKER_HOST_KEY] ?? BROKER_HOST_DEFAULT,
BROKER_USER_KEY => $_ENV[ENV_BROKER_USER_KEY] ?? BROKER_USER_DEFAULT,
@@ -18,5 +18,5 @@
BROKER_VIRTUAL_HOST_KEY => $_ENV[ENV_BROKER_VIRTUAL_HOST_KEY] ?? BROKER_VIRTUAL_HOST_DEFAULT,
]
);
-$handler = new \Examples\RPC\Consumer\Handlers\RPCExampleHandler();
-$consumer->retrieveExampleByIdRPC($handler);
+$handler = new \Examples\RPC\Subscriber\Handlers\RPCExampleHandler();
+$subscriber->retrieveExampleByIdRPC($handler);
diff --git a/template/phpcs.xml.dist b/template/phpcs.xml.dist
index 69b9266..fecfc98 100644
--- a/template/phpcs.xml.dist
+++ b/template/phpcs.xml.dist
@@ -1,6 +1,6 @@
-
- The coding standard of BrokerAPI package
+
+ The coding standard of AsyncAPI package
@@ -11,4 +11,4 @@
-
\ No newline at end of file
+
diff --git a/template/phpunit.xml b/template/phpunit.xml
index 09de245..e2c4744 100644
--- a/template/phpunit.xml
+++ b/template/phpunit.xml
@@ -11,7 +11,7 @@
stopOnFailure = "true">
-
+
tests
@@ -20,4 +20,4 @@
-
\ No newline at end of file
+
diff --git a/template/src/Applications/ApplicationContract.php b/template/src/Applications/ApplicationContract.php
index f3ad412..c1b281a 100644
--- a/template/src/Applications/ApplicationContract.php
+++ b/template/src/Applications/ApplicationContract.php
@@ -1,7 +1,7 @@
'',
- 'consumerTag' => '',
+ 'publisherTag' => '',
'noLocal' => false,
'noAck' => false,
'exclusive' => {{queueExclusive}},
diff --git a/template/src/BrokerAPI.php b/template/src/AsyncAPI.php
similarity index 92%
rename from template/src/BrokerAPI.php
rename to template/src/AsyncAPI.php
index ff55d52..0290ac8 100644
--- a/template/src/BrokerAPI.php
+++ b/template/src/AsyncAPI.php
@@ -1,6 +1,6 @@
createBrokerClient($config);
switch ($applicationType) {
- case PRODUCER_KEY:
- $application = new Producer(
+ case SUBSCRIBER_KEY:
+ $application = new Subscriber(
$brokerClient
);
break;
- case CONSUMER_KEY:
- $application = new Consumer(
+ case PUBLISHER_KEY:
+ $application = new Publisher(
$brokerClient
);
break;
diff --git a/template/src/Handlers/AMQPRPCClientHandler.php b/template/src/Handlers/AMQPRPCClientHandler.php
index e63161f..006a271 100644
--- a/template/src/Handlers/AMQPRPCClientHandler.php
+++ b/template/src/Handlers/AMQPRPCClientHandler.php
@@ -1,6 +1,6 @@
channel->queue_bind($queueName, $exchangeName, $bindingKey);
$this->channel->basic_consume(
$queueName,
- $consumerTag ?? '',
+ $publisherTag ?? '',
$noLocal ?? false,
$noAck ?? false,
$exclusive ?? false,
diff --git a/template/src/Messages/MessageContract.php b/template/src/Messages/MessageContract.php
index f5564e6..ced8197 100644
--- a/template/src/Messages/MessageContract.php
+++ b/template/src/Messages/MessageContract.php
@@ -1,6 +1,6 @@
reveal());
- $consumer = new Consumer($brokerClientProphecy->reveal());
- $producer->$brokerSetter($brokerClientProphecy->reveal());
- $consumer->$brokerSetter($brokerClientProphecy->reveal());
- $producer->$factorySetter($factoryProphecy->reveal());
- $consumer->$factorySetter($factoryProphecy->reveal());
+ $subscriber = new Subscriber($brokerClientProphecy->reveal());
+ $publisher = new Publisher($brokerClientProphecy->reveal());
+ $subscriber->$brokerSetter($brokerClientProphecy->reveal());
+ $publisher->$brokerSetter($brokerClientProphecy->reveal());
+ $subscriber->$factorySetter($factoryProphecy->reveal());
+ $publisher->$factorySetter($factoryProphecy->reveal());
//Then we assert we get it back
- $this->assertDependenciesFromDataProvider($producer, $brokerClient, $factory, $consumer);
+ $this->assertDependenciesFromDataProvider($subscriber, $brokerClient, $factory, $publisher);
}
/**
@@ -50,17 +50,17 @@ public function it_loads_dependencies_on_constructor($expectedDependencies)
list($brokerClient, $factory, $brokerClientProphecy, $factoryProphecy) = $this->setDependenciesFromDataProvider($expectedDependencies);
//When we instantiate applications
- $producer = new Producer(
+ $subscriber = new Subscriber(
$brokerClientProphecy->reveal(),
$factoryProphecy->reveal()
);
- $consumer = new Consumer(
+ $publisher = new Publisher(
$brokerClientProphecy->reveal(),
$factoryProphecy->reveal()
);
//Then we assert we get expected dependencies back
- $this->assertDependenciesFromDataProvider($producer, $brokerClient, $factory, $consumer);
+ $this->assertDependenciesFromDataProvider($subscriber, $brokerClient, $factory, $publisher);
}
public function dependenciesWithSettersAndGetters()
@@ -97,18 +97,18 @@ private function setDependenciesFromDataProvider($expectedDependencies): array
}
/**
- * @param $producer
+ * @param $subscriber
* @param $brokerClient
* @param $factory
- * @param $consumer
+ * @param $publisher
*/
- private function assertDependenciesFromDataProvider($producer, $brokerClient, $factory, $consumer): void
+ private function assertDependenciesFromDataProvider($subscriber, $brokerClient, $factory, $publisher): void
{
$brokerGetter = $brokerClient['getter'];
$factoryGetter = $factory['getter'];
- $this->assertTrue($producer->$brokerGetter() instanceof $brokerClient['dependency']);
- $this->assertTrue($producer->$factoryGetter() instanceof $factory['dependency']);
- $this->assertTrue($consumer->$brokerGetter() instanceof $brokerClient['dependency']);
- $this->assertTrue($consumer->$factoryGetter() instanceof $factory['dependency']);
+ $this->assertTrue($subscriber->$brokerGetter() instanceof $brokerClient['dependency']);
+ $this->assertTrue($subscriber->$factoryGetter() instanceof $factory['dependency']);
+ $this->assertTrue($publisher->$brokerGetter() instanceof $brokerClient['dependency']);
+ $this->assertTrue($publisher->$factoryGetter() instanceof $factory['dependency']);
}
}
diff --git a/template/tests/BrokerAPITest.php b/template/tests/AsyncAPITest.php
similarity index 80%
rename from template/tests/BrokerAPITest.php
rename to template/tests/AsyncAPITest.php
index 81f58e9..05af5cc 100644
--- a/template/tests/BrokerAPITest.php
+++ b/template/tests/AsyncAPITest.php
@@ -2,10 +2,10 @@
namespace {{ params.packageName }}\Tests;
-use {{ params.packageName }}\BrokerAPI;
+use {{ params.packageName }}\AsyncAPI;
use {{ params.packageName }}\Common\AMQPFactory;
-class BrokerAPITest extends BaseTest
+class AsyncAPITest extends BaseTest
{
/**
* @test
@@ -15,9 +15,9 @@ public function it_creates_factory_by_protocol(
$protocolConstantName,
$expectedFactoryFqn
) {
- //Given we have a valid protocol string and a BrokerAPI instance
+ //Given we have a valid protocol string and a AsyncAPI instance
$protocol = constant($protocolConstantName);
- $brokerAPI = new BrokerAPI($protocol);
+ $brokerAPI = new AsyncAPI($protocol);
//When we try to create the factory
$factory = $brokerAPI->init();
diff --git a/template/tests/Common/AMQPFactoryTest.php b/template/tests/Common/AMQPFactoryTest.php
index efef265..e26b087 100644
--- a/template/tests/Common/AMQPFactoryTest.php
+++ b/template/tests/Common/AMQPFactoryTest.php
@@ -12,8 +12,8 @@
use {{ params.packageName }}\Infrastructure\AMQPBrokerClient;
use {{ params.packageName }}\Infrastructure\BrokerClientContract;
use {{ params.packageName }}\Messages\MessageContract;
-use {{ params.packageName }}\Applications\Consumer;
-use {{ params.packageName }}\Applications\Producer;
+use {{ params.packageName }}\Applications\Subscriber;
+use {{ params.packageName }}\Applications\Publisher;
use {{ params.packageName }}\Tests\BaseTest;
use {{ params.packageName }}\Handlers\HandlerContract;
use {{ params.packageName }}\Handlers\AMQPRPCClientHandler;
@@ -147,8 +147,8 @@ public function applicationTypesDataProvider()
{
return [
[
- 'applicationTypeConstant' => 'PRODUCER_KEY',
- 'expectedApplicationFqn' => Producer::class,
+ 'applicationTypeConstant' => 'SUBSCRIBER_KEY',
+ 'expectedApplicationFqn' => Subscriber::class,
'expectedDependencies' => [
'brokerClient' => [
'getter' => 'getBrokerClient',
@@ -161,8 +161,8 @@ public function applicationTypesDataProvider()
],
],
[
- 'applicationTypeConstant' => 'CONSUMER_KEY',
- 'expectedApplicationFqn' => Consumer::class,
+ 'applicationTypeConstant' => 'PUBLISHER_KEY',
+ 'expectedApplicationFqn' => Publisher::class,
'expectedDependencies' => [
'brokerClient' => [
'getter' => 'getBrokerClient',