public function evaluate($values)
 {
     if ($this->isBindable()) {
         Assert::isPositiveInteger($this->getValue(), 'wrong substitution number: $' . $this->getValue());
         Assert::isIndexExists($values, $this->getValue(), 'parameter $' . $this->getValue() . ' is not binded');
         $value = $values[$this->getValue()];
     } else {
         $value = $this->getValue();
     }
     if ($value instanceof Query) {
         return $value;
     } elseif ($value instanceof Identifiable) {
         return $value->getId();
     } elseif (is_array($value)) {
         $list = array();
         foreach ($value as $key => $parameter) {
             if ($parameter instanceof OqlQueryParameter) {
                 $list[$key] = $parameter->evaluate($values);
             } else {
                 $list[$key] = $parameter;
             }
         }
         return $list;
     }
     return $value;
 }
 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);
 }
 /**
  * @throws WrongArgumentException
  * @return QueryCombination
  **/
 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;
 }
 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;
 }
Esempio n. 6
0
 function setOffset($offset)
 {
     if ($offset) {
         Assert::isPositiveInteger($offset);
     }
     $this->offset = $offset;
     return $this;
 }
 function __construct($name, $label, $defaultInputCount = 1)
 {
     Assert::isPositiveInteger($defaultInputCount);
     parent::__construct($name, $label);
     $this->setDefaultValue(array_fill(0, $defaultInputCount, null));
 }
 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;
 }
 public function getBytes($numberOfBytes)
 {
     Assert::isPositiveInteger($numberOfBytes);
     return fread($this->handle, $numberOfBytes);
 }
Esempio n. 10
0
 /**
  * Sets a cookie lifetime (in seconds)
  * @param int $ttl
  * @return Cookie
  */
 function setTtl($ttl)
 {
     Assert::isPositiveInteger($ttl);
     $this->ttl = $ttl;
     return $this;
 }
 /**
  * @return CropFilter
  **/
 public function setLength($length)
 {
     Assert::isPositiveInteger($length);
     $this->length = $length;
     return $this;
 }
 function setMinSize($bytes)
 {
     Assert::isPositiveInteger($bytes);
     $this->minSize = $bytes;
     return $this;
 }
 public function setSize($size)
 {
     Assert::isPositiveInteger($size);
     $this->size = $size;
     return $this;
 }
 /**
  * @return GoogleChartSize
  **/
 public function setHeight($height)
 {
     Assert::isPositiveInteger($height);
     $this->height = $height;
     return $this;
 }