當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MapUtils::IsMap方法代碼示例

本文整理匯總了PHP中MapUtils::IsMap方法的典型用法代碼示例。如果您正苦於以下問題:PHP MapUtils::IsMap方法的具體用法?PHP MapUtils::IsMap怎麽用?PHP MapUtils::IsMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MapUtils的用法示例。


在下文中一共展示了MapUtils::IsMap方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Create

 /**
  * Creates a new object of the given type, using the optional parameters.
  * When pseudo-namespace support is enabled class names can become very long,
  * and this function provides an alternative way to create objects that is
  * more readable.
  * @param string $type the type of object to create
  * @param array $params parameters to pass into the constructor, as either
  *     flat array in the correct order for the constructor or as an
  *     associative array from parameter name to value
  * @return mixed a new instance of a class that represents that type
  */
 public function Create($type, $params = null)
 {
     if (array_key_exists($type, $this->options['classmap'])) {
         $class = $this->options['classmap'][$type];
         $reflectionClass = new ReflectionClass($class);
         if (isset($params)) {
             if (MapUtils::IsMap($params)) {
                 $params = MapUtils::MapToMethodParameters($params, $reflectionClass->getConstructor());
             }
             return $reflectionClass->newInstanceArgs($params);
         } else {
             return $reflectionClass->newInstance();
         }
     } else {
         trigger_error('Unknown type: ' . $type, E_USER_ERROR);
     }
 }
開發者ID:a1pro,項目名稱:adwords_dashboard,代碼行數:28,代碼來源:AdsSoapClient.php

示例2: ConvertObjectToElement

 /**
  * Converts an object to an DOMElement.
  * @param Object $object the object to serialize
  * @param string $elementName the name of the element to serialize
  * @param DOMDocument $document the document that the element will be added to
  * @return DOMElement the element representing the object
  */
 private static function ConvertObjectToElement($object, $elementName, $document)
 {
     if (!isset($object)) {
         return null;
     }
     $element = $document->createElement($elementName);
     $children = array();
     if (is_array($object) && MapUtils::IsMap($object)) {
         $object = (object) $object;
     }
     if (is_object($object)) {
         foreach (get_object_vars($object) as $field => $value) {
             if (is_array($value) && !MapUtils::IsMap($value)) {
                 foreach ($value as $item) {
                     $children[] = self::ConvertObjectToElement($item, $field, $document);
                 }
             } else {
                 $children[] = self::ConvertObjectToElement($value, $field, $document);
             }
         }
         foreach ($children as $child) {
             if (isset($child)) {
                 $element->appendChild($child);
             }
         }
     } else {
         $element->nodeValue = self::ConvertObjectToNodeValue($object);
     }
     return $element;
 }
開發者ID:mikeytag,項目名稱:googleads-php-lib,代碼行數:37,代碼來源:XmlUtils.php

示例3: testIsMap

 /**
  * Test determining if an array is a map.
  * @param array $value the array to evaluate
  * @param bool $expected the expected result of IsMap()
  * @covers MapUtils::IsMap
  * @dataProvider IsMapProvider
  */
 public function testIsMap(array $value, $expected)
 {
     $result = MapUtils::IsMap($value);
     $this->assertEquals($expected, $result);
 }
開發者ID:sambavade,項目名稱:google-api-adwords-php,代碼行數:12,代碼來源:MapUtilsTest.php

示例4: CreateChildListForObjects

 /**
  * Creates an array of child elements for objects.
  * @param object $object the object whose properties will be serialized
  * @param DOMDocument $document the document being constructed
  * @param bool $useXsiType whether the xsi:type will be added into XML tags
  *     when available
  * @return array an array of child elements created from the specified object
  */
 private function CreateChildListForObjects($object, DOMDocument $document, $useXsiType)
 {
     $children = array();
     foreach (get_object_vars($object) as $field => $value) {
         if (is_array($value) && !MapUtils::IsMap($value)) {
             foreach ($value as $item) {
                 $children[] = self::ConvertObjectToElement($item, $field, $document, $useXsiType);
             }
         } else {
             $children[] = self::ConvertObjectToElement($value, $field, $document, $useXsiType);
         }
     }
     return $children;
 }
開發者ID:sonicgd,項目名稱:google-adwords-api-light,代碼行數:22,代碼來源:XmlSerializer.php


注:本文中的MapUtils::IsMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。