示例#1
0
 /**
  * This method is used to retrieve the first constant-name in a class that matches the value provided.
  *
  * @access public
  * @static
  * @param string $name                                      the name of the constant to return
  * @return integer                                          the value of the named constant
  *
  * @see http://stackoverflow.com/questions/1880148/how-to-get-name-of-the-constant
  */
 public static function valueOf($name)
 {
     if (static::$constants === null) {
         $class = new \ReflectionClass(__CLASS__);
         static::$constants = new Common\HashMap($class->getConstants());
     }
     return static::$constants->getValue($name);
 }
示例#2
0
 /**
  * This method logs any changes between the source and target objects.
  *
  * @access protected
  * @param Common\IMap $source                               the source object to be evaluated
  * @param Common\IMap $target                               the target object to be evaluated
  * @param string $path                                      the current path
  * @param Common\Mutable\IList $log                         a reference to the log
  */
 protected function compareMaps(Common\IMap $source, Common\IMap $target, $path, Common\Mutable\IList $log)
 {
     foreach ($source as $key => $source_value) {
         $new_path = static::buildPath($path, $key);
         if ($this->doLog($new_path)) {
             if ($target->hasKey($key)) {
                 $target_value = $target->getValue($key);
                 if ($source_value instanceof Common\IList && $target_value instanceof Common\IList) {
                     $this->compareLists($source_value, $target_value, $new_path, $log);
                 } else {
                     if ($source_value instanceof Common\IMap && $target_value instanceof Common\IMap) {
                         $this->compareMaps($source_value, $target_value, $new_path, $log);
                     } else {
                         $this->compareValues($source_value, $target_value, $new_path, $log);
                     }
                 }
             } else {
                 $log->addValue(array('body' => strtr('Target key ":key" is missing in map.', array(':key' => $key)), 'level' => Log\Level::warning()->__name(), 'path' => $new_path, 'time' => date('c')));
             }
         }
     }
 }