PHP Classes

File: subClass.class.php

Recommend this page to a friend!
  Classes of Ben A. Noone   Master Class SubClass   subClass.class.php   Download  
File: subClass.class.php
Role: Class source
Content type: text/plain
Description: Abstract Class SubClass
Class: Master Class SubClass
Create and manage hierarchies of classes
Author: By
Last change: removed file specific code
Date: 10 years ago
Size: 1,085 bytes
 

Contents

Class file image Download
<?php
/*
    subclass
    Extendable template class subclass
    Enables Class Hierarchy without comprising structure
    Requires: masterClass
*/
/*****************************************/

abstract class subclass{
    protected
$masterClass;
    private
$masterClassCon;

    public function
__construct(&$masterClassCon = ''){
        if(
$masterClassCon != '') $this->masterClassCon = $masterClassCon;
    }

    public function
__call($function, $arguments){
       
$class = $this->getInstance();
        return
call_user_func_array(array(&$class, $function), $arguments);
    }

    public function &
__get($variable){
       
$class = $this->getInstance();
        return
$class->$variable;
    }

    public function
__set($variable, $value){
       
$class = $this->getInstance();
       
$class->$variable = $value;
    }

    private function &
getInstance(){
        if(isset(
$this->masterClassCon)) return $this->masterClassCon;
       
$this->masterClassCon = new $this->masterClass();
        return
$this->masterClassCon;
    }
}
?>