This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
vbbs/app/Classes/Parser.php

40 lines
828 B
PHP

<?php
namespace App\Classes;
/**
* The Frame Parser looks into frames for ESC codes that renders dynamic information
*/
abstract class Parser
{
// Fields in the frame
public $fields = [];
// Parsed frame, ready to send to client
public $output = '';
// Position array of frame control chars
protected $frame_data = [];
// Position array of frame chars
protected $frame_content = [];
// Magic Fields that are pre-filled
protected $fieldmap = [
'a'=>'address#',
'd'=>'%date',
];
public function __construct(string $content,int $width,int $startline=1)
{
$this->fields = collect();
$this->output = $this->parse($startline,$content,$width);
}
public function __toString(): string
{
return $this->output;
}
abstract protected function parse(int $startline,string $content,int $width): string;
}