本文整理汇总了PHP中Checker::argIntPositive方法的典型用法代码示例。如果您正苦于以下问题:PHP Checker::argIntPositive方法的具体用法?PHP Checker::argIntPositive怎么用?PHP Checker::argIntPositive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Checker
的用法示例。
在下文中一共展示了Checker::argIntPositive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRandomBytes
/**
* Returns cryptographically strong secure random bytes (as a PHP string).
*
* @param int $numBytes
* The number of bytes of random data to return.
*
* @return string
*/
static function getRandomBytes($numBytes)
{
Checker::argIntPositive("numBytes", $numBytes);
// openssl_random_pseudo_bytes had some issues prior to PHP 5.3.4
if (function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4') >= 0) {
$s = openssl_random_pseudo_bytes($numBytes, $isCryptoStrong);
if ($isCryptoStrong) {
return $s;
}
}
if (function_exists('mcrypt_create_iv')) {
return mcrypt_create_iv($numBytes);
}
// Hopefully the above two options cover all our users. But if not, there are
// other platform-specific options we could add.
assert(False, "no suitable random number source available");
}
示例2: uploadFileChunked
/**
* Creates a file on Dropbox, using the data from $inStream as the file contents.
*
* This version of <code>uploadFile</code> splits uploads the file ~4MB chunks at a time and
* will retry a few times if one chunk fails to upload. Uses {@link chunkedUploadStart()},
* {@link chunkedUploadContinue()}, and {@link chunkedUploadFinish()}.
*
* @param string $path
* The Dropbox path to save the file to (UTF-8).
*
* @param WriteMode $writeMode
* What to do if there's already a file at the given path.
*
* @param resource $inStream
* The data to use for the file contents.
*
* @param int|null $numBytes
* The number of bytes available from $inStream.
* You can pass in <code>null</code> if you don't know.
*
* @param int|null $chunkSize
* The number of bytes to upload in each chunk. You can omit this (or pass in
* <code>null</code> and the library will use a reasonable default.
*
* @return mixed
* The <a href="https://www.dropbox.com/developers/core/docs#metadata-details>metadata
* object</a> for the newly-added file.
*
* @throws Exception
*/
function uploadFileChunked($path, $writeMode, $inStream, $numBytes = null, $chunkSize = null)
{
if ($chunkSize === null) {
$chunkSize = self::$DEFAULT_CHUNK_SIZE;
}
Path::checkArgNonRoot("path", $path);
WriteMode::checkArg("writeMode", $writeMode);
Checker::argResource("inStream", $inStream);
Checker::argNatOrNull("numBytes", $numBytes);
Checker::argIntPositive("chunkSize", $chunkSize);
return $this->_uploadFileChunked($path, $writeMode, $inStream, $numBytes, $chunkSize);
}
示例3: uploadFileChunked
/**
* Creates a file on Dropbox, using the data from $inStream as the file contents.
*
* This version of <code>uploadFile</code> splits uploads the file ~4MB chunks at a time and
* will retry a few times if one chunk fails to upload. Uses {@link chunkedUploadStart()},
* {@link chunkedUploadContinue()}, and {@link chunkedUploadFinish()}.
*
* @param string $path
* The Dropbox path to save the file to (UTF-8).
*
* @param WriteMode $writeMode
* What to do if there's already a file at the given path.
*
* @param resource $inStream
* The data to use for the file contents. This stream will be closed with
* <code>fclose</code>, whether the upload succeeds or not.
*
* @param int|null $numBytes
* The number of bytes available from $inStream.
* You can pass in <code>null</code> if you don't know.
*
* @param int|null $chunkSize
* The number of bytes to upload in each chunk. You can omit this (or pass in
* <code>null</code> and the library will use a reasonable default.
*
* @return mixed
* The <a href="https://www.dropbox.com/developers/core/api#metadata-details>metadata
* object</a> for the newly-added file.
*
* @throws Exception
*/
function uploadFileChunked($path, $writeMode, $inStream, $numBytes = null, $chunkSize = null)
{
try {
if ($chunkSize === null) {
$chunkSize = self::$DEFAULT_CHUNK_SIZE;
}
Path::checkArgNonRoot("path", $path);
WriteMode::checkArg("writeMode", $writeMode);
Checker::argResource("inStream", $inStream);
Checker::argNatOrNull("numBytes", $numBytes);
Checker::argIntPositive("chunkSize", $chunkSize);
$metadata = $this->_uploadFileChunked($path, $writeMode, $inStream, $numBytes, $chunkSize);
} catch (\Exception $ex) {
fclose($inStream);
throw $ex;
}
fclose($inStream);
return $metadata;
}