Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2 #3

Merged
merged 4 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/standard-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- dev

jobs:
coding-standard:
Expand Down
4 changes: 2 additions & 2 deletions src/AmqpFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Anik\Amqp\Qos\Qos;
use Anik\Amqp\Queues\Queue;
use Anik\Laravel\Amqp\Exceptions\LaravelAmqpException;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Container\Container;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use PHPUnit\Framework\Assert;
Expand All @@ -17,7 +17,7 @@ class AmqpFake extends AmqpManager implements AmqpPubSub
protected $activeConnection;
protected $connections;

public function __construct(Application $app)
public function __construct(Container $app)
{
parent::__construct($app);
$this->messages = [];
Expand Down
15 changes: 12 additions & 3 deletions src/AmqpManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@

use Anik\Amqp\AmqpConnectionFactory;
use Anik\Laravel\Amqp\Exceptions\LaravelAmqpException;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Config\Repository;
use Illuminate\Contracts\Container\Container;
use PhpAmqpLib\Connection\AMQPLazySSLConnection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class AmqpManager
{
protected $app;

protected $connections;

public function __construct(Application $app)
public function __construct(Container $app)
{
$this->app = $app;
}
Expand All @@ -37,7 +40,13 @@ protected function getDefaultConnection(): string

protected function config($key, $default = null)
{
return $this->app['config'][$key] ?? $default;
try {
$repository = $this->app->get('config');
} catch (NotFoundExceptionInterface | ContainerExceptionInterface $e) {
return $default;
}

return $repository instanceof Repository ? $repository->get($key, $default) : $default;
}

protected function resolve(string $name): AmqpPubSub
Expand Down