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 (#7)
by Jérémiah
09:24
created

GraphDumpSchemaCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 82.35%

Importance

Changes 2
Bugs 1 Features 2
Metric Value
wmc 5
c 2
b 1
f 2
lcom 0
cbo 6
dl 0
loc 51
ccs 28
cts 34
cp 0.8235
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 12 1
B execute() 0 35 4
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 GraphDumpSchemaCommand extends ContainerAwareCommand
22
{
23 1
    protected function configure()
24
    {
25 1
        $this
26 1
            ->setName('graph:dump-schema')
27 1
            ->setDescription('Dumps GraphQL schema')
28 1
            ->addOption(
29 1
                'file',
30 1
                null,
31 1
                InputOption::VALUE_OPTIONAL,
32
                'Path to generate schema file.'
33 1
            );
34 1
    }
35
36 1
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38 1
        $output = new SymfonyStyle($input, $output);
39
40
        $request = [
41 1
            'query' => Introspection::getIntrospectionQuery(false),
42 1
            'variables' => [],
43 1
            'operationName' => null,
44 1
        ];
45
46 1
        $container = $this->getContainer();
47
        $result = $container
48 1
            ->get('overblog_graphql.request_executor')
49 1
            ->execute($request)
50 1
            ->toArray();
51
52 1
        if (isset($result['errors'])) {
53
            foreach ($result['errors'] as $error) {
54
                $output->error($error['message']);
55
            }
56
57
            return 1;
58 1
        }
59
60 1
        $file = $input->getOption('file');
61 1
        if (empty($file)) {
62
            $file = $container->getParameter('kernel.root_dir').'/../var/schema.json';
63
        }
64
65 1
        $schema = json_encode($result['data']);
66
67 1
        file_put_contents($file, $schema);
68
69 1
        $output->success(sprintf('GraphQL schema "%s" was successfully dumped.', realpath($file)));
70 1
    }
71
}
72