mercredi 28 mars 2018

How a pattern that force super class to init all subcasses is called?

I've a super class

class Super
{
    public function __construct(array $params = [])
    {
        if ($params === []) {
            return;
        }

        $this->init();
    }

    abstract public function init();
}

And few sub classes

class SubClass extends Super {
    public function init() { ... }
}

class AnotherSubClass extends Super {
    public function init() { ... }
}

Aucun commentaire:

Enregistrer un commentaire