renaming clients to apps

This commit is contained in:
freek 2018-12-01 13:58:00 +01:00
parent e90e86798c
commit 69acbb704a
2 changed files with 11 additions and 12 deletions

View File

@ -7,17 +7,17 @@ use Illuminate\Support\Collection;
class ConfigAppProvider implements AppProvider class ConfigAppProvider implements AppProvider
{ {
/** @var Collection */ /** @var Collection */
protected $clients; protected $apps;
public function __construct() public function __construct()
{ {
$this->clients = collect(config('websockets.clients')); $this->apps = collect(config('websockets.clients'));
} }
/** @return array[\BeyondCode\LaravelWebSockets\ClientProviders\Client] */ /** @return array[\BeyondCode\LaravelWebSockets\ClientProviders\Client] */
public function all(): array public function all(): array
{ {
return $this->clients return $this->apps
->map(function ($client) { ->map(function ($client) {
return $this->instanciate($client); return $this->instanciate($client);
}) })
@ -27,7 +27,7 @@ class ConfigAppProvider implements AppProvider
public function findById(int $appId): ?App public function findById(int $appId): ?App
{ {
$clientAttributes = $this $clientAttributes = $this
->clients ->apps
->firstWhere('id', $appId); ->firstWhere('id', $appId);
return $this->instanciate($clientAttributes); return $this->instanciate($clientAttributes);
@ -36,23 +36,23 @@ class ConfigAppProvider implements AppProvider
public function findByKey(string $appKey): ?App public function findByKey(string $appKey): ?App
{ {
$clientAttributes = $this $clientAttributes = $this
->clients ->apps
->firstWhere('key', $appKey); ->firstWhere('key', $appKey);
return $this->instanciate($clientAttributes); return $this->instanciate($clientAttributes);
} }
protected function instanciate(?array $clientAttributes): ?App protected function instanciate(?array $appAttributes): ?App
{ {
if (! $clientAttributes) { if (! $appAttributes) {
return null; return null;
} }
return new App( return new App(
$clientAttributes['id'], $appAttributes['id'],
$clientAttributes['key'], $appAttributes['key'],
$clientAttributes['secret'], $appAttributes['secret'],
$clientAttributes['name'] ?? null $appAttributes['name'] ?? null
); );
} }
} }

View File

@ -12,7 +12,6 @@ use Ratchet\ConnectionInterface;
abstract class TestCase extends \Orchestra\Testbench\TestCase abstract class TestCase extends \Orchestra\Testbench\TestCase
{ {
/** @var \BeyondCode\LaravelWebSockets\WebSockets\WebSocketHandler */ /** @var \BeyondCode\LaravelWebSockets\WebSockets\WebSocketHandler */
protected $pusherServer; protected $pusherServer;