Files
logview/app/common/Implement/Parser.php

28 lines
612 B
PHP

<?php
namespace ProVM\Common\Implement;
use ProVM\Common\Define\Log;
abstract class Parser implements \ProVM\Common\Define\Parser
{
public function total(string $filename): int
{
try {
$fh = \Safe\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 \ProVM\Logview\Log($content);
}
}