32 lines
703 B
PHP
32 lines
703 B
PHP
<?php
|
|
namespace ProVM\Common\Implement;
|
|
|
|
use Exception;
|
|
use ProVM\Common\Define\Log;
|
|
use ProVM\Logview\Log as LogContent;
|
|
use ProVM\Common\Define\Parser as Definition;
|
|
use function Safe\fopen;
|
|
|
|
abstract class Parser implements Definition
|
|
{
|
|
public function total(string $filename): int
|
|
{
|
|
try {
|
|
$fh = fopen($filename, 'r');
|
|
$cnt = 0;
|
|
while(!feof($fh)) {
|
|
$line = fgets($fh);
|
|
$cnt ++;
|
|
}
|
|
fclose($fh);
|
|
return $cnt;
|
|
} catch (Exception $e) {
|
|
return 0;
|
|
}
|
|
}
|
|
public function parse(string $content): Log
|
|
{
|
|
return new LogContent($content);
|
|
}
|
|
}
|