This kind of question. There is a base class that is a cache. Now we need to look at the base class before calling child methods and check the feasibility of executing child methods.
interface ICache { public function getCategory(); } abstract class Cache { //Вытягиваем из кэша public function getCategory() { return null; } //Кладём в кэш public function setCategory($data) { } } class FileProvider extends Cache implements ICache { public function getCategory() { $data = parent::getCategory(); if (!is_null($data)) { return $data; } //$data = file_get_content(); parent::setCategory($data); return $data; } } class DBProvider extends Cache implements ICache { public function getCategory() { $data = parent::getCategory(); if (!is_null($data)) { return $data; } //$data = db::query(); parent::setCategory($data); return $data; } } And if the presence of methods in child classes is solved using interfaces, then how to make child classes call the parent method before executing? There will be plenty of providers and other people will write them.
Or am I from the wrong side?