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

RecentPosts   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 30
ccs 0
cts 14
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A getHTML() 0 6 1
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