From 84743b12e00c5360cbe1ae5f5ff024838bd152f7 Mon Sep 17 00:00:00 2001 From: Paul Rock Date: Sat, 20 Jul 2019 15:27:04 +0300 Subject: [PATCH] Rosario class converted to method of Client --- src/Rosario.php | 209 -------------------------------------------------------- 1 file changed, 209 deletions(-) delete mode 100644 src/Rosario.php diff --git a/src/Rosario.php b/src/Rosario.php deleted file mode 100644 index 1449268..0000000 --- a/src/Rosario.php +++ /dev/null @@ -1,209 +0,0 @@ -current = 0; - - // This RAW should't be an error - $position = array_keys($raw, '!re'); - - // Split RAW to chinks or use as subarray - if (isset($position[1])) { - $length = $position[1] - $position[0]; - $raw = array_chunk($raw, $length); - array_pop($raw); - } else { - $raw = [$raw]; - } - - // Store parsed RAW data - $this->raw = $raw; - - // Return ready to use array - return $orig; - } - - /** - * Move forward to next element - */ - public function next() - { - ++$this->current; - } - - /** - * Return the current element - * - * @return mixed - */ - public function current() - { - if (isset($this->parsed[$this->current])) { - return $this->parsed[$this->current]; - } - - if (isset($this->raw[$this->current])) { - return $this->parseResponse($this->raw[$this->current])[0]; - } - - return false; - } - - /** - * Return the key of the current element - * - * @return mixed - */ - public function key() - { - return $this->current; - } - - /** - * Checks if current position is valid - * - * @return bool - */ - public function valid(): bool - { - return isset($this->raw[$this->current]); - } - - /** - * Count elements of an object - * - * @return int - */ - public function count(): int - { - return count($this->raw); - } - - /** - * Rewind the Iterator to the first element - */ - public function rewind() - { - $this->current = 0; - } - - /** - * Offset to set - * - * @param mixed $offset - * @param mixed $value - */ - public function offsetSet($offset, $value) - { - if (null === $offset) { - $this->parsed[] = $value; - } - $this->parsed[$offset] = $value; - } - - /** - * Whether a offset exists - * - * @param mixed $offset - * @return bool - */ - public function offsetExists($offset): bool - { - return isset($this->raw[$offset]); - } - - /** - * Offset to unset - * - * @param mixed $offset - */ - public function offsetUnset($offset) - { - unset($this->parsed[$offset], $this->raw[$offset]); - } - - /** - * Offset to retrieve - * - * @param mixed $offset - * @return mixed - */ - public function offsetGet($offset) - { - if (isset($this->parsed[$offset])) { - return $this->parsed[$offset]; - } - - if (isset($this->raw[$offset])) { - return $this->parsed[$offset] = $this->parseResponse($this->raw[$offset])[0]; - } - - // For empty() function - return null; - } - - /** - * Cleanup the array - */ - public function flush() - { - $this->raw = []; - $this->parsed = []; - } - -}