54 lines
892 B
PHP
54 lines
892 B
PHP
|
<?php
|
||
|
|
||
|
abstract class PTElement {
|
||
|
|
||
|
const UNKNOWN = 1;
|
||
|
const TRAM = 1;
|
||
|
const BUS = 2;
|
||
|
const BELBUS = 4;
|
||
|
|
||
|
protected $ref;
|
||
|
protected $publicRef;
|
||
|
|
||
|
protected $infoFetched = false;
|
||
|
|
||
|
public function __construct ($ref) {
|
||
|
|
||
|
if (!is_int($ref)) {
|
||
|
throw new InvalidArgumentException('$ref must be an integer');
|
||
|
}
|
||
|
$this->ref = $ref;
|
||
|
|
||
|
}
|
||
|
|
||
|
public function __toString () {
|
||
|
return 'PTElement[' . $this->ref . ']';
|
||
|
}
|
||
|
|
||
|
public function getRef () {
|
||
|
return $this->ref;
|
||
|
}
|
||
|
|
||
|
protected abstract function fetchInfo ();
|
||
|
|
||
|
|
||
|
public static function lineTypeTextToConst ($lineTypeText) {
|
||
|
switch ($lineTypeText) {
|
||
|
case 'tram';
|
||
|
return static::TRAM;
|
||
|
break;
|
||
|
case 'bus';
|
||
|
return static::BUS;
|
||
|
break;
|
||
|
case 'belbus';
|
||
|
return static::BELBUS;
|
||
|
break;
|
||
|
default;
|
||
|
return static::UNKNOWN;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|