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