/** * Adds new entry to the block list entries. * * @param string $blockId The block id. * @param string $type The entry type, you can use BlobBlockType. * * @return none */ public function addEntry($blockId, $type) { Validate::isString($blockId, 'blockId'); Validate::isTrue(BlobBlockType::isValid($type), sprintf(Resources::INVALID_BTE_MSG, get_class(new BlobBlockType()))); $block = new Block(); $block->setBlockId($blockId); $block->setType($type); $this->_entries[] = $block; }
/** * 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)); } }
/** * Unserializes given serialized string to array. * * @param string $serialized The serialized object in string representation. * * @return array */ public function unserialize($serialized) { Validate::isString($serialized, 'serialized'); $json = json_decode($serialized); if ($json && !is_array($json)) { return get_object_vars($json); } else { return $json; } }
/** * Fill storage account from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['IsDefault'])) { Validate::isBoolean($options['IsDefault'], 'options[IsDefault]'); $this->_isDefault = $options['IsDefault']; } }
/** * Fill ChannelSlate from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['InsertSlateOnAdMarker'])) { Validate::isBoolean($options['InsertSlateOnAdMarker'], 'options[InsertSlateOnAdMarker]'); $this->_insertSlateOnAdMarker = (bool) $options['InsertSlateOnAdMarker']; } if (isset($options['DefaultSlateAssetId'])) { Validate::isString($options['DefaultSlateAssetId'], 'options[DefaultSlateAssetIdUrl]'); $this->_defaultSlateAssetId = $options['DefaultSlateAssetId']; } }
/** * Fill error detail from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Code'])) { Validate::isInteger($options['Code'], 'options[Code]'); $this->_code = $options['Code']; } if (isset($options['Message'])) { Validate::isString($options['Message'], 'options[Message]'); $this->_message = $options['Message']; } }
/** * Fill ContentKeyAuthorizationPolicy from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } }
/** * Fill CrossSiteAccessPolicies from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['ClientAccessPolicy'])) { Validate::isString($options['ClientAccessPolicy'], 'options[ClientAccessPolicy]'); $this->_clientAccessPolicy = $options['ClientAccessPolicy']; } if (isset($options['CrossDomainPolicy'])) { Validate::isString($options['CrossDomainPolicy'], 'options[CrossDomainPolicy]'); $this->_crossDomainPolicy = $options['CrossDomainPolicy']; } }
/** * Fill ChannelEndpoint from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['Protocol'])) { Validate::isString($options['Protocol'], 'options[Protocol]'); $this->_protocol = $options['Protocol']; } if (isset($options['Url'])) { Validate::isString($options['Url'], 'options[Url]'); $this->_url = $options['Url']; } }
/** * Creates an RuleInfo with specified parameters. * * @param string $title The title of the rule. * @param RuleDescription $ruleDescription The description of the rule. */ public function __construct($title = Resources::EMPTY_STRING, $ruleDescription = null) { Validate::isString($title, 'title'); if (is_null($ruleDescription)) { $ruleDescription = new RuleDescription(); } $this->_ruleDescription = $ruleDescription; $this->_entry = new Entry(); $this->_entry->setTitle($title); $this->_entry->setAttribute(Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE); }
/** * Constructor. * * @param string $accountName account name. * @param string $accountKey account * secondary key. * @param string $grantType grant type * for OAuth request. * @param string $scope scope for * OAurh request. * @param WindowsAzure\Common\Internal\OAuthRestProxy $oauthService account * primary or secondary key. */ public function __construct($accountName, $accountKey, $grantType, $scope, $oauthService) { Validate::isString($accountName, 'accountName'); Validate::isString($accountKey, 'accountKey'); Validate::isString($grantType, 'grantType'); Validate::isString($scope, 'scope'); Validate::notNull($oauthService, 'oauthService'); $this->accountName = $accountName; $this->accountKey = $accountKey; $this->grantType = $grantType; $this->scope = $scope; $this->oauthService = $oauthService; }
/** * Creates an ATOM CONTENT instance with specified xml string. * * @param string $xmlString an XML based string of ATOM CONTENT. * * @return none */ public function parseXml($xmlString) { Validate::notNull($xmlString, 'xmlString'); Validate::isString($xmlString, 'xmlString'); $contentXml = simplexml_load_string($xmlString); Validate::notNull($contentXml, 'contentXml'); $attributes = $contentXml->attributes(); if (!empty($attributes['type'])) { $this->content = (string) $attributes['type']; } $text = ''; foreach ($contentXml->children() as $child) { $text .= $child->asXML(); } $this->text = $text; }
/** * Sets max results. * * @param string $maxResults value. * * @return none. */ public function setMaxResults($maxResults) { Validate::isString($maxResults, 'maxResults'); $this->_maxResults = $maxResults; }
/** * Deletes a queue. * * @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780747 * * @param string $queuePath The path of the queue. * * @return none */ public function deleteQueue($queuePath) { Validate::isString($queuePath, 'queuePath'); Validate::notNullOrEmpty($queuePath, 'queuePath'); $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_DELETE); $httpCallContext->addStatusCode(Resources::STATUS_OK); $httpCallContext->setPath($queuePath); $this->sendContext($httpCallContext); }
/** * Creates new media services settings instance. * * @param string $accountName The user provided account name. * @param string $accessKey The user provided primary access key * @param string $endpointUri The service management endpoint uri. * @param string $oauthEndpointUri The OAuth service endpoint uri. */ public function __construct($accountName, $accessKey, $endpointUri = null, $oauthEndpointUri = null) { Validate::notNullOrEmpty($accountName, 'accountName'); Validate::notNullOrEmpty($accessKey, 'accountKey'); Validate::isString($accountName, 'accountName'); Validate::isString($accessKey, 'accountKey'); if ($endpointUri != null) { Validate::isValidUri($endpointUri); } else { $endpointUri = Resources::MEDIA_SERVICES_URL; } if ($oauthEndpointUri != null) { Validate::isValidUri($oauthEndpointUri); } else { $oauthEndpointUri = Resources::MEDIA_SERVICES_OAUTH_URL; } $this->_accountName = $accountName; $this->_accessKey = $accessKey; $this->_endpointUri = $endpointUri; $this->_oauthEndpointUri = $oauthEndpointUri; }
/** * Unregisters a connection string source. * * @param string $name The source name. * * @return callable */ public static function unregisterSource($name) { Validate::isString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); self::_init(); $sourceCallback = Utilities::tryGetValue(self::$_sources, $name); if (!is_null($sourceCallback)) { unset(self::$_sources[$name]); } return $sourceCallback; }
/** * Fill locator from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['ExpirationDateTime'])) { Validate::isDateString($options['ExpirationDateTime'], 'options[ExpirationDateTime]'); $this->_expirationDateTime = new \DateTime($options['ExpirationDateTime']); } if (isset($options['Type'])) { Validate::isInteger($options['Type'], 'options[Type]'); $this->_type = $options['Type']; } if (isset($options['Path'])) { Validate::isValidUri($options['Path'], 'options[Path]'); $this->_path = $options['Path']; } if (isset($options['BaseUri'])) { Validate::isValidUri($options['BaseUri'], 'options[BaseUri]'); $this->_baseUri = $options['BaseUri']; } if (isset($options['ContentAccessComponent'])) { Validate::isString($options['ContentAccessComponent'], 'options[ContentAccessComponent]'); $this->_contentAccessComponent = $options['ContentAccessComponent']; } if (isset($options['AccessPolicyId'])) { Validate::isString($options['AccessPolicyId'], 'options[AccessPolicyId]'); $this->_accessPolicyId = $options['AccessPolicyId']; } if (isset($options['AssetId'])) { Validate::isString($options['AssetId'], 'options[AssetId]'); $this->_assetId = $options['AssetId']; } if (isset($options['StartTime'])) { Validate::isDateString($options['StartTime'], 'options[StartTime]'); $this->_startTime = new \DateTime($options['StartTime']); } }
/** * Sets the value of a custom property. * * @param string $propertyName The name of the property. * @param mixed $propertyValue The value of the property. * * @return none */ public function setProperty($propertyName, $propertyValue) { Validate::isString($propertyName, 'propertyName'); Validate::notNull($propertyValue, 'propertyValue'); $this->_customProperties[strtolower($propertyName)] = $propertyValue; }
/** * Sets blob etag. * * @param string $etag value. * * @return none. */ public function setETag($etag) { Validate::isString($etag, 'etag'); $this->_etag = $etag; }
/** * @covers WindowsAzure\Common\Internal\Validate::isString */ public function testIsStringWithNonString() { $this->setExpectedException(get_class(new InvalidArgumentTypeException(''))); Validate::isString(new \DateTime(), 'string'); }
/** * Validate if string is date formatted * * @param string $value Value to validate * @param string $name Name of parameter to insert in erro message * * @throws \InvalidArgumentException * * @return boolean */ public static function isDateString($value, $name) { Validate::isString($value, 'value'); try { new \DateTime($value); return true; } catch (\Exception $e) { throw new \InvalidArgumentException(sprintf(Resources::ERROR_INVALID_DATE_STRING, $name, $value)); } }
/** * Sets the deployment name. * * @param string $deploymentName The deployment name. * * @return none */ public function setDeploymentName($deploymentName) { Validate::isString($deploymentName, 'deploymentName'); Validate::notNullOrEmpty($deploymentName, 'deploymentName'); $this->_deploymentName = $deploymentName; }
/** * Fill contentKey from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Created'])) { Validate::isDateString($options['Created'], 'options[Created]'); $this->_created = new \DateTime($options['Created']); } if (isset($options['LastModified'])) { Validate::isDateString($options['LastModified'], 'options[LastModified]'); $this->_lastModified = new \DateTime($options['LastModified']); } if (isset($options['ContentKeyType'])) { Validate::isInteger($options['ContentKeyType'], 'options[ContentKeyType]'); $this->_contentKeyType = $options['ContentKeyType']; } if (isset($options['EncryptedContentKey'])) { Validate::isString($options['EncryptedContentKey'], 'options[EncryptedContentKey]'); $this->_encryptedContentKey = $options['EncryptedContentKey']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['ProtectionKeyId'])) { Validate::isString($options['ProtectionKeyId'], 'options[ProtectionKeyId]'); $this->_protectionKeyId = $options['ProtectionKeyId']; } if (isset($options['ProtectionKeyType'])) { Validate::isInteger($options['ProtectionKeyType'], 'options[ProtectionKeyType]'); $this->_protectionKeyType = $options['ProtectionKeyType']; } if (isset($options['Checksum'])) { Validate::isString($options['Checksum'], 'options[Checksum]'); $this->_checksum = $options['Checksum']; } }
/** * Fill Encoding from array. * * @param array $options Array containing values for object properties */ public function fromArray($options) { if (isset($options['AdMarkerSource'])) { Validate::isString($options['AdMarkerSource'], 'options[AdMarkerSource]'); $this->_adMarkerSource = $options['AdMarkerSource']; } if (isset($options['IgnoreCea708ClosedCaptions'])) { Validate::isString($options['IgnoreCea708ClosedCaptions'], 'options[IgnoreCea708ClosedCaptions]'); $this->_ignoreCea708ClosedCaptions = (bool) $options['IgnoreCea708ClosedCaptions']; } if (!empty($options['VideoStreams'])) { Validate::isArray($options['VideoStreams'], 'options[VideoStreams]'); foreach ($options['VideoStreams'] as $videoStream) { $this->_videoStreams[] = VideoStream::createFromOptions($videoStream); } } if (!empty($options['AudioStreams'])) { Validate::isArray($options['AudioStreams'], 'options[AudioStreams]'); foreach ($options['AudioStreams'] as $audioStream) { $this->_audioStreams[] = AudioStream::createFromOptions($audioStream); } } if (isset($options['SystemPreset'])) { Validate::isString($options['SystemPreset'], 'options[SystemPreset]'); $this->_systemPreset = $options['SystemPreset']; } }
/** * Fill task historical event from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Code'])) { Validate::isInteger($options['Code'], 'options[Code]'); $this->_code = $options['Code']; } if (isset($options['Message'])) { Validate::isString($options['Message'], 'options[Message]'); $this->_message = $options['Message']; } if (isset($options['TimeStamp'])) { Validate::isDateString($options['TimeStamp'], 'options[TimeStamp]'); $this->_timeStamp = new \DateTime($options['TimeStamp']); } }
/** * Parse an ATOM Link xml. * * @param string $xmlString an XML based string of ATOM Link. * * @return none */ public function parseXml($xmlString) { Validate::notNull($xmlString, 'xmlString'); Validate::isString($xmlString, 'xmlString'); $atomLinkXml = simplexml_load_string($xmlString); $attributes = $atomLinkXml->attributes(); if (!empty($attributes['href'])) { $this->href = (string) $attributes['href']; } if (!empty($attributes['rel'])) { $this->rel = (string) $attributes['rel']; } if (!empty($attributes['type'])) { $this->type = (string) $attributes['type']; } if (!empty($attributes['hreflang'])) { $this->hreflang = (string) $attributes['hreflang']; } if (!empty($attributes['title'])) { $this->title = (string) $attributes['title']; } if (!empty($attributes['length'])) { $this->length = (int) $attributes['length']; } $undefinedContent = (string) $atomLinkXml; if (empty($undefinedContent)) { $this->undefinedContent = null; } else { $this->undefinedContent = (string) $atomLinkXml; } }
/** * Adds or sets query parameter pair. * * Ignores query parameter if it's value satisfies empty(). * * @param string $name The URI query parameter name. * @param mix $value The URI query parameter value. * * @return none */ public function addOptionalQueryParameter($name, $value) { Validate::isString($name, 'name'); Validate::isString($value, 'value'); if (!empty($value)) { $this->_queryParams[$name] = $value; } }
/** * Sets the description. * * @param string $description The description. * * @return none */ public function setDescription($description) { Validate::isString($description, 'description'); $this->_description = $description; }
/** * Fill asset file from array * * @param array $options Array containing values for object properties * * @return none */ public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['ContentFileSize'])) { Validate::isString($options['ContentFileSize'], 'options[ContentFileSize]'); $this->_contentFileSize = $options['ContentFileSize']; } if (isset($options['ParentAssetId'])) { Validate::isString($options['ParentAssetId'], 'options[ParentAssetId]'); $this->_parentAssetId = $options['ParentAssetId']; } if (isset($options['EncryptionVersion'])) { Validate::isString($options['EncryptionVersion'], 'options[EncryptionVersion]'); $this->_encryptionVersion = $options['EncryptionVersion']; } if (isset($options['EncryptionScheme'])) { Validate::isString($options['EncryptionScheme'], 'options[EncryptionScheme]'); $this->_encryptionScheme = $options['EncryptionScheme']; } if (isset($options['IsEncrypted'])) { Validate::isBoolean($options['IsEncrypted'], 'options[IsEncrypted]'); $this->_isEncrypted = $options['IsEncrypted']; } if (isset($options['EncryptionKeyId'])) { Validate::isString($options['EncryptionKeyId'], 'options[EncryptionKeyId]'); $this->_encryptionKeyId = $options['EncryptionKeyId']; } if (isset($options['InitializationVector'])) { Validate::isString($options['InitializationVector'], 'options[InitializationVector]'); $this->_initializationVector = $options['InitializationVector']; } if (isset($options['IsPrimary'])) { Validate::isBoolean($options['IsPrimary'], 'options[IsPrimary]'); $this->_isPrimary = $options['IsPrimary']; } if (isset($options['LastModified'])) { Validate::isDateString($options['LastModified'], 'options[LastModified]'); $this->_lastModified = new \DateTime($options['LastModified']); } if (isset($options['Created'])) { Validate::isDateString($options['Created'], 'options[Created]'); $this->_created = new \DateTime($options['Created']); } if (isset($options['MimeType'])) { Validate::isString($options['MimeType'], 'options[MimeType]'); $this->_mimeType = $options['MimeType']; } if (isset($options['ContentChecksum'])) { Validate::isString($options['ContentChecksum'], 'options[ContentChecksum]'); $this->_contentCheckSum = $options['ContentChecksum']; } }
/** * Retrieve the specific X.509 certificate that should be used to encrypt your * user-defined content key * * @param string $protectionKeyId ProtectionKey id * * @return string */ public function getProtectionKey($protectionKeyId) { Validate::isString($protectionKeyId, 'protectionKeyId'); $method = Resources::HTTP_GET; $path = "GetProtectionKey?ProtectionKeyId='{$protectionKeyId}'"; $headers = array(); $postParams = array(); $queryParams = array(); $statusCode = Resources::STATUS_OK; $response = $this->send($method, $headers, $postParams, $queryParams, $path, $statusCode); $encoded = (string) simplexml_load_string($response->getBody()); $encoded = implode("\n", str_split($encoded, 76)); $encoded = "-----BEGIN CERTIFICATE-----\n" . $encoded; $encoded .= "\n-----END CERTIFICATE-----"; return $encoded; }