GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 5701b0...88717a )
by Brian
02:03
created

Compiler::getContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace SocialiteProviders\Generators\Compilers;
4
5
use SocialiteProviders\Generators\Contexts\Stub;
6
use Illuminate\Contracts\View\Factory as ViewFactory;
7
8
class Compiler
9
{
10
    /**
11
     * The filesystem instance.
12
     *
13
     * @var \Illuminate\Filesystem\Filesystem
14
     */
15
    protected $files;
16
17
    /**
18
     * Blade Engine.
19
     *
20
     * @var \Illuminate\View\Factory
21
     */
22
    protected $view;
23
24
    /**
25
     * View Context.
26
     *
27
     * @var \SocialiteProviders\Generators\Contexts\Stub
28
     */
29
    protected $context;
30
31
    /**
32
     * Create a new compiler instance.
33
     *
34
     * @param array $data
35
     */
36
    public function __construct(array $data)
37
    {
38
        $this->files = app('files');
39
        $this->view = app(ViewFactory::class);
40
        $this->context = new Stub($data);
41
    }
42
43
    /**
44
     * Generate the composer.json.
45
     */
46
    public function composer()
47
    {
48
        return $this->compile('composer', 'composer.json');
49
    }
50
51
    /**
52
     * @return \SocialiteProviders\Generators\Contexts\Stub
53
     */
54
    public function getContext()
55
    {
56
        return $this->context;
57
    }
58
59
    /**
60
     * Generate the target file from a stub.
61
     *
62
     * @param $stub
63
     * @param $targetLocation
64
     */
65
    protected function compile($stub, $targetLocation)
66
    {
67
        $view = $this->view->make("generator.stubs::$stub", $this->context->toArray());
68
69
        $contents = "<?php\r\n\r\n".$view->render();
70
71
        $targetDir = base_path('/SocialiteProviders/'.$this->context->nameStudlyCase());
72
        if (!$this->files->isDirectory($targetDir)) {
73
            $this->files->makeDirectory($targetDir, 0755, true, true);
74
            $this->files->makeDirectory($targetDir.'/src', 0755, true, true);
75
        }
76
77
        $this->files->put($targetDir.'/'.$targetLocation, $contents);
78
    }
79
}
80