本文整理汇总了PHP中Hesper\Core\Base\Assert::isPositiveInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isPositiveInteger方法的具体用法?PHP Assert::isPositiveInteger怎么用?PHP Assert::isPositiveInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hesper\Core\Base\Assert
的用法示例。
在下文中一共展示了Assert::isPositiveInteger方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSummaryWeight
public function setSummaryWeight($weight)
{
Assert::isPositiveInteger($weight);
$this->summaryWeight = $weight;
$this->sorted = false;
return $this;
}
示例2: getBytes
public function getBytes($numberOfBytes)
{
Assert::isPositiveInteger($numberOfBytes);
$bytes = null;
for ($i = 0; $i < $numberOfBytes; $i += 4) {
$bytes .= pack('L', mt_rand());
}
return substr($bytes, 0, $numberOfBytes);
}
示例3: encode
public static function encode($integer)
{
Assert::isPositiveInteger($integer, 'Out of range');
$magicInt = strlen(self::$chars);
$string = '';
do {
$i = $integer % $magicInt;
$string = self::$chars[$i] . $string;
$integer = ($integer - $i) / $magicInt;
} while ($integer > 0);
return $string;
}
示例4: getAverage
public static function getAverage(array $list, $size = null)
{
if (!$size) {
$size = count($list);
}
Assert::isPositiveInteger($size);
$tempSum = 0;
for ($i = 0; $i < $size; $i++) {
$tempSum += $list[$i];
}
return $tempSum / $size;
}
示例5: limit
/**
* @throws WrongArgumentException
* @return SelectQuery
**/
public function limit($limit = null, $offset = null)
{
if ($limit !== null) {
Assert::isPositiveInteger($limit, 'invalid limit specified');
}
if ($offset !== null) {
Assert::isInteger($offset, 'invalid offset specified');
}
$this->limit = $limit;
$this->offset = $offset;
return $this;
}
示例6: setLength
/**
* @return CropFilter
**/
public function setLength($length)
{
Assert::isPositiveInteger($length);
$this->length = $length;
return $this;
}
示例7: getBytes
public function getBytes($numberOfBytes)
{
Assert::isPositiveInteger($numberOfBytes);
return fread($this->handle, $numberOfBytes);
}