55 lines
1.0 KiB
PHP
55 lines
1.0 KiB
PHP
<?php
|
|
|
|
class mtgMetaInterface extends mtgUserType
|
|
{
|
|
protected $funcs = array();
|
|
protected $implements = null;
|
|
|
|
function __construct($name, array $implements = array(), $tokens = array())
|
|
{
|
|
parent::__construct($name);
|
|
|
|
$this->implements = $implements;
|
|
$this->tokens = $tokens;
|
|
}
|
|
|
|
function validate(mtgMetaInfo $meta) {}
|
|
|
|
function getImplements()
|
|
{
|
|
if(!$this->implements)
|
|
return array();
|
|
|
|
$imps = array();
|
|
foreach($this->implements as $imp)
|
|
$imps[] = $imp->resolve();
|
|
return $imps;
|
|
}
|
|
|
|
function getFuncs()
|
|
{
|
|
return $this->funcs;
|
|
}
|
|
|
|
function addFunc(mtgMetaFunc $fn)
|
|
{
|
|
if($this->hasFunc($fn->getName()))
|
|
throw new Exception("Interface '{$this->name}' already has func '{$fn->getName()}'");
|
|
|
|
$this->funcs[$fn->getName()] = $fn;
|
|
}
|
|
|
|
function hasFunc($name)
|
|
{
|
|
return isset($this->funcs[$name]);
|
|
}
|
|
|
|
function getFunc($name)
|
|
{
|
|
if(!isset($this->funcs[$name]))
|
|
throw new Exception("No such funcs '$name'");
|
|
return $this->funcs[$name];
|
|
}
|
|
}
|
|
|