PHP Classes
Icontem

File: TypedStruct.class.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tom Schaefer  >  TypeSafeStruct  >  TypedStruct.class.php  
File: TypedStruct.class.php
Role: Class source
Content type: text/plain
Description: Base class
Class: TypeSafeStruct
Manipulate type safe objects
 

Contents

Class file image Download
<?php
/**
 * @author Thomas Schaefer
 * @mail scaphare@gmail.com
*/
class TypedStruct
{

    
private $activeClass "";

    
/**
     * TypedStructProperties
     * @var static array
     */
    
private static $TypedStructProperties = array();


    
/**
     * hasProperty
     *
     * @param string $k
     * @return bool
     *
     */
    
public function hasProperty($k) {
        
$r = new ReflectionClass($this);
        
$this->activeClass $r->name;
        if(!isset(
TypedStruct::$TypedStructProperties[$this->activeClass])){
            foreach(
$r->getProperties() as $p){
                
$a=substr($p->name,strpos($p->name,"_")+1);
                
$b=substr($p->name,0,strpos($p->name,"_"));
                if(
strlen($b)) TypedStruct::$TypedStructProperties[$this->activeClass][$a] = $b;
            }
        }
        return 
array_key_exists$kTypedStruct::$TypedStructProperties[$this->activeClass] );
    }


    
/**
     * getPropertyType
     *
     * @param string $k
     * @return string return type of object property type
     *
     */
    
public function getPropertyType($k) {

        if (!
array_key_exists$kTypedStruct::$TypedStructProperties[$this->activeClass] )) {
            return 
false;
        }
        return 
TypedStruct::$TypedStructProperties[$this->activeClass][$k];
    }


    
/**
     * getProperties
     * @desc used by SerializeTypedStruct
     * @return array
     */
    
public function getProperties(){
        return 
TypedStruct::$TypedStructProperties[$this->activeClass];
    }

    
protected function __set($key,$value) {
        
$this->{$key} = $value;
    }

    
protected function __get($key) {
        return 
$this->{$key};
    }

}

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products