Класс PastebinModel должен из исходного текста выдать сформатированный html, по указанной схеме. То есть должен быть набор разных синтаксических парсеров. Очевидно, что этот HTML может быть затребован многократно и его стОит где-то держать готовый. Хотелось бы не привязывать класс к конкретному Backend. Может понадобиться файловое хранилище или MySQl или Redis. Сталобыть опишу интерфейсы.
class PastebinModel
{
public function __construct(IPastebinBackend $backend) {}
public function parseAndSave($text, $parserId, $userId) {} // returns id:integer
public function getHtmlById($id) {} // returns html
public function getSourceById($id) {} // returns array(text, parserId, userId, time)
}
interface IPastebinParser
{
public function parse($text); // returns html
}
interface IPastebinBackend
{
public function save($text, $html, $parserId, $userId, $time); // returns id:integer
public function load($id); // returns array(text, html, parserId, userId, time)
}
class PastebinParserLocator
{
public static function getParserById($parserId); // returns parser:IPastebinParser
}
Есть у кого замечания?