Skip to content

Commit

Permalink
Merge pull request #3 from ssi-anik/dev
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
ssi-anik authored Feb 8, 2022
2 parents 7b31675 + 185dbc4 commit 3ce5bb3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
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

0 comments on commit 3ce5bb3

Please sign in to comment.