Ejemplo n.º 1
0
 /**
  *
  * @param <type> $table
  * @param ArrayIterator $params
  * @return ArrayObject
  */
 public function search($table, ArrayIterator $params)
 {
     $this->searchParams = $params;
     $this->join();
     if ($table == "analysis") {
         $this->statements->remove("type_event");
     }
     $statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ ";
     $statement .= $this->join();
     $i = 0;
     $this->searchParams->rewind();
     if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) {
         $statement .= " WHERE ";
     }
     while ($this->searchParams->valid()) {
         if ($this->statements->containsKey($this->searchParams->key())) {
             if ($i++ > 0) {
                 $statement .= " AND ";
             }
             $clause = $this->statements->get($this->searchParams->key());
             $statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']);
         }
         $this->searchParams->next();
     }
     return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC");
 }
Ejemplo n.º 2
0
 static function create_tree(ArrayIterator &$it)
 {
     if (!in_array($it->current()["term"], self::operators_dictionary)) {
         $leaf = new leaf($it->current());
         $it->next();
         return $leaf;
     } else {
         if ($it->current()["term"] == "not") {
             $it->next();
             $op = self::create_tree($it);
             return new notEx($op);
         } else {
             if ($it->current()["term"] == "and") {
                 $it->next();
                 $left = self::create_tree($it);
                 $right = self::create_tree($it);
                 return new andEx($left, $right);
             } else {
                 if ($it->current()["term"] == "or") {
                     $it->next();
                     $left = self::create_tree($it);
                     $right = self::create_tree($it);
                     return new orEx($left, $right);
                 }
             }
         }
     }
     return null;
 }
Ejemplo n.º 3
0
 /**
  * Switches to alternate nicks as needed when nick collisions occur.
  *
  * @return void
  */
 public function onResponse()
 {
     // If no alternate nick list was found, return
     if (empty($this->iterator)) {
         return;
     }
     // If the response event indicates that the nick set is in use...
     $code = $this->getEvent()->getCode();
     if ($code == Phergie_Event_Response::ERR_NICKNAMEINUSE) {
         // Attempt to move to the next nick in the alternate nick list
         $this->iterator->next();
         // If another nick is available...
         if ($this->iterator->valid()) {
             // Switch to the new nick
             $altNick = $this->iterator->current();
             $this->doNick($altNick);
             // Update the connection to reflect the nick change
             $this->getConnection()->setNick($altNick);
         } else {
             // If no other nicks are available...
             // Terminate the connection
             $this->doQuit('All specified alternate nicks are in use');
         }
     }
 }
 /**
  * @return NormalizedProduction|null
  */
 public function key()
 {
     if ($this->innerIterator->valid()) {
         /** @var LookAheadSetEntry $entry */
         $entry = $this->innerIterator->current();
         return $entry->getKey();
     }
     return null;
 }
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     $current = $this->iterator->current();
     $data = array();
     foreach ($this->propertyPaths as $name => $propertyPath) {
         $data[$name] = $this->getValue($this->propertyAccessor->getValue($current, $propertyPath));
     }
     return $data;
 }
Ejemplo n.º 6
0
 private function dayInfo()
 {
     $this->daysInfo = new ArrayIterator();
     while ($this->days->valid()) {
         $day = explode(") - ", $this->days->current());
         $infos = explode("/", $day[1]);
         $this->daysInfo->append($this->buildWeatherDayInfo($day[0], $infos));
         $this->days->next();
     }
 }
Ejemplo n.º 7
0
 /**
  * get current testable object from collection
  *
  * @return \PhpUnitTestGenerator\Testable\Object
  */
 public function current()
 {
     $f = $this->fileList->current();
     if (is_file($f)) {
         $object = Builder::buildTestableObjectFromFile($f);
         /* @var $object \PhpUnitTestGenerator\Testable\Object */
         return $object;
     }
     return null;
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (!$this->isExecuted) {
         $this->isExecuted = true;
         $this->results = $this->getResults();
     }
     if (null !== ($result = $this->results->current())) {
         $this->results->next();
         $this->stepExecution->incrementSummaryInfo('read');
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (null === $this->results) {
         $items = $this->readItems();
         $this->results = new \ArrayIterator($items);
     }
     if (null !== ($result = $this->results->current())) {
         $this->results->next();
         $this->stepExecution->incrementSummaryInfo('read');
     }
     return $result;
 }
Ejemplo n.º 10
0
 /**
  * @param $fixtureType
  * @param FixtureBuilder $builder
  * @param array $entities
  * @param string $hook
  * @return array
  * @throws UndefinedFixtureModel
  */
 public static function buildMany($fixtureType, FixtureBuilder $builder, array $entities, $hook = '')
 {
     $many = [];
     $iterator = new \ArrayIterator($entities);
     while ($iterator->valid()) {
         $builder->throwUndefinedDataProvider($iterator->current());
         $fixtureId = self::_buildAndRegisterFixture($fixtureType, $hook, $iterator->current());
         $many[] = self::_getMagentoModel($iterator->current(), $fixtureId);
         $iterator->next();
     }
     return $many;
 }
 /**
  * {@inheritDoc}
  */
 public function proceed(CommandMessageInterface $commandProceedWith = null)
 {
     if (null !== $commandProceedWith) {
         $this->command = $commandProceedWith;
     }
     if ($this->chain->valid()) {
         $next = $this->chain->current();
         $this->chain->next();
         return $next->handle($this->command, $this->unitOfWork, $this);
     } else {
         return $this->handler->handle($this->command, $this->unitOfWork);
     }
 }
Ejemplo n.º 12
0
 private function getValuesFromData(ArrayIterator $dataValues)
 {
     $values = array();
     while ($dataValues->valid()) {
         if ($dataValues->current() instanceof Data) {
             array_push($values, $dataValues->current()->getValue());
         }
         $dataValues->next();
     }
     if (sizeof($values) > 0) {
         return new ArrayIterator($values);
     }
     return $dataValues;
 }
Ejemplo n.º 13
0
 function testSeek()
 {
     $iterator = new ArrayIterator([0, 5, 2, 6]);
     $iterator->rewind();
     $iterator->seek(3);
     $this->assertEquals(6, $iterator->current());
     $iterator->seek(1);
     $this->assertEquals(5, $iterator->current());
     $iterator->seek(2);
     $this->assertEquals(2, $iterator->current());
     $iterator->seek(0);
     $this->assertEquals(0, $iterator->current());
     $iterator->seek(3);
     $this->assertEquals(6, $iterator->current());
 }
Ejemplo n.º 14
0
 public static function buildLinesHtml(ArrayIterator $cot, $anotherType = null)
 {
     $html = "";
     while ($cot->valid()) {
         $html .= "<tr id='" . $cot->current()->getCode() . "' class='cotation-values'>";
         if ($anotherType == null) {
             $html .= self::buildLineWithCurrent($cot->current());
         } else {
             $html .= self::buildLineWithCurrentFisicaOrIndicador($cot->current(), $anotherType);
         }
         $html .= "</tr>";
         $cot->next();
     }
     return $html;
 }
Ejemplo n.º 15
0
 /**
  * Return the current resource.
  *
  * @return \com\mohiva\common\io\Resource The current `Resource` object or null if no resource
  * exists.
  */
 public function current()
 {
     if (!$this->valid()) {
         return null;
     }
     return $this->iterator->current();
 }
Ejemplo n.º 16
0
 /**
  * iterate the complete data collection and execute callback for each key => value pair passing the key
  * and the value to the callback function/method as first and second parameter. the callback must be
  * a valid callable that can be executed call_user_func_array
  *
  * @error 16307
  * @param callable $callback expects the callback function/method
  * @return void
  */
 public function each(callable $callback)
 {
     while ($this->iterator->valid()) {
         call_user_func_array($callback, array($this->iterator->key(), $this->iterator->current()));
         $this->iterator->next();
     }
 }
Ejemplo n.º 17
0
 /**
  *
  *@param $id_ciu
  *
  *
  **/
 public function getById($id_jefe)
 {
     $this->conex = DataBase::getInstance();
     //Consulta SQL
     $consulta = "SELECT * FROM FISC_JEFE_OFICINA WHERE \n\t\t\t\t\t\tID_JEFE=:id_jefe";
     $stid = oci_parse($this->conex, $consulta);
     if (!$stid) {
         $e = oci_error($this->conex);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Realizar la lógica de la consulta
     oci_bind_by_name($stid, ':id_jefe', $id_jefe);
     $r = oci_execute($stid);
     if (!$r) {
         $e = oci_error($stid);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     $result = array();
     // Obtener los resultados de la consulta
     while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $it = new ArrayIterator($fila);
         $alm = new Denuncia();
         while ($it->valid()) {
             $alm->__SET(strtolower($it->key()), $it->current());
             $it->next();
         }
         $result[] = $alm;
     }
     //Libera los recursos
     oci_free_statement($stid);
     // Cierra la conexión Oracle
     oci_close($this->conex);
     //retorna el resultado de la consulta
     return $result;
 }
Ejemplo n.º 18
0
 public function matchesList(array $items)
 {
     $itemIterator = new \ArrayIterator($items);
     $matcherIterator = new \ArrayIterator($this->getMatchers());
     $currentMatcher = null;
     if ($matcherIterator->valid()) {
         $currentMatcher = $matcherIterator->current();
     }
     while ($itemIterator->valid() && null !== $currentMatcher) {
         $hasMatch = $currentMatcher->matches($itemIterator->current());
         if ($hasMatch) {
             $matcherIterator->next();
             if ($matcherIterator->valid()) {
                 $currentMatcher = $matcherIterator->current();
             } else {
                 $currentMatcher = null;
             }
         }
         $itemIterator->next();
     }
     //echo sprintf("%s->%s, %s->%s\n", $itemIterator->key(), $itemIterator->count(),
     //      $matcherIterator->key(), $matcherIterator->count());
     if (null !== $currentMatcher && !$currentMatcher->matches(null)) {
         $this->reportFailed($currentMatcher);
         return false;
     }
     $matcherIterator->next();
     return $this->matchRemainder($matcherIterator);
 }
Ejemplo n.º 19
0
 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (null === $this->yaml) {
         $fileData = $this->getFileData();
         if (null === $fileData) {
             return null;
         }
         $this->yaml = new \ArrayIterator($fileData);
     }
     if ($data = $this->yaml->current()) {
         $this->yaml->next();
         if (null !== $this->stepExecution) {
             $this->stepExecution->incrementSummaryInfo('read_lines');
         }
         try {
             $data = $this->converter->convert($data);
         } catch (DataArrayConversionException $e) {
             $this->skipItemFromConversionException($data, $e);
         }
         return $data;
     }
     // if not used in the context of an ItemStep, the previous read file will be returned
     $this->flush();
     return null;
 }
 protected function renderRows($rows, ArrayIterator $splitcontent, &$pos = -1)
 {
     $output = "";
     $rownumber = 0;
     foreach ($rows as $row) {
         if ($row->cols) {
             $columns = array();
             foreach ($row->cols as $col) {
                 $nextcontent = $splitcontent->current();
                 $isholder = !isset($col->rows);
                 if ($isholder) {
                     $splitcontent->next();
                     //advance iterator if there are no sub-rows
                     $pos++;
                     //wrap split content in a HTMLText object
                     $dbObject = DBField::create_field('HTMLText', $nextcontent, "Content");
                     $dbObject->setOptions(array("shortcodes" => true));
                     $nextcontent = $dbObject;
                 }
                 $width = $col->width ? (int) $col->width : 1;
                 //width is at least 1
                 $columns[] = new ArrayData(array("Width" => $width, "EnglishWidth" => $this->englishWidth($width), "Content" => $isholder ? $nextcontent : $this->renderRows($col->rows, $splitcontent, $pos), "IsHolder" => $isholder, "GridPos" => $pos, "ExtraClasses" => isset($col->extraclasses) ? $col->extraclasses : null));
             }
             $output .= ArrayData::create(array("Columns" => new ArrayList($columns), "RowNumber" => (string) $rownumber++, "ExtraClasses" => isset($row->extraclasses) ? $row->extraclasses : null))->renderWith($this->template);
         } else {
             //every row should have columns!!
         }
     }
     return $output;
 }
 public function next()
 {
     parent::next();
     if ($this->valid()) {
         $this->sum += parent::current();
     }
 }
 public function getById($id)
 {
     $this->conex = DataBase::getInstance();
     $stid = oci_parse($this->conex, "SELECT *\n\t\t\tFROM FISC_CIUDADANO WHERE ID_CIUDADANO=:id");
     if (!$stid) {
         $e = oci_error($this->conex);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Realizar la lógica de la consulta
     oci_bind_by_name($stid, ':id', $id);
     $r = oci_execute($stid);
     if (!$r) {
         $e = oci_error($stid);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Obtener los resultados de la consulta
     $alm = new FiscCiudadano();
     while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $it = new ArrayIterator($fila);
         while ($it->valid()) {
             $alm->__SET(strtolower($it->key()), $it->current());
             $it->next();
         }
     }
     //Libera los recursos
     oci_free_statement($stid);
     // Cierra la conexión Oracle
     oci_close($this->conex);
     //retorna el resultado de la consulta
     return $alm;
 }
Ejemplo n.º 23
0
 /**
  * Returns the data of the current cache entry pointed to by the cache entry
  * iterator.
  *
  * @return mixed
  * @api
  */
 public function current()
 {
     if ($this->cacheEntriesIterator === null) {
         $this->rewind();
     }
     return $this->cacheEntriesIterator->current();
 }
Ejemplo n.º 24
0
 public function processStatesItr(ArrayIterator $statesItr)
 {
     // ArrayIterator
     for ($statesItr; $statesItr->valid(); $statesItr->next()) {
         echo $statesItr->key() . ' : ' . $statesItr->current() . PHP_EOL;
     }
 }
Ejemplo n.º 25
0
 function printer(ArrayIterator $iterator){
     while($iterator->valid()){
         print_r($iterator->current());
         echo "<br /><br />";
         $iterator->next();
     }
 }
Ejemplo n.º 26
0
 /**
  * Returns the current instance of Source object stored in the 'sources' iterator
  *
  * @return null|SourceInterface
  */
 public function getCurrentSource()
 {
     if ($this->sourcesIterator->valid()) {
         return $this->sourcesIterator->current();
     }
     return null;
 }
Ejemplo n.º 27
0
 /**
  * Helper method for recursively building a parse tree.
  *
  * @param \ArrayIterator $tokens Stream of tokens
  *
  * @throws \LogicException when nesting errors or mismatched section tags
  * are encountered.
  * @return array Token parse tree
  *
  */
 private function _buildTree(\ArrayIterator $tokens)
 {
     $stack = array();
     do {
         $token = $tokens->current();
         $tokens->next();
         if ($token !== null) {
             switch ($token[Tokenizer::TYPE]) {
                 case Tokenizer::T_END_SECTION:
                     $newNodes = array();
                     do {
                         $result = array_pop($stack);
                         if ($result === null) {
                             throw new \LogicException('Unexpected closing tag: /' . $token[Tokenizer::NAME]);
                         }
                         if (!array_key_exists(Tokenizer::NODES, $result) && isset($result[Tokenizer::NAME]) && $result[Tokenizer::NAME] == $token[Tokenizer::NAME]) {
                             $result[Tokenizer::NODES] = $newNodes;
                             $result[Tokenizer::END] = $token[Tokenizer::INDEX];
                             array_push($stack, $result);
                             break;
                         } else {
                             array_unshift($newNodes, $result);
                         }
                     } while (true);
                     // There is no break here, since we need the end token to handle the whitespace trim
                 // There is no break here, since we need the end token to handle the whitespace trim
                 default:
                     array_push($stack, $token);
             }
         }
     } while ($tokens->valid());
     return $stack;
 }
Ejemplo n.º 28
0
 /**
  * Helper method for recursively building a parse tree.
  *
  * @param ArrayIterator $tokens Stream of  tokens
  *
  * @return array Token parse tree
  *
  * @throws LogicException when nesting errors or mismatched section tags are encountered.
  */
 private function _buildTree(ArrayIterator $tokens)
 {
     $stack = array();
     do {
         $token = $tokens->current();
         $tokens->next();
         if ($token === null) {
             continue;
         } else {
             switch ($token[Handlebars_Tokenizer::TYPE]) {
                 case Handlebars_Tokenizer::T_END_SECTION:
                     $newNodes = array();
                     $continue = true;
                     do {
                         $result = array_pop($stack);
                         if ($result === null) {
                             throw new LogicException('Unexpected closing tag: /' . $token[Handlebars_Tokenizer::NAME]);
                         }
                         if (!array_key_exists(Handlebars_Tokenizer::NODES, $result) && isset($result[Handlebars_Tokenizer::NAME]) && $result[Handlebars_Tokenizer::NAME] == $token[Handlebars_Tokenizer::NAME]) {
                             $result[Handlebars_Tokenizer::NODES] = $newNodes;
                             $result[Handlebars_Tokenizer::END] = $token[Handlebars_Tokenizer::INDEX];
                             array_push($stack, $result);
                             break 2;
                         } else {
                             array_unshift($newNodes, $result);
                         }
                     } while (true);
                     break;
                 default:
                     array_push($stack, $token);
             }
         }
     } while ($tokens->valid());
     return $stack;
 }
Ejemplo n.º 29
0
/**
 * 自动加载
 *
 * @param $className
 */
function zroneClassLoader($className)
{
    $path = array(str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Vendor/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "FrameWork/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Application/"));
    if (isset($path) && is_array($path)) {
        $Iterator = new ArrayIterator($path);
        $Iterator->rewind();
        $pathString = "";
        while ($Iterator->valid()) {
            $pathString .= $Iterator->current() . ";";
            if ($Iterator->key() == count($path) - 1) {
                $pathString = rtrim($pathString, ";");
            }
            $Iterator->next();
        }
        set_include_path($pathString);
        spl_autoload_extensions(".php, .class.php");
        spl_autoload($className);
    } else {
        try {
            throw new Exception("<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>");
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
}
Ejemplo n.º 30
0
 /**
 * Replace portion of the string
 *
 * @deprecated
 *
 * @param integer $index
 * @param string $value
 * @param integer $start
 * @param integer $length
 *
 * @access public
 * @return void
 */
 public function ReplaceChunk($index, $value, $start = 0, $length = null)
 {
     if (null !== $length) {
         $this->length = $length;
     }
     switch (true) {
         case is_string($value):
             $this->temp_string = new \ArrayIterator(str_split($value));
             if (null === $length) {
                 $this->length = strlen($value);
             }
             break;
         case $value instanceof \ArrayIterator:
             $this->temp_string = $value;
             if (null === $length) {
                 $this->length = $value->count();
             }
             break;
         case is_array($value):
             $this->temp_string = new \ArrayIterator($value);
             if (null === $length) {
                 $this->length = count($value);
             }
             break;
         default:
             throw new \Exception('Invalid data type', 101);
     }
     $this->temp_string->seek($start);
     for ($i = $start; $i < $this->length; $i++) {
         $this->offsetSet($index, $this->temp_string->current());
         $index++;
         $this->temp_string->next();
     }
     $this->temp_string = null;
 }