Absent materials from Matt Zandstra book "PHP 5 Objects, Patterns, and Practice"


File:listing09.04a.php


<?php


class Preferences {
    private
$props = array();
    private static
$instance;

    private function
__construct() { }

    public static function
setInstance() {
        if ( empty(
self::$instance ) ) {
            
self::$instance = new Preferences();
        }
        return
self::$instance;
    }

    public function
setProperty( $key, $val ) {
        
$this->props[$key] = $val;
    }

    public function
getProperty( $key ) {
        return
$this->props[$key];
    }
}

?>