Test Failed
Push — dev6 ( ab8d6f...f89a9a )
by Ron
19:50
created

GetTipDetailsController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 4
1
<?php
2
3
namespace App\Http\Controllers\TechTips;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Http\Request;
7
8
use App\Models\TechTip;
9
use App\Models\TechTipBookmark;
0 ignored issues
show
Bug introduced by
The type App\Models\TechTipBookmark 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...
10
use App\Models\UserTechTipBookmark;
11
12
class GetTipDetailsController extends Controller
13
{
14
    /**
15
     * Get Admin details of a Tech Tip
16
     */
17
    public function __invoke($tipId)
18
    {
19
        $tip       = TechTip::find($tipId);
20
        $favorites = UserTechTipBookmark::where('tip_id', $tipId)->count();
21
22
        return [
23
            'author'      => $tip->CreatedBy->full_name,
24
            'dateCreated' => date('M d, Y', strtotime($tip->created_at)),
25
            'lastEdited'  => $tip->updated_id !== null ? date('M d, Y', strtotime($tip->updated_at)) : null,
26
            'editedBy'    => $tip->updated_id !== null ? $tip->UpdatedBy->full_name : null,
27
            'views'       => $tip->views,
28
            'favorites'   => $favorites,
29
            'isPinned'    => $tip->sticky ? 'Yes' : 'No',
30
        ];
31
    }
32
}
33