AspireCloud/app/Utils/File.php
Chuck Adams be1660cce5
New plugin/theme loading system (#104)
* feat: add ClosedPlugin model

* fix: don't chop line if it doesn't end with \n

* build: rm unused robmorgan/phinx dependency

* chore: rm all App\Models\Sync classes

* feat: new unified plugin and theme loader

* docs: update README.md

* fix: fix or suppress phpstan warnings

* docs: fix dump commands in readme

* feat: add ac_origin column to all resource tables

* chore: add ac_* columns including ac_raw_metadata

we used to point to the raw metadata in the corresponding SyncPlugin/SyncTheme record, but that's gone.  thus, adding it as a column.

* chore: mark eloquent properties as readonly in phpdoc

* fix: drop bogus HasFactory from Author
2024-11-21 11:26:52 -07:00

26 lines
494 B
PHP

<?php
namespace App\Utils;
use Generator;
use SplFileObject;
final class File
{
public static function lazyLines(string $filename): Generator
{
$file = new SplFileObject($filename);
while (!$file->eof()) {
$line = $file->fgets();
if (str_ends_with($line, "\n")) {
$line = substr($line, 0, -1);
}
yield $line;
}
}
private function __construct()
{
// not instantiable
}
}