Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class A {
  2. protected function __construct(){
  3. // made protected to disallow calling with $aa = new A()
  4. // in fact, does nothing
  5. };
  6.  
  7. static public function create(){
  8. $instance = new self();
  9. //... some important code
  10. return $instance;
  11. }
  12.  
  13. static public function createFromYetAnotherClass(YetAnotherClass $xx){
  14. // ...
  15. }
  16.  
  17. class B extends A {};
  18.  
  19. $aa = A::create();
  20. $bb = B::create();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement