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 ( 6db13b...4f93b1 )
by Mark
02:28
created

UpgradePageMenuLinks   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
B handle() 0 26 3
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Classes\Repositories\MenuRepository;
6
use App\Classes\Repositories\PageRepository;
7
use App\Model\Link;
8
use App\Model\Menu;
9
use App\Model\Page;
10
use Illuminate\Console\Command;
11
12
class UpgradePageMenuLinks extends Command
13
{
14
15
    private $menus;
16
17
    private $pages;
18
19
    /**
20
     * The name and signature of the console command.
21
     *
22
     * @var string
23
     */
24
    protected $signature = 'upgrade:page_links';
25
26
    /**
27
     * The console command description.
28
     *
29
     * @var string
30
     */
31
    protected $description = 'Upgrade for version 5.0.1';
32
33
    /**
34
     * Create a new command instance.
35
     *
36
     * @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...
37
     */
38
    public function __construct(PageRepository $pages, MenuRepository $menus)
39
    {
40
        parent::__construct();
41
        
42
        $this->pages = $pages;
43
44
        $this->menus = $menus;
45
    }
46
47
    /**
48
     * Execute the console command.
49
     *
50
     * @return mixed
51
     */
52
    public function handle()
53
    {
54
        /** @var Menu $menu */
55
        foreach($this->menus->all() as $menu)
56
        {
57
            $link = new Link;
58
59
            /** @var Page $page */
60
            $page = $this->pages->whereID($menu->page_id);
61
62
            if ($menu->getAttribute('parent_id'))
63
            {
64
                $prefix = str_slug($menu->parent->title);
65
            }
66
            else
67
            {
68
                $prefix = "";
69
            }
70
71
            $page->setAttribute('prefix', $prefix)->save();
72
            
73
            $link->connect($menu, $page)->save();
74
75
            $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 163 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...
76
        }
77
    }
78
}
79