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/Control.php
2018-12-25 12:48:57 +11:00

48 lines
892 B
PHP

<?php
namespace App\Classes;
use App\Classes\Control\Register;
use App\Classes\Control\Telnet;
abstract class Control
{
protected $complete = FALSE;
protected $so = NULL;
public $state = [];
public function __construct(Server $so) {
$this->so = $so;
$this->boot();
}
// Default boot method if a child class doesnt have one.
protected function boot() {
$this->state['mode'] = FALSE;
}
/**
* Has control completed?
*/
public function complete()
{
return $this->complete;
}
// @todo Change to Dynamic Calls by the existence of files in App\Classes\Control
public static function factory(string $name, Server $so) {
switch ($name) {
case 'register':
return new Register($so);
case 'telnet':
return new Telnet($so);
default:
throw new \Exception('Unknown control method: '.$name);
}
}
abstract public function handle(string $char);
}