Exemplo n.º 1
0
 /**
  * Initialised option nodes
  * @method initOptions
  * @param  array   $options        Array of the form:
  *                                    ['value' => 'displayedValue', ...]
  * @param  string  $defaultOption  Key of default value in array $options.
  * @return void
  */
 private function initOptions(array $options, $defaultOption)
 {
     $optionNode = new HtmlLeaf(['kind' => 'option']);
     foreach ($options as $value => $displayedValue) {
         $this->appendChild(clone $optionNode)->setAttr(['value' => $value])->setCont("{$displayedValue}");
     }
     if (isset($options[$defaultOption])) {
         $offset = ArrayUtils::key2offset($options, $defaultOption);
         $this->childNodes[$offset]->attr['selected'] = 'selected';
         $this->defaultOption = $this->childNodes[$offset];
     }
 }
Exemplo n.º 2
0
 /**
  * Calculates $this->calib, the average time between immediate calls
  * to tic() and toc().
  * Initialises the standard deviation of $this->calib.
  * @return void
  */
 private function calibrate()
 {
     $imax = 20;
     $this->tic();
     $this->tac();
     for ($i = 0; $i < $imax; $i++) {
         $this->tic();
         $this->tac(self::RESET_LAP);
         $calib[] = $this->elapsed;
     }
     $this->calib = ArrayUtils::mean($calib);
     $this->stDev = ArrayUtils::stDeviation($calib);
 }