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

View File

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