public function setSummaryWeight($weight) { Assert::isPositiveInteger($weight); $this->summaryWeight = $weight; $this->sorted = false; return $this; }
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); }
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; }
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; }
/** * @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; }
/** * @return CropFilter **/ public function setLength($length) { Assert::isPositiveInteger($length); $this->length = $length; return $this; }
public function getBytes($numberOfBytes) { Assert::isPositiveInteger($numberOfBytes); return fread($this->handle, $numberOfBytes); }