Completed
Push — master ( eaa10a...12d04d )
by Albert
03:25
created

RecentPosts::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Albert221\Blog\Sidebar\Widget;
4
5
use Albert221\Blog\Repository\PostRepositoryInterface;
6
use Twig_Environment;
7
8
class RecentPosts implements WidgetInterface
9
{
10
    /**
11
     * @var PostRepositoryInterface
12
     */
13
    private $posts;
14
15
    /**
16
     * @var Twig_Environment
17
     */
18
    private $twig;
19
20
    public function __construct(PostRepositoryInterface $posts, Twig_Environment $twig)
21
    {
22
        $this->posts = $posts;
23
        $this->twig = $twig;
24
    }
25
26
    public function getName()
27
    {
28
        return 'Najnowsze posty';
29
    }
30
31
    public function getHTML()
32
    {
33
        $posts = $this->posts->paginated(1, 10);
34
35
        return $this->twig->render('widgets/recent_posts.twig', compact('posts'));
36
    }
37
}
38