LatestPostsComposer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 2
1
<?php namespace Modules\Blog\Composers\Frontend;
2
3
use Illuminate\Contracts\View\View;
4
use Modules\Blog\Repositories\PostRepository;
5
use Modules\Core\Contracts\Setting;
6
7
class LatestPostsComposer
8
{
9
    /**
10
     * @var PostRepository
11
     */
12
    private $post;
13
    /**
14
     * @var Setting
15
     */
16
    private $setting;
17
18
    public function __construct(PostRepository $post, Setting $setting)
19
    {
20
        $this->post = $post;
21
        $this->setting = $setting;
22
    }
23
24
    public function compose(View $view)
25
    {
26
        $limit = $this->setting->get('blog::latest-posts-amount', locale(), 5);
27
28
        $view->with('latestPosts', $this->post->latest($limit));
29
    }
30
}
31