Version 1.0.0
This commit is contained in:
30
src/Service/Configuration.php
Normal file
30
src/Service/Configuration.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Diffhead\PHP\LaravelRabbitMQ\Service;
|
||||
|
||||
use Diffhead\PHP\LaravelRabbitMQ\Object\Configuration as ConfigurationObject;
|
||||
use RuntimeException;
|
||||
|
||||
class Configuration
|
||||
{
|
||||
public function get(string $connection = 'default'): ConfigurationObject
|
||||
{
|
||||
$config = config(sprintf('rabbitmq.connections.%s', $connection));
|
||||
|
||||
if (empty($config)) {
|
||||
throw new RuntimeException(
|
||||
sprintf('Not found rabbitmq config for connection %s', $connection)
|
||||
);
|
||||
}
|
||||
|
||||
return new ConfigurationObject(
|
||||
$config['host'],
|
||||
(int) $config['port'],
|
||||
$config['user'],
|
||||
$config['password'],
|
||||
$config['vhost'],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user