Answer the question
In order to leave comments, you need to log in
Is it possible to stop execution of further class methods in the constructor?
Code example:
$obj = new Class();
$obj->method_1()->method_2()->...method_n();
Let's assume that checks passed in the constructor that do not suit us and we do not need further execution of class methods. Is it possible somehow not to start executing further class methods?
Answer the question
In order to leave comments, you need to log in
Usually an exception is thrown. Make a boolean property of the class and set it in the constructor, and in the methods, perform checks.
Is it possible to stop execution of further class methods in the constructor?
Well, you can’t just cancel the execution of classes, although you can make one crutch.
You can write a simple dummy class
class Blank {
public function __call($name, $arguments) {
return this;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question