Show
Ignore:
Timestamp:
10/03/08 18:15:28 (6 years ago)
Author:
nowelium
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/php/misc/Hermit/src/Hermit/HermitParam.php

    r20492 r20612  
    55 */ 
    66class HermitParam extends stdClass { 
     7    private $__accessKeys__; 
     8    protected static function accessKeys(HermitParam $target){ 
     9        $ref = new ReflectionObject($target); 
     10        return array_flip($ref->getConstants()); 
     11    } 
     12    protected static function accessValue(HermitParam $target, $name){ 
     13        $target->checkAccessKey(); 
     14        if(isset($target->__accessKeys__[$name])){ 
     15            $name = preg_replace('/_KEY$/', '', $target->__accessKeys__[$name]); 
     16        } 
     17        return $name; 
     18    } 
     19    public function __init__(){ 
     20        $this->__accessKeys__ = self::accessKeys($this); 
     21    } 
     22    public function checkAccessKey(){ 
     23        if(null === $this->__accessKeys__){ 
     24            $this->__accessKeys__ = self::accessKeys($this); 
     25        } 
     26    } 
     27    public function issetValue($name){ 
     28        $name = self::accessValue($this, $name); 
     29        return isset($this->$name); 
     30    } 
    731    public function set($name, $value){ 
     32        $name = self::accessValue($this, $name); 
    833        $this->$name = $value; 
    934    } 
    1035    public function get($name){ 
     36        $name = self::accessValue($this, $name); 
    1137        return $this->$name; 
    1238    }