Build Reactive Signals for Bluesky's AT Protocol Firehose in Laravel
at dev 1.2 kB view raw
1<?php 2 3namespace SocialDept\AtpSignals\Commands; 4 5use Illuminate\Console\GeneratorCommand; 6use Symfony\Component\Console\Input\InputOption; 7 8class MakeSignalCommand extends GeneratorCommand 9{ 10 protected $name = 'make:signal'; 11 12 protected $description = 'Create a new Signal class'; 13 14 protected $type = 'Signal'; 15 16 protected function getStub(): string 17 { 18 return __DIR__ . '/../../stubs/signal.stub'; 19 } 20 21 protected function getDefaultNamespace($rootNamespace): string 22 { 23 return $rootNamespace . '\\Signals'; 24 } 25 26 protected function buildClass($name): string 27 { 28 $stub = parent::buildClass($name); 29 30 $eventType = $this->option('type') ?? 'commit'; 31 $collection = $this->option('collection') ?? 'app.bsky.feed.post'; 32 33 $stub = str_replace('{{ eventType }}', $eventType, $stub); 34 $stub = str_replace('{{ collection }}', $collection, $stub); 35 36 return $stub; 37 } 38 39 protected function getOptions(): array 40 { 41 return [ 42 ['type', 't', InputOption::VALUE_OPTIONAL, 'The event type (commit, identity, account)'], 43 ['collection', 'c', InputOption::VALUE_OPTIONAL, 'The collection to watch'], 44 ]; 45 } 46}