| | 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 | } |