TagCloud::__construct()   A
last analyzed

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 1
Metric Value
c 1
b 0
f 1
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\Widget;
4
5
use Albert221\Blog\Repository\TagRepositoryInterface;
6
use Doctrine\Common\Collections\Criteria;
7
use Twig_Environment;
8
9
class TagCloud implements WidgetInterface
10
{
11
    /**
12
     * @var TagRepositoryInterface
13
     */
14
    private $tags;
15
16
    /**
17
     * @var Twig_Environment
18
     */
19
    private $twig;
20
21
    public function __construct(TagRepositoryInterface $tags, Twig_Environment $twig)
22
    {
23
        $this->tags = $tags;
24
        $this->twig = $twig;
25
    }
26
    
27
    public function getName()
28
    {
29
        return 'Chmura tagów';
30
    }
31
32
    public function getHTML()
33
    {
34
        $criteria = Criteria::create()
35
            ->setMaxResults(50);
36
        
37
        $tags = $this->tags->paginated($criteria);
38
        
39
        return $this->twig->render('widgets/tag_cloud.twig', compact('tags'));
40
    }
41
}
42