Skip to content

Commit

Permalink
Refactor console output methods to be non-static
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 11, 2023
1 parent c213fd0 commit bd7740e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/framework/src/Console/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ protected function printStartMessage(): void
{
$this->useBasicOutput()
? $this->output->writeln('<info>Starting the HydeRC server...</info> Press Ctrl+C to stop')
: ConsoleOutput::printStartMessage($this->getHostSelection(), $this->getPortSelection());
: $this->console->printStartMessage($this->getHostSelection(), $this->getPortSelection());
}

protected function getOutputHandler(): Closure
{
return $this->useBasicOutput() ? function (string $type, string $line): void {
$this->output->write($line);
} : ConsoleOutput::getFormatter($this->output->isVerbose());
} : $this->console->getFormatter();
}

protected function useBasicOutput(): bool
Expand Down
10 changes: 4 additions & 6 deletions packages/realtime-compiler/src/ConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(bool $verbose = false)
$this->verbose = $verbose;
}

public static function printStartMessage(string $host, int $port): void
public function printStartMessage(string $host, int $port): void
{
$title = 'HydePHP Realtime Compiler';
$version = ' v'.Hyde::version();
Expand Down Expand Up @@ -50,12 +50,10 @@ public static function printStartMessage(string $host, int $port): void
HTML);
}

public static function getFormatter(bool $verbose): Closure
public function getFormatter(): Closure
{
$console = (new static($verbose));

return function (string $type, string $line) use ($console): void {
$console->handleOutput($line);
return function (string $type, string $line): void {
$this->handleOutput($line);
};
}

Expand Down

0 comments on commit bd7740e

Please sign in to comment.