CommentStatusRenderer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handlesObject() 0 4 1
A getStatusClass() 0 13 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\NewsBundle\Status;
15
16
use Sonata\NewsBundle\Model\CommentInterface;
17
use Sonata\Twig\Status\StatusClassRendererInterface;
18
19
/**
20
 * @author Hugo Briand <[email protected]>
21
 */
22
class CommentStatusRenderer implements StatusClassRendererInterface
23
{
24
    public function handlesObject($object, $statusName = null)
25
    {
26
        return $object instanceof CommentInterface;
27
    }
28
29
    public function getStatusClass($object, $statusName = null, $default = '')
30
    {
31
        switch ($object->getStatus()) {
32
            case CommentInterface::STATUS_INVALID:
33
                return 'danger';
34
            case CommentInterface::STATUS_MODERATE:
35
                return 'warning';
36
            case CommentInterface::STATUS_VALID:
37
                return 'success';
38
            default:
39
                return null;
40
        }
41
    }
42
}
43