本文整理汇总了PHP中WindowsAzure\Common\Internal\Validate::isA方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isA方法的具体用法?PHP Validate::isA怎么用?PHP Validate::isA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowsAzure\Common\Internal\Validate
的用法示例。
在下文中一共展示了Validate::isA方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param string $content Http response
* as string
*
* @param WindowsAzure\Common\Internal\Http\BatchRequest $request Source batch
* request object
*/
public function __construct($content, $request = null)
{
$params['include_bodies'] = true;
$params['input'] = $content;
$mimeDecoder = new \Mail_mimeDecode($content);
$structure = $mimeDecoder->decode($params);
$parts = $structure->parts;
$this->_contexts = array();
$requestContexts = null;
if ($request != null) {
Validate::isA($request, 'WindowsAzure\\Common\\Internal\\Http\\BatchRequest', 'request');
$requestContexts = $request->getContexts();
}
$i = 0;
foreach ($parts as $part) {
if (!empty($part->body)) {
$headerEndPos = strpos($part->body, "\r\n\r\n");
$header = substr($part->body, 0, $headerEndPos);
$body = substr($part->body, $headerEndPos + 4);
$headerStrings = explode("\r\n", $header);
$response = new \HTTP_Request2_Response(array_shift($headerStrings));
foreach ($headerStrings as $headerString) {
$response->parseHeaderLine($headerString);
}
$response->appendBody($body);
$this->_contexts[] = $response;
if (is_array($requestContexts)) {
$expectedCodes = $requestContexts[$i]->getStatusCodes();
$statusCode = $response->getStatus();
if (!in_array($statusCode, $expectedCodes)) {
$reason = $response->getReasonPhrase();
throw new ServiceException($statusCode, $reason, $body);
}
}
$i++;
}
}
}
示例2: updateEncodingReservedUnit
/**
* Update encoding reserved units settings.
*
* @param Models\EncodingReservedUnit $encodingReservedUnit Update data
* valid idli
*
* @return void
*/
public function updateEncodingReservedUnit($encodingReservedUnit)
{
Validate::isA($encodingReservedUnit, 'WindowsAzure\\MediaServices\\Models\\EncodingReservedUnit', 'encodingReservedUnit');
$accountID = $encodingReservedUnit->getAccountId();
$encodingReservedUnit->setAccountId(null);
// never send account Id
$this->_updateEntity($encodingReservedUnit, "EncodingReservedUnitTypes(guid'{$accountID}')");
$encodingReservedUnit->setAccountId($accountID);
}
示例3: fromXml
/**
* Creates an ATOM ENTRY instance with specified simpleXML object
*
* @param \SimpleXMLElement $entryXml xml element of ATOM ENTRY
*
* @return none
*/
public function fromXml($entryXml)
{
Validate::notNull($entryXml, 'entryXml');
Validate::isA($entryXml, '\\SimpleXMLElement', 'entryXml');
$this->attributes = (array) $entryXml->attributes();
$entryArray = (array) $entryXml;
if (array_key_exists(Resources::AUTHOR, $entryArray)) {
$this->author = $this->processAuthorNode($entryArray);
}
if (array_key_exists(Resources::CATEGORY, $entryArray)) {
$this->category = $this->processCategoryNode($entryArray);
}
if (array_key_exists('content', $entryArray)) {
$content = new Content();
$content->fromXml($entryArray['content']);
$this->content = $content;
}
if (array_key_exists(Resources::CONTRIBUTOR, $entryArray)) {
$this->contributor = $this->processContributorNode($entryArray);
}
if (array_key_exists('id', $entryArray)) {
$this->id = (string) $entryArray['id'];
}
if (array_key_exists(Resources::LINK, $entryArray)) {
$this->link = $this->processLinkNode($entryArray);
}
if (array_key_exists('published', $entryArray)) {
$this->published = $entryArray['published'];
}
if (array_key_exists('rights', $entryArray)) {
$this->rights = $entryArray['rights'];
}
if (array_key_exists('source', $entryArray)) {
$source = new Source();
$source->parseXml($entryArray['source']->asXML());
$this->source = $source;
}
if (array_key_exists('title', $entryArray)) {
$this->title = $entryArray['title'];
}
if (array_key_exists('updated', $entryArray)) {
$this->updated = \DateTime::createFromFormat(\DateTime::ATOM, (string) $entryArray['updated']);
}
}
示例4: sendUpdateProgramOperation
/**
* Send Update Program operation
*
* @param Models\Programs $program Programs data
*
* @return Models\Operation The operation to track the program update.
*/
public function sendUpdateProgramOperation($program)
{
Validate::isA($program, 'WindowsAzure\\MediaServices\\Models\\Program', 'program');
$programId = $program->getId();
Validate::notNull($programId, "programId");
return $this->_sendOperation($program, "Programs('{$programId}')", Resources::HTTP_MERGE, [Resources::STATUS_ACCEPTED, Resources::STATUS_NO_CONTENT]);
}
示例5: fromXml
/**
* Creates an ATOM CONTENT instance with specified simpleXML object
*
* @param \SimpleXMLElement $contentXml xml element of ATOM CONTENT
*
* @return none
*/
public function fromXml($contentXml)
{
Validate::notNull($contentXml, 'contentXml');
Validate::isA($contentXml, '\\SimpleXMLElement', '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;
$this->xml = $contentXml;
}
示例6: createMediaServicesService
/**
* Builds a media services object.
*
* @param WindowsAzure\Common\Internal\MediaServicesSettings $settings The media
* services configuration settings.
*
* @return WindowsAzure\MediaServices\Internal\IMediaServices
*/
public function createMediaServicesService($settings)
{
Validate::isA($settings, 'WindowsAzure\\Common\\Internal\\MediaServicesSettings', 'settings');
$httpClient = new HttpClient();
$serializer = $this->serializer();
$uri = Utilities::tryAddUrlScheme($settings->getEndpointUri(), Resources::HTTPS_SCHEME);
$mediaServicesWrapper = new MediaServicesRestProxy($httpClient, $uri, $settings->getAccountName(), $serializer);
// Adding headers filter
$xMSVersion = Resources::MEDIA_SERVICES_API_LATEST_VERSION;
$dataVersion = Resources::MEDIA_SERVICES_DATA_SERVICE_VERSION_VALUE;
$dataMaxVersion = Resources::MEDIA_SERVICES_MAX_DATA_SERVICE_VERSION_VALUE;
$accept = Resources::ACCEPT_HEADER_VALUE;
$contentType = Resources::ATOM_ENTRY_CONTENT_TYPE;
$userAgent = Resources::SDK_USER_AGENT;
$headers = array(Resources::X_MS_VERSION => $xMSVersion, Resources::DATA_SERVICE_VERSION => $dataVersion, Resources::MAX_DATA_SERVICE_VERSION => $dataMaxVersion, Resources::ACCEPT_HEADER => $accept, Resources::CONTENT_TYPE => $contentType, Resources::USER_AGENT => $userAgent);
$headersFilter = new HeadersFilter($headers);
$mediaServicesWrapper = $mediaServicesWrapper->withFilter($headersFilter);
// Adding OAuth filter
$oauthService = new OAuthRestProxy(new HttpClient(), $settings->getOAuthEndpointUri());
$authentification = new OAuthScheme($settings->getAccountName(), $settings->getAccessKey(), Resources::OAUTH_GT_CLIENT_CREDENTIALS, Resources::MEDIA_SERVICES_OAUTH_SCOPE, $oauthService);
$authentificationFilter = new AuthenticationFilter($authentification);
$mediaServicesWrapper = $mediaServicesWrapper->withFilter($authentificationFilter);
return $mediaServicesWrapper;
}
示例7: generateTestToken
public static function generateTestToken($template, $verificationKey, $contentKeyUUID, $tokenExpiration = null, $notBefore = null)
{
Validate::notNull($template, 'template');
Validate::isA($template, 'WindowsAzure\\MediaServices\\Templates\\TokenRestrictionTemplate', 'template');
if ($verificationKey == null) {
$verificationKey = $template->getPrimaryVerificationKey();
}
Validate::notNull($verificationKey, 'verificationKey');
Validate::isA($verificationKey, 'WindowsAzure\\MediaServices\\Templates\\SymmetricVerificationKey', 'verificationKey');
if ($tokenExpiration == null) {
$tokenExpiration = time() + 60 * 10;
}
if ($notBefore == null) {
$notBefore = time() - 60 * 5;
}
if ($template->getTokenType() == TokenType::SWT) {
return TokenRestrictionTemplateSerializer::generateTestTokenSWT($template, $verificationKey, $contentKeyUUID, $tokenExpiration);
} else {
return TokenRestrictionTemplateSerializer::generateTestTokenJWT($template, $verificationKey, $contentKeyUUID, $tokenExpiration, $notBefore);
}
}
示例8: serialize
/**
* Serialize a WidevineMessage as JSON
* @param WidevineMessage $template
* @return string
*/
public static function serialize($template)
{
Validate::isA($template, 'WindowsAzure\\MediaServices\\Templates\\WidevineMessage', 'template');
return json_encode($template);
}
示例9: testIsANotAClass
/**
* @covers WindowsAzure\Common\Internal\Validate::isA
*/
public function testIsANotAClass()
{
// Setup
$this->setExpectedException(get_class(new InvalidArgumentTypeException('')));
$value = 'test string';
$type = 'WindowsAzure\\Common\\Internal\\Resources';
// Test
$result = Validate::isA($value, $type, 'value');
// Assert
}
示例10: createJobTemplate
/**
* Create a job.
*
* @param WindowsAzure\MediaServices\Models\JobTemplate $jobTemplate Job
* template data
*
* @param array $taskTemplates Performed
* tasks template array
*
* @return array
*/
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);
}
示例11: updateAssetDeliveryPolicy
/**
* Update asset delivery policy
*
* @param Models\AssetDeliveryPolicy $assetDeliveryPolicy New asset delivery policy data with
* valid id
*
* @return void
*/
public function updateAssetDeliveryPolicy($assetDeliveryPolicy)
{
Validate::isA($assetDeliveryPolicy, 'WindowsAzure\\MediaServices\\Models\\AssetDeliveryPolicy', 'assetDeliveryPolicy');
$this->_updateEntity($assetDeliveryPolicy, "AssetDeliveryPolicies('{$assetDeliveryPolicy->getId()}')");
}
示例12: createContentKey
/**
* Create new ContentKey
*
* @param Models\ContentKey $contentKey ContentKey data
*
* @return Models\ContentKey Created ContentKey
*/
public function createContentKey($contentKey)
{
Validate::isA($contentKey, 'WindowsAzure\\Mediaservices\\Models\\ContentKey', 'contentKey');
return ContentKey::createFromOptions($this->_createEntity($contentKey, 'ContentKeys'));
}