Failed Conditions
Push — master ( 2b3b32...674f38 )
by Adrien
03:18
created

StatusLinks   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
eloc 17
dl 0
loc 34
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B statusLinks() 0 25 8
1
<?php
2
3
namespace mQueue\View\Helper;
4
5
use mQueue\Model\User;
6
use Zend_View_Helper_Abstract;
7
8
class StatusLinks extends Zend_View_Helper_Abstract
9
{
10
    /**
11
     * Returns the set of links to display a status (the icons used to rate movies)
12
     *
13
     * @param \mQueue\Model\Status $status
14
     *
15
     * @return string
16
     */
17
    public function statusLinks(\mQueue\Model\Status $status)
18
    {
19
        $result = '<div class="mqueue_status_links mqueue_status_links_' . $status->getUniqueId() . '">';
20
        $user = User::getCurrent();
21
22
        // Deactivate links if no logged user
23
        if ($user) {
0 ignored issues
show
introduced by
$user is of type mQueue\Model\User, thus it always evaluated to true.
Loading history...
24
            $tag = 'a';
25
        } else {
26
            $tag = 'span';
27
        }
28
29
        foreach (\mQueue\Model\Status::$ratings as $val => $name) {
30
            $class = $val . ($status->rating == $val ? ' current' : '');
0 ignored issues
show
Bug Best Practice introduced by
The property rating does not exist on mQueue\Model\Status. Since you implemented __get, consider adding a @property annotation.
Loading history...
31
            $url = $this->view->serverUrl() . $this->view->url([
32
                        'controller' => 'status',
33
                        'movie' => $status->idMovie,
0 ignored issues
show
Bug Best Practice introduced by
The property idMovie does not exist on mQueue\Model\Status. Since you implemented __get, consider adding a @property annotation.
Loading history...
34
                        'rating' => ($val == $status->rating && $user && $user->id == $status->idUser) ? 0 : $val,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on mQueue\Model\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property idUser does not exist on mQueue\Model\Status. Since you implemented __get, consider adding a @property annotation.
Loading history...
35
                            ], 'status', true);
36
37
            $result .= '<' . $tag . ' class="mqueue_status mqueue_status_' . $class . '"' . ($tag == 'a' ? ' href="' . $url . '"' : '') . ' title="' . $name . '"><span>' . $name . '</span></' . $tag . '>';
38
        }
39
        $result .= '<span class="preloader"></span></div>';
40
41
        return $result;
42
    }
43
}
44