Returns the index of the first row to return.

@param array $arguments overrides $this->requestArguments if set

@return int
960538
protected function getOffset($arguments = null)
    {
        if (null === $arguments) {
            $arguments = $this->requestArguments;
        }

        $offset = 0;

        if (array_key_exists('start', $arguments)) {
            $offset = (int) $arguments['start'];
        } else {
            if (array_key_exists('page', $arguments)) {
                $offset = ((int) $arguments['page'] - 1) * $this->getCount();
            }
        }

        $this->setConfigurationValue('offset', $offset);

        return $offset;
    }
657412
public function rowIndex($position = null)
    {
        if ($position === null) {
            $position = $this->position();
        }

        $i = 0;
        $p = 0;
        foreach ($this->structure as $row_ident => $row) {
            $numCells = count($row['columns']);
            $p += $numCells;
            if ($p > $position) {
                return $i;
            }
            $i++;
        }
        return null;
    }
120627
private function callCountBy(string $method, array $arguments)
    {
        $whereByWithUpper = lcfirst(substr($method, 7, mb_strlen($method)));
        $whereBy = Str::convertCamelCaseToSnakeCase($whereByWithUpper);

        $column = (isset($arguments[1])) ? $arguments[1] : '*';

        return $this->where($whereBy, '=', $arguments[0])->count($column);
    }
887192
public function passthru(array $arguments = [])
    {
        passthru($this->getBin() . $this->prepareCommand($arguments), $exitCode);
        return $exitCode;
    }
1188907
public function forward(Argument $args)
    {
        $args = $this->protectArgs($args);
        $limit = $args['first'];
        $offset = $this->connectionBuilder->getOffsetWithDefault($args['after'], 0);

        // If we don't have a cursor or if it's not valid, then we must not use the slice method
        if (!\is_numeric($this->connectionBuilder->cursorToOffset($args['after'])) || !$args['after']) {
            $entities = \call_user_func($this->fetcher, $offset, $limit ? $limit + 1 : $limit);

            return $this->handleEntities($entities, function ($entities) use ($args) {
                return $this->connectionBuilder->connectionFromArray($entities, $args);
            });
        } else {
            $entities = \call_user_func($this->fetcher, $offset, $limit ? $limit + 2 : $limit);

            return $this->handleEntities($entities, function ($entities) use ($args, $offset) {
                return $this->connectionBuilder->connectionFromArraySlice($entities, $args, [
                    'sliceStart' => $offset,
                    'arrayLength' => $offset + \count($entities),
                ]);
            });
        }
    }
449916
public function shouldRender(array $arguments = []) {
        $callback = $this->shouldRenderCallback;
        $result = $callback($this, $arguments);

        return $result;
    }
816824
public static function min(array $args)
    {
        usort(
            $args,
            function ($a, $b) {
                return count($a) < count($b) ? 1 : -1;
            }
        );
        return count(end($args));
    }
593130
public function fetchAll($as = 'array', $arguments = '')
    {

        $rows = array();
        $style = array(
            "array" => "fetchAssoc",
            "numeric" => "fetch",
            "object" => "fetchObject"
        );

        $as = !array_key_exists((string)$as, $style) ? "array" : (string)$as;

        //Getting all as an array
        while ($row = $this->$style[$as]($arguments)) {
            $rows[] = $row;
        }

        //Return the resultset;
        return $rows;
    }
1123316
protected function normalizeInput($arguments)
    {
        if (is_array($arguments[0])) {
            return $arguments[0];
        }

        if (count($arguments) == 2) {
            return [$arguments[0] => $arguments[1]];
        }

        throw new Exception('Try JavaScript::put(["foo" => "bar"])');
    }
502642
public function getFirst()
    {
        $row = $this->getIterator()->current();

        if ($row !== null) {
            $this->close(); // don't leave the SQL statement open
        }

        return $row;
    }
489136
public function getMostRecentVisitorId($arguments = [], $format = null)
    {
        $options = $this->getOptions($format)
            ->usePeriod(false)
            ->setArguments($arguments);

        return $this->request->send($options);
    }
44690
public function query(array $arguments = [])
    {
        return $this->plugger
            ->setModel($this)
            ->setAdapter(User::class)
            ->plugIn(get_users($arguments))
            ->getConnected();
    }
418134
public function GetRow($q, $arguments = [])
    {
        if (!is_array($arguments)) {
            $arguments = [$arguments]; // adodb backward compatibility
        }
        $r = $this->fetchAssoc($q, $arguments);
        if (!is_array($r)) {
            $r = [];
        }

        return $r;
    }
1372085
public function split(array $arguments = array()) {
		$splittedArguments = new AppendIterator();

		foreach ($this->_options['Period'] as $Date) {
			$_arguments = $arguments;
			$_arguments['--range'] = $Date->format(Configure::read('Task.dateFormat'));
			$splittedArguments->append($this->splitInner($_arguments));
		}

		return $splittedArguments;
	}
563940
protected function getSize( $arguments ) {
		$size = 'full';

		if ( ! empty( $arguments['width'] ) && ! empty( $arguments['height'] ) ) {
			$size = [ intval( $arguments['width'] ), intval( $arguments['height'] ) ];
		} elseif ( ! empty( $arguments['size'] ) ) {
			$size = [ intval( $arguments['size'] ), intval( $arguments['size'] ) ];
		}

		return $size;
	}
1264568
public function GetCol($q, $arguments = [])
    {
        $r = $this->fetchAll($q, $arguments);
        $return = [];

        foreach ($r as $value) {
            $return[] = $value[key($value)];
        }

        return $return;
    }
369301
public function query(array $arguments = [])
    {
        $options = array_merge([
            'hierarchical' => 'threaded',
        ], $arguments);

        return $this->plugger
            ->setModel($this)
            ->setAdapter(Comment::class)
            ->plugIn(get_comments($options))
            ->getConnected();
    }