本文整理汇总了PHP中Configuration::getDefaultConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::getDefaultConfiguration方法的具体用法?PHP Configuration::getDefaultConfiguration怎么用?PHP Configuration::getDefaultConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration::getDefaultConfiguration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor of the class
*
* @param Configuration $config config for this ApiClient
*/
public function __construct(\Squiggle\Configuration $config = null)
{
if ($config === null) {
$config = Configuration::getDefaultConfiguration();
}
$this->config = $config;
$this->serializer = new ObjectSerializer();
}
示例2: __construct
/**
* Constructor of the class
*
* @param Configuration $config config for this ApiClient
*/
public function __construct(\QuantiModo\Client\Configuration $config = null)
{
if ($config === null) {
$config = Configuration::getDefaultConfiguration();
}
$this->config = $config;
$this->serializer = new ObjectSerializer();
}
示例3: deserialize
/**
* Deserialize a JSON string into an object
*
* @param mixed $data object or primitive to be deserialized
* @param string $class class name is passed as a string
* @param string $httpHeader HTTP headers
*
* @return object an instance of $class
*/
public function deserialize($data, $class, $httpHeader = null)
{
if (null === $data) {
$deserialized = null;
} elseif (substr($class, 0, 4) === 'map[') {
// for associative array e.g. map[string,int]
$inner = substr($class, 4, -1);
$deserialized = array();
if (strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = $this->deserialize($value, $subClass);
}
}
} elseif (strcasecmp(substr($class, -2), '[]') == 0) {
$subClass = substr($class, 0, -2);
$values = array();
foreach ($data as $key => $value) {
$values[] = $this->deserialize($value, $subClass);
}
$deserialized = $values;
} elseif ($class === '\\DateTime') {
$deserialized = new \DateTime($data);
} elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
settype($data, $class);
$deserialized = $data;
} elseif ($class === '\\SplFileObject') {
// determine file name
if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\\s]+)[\'"]?$/i', $httpHeader, $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . $match[1];
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
error_log("[INFO] Written {$byte_written} byte to {$filename}. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile());
} else {
$instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) {
$propertySetter = $instance::$setters[$property];
if (!isset($propertySetter) || !isset($data->{$instance::$attributeMap[$property]})) {
continue;
}
$propertyValue = $data->{$instance::$attributeMap[$property]};
if (isset($propertyValue)) {
$instance->{$propertySetter}($this->deserialize($propertyValue, $type));
}
}
$deserialized = $instance;
}
return $deserialized;
}
示例4: deserialize
/**
* Deserialize a JSON string into an object
*
* @param mixed $data object or primitive to be deserialized
* @param string $class class name is passed as a string
* @param string $httpHeaders HTTP headers
* @param string $discriminator discriminator if polymorphism is used
*
* @return object an instance of $class
*/
public static function deserialize($data, $class, $httpHeaders = null, $discriminator = null)
{
if (null === $data) {
return null;
} elseif (substr($class, 0, 4) === 'map[') {
// for associative array e.g. map[string,int]
$inner = substr($class, 4, -1);
$deserialized = array();
if (strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass, null, $discriminator);
}
}
return $deserialized;
} elseif (strcasecmp(substr($class, -2), '[]') == 0) {
$subClass = substr($class, 0, -2);
$values = array();
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass, null, $discriminator);
}
return $values;
} elseif ($class === 'object') {
settype($data, 'array');
return $data;
} elseif ($class === '\\DateTime') {
// Some API's return an invalid, empty string as a
// date-time property. DateTime::__construct() will return
// the current time for empty input which is probably not
// what is meant. The invalid empty string is probably to
// be interpreted as a missing field/value. Let's handle
// this graceful.
if (!empty($data)) {
return new \DateTime($data);
} else {
return null;
}
} elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
settype($data, $class);
return $data;
} elseif ($class === '\\SplFileObject') {
// determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . sanitizeFilename($match[1]);
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
if (Configuration::getDefaultConfiguration()->getDebug()) {
error_log("[DEBUG] Written {$byte_written} byte to {$filename}. Please move the file to a proper folder or delete the temp file after processing." . PHP_EOL, 3, Configuration::getDefaultConfiguration()->getDebugFile());
}
return $deserialized;
} else {
// If a discriminator is defined and points to a valid subclass, use it.
if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
$subclass = '\\Swagger\\Client\\Model\\' . $data->{$discriminator};
if (is_subclass_of($subclass, $class)) {
$class = $subclass;
}
}
$instance = new $class();
foreach ($instance::swaggerTypes() as $property => $type) {
$propertySetter = $instance::setters()[$property];
if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) {
continue;
}
$propertyValue = $data->{$instance::attributeMap()[$property]};
if (isset($propertyValue)) {
$instance->{$propertySetter}(self::deserialize($propertyValue, $type, null, $discriminator));
}
}
return $instance;
}
}