getQueryParams(); $this->checkRequiredParams($params); $rows = isset($params['rows']) ? (int)$params['rows'] : null; $page = isset($params['page']) ? (int)$params['page'] : null; $startRow = is_null($rows) ? 0 : $rows * ($page - 1); return new SearchQuery( $params['params']['query'], $params['params']['structure'], $params['params']['parentNode'], $startRow, $rows, $page ); } /** * @throws CreateSearchQueryException */ private function checkRequiredParams(array $params): void { if (!isset($params['params']['rootNode'])) { throw new CreateSearchQueryException('Root node is missing from request'); } if (!isset($params['params']['query'])) { throw new CreateSearchQueryException('User input is missing'); } } }