phpvms/app/Contracts/Command.php
Arthur Parienté 489a68b54e
[8.x] feat(phpstan): support levels 3, 4 and 5 (#2095)
* wip

* feat(phpstan): support level 3

* feat(phpstan): support level 4

* feat(phpstan): support level 5

* fix(phpstan): fix Money constructor

* some fixes after merge

* fix time during tests
2025-10-21 13:05:36 -05:00

56 lines
1.1 KiB
PHP

<?php
namespace App\Contracts;
use Generator;
/**
* Class BaseCommand
*/
abstract class Command extends \Illuminate\Console\Command
{
/**
* @return mixed
*/
abstract public function handle();
/**
* Adjust the logging depending on where we're running from
*/
public function __construct()
{
parent::__construct();
// Running in the console but not in the tests
/*if (app()->runningInConsole() && env('APP_ENV') !== 'testing') {
$this->redirectLoggingToFile('stdout');
}*/
}
/**
* Return the signature of the command
*/
public function getSignature(): string
{
return $this->signature;
}
/**
* Streaming file reader
*/
public function readFile($filename): ?Generator
{
$fp = fopen($filename, 'rb');
while (($line = fgets($fp)) !== false) {
$line = rtrim($line, "\r\n");
if ($line[0] === ';') {
continue;
}
yield $line;
}
fclose($fp);
}
}