/** * Get current element * * Takes into account if the callback returns a Generator * * @return mixed */ public function current() { if ($this->generator) { return $this->generator->current(); } $callable = $this->callable; $result = $callable(); if (!$this->generator && $this->generator !== false) { $this->generator = $result instanceof \Generator ? $result : false; if ($this->generator) { return $this->generator->current(); } } return $result; }
/** * Returns the current leaf. * * @return false|RecursiveLeafInterface Returns the current leaf on success, * false otherwise */ public function current() { if (is_null($this->current)) { $this->current = current($this->branch); } if ($this->current instanceof RecursiveLeafInterface) { return $this->current->current(); } return false; }