Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
For example
class Parser
{
public static function factory($url)
{
$url = Functions::getRealUrl($url);
$className = static::getParserClassName($url);
$instance = new $className($url);
if (!($instance instanceof Parser_Interface)) {
throw new Exception("{$className} must implement Parser_Interface");
}
return $instance;
}
}
$parser = Parser::factory('https://toster.ru/q/286564');
$parser->getTitle();
$parser->getBody();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question