コード例 #1
0
ファイル: Http.php プロジェクト: Grummfy/Central
 /**
  * Constructor.
  *
  * @return  void
  */
 public function __construct(array $parameters = [])
 {
     $this->_parameters = new Core\Parameter($this, [], ['prefix' => null, 'rules.public' => [], 'rules.private' => []]);
     $this->_parameters->setParameters($parameters);
     if (null === ($prefix = $this->_parameters->getParameter('prefix'))) {
         $this->setPrefix('\\' === ($_ = dirname($this->getBootstrap())) ? '/' : $_);
     } else {
         $this->setPrefix($prefix);
     }
     foreach ($this->_parameters->getParameter('rules.public') as $id => $rule) {
         @(list($methods, $pattern, $call, $able, $variables) = $rule);
         if (null === $variables) {
             $variables = [];
         }
         $this->addRule($id, $methods, $pattern, $call, $able, $variables);
     }
     foreach ($this->_parameters->getParameter('rules.private') as $id => $rule) {
         @(list($methods, $pattern, $call, $able, $variables) = $rule);
         if (null === $variables) {
             $variables = [];
         }
         $this->addPrivateRule($id, $methods, $pattern, $call, $able, $variables);
     }
     $this->setDefaultPort(static::getPort(), static::isSecure());
     return;
 }
コード例 #2
0
ファイル: Cli.php プロジェクト: Grummfy/Central
 /**
  * Constructor.
  *
  * @return  void
  */
 public function __construct(array $parameters = [])
 {
     $this->_parameters = new Core\Parameter($this, [], ['rules.public' => [], 'rules.private' => []]);
     $this->_parameters->setParameters($parameters);
     foreach ($this->_parameters->getParameter('rules.public') as $id => $rule) {
         @(list($methods, $pattern, $call, $able, $variables) = $rule);
         if (null === $variables) {
             $variables = [];
         }
         $this->addRule($id, $methods, $pattern, $call, $able, $variables);
     }
     foreach ($this->_parameters->getParameter('rules.private') as $id => $rule) {
         @(list($methods, $pattern, $call, $able, $variables) = $rule);
         if (null === $variables) {
             $variables = [];
         }
         $this->addPrivateRule($id, $methods, $pattern, $call, $able, $variables);
     }
     return;
 }
コード例 #3
0
ファイル: Sampler.php プロジェクト: dantleech/Math
 /**
  * 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);
 }
コード例 #4
0
ファイル: Cache.php プロジェクト: Grummfy/Central
 /**
  * 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);
 }