/**
  * Fill ChannelOutput from array.
  *
  * @param array $options Array containing values for object properties
  */
 public function fromArray($options)
 {
     if (isset($options['Hls'])) {
         Validate::isArray($options['Hls'], 'options[Hls]');
         $this->_hls = ChannelOutputHls::createFromOptions($options['Hls']);
     }
 }
 /**
  * Fill ChannelPreviewAccessControl from array.
  *
  * @param array $options Array containing values for object properties
  */
 public function fromArray($options)
 {
     if (!empty($options['IP'])) {
         Validate::isArray($options['IP'], 'options[IP]');
         $this->_ip = IPAccessControl::createFromOptions($options['IP']);
     }
 }
 /**
  * Fill IPRange from array.
  *
  * @param array $options Array containing values for object properties
  */
 public function fromArray($options)
 {
     if (isset($options['Allow'])) {
         Validate::isArray($options['Allow'], 'options[Allow]');
         foreach ($options['Allow'] as $allow) {
             $this->_allow[] = IPRange::createFromOptions($allow);
         }
     }
 }
Beispiel #4
0
 /**
  * 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));
     }
 }
Beispiel #5
0
 /**
  * Creates BatchError object.
  * 
  * @param WindowsAzure\Common\ServiceException $error   The error object.
  * @param array                                $headers The response headers.
  * 
  * @return \WindowsAzure\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;
 }
Beispiel #6
0
 /**
  * Constructor
  * 
  * @param string $name      The role name.
  * @param array  $instances The role instances.
  */
 public function __construct($name, $instances)
 {
     Validate::isArray($instances, 'instances');
     $this->_name = $name;
     $this->_instances = $instances;
 }
Beispiel #7
0
 /**
  * Sets a DateTime value in an array. 
  *
  * @param array     &$valueArray The array of a set of values. 
  * @param string    $key         The key of the key value pair. 
  * @param \DateTime $value       The value of the key value pair. 
  * 
  * @return none
  */
 public function setValueArrayDateTime(&$valueArray, $key, $value)
 {
     Validate::isArray($valueArray, 'valueArray');
     Validate::isString($key, 'key');
     if (!empty($value)) {
         Validate::isDate($value, 'value');
         $valueArray[$key] = gmdate(Resources::AZURE_DATE_FORMAT, $value->getTimestamp());
     }
 }
Beispiel #8
0
 /**
  * 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;
     }
 }
Beispiel #9
0
 /**
  * Processes author node.
  *
  * @param array $xmlWriter   The XML writer.
  * @param array $itemArray   An array of item to write.
  * @param array $elementName The name of the element.
  *
  * @return array
  */
 protected function writeArrayItem($xmlWriter, $itemArray, $elementName)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     Validate::isArray($itemArray, 'itemArray');
     Validate::isString($elementName, 'elementName');
     foreach ($itemArray as $itemInstance) {
         $xmlWriter->startElementNS('atom', $elementName, Resources::ATOM_NAMESPACE);
         $itemInstance->writeInnerXml($xmlWriter);
         $xmlWriter->endElement();
     }
 }
 /**
  * Fill ChannelInput from array.
  *
  * @param array $options Array containing values for object properties
  */
 public function fromArray($options)
 {
     if (!empty($options['KeyFrameInterval'])) {
         Validate::isString($options['KeyFrameInterval'], 'options[KeyFrameInterval]');
         $this->_keyFrameInterval = $options['KeyFrameInterval'];
     }
     if (isset($options['StreamingProtocol'])) {
         Validate::isString($options['StreamingProtocol'], 'options[StreamingProtocol]');
         $this->_streamingProtocol = $options['StreamingProtocol'];
     }
     if (isset($options['AccessControl'])) {
         Validate::isArray($options['AccessControl'], 'options[AccessControl]');
         $this->_accessControl = ChannelInputAccessControl::createFromOptions($options['AccessControl']);
     }
     if (!empty($options['Endpoints'])) {
         Validate::isArray($options['Endpoints'], 'options[Endpoints]');
         foreach ($options['Endpoints'] as $endpoint) {
             $this->_endpoints[] = ChannelEndpoint::createFromOptions($endpoint);
         }
     }
 }
 /**
  * @covers WindowsAzure\Common\Internal\Validate::isArray
  */
 public function testIsArrayWithNonArray()
 {
     $this->setExpectedException(get_class(new InvalidArgumentTypeException('')));
     Validate::isArray(123, 'array');
 }
Beispiel #12
0
 /**
  * Sets the link of the feed. 
  * 
  * @param array $link The link of the feed. 
  * 
  * @return none
  */
 public function setLink($link)
 {
     Validate::isArray($link, 'link');
     $this->link = $link;
 }
 /**
  * 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');
     }
 }
 /**
  * Fill Channel 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'];
     }
     if (isset($options['Created'])) {
         Validate::isDateString($options['Created'], 'options[Created]');
         $this->_created = new \DateTime($options['Created']);
     }
     if (isset($options['Description'])) {
         Validate::isString($options['Description'], 'options[Description]');
         $this->_description = $options['Description'];
     }
     if (isset($options['LastModified'])) {
         Validate::isDateString($options['LastModified'], 'options[LastModified]');
         $this->_lastModified = new \DateTime($options['LastModified']);
     }
     if (isset($options['State'])) {
         Validate::isString($options['State'], 'options[State]');
         $this->_state = $options['State'];
     }
     if (!empty($options['Input'])) {
         Validate::isArray($options['Input'], 'options[Input]');
         $this->_input = ChannelInput::createFromOptions($options['Input']);
     }
     if (!empty($options['Output'])) {
         Validate::isArray($options['Output'], 'options[Output]');
         $this->_output = ChannelOutput::createFromOptions($options['Output']);
     }
     if (!empty($options['Preview'])) {
         Validate::isArray($options['Preview'], 'options[Preview]');
         $this->_preview = ChannelPreview::createFromOptions($options['Preview']);
     }
     if (!empty($options['CrossSiteAccessPolicies'])) {
         Validate::isArray($options['CrossSiteAccessPolicies'], 'options[CrossSiteAccessPolicies]');
         $this->_crossSiteAccessPolicies = CrossSiteAccessPolicies::createFromOptions($options['CrossSiteAccessPolicies']);
     }
     if (isset($options['EncodingType'])) {
         Validate::isString($options['EncodingType'], 'options[EncodingType]');
         $this->_encodingType = $options['EncodingType'];
     }
     if (!empty($options['Encoding'])) {
         Validate::isArray($options['Encoding'], 'options[Encoding]');
         $this->_encoding = ChannelEncoding::createFromOptions($options['Encoding']);
     }
     if (!empty($options['Slate'])) {
         Validate::isArray($options['Slate'], 'options[Slate]');
         $this->_slate = ChannelSlate::createFromOptions($options['Slate']);
     }
 }
 /**
  * Fill ContentKeyAuthorizationPolicyOption from array
  *
  * @param array $options Array containing values for object properties
  *
  * @return void
  */
 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['KeyDeliveryType'])) {
         Validate::isInteger($options['KeyDeliveryType'], 'options[KeyDeliveryType]');
         $this->_keyDeliveryType = $options['KeyDeliveryType'];
     }
     if (isset($options['KeyDeliveryConfiguration'])) {
         Validate::isString($options['KeyDeliveryConfiguration'], 'options[KeyDeliveryConfiguration]');
         $this->_keyDeliveryConfiguration = $options['KeyDeliveryConfiguration'];
     }
     if (!empty($options['Restrictions'])) {
         Validate::isArray($options['Restrictions'], 'options[Restrictions]');
         foreach ($options['Restrictions'] as $restriction) {
             $this->_restrictions[] = ContentKeyAuthorizationPolicyRestriction::createFromOptions($restriction);
         }
     }
 }
 /**
  * Create a job.
  *
  * @param WindowsAzure\MediaServices\Models\JobTemplate $jobTemplate   Job
  * template data
  *
  * @param array                                         $taskTemplates Performed
  * tasks template array
  *
  * @return Models\JobTemplate
  */
 public function createJobTemplate($jobTemplate, $taskTemplates)
 {
     Validate::isA($jobTemplate, 'WindowsAzure\\MediaServices\\Models\\JobTemplate', 'jobTemplate');
     Validate::isArray($taskTemplates, 'taskTemplates');
     $batch = new BatchRequest();
     $batch->appendContext($this->_getCreateEmptyJobTemplateContext($jobTemplate));
     if ($taskTemplates != null) {
         foreach ($taskTemplates as $taskTemplate) {
             $batch->appendContext($this->_getCreateTaskTemplateContext($taskTemplate));
         }
     }
     $batch->encode();
     $method = Resources::HTTP_POST;
     $headers = $batch->getHeaders();
     $postParams = array();
     $queryParams = array();
     $path = '$batch';
     $statusCode = Resources::STATUS_ACCEPTED;
     $body = $batch->getBody();
     $response = $this->send($method, $headers, $postParams, $queryParams, $path, $statusCode, $body);
     $batchResponse = new BatchResponse($response->getBody(), $batch);
     $responses = $batchResponse->getContexts();
     $jobTemplateResponse = $responses[0];
     $entry = new Entry();
     $entry->parseXml($jobTemplateResponse->getBody());
     $properties = $this->getPropertiesFromAtomEntry($entry);
     return JobTemplate::createFromOptions($properties);
 }
 /**
  * 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);
 }
 /**
  * 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'];
     }
 }
 /** 
  * Writes a inner XML representing the source object.
  * 
  * @param \XMLWriter $xmlWriter The XML writer.
  * 
  * @return none
  */
 public function writeInnerXml($xmlWriter)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     if (!is_null($this->attributes)) {
         if (is_array($this->attributes)) {
             foreach ($this->attributes as $attributeName => $attributeValue) {
                 $xmlWriter->writeAttribute($attributeName, $attributeValue);
             }
         }
     }
     if (!is_null($this->author)) {
         Validate::isArray($this->author, Resources::AUTHOR);
         $this->writeArrayItem($xmlWriter, $this->author, Resources::AUTHOR);
     }
     if (!is_null($this->category)) {
         Validate::isArray($this->category, Resources::CATEGORY);
         $this->writeArrayItem($xmlWriter, $this->category, Resources::CATEGORY);
     }
     if (!is_null($this->contributor)) {
         Validate::isArray($this->contributor, Resources::CONTRIBUTOR);
         $this->writeArrayItem($xmlWriter, $this->contributor, Resources::CONTRIBUTOR);
     }
     if (!is_null($this->generator)) {
         $this->generator->writeXml($xmlWriter);
     }
     if (!is_null($this->icon)) {
         $xmlWriter->writeElementNS('atom', 'icon', Resources::ATOM_NAMESPACE, $this->icon);
     }
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'logo', Resources::ATOM_NAMESPACE, $this->logo);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'id', Resources::ATOM_NAMESPACE, $this->id);
     if (!is_null($this->link)) {
         Validate::isArray($this->link, Resources::LINK);
         $this->writeArrayItem($xmlWriter, $this->link, Resources::LINK);
     }
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'rights', Resources::ATOM_NAMESPACE, $this->rights);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'subtitle', Resources::ATOM_NAMESPACE, $this->subtitle);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'title', Resources::ATOM_NAMESPACE, $this->title);
     if (!is_null($this->updated)) {
         $xmlWriter->writeElementNS('atom', 'updated', Resources::ATOM_NAMESPACE, $this->updated->format(\DateTime::ATOM));
     }
 }
 /** 
  * Sets HTTP POST parameters.
  * 
  * @param array $postParameters The HTTP POST parameters.
  * 
  * @return none
  */
 public function setPostParameters($postParameters)
 {
     Validate::isArray($postParameters, 'postParameters');
     $this->_postParameters = $postParameters;
 }
 /**
  * Fill ChannelPreview from array.
  *
  * @param array $options Array containing values for object properties
  */
 public function fromArray($options)
 {
     if (!empty($options['AccessControl'])) {
         Validate::isArray($options['AccessControl'], 'options[AccessControl]');
         $this->_accessControl = ChannelPreviewAccessControl::createFromOptions($options['AccessControl']);
     }
     if (!empty($options['Endpoints'])) {
         Validate::isArray($options['Endpoints'], 'options[Endpoints]');
         foreach ($options['Endpoints'] as $endpoint) {
             $this->_endpoints[] = ChannelEndpoint::createFromOptions($endpoint);
         }
     }
 }