ExploreComposer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 6
c 4
b 0
f 2
lcom 0
cbo 1
dl 0
loc 44
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B compose() 0 36 6
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 *
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Composers;
13
14
use Gitamin\Models\Issue;
15
use Gitamin\Models\Owner;
16
use Gitamin\Models\Project;
17
use Illuminate\Contracts\View\View;
18
19
class ExploreComposer
20
{
21
    /**
22
     * Index page view composer.
23
     *
24
     * @param \Illuminate\Contracts\View\View $view
25
     */
26
    public function compose(View $view)
27
    {
28
        // Default data
29
        $withData = [
30
            'systemStatus' => 'info',
31
            'systemMessage' => trans('gitamin.service.bad'),
32
            'favicon' => 'favicon-high-alert',
33
        ];
34
35
        if (Project::notVisibilityLevel(1)->count() === 0) {
0 ignored issues
show
Bug introduced by
The method notVisibilityLevel() does not exist on Gitamin\Models\Project. Did you maybe mean scopeNotVisibilityLevel()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
36
            // If all our projects are ok, do we have any non-fixed issues?
37
            $issues = Issue::orderBy('created_at', 'desc')->get();
38
            $issueCount = $issues->count();
39
40
            if ($issueCount === 0 || ($issueCount >= 1 && (int) $issues->first()->visibility_level === 4)) {
41
                $withData = [
42
                    'systemStatus' => 'success',
43
                    'systemMessage' => trans('gitamin.service.good'),
44
                    'favicon' => 'favicon',
45
                ];
46
            }
47
        } else {
48
            if (Project::whereIn('visibility_level', [2, 3])->count() > 0) {
49
                $withData['favicon'] = 'favicon-medium-alert';
50
            }
51
        }
52
53
        // Project & Project Team lists.
54
        $usedProjectTeams = Project::where('owner_id', '>', 0)->groupBy('owner_id')->lists('owner_id');
55
        $projectTeams = Owner::whereIn('id', $usedProjectTeams)->get();
56
        $unteamedProjects = Project::where('owner_id', 0)->orderBy('created_at')->get();
57
58
        $view->with($withData)
0 ignored issues
show
Bug introduced by
The method withProjectTeams() does not seem to exist on object<Illuminate\Contracts\View\View>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
            ->withProjectTeams($projectTeams)
60
            ->withUnteamedProjects($unteamedProjects);
61
    }
62
}
63