tester_toster @tester_toster
Попытка номер 2:
interface RouteInterface {
public fucntion supports();
}
interface RequestRunnerInterface{
public function RequestRunnerInterface();
}
class RegExpRoute impliments RouteInterface, RequestRunnerInterface{
public function RequestRunnerInterface();
public fucntion supports();
}
class StaticRoute impliments RouteInterface, RequestRunnerInterface{
public function RequestRunnerInterface();
public fucntion supports();
}
classRouter(){
private $map;
public function add($data){
if(// Проверка на static){
$this->map['static'] = new StaticRoute($data);
}else{
$this->map['regexp'] = new RegExpRoute($data);
}
}
public function start(){
// Проверка static
foreach($map['static'] as $route){
if($route->supports()){
return $route->run();
}
}
// Проверка regexp
foreach($map['regexp'] as $route){
if($route->supports()){
return $route->run();
}
}
return false;
}
}
Ближе к истине?
И почему не нужен static?
Я же не все буду проверять regexp
Попытка номер 2:
interface RouteInterface {
public fucntion supports();
}
interface RequestRunnerInterface{
public function RequestRunnerInterface();
}
class RegExpRoute impliments RouteInterface, RequestRunnerInterface{
public function RequestRunnerInterface();
public fucntion supports();
}
class StaticRoute impliments RouteInterface, RequestRunnerInterface{
public function RequestRunnerInterface();
public fucntion supports();
}
classRouter(){
private $map;
public function add($data){
if(// Проверка на static){
$this->map['static'] = new StaticRoute($data);
}else{
$this->map['regexp'] = new RegExpRoute($data);
}
}
public function start(){
// Проверка static
foreach($map['static'] as $route){
if($route->supports()){
return $route->run();
}
}
// Проверка regexp
foreach($map['regexp'] as $route){
if($route->supports()){
return $route->run();
}
}
return false;
}
}
Ближе к истине?
И почему не нужен static?
Я же не все буду проверять regexp