Exemplo n.º 1
0
 /**
  * Generate a continuous uniform distribution.
  *
  * @param   float   $lower    Lower bound value.
  * @param   float   $upper    Upper bound value.
  * @return  float
  */
 public function getFloat($lower = null, $upper = null)
 {
     if (null === $lower) {
         $lower = $this->_parameters->getParameter('float.min');
     }
     /*
     $lower = true === S_32\BITS
                  ? -3.4028235e38 + 1
                  : -1.7976931348623157e308 + 1;
     */
     if (null === $upper) {
         $upper = $this->_parameters->getParameter('float.max');
     }
     /*
     $upper = true === S_32\BITS
                  ? 3.4028235e38 - 1
                  : 1.7976931348623157e308 - 1;
     */
     if ($lower > $upper) {
         throw new Math\Exception('Unexpected values, float %f should be lower than %f', 2, [$lower, $upper]);
     }
     return $this->_getFloat($lower, $upper);
 }
Exemplo n.º 2
0
Arquivo: Cache.php Projeto: Jir4/Cache
 /**
  * Make an ID according to frontend options.
  * We privilage _makeId to built suffixe of ID.
  * As an idenfier shoud be unique, we add environments variables values. In
  * this way, the identifier represents the current state of application.
  *
  * @param   string    $id    Identifier.
  * @return  string
  * @throws  \Hoa\Cache\Exception
  */
 protected function makeId($id = null)
 {
     $_id = $id;
     if (true === $this->_parameters->getParameter('make_id_with.cookie') && isset($_COOKIE)) {
         $_id .= serialize($this->ksort($_COOKIE));
     }
     if (true === $this->_parameters->getParameter('make_id_with.files') && isset($_FILES)) {
         $_id .= serialize($this->ksort($_FILES));
     }
     if (true === $this->_parameters->getParameter('make_id_with.get') && isset($_GET)) {
         $_id .= serialize($this->ksort($_GET));
     }
     if (true === $this->_parameters->getParameter('make_id_with.post') && isset($_POST)) {
         $_id .= serialize($this->ksort($_POST));
     }
     if (true === $this->_parameters->getParameter('make_id_with.server') && isset($_SERVER)) {
         $_id .= serialize($this->ksort($_SERVER));
     }
     if (true === $this->_parameters->getParameter('make_id_with.session') && isset($_SESSION)) {
         $_id .= serialize($this->ksort($_SESSION));
     }
     return self::$_id[$id] = md5($id . $_id);
 }