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

Completed
Push — master ( c08359...df3a1d )
by Mark
02:41
created

UpgradePageMenuLinks::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 3
nop 0
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Model\Link;
6
use App\Model\Menu;
7
use App\Model\Page;
8
use Illuminate\Console\Command;
9
use App\Classes\Repositories\MenuRepository;
10
use App\Classes\Repositories\PageRepository;
11
12
class UpgradePageMenuLinks extends Command
13
{
14
    private $menus;
15
16
    private $pages;
17
18
    /**
19
     * The name and signature of the console command.
20
     *
21
     * @var string
22
     */
23
    protected $signature = 'upgrade:page_links';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = 'Upgrade for version 5.0.1';
31
32
    /**
33
     * Create a new command instance.
34
     *
35
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
36
     */
37
    public function __construct(PageRepository $pages, MenuRepository $menus)
38
    {
39
        parent::__construct();
40
41
        $this->pages = $pages;
42
43
        $this->menus = $menus;
44
    }
45
46
    /**
47
     * Execute the console command.
48
     *
49
     * @return mixed
50
     */
51
    public function handle()
52
    {
53
        /** @var Menu $menu */
54
        foreach ($this->menus->all() as $menu) {
55
            $link = new Link;
56
57
            /** @var Page $page */
58
            $page = $this->pages->whereID($menu->page_id);
59
60
            if ($menu->getAttribute('parent_id')) {
61
                $prefix = str_slug($menu->parent->title);
62
            } else {
63
                $prefix = '';
64
            }
65
66
            $page->setAttribute('prefix', $prefix)->save();
67
68
            $link->connect($menu, $page)->save();
69
70
            $this->info($menu->title.' => '.$page->getAttribute('seo_title').' ('.$page->getAttribute('prefix').'/'.$page->getAttribute('slug').')');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 149 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
71
        }
72
    }
73
}
74