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 ( 0975eb...5701b0 )
by
unknown
03:37
created

Compiler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 64
rs 10
c 0
b 0
f 0

3 Methods

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