HomeController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 43
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A index() 0 15 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Services\PostService;
6
use App\Services\StaticPageService;
7
use App\Services\TestimonialService;
8
9
class HomeController extends Controller
10
{
11
    private PostService $postService;
12
    private StaticPageService $staticPageService;
13
    private TestimonialService $testimonialService;
14
15
    /**
16
     * Create a new controller instance.
17
     *
18
     * @param  PostService  $postService
19
     * @param  StaticPageService  $staticPageService
20
     * @param  TestimonialService  $testimonialService
21
     */
22
    public function __construct(
23
        PostService $postService,
24
        StaticPageService $staticPageService,
25
        TestimonialService $testimonialService
26
    ) {
27
        $this->postService = $postService;
28
        $this->staticPageService = $staticPageService;
29
        $this->testimonialService = $testimonialService;
30
    }
31
32
    /**
33
     * Show the application dashboard.
34
     *
35
     * @return \Illuminate\Contracts\Support\Renderable
36
     */
37
    public function index()
38
    {
39
        $posts = $this->postService->getPosts();
0 ignored issues
show
Unused Code introduced by
The assignment to $posts is dead and can be removed.
Loading history...
40
41
        $videoIntro = $this->staticPageService->getStaticImageHtml('1');
42
43
        $lastPosts = $this->postService->getPosts(3, ['status' => 'published']);
44
45
        $testimonials = $this->testimonialService->getTestimonials(null, ['status' => 'published']);
46
        $random = $testimonials->random(3);
47
48
        return view('home', [
49
            'lastPosts' => $lastPosts,
50
            'videoIntro' => $videoIntro,
51
            'testimonials' => $random
52
        ]);
53
    }
54
}
55