iteritems() публичный Метод

public iteritems ( )
Пример #1
0
 function test_iteration()
 {
     $nsm = new Auth_OpenID_NamespaceMap();
     $uripat = 'http://example.com/foo%d';
     $nsm->add(sprintf($uripat, 0));
     for ($n = 1; $n < 23; $n++) {
         $this->assertTrue($nsm->contains(sprintf($uripat, $n - 1)));
         $this->assertTrue($nsm->isDefined(sprintf($uripat, $n - 1)));
         $nsm->add(sprintf($uripat, $n));
     }
     foreach ($nsm->iteritems() as $pair) {
         list($uri, $alias) = $pair;
         $this->assertTrue('ext' . substr($uri, 22) == $alias);
     }
     $it = $nsm->iterAliases();
     $this->assertTrue(count($it) == 23);
     $it = $nsm->iterNamespaceURIs();
     $this->assertTrue(count($it) == 23);
 }
Пример #2
0
 /**
  * Parse attribute exchange key/value arguments into this object.
  *
  * @param ax_args: The attribute exchange fetch_response
  * arguments, with namespacing removed.
  *
  * @return Auth_OpenID_AX_Error or true
  */
 function parseExtensionArgs($ax_args)
 {
     $result = $this->_checkMode($ax_args);
     if (Auth_OpenID_AX::isError($result)) {
         return $result;
     }
     $aliases = new Auth_OpenID_NamespaceMap();
     foreach ($ax_args as $key => $value) {
         if (strpos($key, 'type.') === 0) {
             $type_uri = $value;
             $alias = substr($key, 5);
             $result = Auth_OpenID_AX_checkAlias($alias);
             if (Auth_OpenID_AX::isError($result)) {
                 return $result;
             }
             $alias = $aliases->addAlias($type_uri, $alias);
             if ($alias === null) {
                 return new Auth_OpenID_AX_Error(sprintf("Could not add alias %s for URI %s", $alias, $type_uri));
             }
         }
     }
     foreach ($aliases->iteritems() as $pair) {
         list($type_uri, $alias) = $pair;
         if (array_key_exists('count.' . $alias, $ax_args)) {
             $count_key = 'count.' . $alias;
             $count_s = $ax_args[$count_key];
             $count = Auth_OpenID::intval($count_s);
             if ($count === false) {
                 return new Auth_OpenID_AX_Error(sprintf("Integer value expected for %s, got %s", 'count. %s' . $alias, $count_s, Auth_OpenID_AX_UNLIMITED_VALUES));
             }
             $values = array();
             for ($i = 1; $i < $count + 1; $i++) {
                 $value_key = sprintf('value.%s.%d', $alias, $i);
                 if (!array_key_exists($value_key, $ax_args)) {
                     return new Auth_OpenID_AX_Error(sprintf("No value found for key %s", $value_key));
                 }
                 $value = $ax_args[$value_key];
                 $values[] = $value;
             }
         } else {
             $key = 'value.' . $alias;
             if (!array_key_exists($key, $ax_args)) {
                 return new Auth_OpenID_AX_Error(sprintf("No value found for key %s", $key));
             }
             $value = $ax_args['value.' . $alias];
             if ($value == '') {
                 $values = array();
             } else {
                 $values = array($value);
             }
         }
         $this->data[$type_uri] = $values;
     }
     return true;
 }