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

Passed
Push — save-to-mobile-without-address... ( 61f1f9 )
by Pedro
13:06
created

PublishHeaderMetas   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 43
c 1
b 0
f 1
dl 0
loc 80
rs 10
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 61 7
1
<?php
2
3
namespace Backpack\CRUD\app\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\File;
7
use Illuminate\Support\Str;
8
9
class PublishHeaderMetas extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'backpack:publish-header-metas';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Publishes the header metas and assets.';
24
25
    /**
26
     * Execute the console command.
27
     */
28
    public function handle()
29
    {
30
        $appName = $this->ask('Whats the application name ?', 'Backpack');
31
        $appUrl = $this->ask('Whats the application url ?', config('app.url'));
32
        $backpackPrefix = config('backpack.base.route_prefix');
33
        $appColor = $this->ask('Whats the application color ?', '#605ca8');
34
        $pathPrefix = $this->ask('Where should icon files be published relative to public folder?');
35
36
        if ( $pathPrefix) {
37
            $pathPrefix = Str::finish($pathPrefix, '/');
38
        }
39
40
        $fileToPublish = [
41
            public_path($pathPrefix.'manifest.json')                                                 => __DIR__.'/../../../resources/stubs/manifest.stub',
42
            public_path($pathPrefix.'site.webmanifest')                                              => __DIR__.'/../../../resources/stubs/manifest.stub',
43
            resource_path('views/vendor/backpack/ui/inc/header_metas.blade.php')              => __DIR__.'/../../../resources/stubs/header_metas.stub',
44
            public_path($pathPrefix.'android-chrome-192x192.png'),
45
            public_path($pathPrefix.'android-chrome-512x512.png'),
46
            public_path($pathPrefix.'apple-touch-icon.png'),
47
            public_path($pathPrefix.'favicon-16x16.png'),
48
            public_path($pathPrefix.'favicon-32x32.png'),
49
            public_path($pathPrefix.'favicon.ico'),
50
            public_path($pathPrefix.'safari-pinned-tab.svg'),
51
        ];
52
53
        foreach ($fileToPublish as $destination => $stub) {
54
            if (! is_string($destination)) {
55
                $destination = $stub;
56
                $stub = null;
57
            }
58
59
            if (File::exists($destination)) {
60
                $this->comment("The file {$destination} already exists. Skipping.");
61
62
                continue;
63
            }
64
65
            if (! File::isDirectory(dirname($destination))) {
66
                File::makeDirectory(dirname($destination), 0755, true);
67
            }
68
69
            if (! $stub) {
70
                File::copy(__DIR__.'/../../../public/'.basename($destination), $destination);
71
                $this->info("File {$destination} published.");
72
                continue;
73
            }
74
75
            $stub = File::get($stub);
76
77
            $stub = str_replace('__APP_NAME__', $appName, $stub);
78
            $stub = str_replace('__APP_URL__', $appUrl, $stub);
79
            $stub = str_replace('__APP_COLOR__', $appColor, $stub);
80
            $stub = str_replace('__BACKPACK_PREFIX__', $backpackPrefix, $stub);
81
            $stub = str_replace('__PATH_PREFIX__', $pathPrefix, $stub);
82
83
            File::put($destination, $stub);
84
85
            $this->info("File {$destination} published.");
86
        }
87
88
        $this->info('Metas and assets published successfully.');
89
    }
90
}
91