We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 17 | class BatchParser implements ParserInterface |
||
| 18 | { |
||
| 19 | const PARAM_ID = 'id'; |
||
| 20 | |||
| 21 | private static $queriesDefaultValue = [ |
||
| 22 | self::PARAM_ID => null, |
||
| 23 | self::PARAM_QUERY => null, |
||
| 24 | self::PARAM_VARIABLES => null, |
||
| 25 | ]; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param Request $request |
||
| 29 | * |
||
| 30 | * @return array |
||
| 31 | */ |
||
| 32 | 5 | public function parse(Request $request) |
|
| 33 | { |
||
| 34 | // Extracts the GraphQL request parameters |
||
| 35 | 5 | $queries = $this->getParsedBody($request); |
|
| 36 | |||
| 37 | 3 | if (empty($queries)) { |
|
| 38 | 1 | throw new BadRequestHttpException('Must provide at least one valid query.'); |
|
| 39 | } |
||
| 40 | |||
| 41 | 2 | foreach ($queries as $i => &$query) { |
|
| 42 | 2 | $query = $query + self::$queriesDefaultValue; |
|
| 43 | |||
| 44 | 2 | if (!is_string($query[static::PARAM_QUERY])) { |
|
| 45 | 1 | throw new BadRequestHttpException(sprintf('%s is not a valid query', json_encode($query[static::PARAM_QUERY]))); |
|
| 46 | } |
||
| 47 | 1 | } |
|
| 48 | |||
| 49 | 1 | return $queries; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Gets the body from the request. |
||
| 54 | * |
||
| 55 | * @param Request $request |
||
| 56 | * |
||
| 57 | * @return array |
||
| 58 | */ |
||
| 59 | 5 | private function getParsedBody(Request $request) |
|
| 76 | } |
||
| 77 |