Completed
Pull Request — master (#12)
by Quang
05:10
created

UpdateSchemaLockCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\Lumen\GraphQL\Commands;
4
5
use Digia\Lumen\GraphQL\Helpers\JsonEncoder;
6
use Digia\Lumen\GraphQL\GraphQLService;
7
use Digia\Lumen\GraphQL\LockFile;
8
use Illuminate\Console\Command;
9
use Jalle19\Laravel\LostInterfaces\Console\Command as CommandInterface;
10
11
/**
12
 * Class UpdateSchemaLockCommand
13
 * @package Digia\Lumen\GraphQL\Commands
14
 */
15
class UpdateSchemaLockCommand extends Command implements CommandInterface
16
{
17
18
    /**
19
     * @var string
20
     */
21
    protected $signature = 'graphql:schema:lock:update';
22
23
    /**
24
     * @var string
25
     */
26
    protected $description = 'Updates the schema.lock file';
27
28
    /**
29
     * @var GraphQLService
30
     */
31
    private $graphQlService;
32
33
    /**
34
     * UpdateSchemaLockCommand constructor.
35
     *
36
     * @param GraphQLService $graphQlService
37
     */
38
    public function __construct(GraphQLService $graphQlService)
39
    {
40
        parent::__construct();
41
42
        $this->graphQlService = $graphQlService;
43
    }
44
45
    /**
46
     * Returns path to graphql query
47
     *
48
     * @return string
49
     */
50
    protected function getQueryPath()
51
    {
52
        return __DIR__ . '/../../resources/graphql/Introspection.graphql';
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58
    public function handle()
59
    {
60
        $response = $this->graphQlService->getQueryResponse($this->getQueryPath());
61
62
        file_put_contents(LockFile::getAbsolutePath(), JsonEncoder::encode($response));
63
    }
64
}
65