LoginState::loginState()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2.1165

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 20
rs 9.8333
ccs 9
cts 13
cp 0.6923
cc 2
nc 2
nop 0
crap 2.1165
1
<?php
2
3
namespace mQueue\View\Helper;
4
5
use mQueue\Model\User;
6
use Zend_View_Helper_Abstract;
7
8
class LoginState extends Zend_View_Helper_Abstract
9
{
10
    /**
11
     * Returns a string displaying the login state of the user and buttons to login/off
12
     *
13
     * @return string
14
     */
15 12
    public function loginState()
16
    {
17 12
        $result = '<div class="loginState">';
18
19 12
        $user = User::getCurrent();
20 12
        if ($user) {
0 ignored issues
show
introduced by
$user is of type mQueue\Model\User, thus it always evaluated to true.
Loading history...
21
            $result .= '<a href="' . $this->view->serverUrl() . $this->view->url(
22
                    ['controller' => 'user', 'action' => 'view', 'id' => $user->id], 'singleid', true) . '">' . $this->view->gravatar($user) . ' ' . $this->view->escape($user->nickname) . '</a> ';
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 nickname does not exist on mQueue\Model\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
23
24
            $result .= '<a href="' . $this->view->serverUrl() . $this->view->url(
25
                    ['controller' => 'user', 'action' => 'logout'], 'default', true) . '">' . $this->view->translate('Logout') . '</a> ';
26
        } else {
27 12
            $result .= ' <a href="' . $this->view->serverUrl() . $this->view->url(
28 12
                    ['controller' => 'user', 'action' => 'new'], 'default', true) . '">' . $this->view->translate('Subscribe') . '</a> ';
29
30 12
            $result .= '<a href="' . $this->view->serverUrl() . $this->view->url(
31 12
                    ['controller' => 'user', 'action' => 'login'], 'default', true) . '">' . $this->view->translate('Login') . '</a>';
32
        }
33
34 12
        return $result . '</div>';
35
    }
36
}
37