Test Setup Failed
Push — master ( f46e6c...b515a7 )
by Sam
05:53
created

AssociationsController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 8 1
1
<?php
2
3
namespace App\Http\Controllers\Api;
4
5
use App\Http\Controllers\Controller;
6
7
use App\Association;
8
use App\Division;
9
use App\ResultSubmission;
10
use App\Round;
11
use App\Series;
12
use App\Schedule;
13
use App\User;
14
use App\Venue;
15
16
use App\Http\Resources\Association as AssociationResource;
17
use App\Http\Resources\AssociationCollection as AssociationCollectionResource;
18
19
use Bouncer;
0 ignored issues
show
Bug introduced by
The type Bouncer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Illuminate\Http\Request;
21
use Illuminate\Support\Arr;
22
use Illuminate\Support\Str;
23
24
class AssociationsController extends Controller
25
{
26
27
    public function __construct(Request $request) {
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
    public function __construct(/** @scrutinizer ignore-unused */ Request $request) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
        $subdomain = Arr::first(explode('.', \Request::getHost()));
29
30
        $this->association = Association::where('subdomain', $subdomain)->first();
0 ignored issues
show
Bug Best Practice introduced by
The property association does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
    }
32
33
    public function index(Request $request) {
34
        $user = $request->user();
0 ignored issues
show
Unused Code introduced by
The assignment to $user is dead and can be removed.
Loading history...
35
36
        $userAssociations = Association::all()->filter(function ($association) {
37
            return Bouncer::can('manage', $association);
38
        });
39
40
        return new AssociationCollectionResource($userAssociations);
41
    }
42
43
}
44