public function testAddOption()
 {
     $instance = new Options();
     $this->assertFalse($instance->has('Foo'));
     $instance->set('Foo', 42);
     $this->assertEquals(42, $instance->get('Foo'));
 }
 /**
  * @since 2.4
  *
  * @param string $key
  * @param mixed $value
  */
 public function setOption($key, $value)
 {
     if ($this->options === null) {
         $this->options = new Options();
     }
     $this->options->set($key, $value);
 }
 private function doRebuildAll()
 {
     $entityRebuildDispatcher = $this->store->refreshData($this->start, 1);
     $entityRebuildDispatcher->setDispatchRangeLimit(1);
     $entityRebuildDispatcher->setUpdateJobParseMode($this->options->has('shallow-update') ? SMW_UJ_PM_CLASTMDATE : false);
     $entityRebuildDispatcher->useJobQueueScheduler(false);
     $this->doDisposeMarkedOutdatedEntities();
     if (!$this->options->has('skip-properties')) {
         $this->options->set('p', true);
         $this->doRebuildDistinctEntities();
         $this->reportMessage("\n");
     }
     $this->store->clear();
     $this->reportMessage("Refreshing all semantic data in the database!\n---\n" . " Some versions of PHP suffer from memory leaks in long-running \n" . " scripts. If your machine gets very slow after many pages \n" . " (typically more than 1000) were refreshed, please abort with\n" . " CTRL-C and resume this script at the last processed page id\n" . " using the parameter -s (use -v to display page ids during \n" . " refresh). Continue this until all pages have been refreshed.\n---\n");
     $total = $this->end && $this->end - $this->start > 0 ? $this->end - $this->start : $entityRebuildDispatcher->getMaxId();
     $id = $this->start;
     $this->reportMessage(" The progress displayed is an estimation and is self-adjusting \n" . " during the update process.\n---\n");
     $this->reportMessage("Processing all IDs from {$this->start} to " . ($this->end ? "{$this->end}" : $entityRebuildDispatcher->getMaxId()) . " ...\n");
     $this->rebuildCount = 0;
     while ((!$this->end || $id <= $this->end) && $id > 0) {
         $progress = '';
         $this->rebuildCount++;
         $this->exceptionLog = array();
         $this->doExecuteFor($entityRebuildDispatcher, $id);
         if ($this->rebuildCount % 60 === 0) {
             $progress = round(($this->end - $this->start > 0 ? $this->rebuildCount / $total : $entityRebuildDispatcher->getEstimatedProgress()) * 100) . "%";
         }
         foreach ($entityRebuildDispatcher->getDispatchedEntities() as $value) {
             $text = $this->getHumanReadableTextFrom($id, $value);
             $this->reportMessage(sprintf("%-16s%s\n", "({$this->rebuildCount}/{$total})", "Finished processing ID " . $text), $this->options->has('v'));
             if ($this->options->has('ignore-exceptions') && isset($this->exceptionLog[$id])) {
                 $this->exceptionFileLogger->doWriteExceptionLog(array($id . ' ' . $text => $this->exceptionLog[$id]));
             }
         }
         $this->doPrintDotProgressIndicator($this->verbose, $this->rebuildCount, $progress);
     }
     $this->writeIdToFile($id);
     $this->reportMessage("\n\n{$this->rebuildCount} IDs refreshed.\n");
     if ($this->options->has('ignore-exceptions') && $this->exceptionFileLogger->getExceptionCounter() > 0) {
         $this->reportMessage("\n" . $this->exceptionFileLogger->getExceptionCounter() . " exceptions were ignored! (See " . $this->exceptionFileLogger->getExceptionFile() . ").\n");
     }
     return true;
 }
 /**
  * Return formatted request parameters
  *
  * @since 1.9
  *
  * @return ObjectDictionary
  */
 protected function formatAskArgs()
 {
     $result = new Options();
     // Set defaults
     $result->set('conditions', array());
     $result->set('printouts', array());
     $result->set('parameters', array());
     if (isset($this->requestParameters['parameters']) && is_array($this->requestParameters['parameters'])) {
         $result->set('parameters', $this->formatParameters());
     }
     if (isset($this->requestParameters['conditions']) && is_array($this->requestParameters['conditions'])) {
         $result->set('conditions', implode(' ', array_map('self::formatConditions', $this->requestParameters['conditions'])));
     }
     if (isset($this->requestParameters['printouts']) && is_array($this->requestParameters['printouts'])) {
         $result->set('printouts', array_map('self::formatPrintouts', $this->requestParameters['printouts']));
     }
     return $result;
 }
 /**
  * @since 2.4
  *
  * @return string $key
  * @param mixed $value
  */
 public function setOption($key, $value)
 {
     $this->options->set($key, $value);
 }