| Conditions | 1 |
| Paths | 1 |
| Total Lines | 12 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 1 |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 1 | public function getIndex(Tag $tag, Project $project, User $user) |
|
| 35 | { |
||
| 36 | 1 | return view('administration.index', [ |
|
| 37 | 1 | 'users' => $user->countUsers(), |
|
| 38 | 1 | 'active_projects' => $project->countOpenProjects(), |
|
| 39 | 1 | 'archived_projects' => $project->countArchivedProjects(), |
|
| 40 | 1 | 'open_issues' => $project->countOpenIssues(), |
|
| 41 | 1 | 'closed_issues' => $project->countClosedIssues(), |
|
| 42 | 1 | 'projects' => $this->auth->user()->projects()->get(), |
|
|
|
|||
| 43 | 1 | 'tags' => $tag->count(), |
|
| 44 | ]); |
||
| 45 | } |
||
| 46 | } |
||
| 47 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: