本文整理匯總了PHP中CommonUtil::is_uuid方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommonUtil::is_uuid方法的具體用法?PHP CommonUtil::is_uuid怎麽用?PHP CommonUtil::is_uuid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CommonUtil
的用法示例。
在下文中一共展示了CommonUtil::is_uuid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getMessage
/**
* Gets a Message
* @param UUID $messageId
* @return Message|HttpResponse|null
* @throws ErrorException
*/
public function getMessage($messageId)
{
$resource = "/messages/";
if (is_null($messageId)) {
throw new ErrorException("Parameter 'messageId' cannot be null");
} elseif (!CommonUtil::is_uuid($messageId)) {
throw new ErrorException("Parameter 'messageId' must be a valid UUID");
}
try {
$resource .= $messageId;
$response = $this->httpClient->get($resource);
if ($response instanceof HttpResponse) {
if ($response->getStatus() === HttpStatusCode::HTTP_OK) {
$json = JsonHelper::getJson($response->getBody());
if (isset($json)) {
return new Message($json);
}
} else {
return $response;
}
}
} catch (Exception $exc) {
echo $exc->getTraceAsString();
}
return null;
}
示例2: updateContentMedia
/**
* Updates the details of an existing content media.
* @param UUID $mediaId The content media
* @param MediaInfo $mediaInfo The content media details
* @return HttpResponse|ContentMedia|null
* @throws ErrorException
*/
public function updateContentMedia($mediaId, $mediaInfo = null)
{
$resource = "/media/";
if (is_null($mediaId)) {
throw new ErrorException("Parameter 'mediaId' cannot be null");
} elseif (!CommonUtil::is_uuid($mediaId)) {
throw new ErrorException("Parameter 'mediaId' must be a valid UUID");
}
if (!is_null($mediaInfo) && !$mediaInfo instanceof MediaInfo) {
throw new ErrorException("Parameter 'mediaInfo' cannot be null and must be an instance of MediaInfo.");
}
try {
$resource .= $mediaId;
// Set the mediainfo data
$params["ContentName"] = $mediaInfo->contentName;
$params["LibraryId"] = $mediaInfo->libraryId;
$params["DestinationFolder"] = $mediaInfo->destinationFolder;
$params["Preference"] = $mediaInfo->preference;
$params["Width"] = $mediaInfo->width;
$params["Height"] = $mediaInfo->height;
$params["DrmProtect"] = $mediaInfo->drmProtect;
$params["Streamable"] = $mediaInfo->streamable;
$params["DisplayText"] = $mediaInfo->displayText;
$params["ContentText"] = $mediaInfo->contentText;
$params["Tags"] = "";
// set the medainfo tags
if (!is_null($mediaInfo->tags) && is_array($mediaInfo->tags) && count($mediaInfo->tags) > 0) {
$params["Tags"] = JsonHelper::toJson($mediaInfo->tags);
}
$response = $this->httpClient->put($resource, $params);
if ($response instanceof HttpResponse) {
if ($response->getStatus() === HttpStatusCode::HTTP_OK) {
$json = JsonHelper::getJson($response->getBody());
if (isset($json)) {
return new ContentMedia($json);
}
} else {
return $response;
}
}
} catch (Exception $ex) {
$ex->getTraceAsString();
}
return null;
}