/** * Validates if properties is valid or not. * * @param mix $properties The properties array. * * @return none */ private function _validateProperties($properties) { Validate::isArray($properties, 'entity properties'); foreach ($properties as $key => $value) { Validate::isString($key, 'key'); Validate::isTrue($value instanceof Property, Resources::INVALID_PROP_MSG); Validate::isTrue(EdmType::validateEdmValue($value->getEdmType(), $value->getValue(), $condition), sprintf(Resources::INVALID_PROP_VAL_MSG, $key, $condition)); } }
/** * Creates BatchError object. * * @param MicrosoftAzure\Storage\Common\ServiceException $error The error object. * @param array $headers The response headers. * * @return \MicrosoftAzure\Storage\Table\Models\BatchError */ public static function create($error, $headers) { Validate::isTrue($error instanceof ServiceException, Resources::INVALID_EXC_OBJ_MSG); Validate::isArray($headers, 'headers'); $result = new BatchError(); $clean = array_change_key_case($headers); $result->setError($error); $contentId = Utilities::tryGetValue($clean, Resources::CONTENT_ID); $result->setContentId(is_null($contentId) ? null : intval($contentId)); return $result; }
/** * @covers MicrosoftAzure\Storage\Common\Internal\Validate::isArray */ public function testIsArrayWithNonArray() { $this->setExpectedException(get_class(new InvalidArgumentTypeException(''))); Validate::isArray(123, 'array'); }
/** * Adds optional header. * * Doesn't add the value if it satisfies empty(). * * @param array &$headers The HTTP header parameters. * @param string $key The HTTP header name. * @param string $value The HTTP header value. * * @return none */ protected function addOptionalHeader(&$headers, $key, $value) { Validate::isArray($headers, 'headers'); Validate::isString($key, 'key'); Validate::isString($value, 'value'); if (!is_null($value) && Resources::EMPTY_STRING !== $value) { $headers[$key] = $value; } }
/** * Validates the provided metadata array. * * @param mix $metadata The metadata array. * * @return none */ public function validateMetadata($metadata) { if (!is_null($metadata)) { Validate::isArray($metadata, 'metadata'); } else { $metadata = array(); } foreach ($metadata as $key => $value) { Validate::isString($key, 'metadata key'); Validate::isString($value, 'metadata value'); } }
/** * Serializes given array. The array indices must be string to use them as * as element name. * * @param array $array The object to serialize represented in array. * @param array $properties The used properties in the serialization process. * * @return string */ public function serialize($array, $properties = null) { Validate::isArray($array, 'array'); return json_encode($array); }
/** * Sets HTTP POST parameters. * * @param array $postParameters The HTTP POST parameters. * * @return none */ public function setPostParameters($postParameters) { Validate::isArray($postParameters, 'postParameters'); $this->_postParameters = $postParameters; }