Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#70)
by Jérémiah
07:10
created

GraphQLDumpSchemaCommand::execute()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
ccs 16
cts 16
cp 1
rs 8.8571
cc 3
eloc 16
nc 2
nop 2
crap 3
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Overblog\GraphQLBundle\Command;
13
14
use GraphQL\Type\Introspection;
15
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Symfony\Component\Console\Style\SymfonyStyle;
20
21
class GraphQLDumpSchemaCommand extends ContainerAwareCommand
22
{
23 1
    protected function configure()
24
    {
25 1
        $this
26 1
            ->setName('graphql:dump-schema')
27 1
            ->setAliases(['graph:dump-schema'])
28 1
            ->setDescription('Dumps GraphQL schema')
29 1
            ->addOption(
30 1
                'file',
31 1
                null,
32 1
                InputOption::VALUE_OPTIONAL,
33
                'Path to generate schema file.'
34 1
            )
35 1
            ->addOption(
36 1
                'schema',
37 1
                null,
38 1
                InputOption::VALUE_OPTIONAL,
39
                'The schema name to generate.'
40 1
            );
41 1
    }
42
43 1
    protected function execute(InputInterface $input, OutputInterface $output)
44
    {
45 1
        $output = new SymfonyStyle($input, $output);
46
47
        $request = [
48 1
            'query' => Introspection::getIntrospectionQuery(false),
49 1
            'variables' => [],
50 1
            'operationName' => null,
51 1
        ];
52 1
        $schemaName = $input->getOption('schema');
53
54 1
        $container = $this->getContainer();
55
        $result = $container
56 1
            ->get('overblog_graphql.request_executor')
57 1
            ->execute($request, [], $schemaName)
58 1
            ->toArray();
59
60 1
        $file = $input->getOption('file') ?: $container->getParameter('kernel.root_dir').sprintf('/../var/schema%s.json', $schemaName? '.'.$schemaName:'');
61
62 1
        $schema = json_encode($result['data']);
63
64 1
        file_put_contents($file, $schema);
65
66 1
        $output->success(sprintf('GraphQL schema "%s" was successfully dumped.', realpath($file)));
67 1
    }
68
}
69