Skip to content

Commit

Permalink
uses Container contract instead of Application contract #2
Browse files Browse the repository at this point in the history
  • Loading branch information
ssi-anik committed Feb 8, 2022
1 parent 7b31675 commit b12844c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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 b12844c

Please sign in to comment.