Completed
Push — master ( 8758f6...2f019a )
by Phecho
03:41
created

app/Composers/ExploreComposer.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
     * @return void
27
     */
28
    public function compose(View $view)
29
    {
30
        // Default data
31
        $withData = [
32
            'systemStatus'  => 'info',
33
            'systemMessage' => trans('gitamin.service.bad'),
34
            'favicon'       => 'favicon-high-alert',
35
        ];
36
37
        if (Project::notVisibilityLevel(1)->count() === 0) {
0 ignored issues
show
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...
38
            // If all our projects are ok, do we have any non-fixed issues?
39
            $issues = Issue::orderBy('created_at', 'desc')->get();
40
            $issueCount = $issues->count();
41
42
            if ($issueCount === 0 || ($issueCount >= 1 && (int) $issues->first()->visibility_level === 4)) {
43
                $withData = [
44
                    'systemStatus'  => 'success',
45
                    'systemMessage' => trans('gitamin.service.good'),
46
                    'favicon'       => 'favicon',
47
                ];
48
            }
49
        } else {
50
            if (Project::whereIn('visibility_level', [2, 3])->count() > 0) {
51
                $withData['favicon'] = 'favicon-medium-alert';
52
            }
53
        }
54
55
        // Project & Project Team lists.
56
        $usedProjectTeams = Project::where('owner_id', '>', 0)->groupBy('owner_id')->lists('owner_id');
57
        $projectTeams = Owner::whereIn('id', $usedProjectTeams)->get();
58
        $unteamedProjects = Project::where('owner_id', 0)->orderBy('created_at')->get();
59
60
        $view->with($withData)
0 ignored issues
show
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...
61
            ->withProjectTeams($projectTeams)
62
            ->withUnteamedProjects($unteamedProjects);
63
    }
64
}
65