StatusLinks   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

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

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\Status;
6
use mQueue\Model\User;
7
use Zend_View_Helper_Abstract;
8
9
class StatusLinks extends Zend_View_Helper_Abstract
10
{
11
    /**
12
     * Returns the set of links to display a status (the icons used to rate movies)
13
     *
14
     * @param Status $status
15
     *
16
     * @return string
17
     */
18 1
    public function statusLinks(Status $status)
19
    {
20 1
        $result = '<div class="mqueue_status_links mqueue_status_links_' . $status->getUniqueId() . '">';
21 1
        $user = User::getCurrent();
22
23
        // Deactivate links if no logged user
24 1
        if ($user) {
0 ignored issues
show
introduced by
$user is of type mQueue\Model\User, thus it always evaluated to true.
Loading history...
25
            $tag = 'a';
26
        } else {
27 1
            $tag = 'span';
28
        }
29
30 1
        foreach (Status::$ratings as $val => $name) {
31 1
            $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...
32 1
            $url = $this->view->serverUrl() . $this->view->url([
33 1
                    'controller' => 'status',
34 1
                    '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...
35 1
                    '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...
36 1
                ], 'status', true);
37
38 1
            $result .= '<' . $tag . ' class="mqueue_status mqueue_status_' . $class . '"' . ($tag == 'a' ? ' href="' . $url . '"' : '') . ' title="' . $name . '"><span>' . $name . '</span></' . $tag . '>';
39
        }
40 1
        $result .= '<span class="preloader"></span></div>';
41
42 1
        return $result;
43
    }
44
}
45