Completed
Push — master ( c41584...7f844e )
by Quang
9s
created

UpdateSchemaLockCommand::getQueryPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
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
     * Path to default Introspection query
20
     *
21
     * @var string
22
     */
23
    public const INTROSPECTION_GRAPHQL =  __DIR__ . '/../../resources/graphql/Introspection.graphql';
24
25
    /**
26
     * @var string
27
     */
28
    protected $signature = 'graphql:schema:lock:update';
29
30
    /**
31
     * @var string
32
     */
33
    protected $description = 'Updates the schema.lock file';
34
35
    /**
36
     * @var GraphQLService
37
     */
38
    private $graphQlService;
39
40
    /**
41
     * UpdateSchemaLockCommand constructor.
42
     *
43
     * @param GraphQLService $graphQlService
44
     */
45
    public function __construct(GraphQLService $graphQlService)
46
    {
47
        parent::__construct();
48
49
        $this->graphQlService = $graphQlService;
50
    }
51
52
    /**
53
     * Returns path to graphql query
54
     *
55
     * @return string
56
     */
57
    protected function getQueryPath()
58
    {
59
        return self::INTROSPECTION_GRAPHQL;
60
    }
61
62
    /**
63
     * @inheritDoc
64
     */
65
    public function handle()
66
    {
67
        $response = $this->graphQlService->getQueryResponse($this->getQueryPath());
68
69
        file_put_contents(LockFile::getAbsolutePath(), JsonEncoder::encode($response));
70
    }
71
}
72