31 lines
722 B
PHP
31 lines
722 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Blax\WebRtc\Tests\Fixtures;
|
|
|
|
use Blax\WebRtc\Contracts\CallEventListener;
|
|
|
|
final class CollectingEvents implements CallEventListener
|
|
{
|
|
/** @var array<int,array<string,mixed>> */
|
|
public array $events = [];
|
|
|
|
public function handle(array $event): void
|
|
{
|
|
$this->events[] = $event;
|
|
}
|
|
|
|
/** @return array<int,string> */
|
|
public function types(): array
|
|
{
|
|
return array_map(fn ($e) => (string) $e['type'], $this->events);
|
|
}
|
|
|
|
/** @return array<int,array<string,mixed>> */
|
|
public function ofType(string $type): array
|
|
{
|
|
return array_values(array_filter($this->events, fn ($e) => ($e['type'] ?? null) === $type));
|
|
}
|
|
}
|