Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A {
- protected function __construct(){
- // made protected to disallow calling with $aa = new A()
- // in fact, does nothing
- };
- static public function create(){
- $instance = new self();
- //... some important code
- return $instance;
- }
- static public function createFromYetAnotherClass(YetAnotherClass $xx){
- // ...
- }
- class B extends A {};
- $aa = A::create();
- $bb = B::create();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement