Failed Conditions
Push — master ( 1a6d63...dcbc0d )
by Adrien
05:26
created

ActivityController::indexAction()   A

Complexity

Conditions 5
Paths 9

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 23
rs 9.6111
ccs 12
cts 12
cp 1
cc 5
nc 9
nop 0
crap 5
1
<?php
2
3
class ActivityController extends Zend_Controller_Action
4
{
5 3
    public function init(): void
6
    {
7
        // Init the Context Switch Action helper
8 3
        $contextSwitch = $this->_helper->contextSwitch();
9
10
        // Add the new context
11 3
        $contextSwitch->setContexts([
12 3
            'rss' => ['suffix' => 'rss'],
13
        ]);
14
15 3
        $contextSwitch->addActionContext('index', 'rss')->initContext();
16 3
    }
17
18 3
    public function indexAction(): void
19
    {
20
        // By default we show overall activity
21 3
        $item = null;
22 3
        $this->view->title = $this->view->translate('Overall activity');
23
24
        // Try to show user's actitvity
25 3
        if ($this->getRequest()->getParam('user')) {
26 1
            $item = \mQueue\Model\UserMapper::find($this->getRequest()->getParam('user'));
27 1
            if ($item) {
28 1
                $this->view->title = $this->view->translate('Activity for %s', [$item->nickname]);
0 ignored issues
show
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...
29
            }
30
        }
31
32
        // Try to show movie's actitvity
33 3
        if ($this->getRequest()->getParam('movie')) {
34 1
            $item = \mQueue\Model\MovieMapper::find($this->getRequest()->getParam('movie'));
35 1
            if ($item) {
36 1
                $this->view->title = $this->view->translate('Activity for %s', [$item->getTitle()]);
37
            }
38
        }
39
40 3
        $this->view->activity = $this->_helper->createPaginator(\mQueue\Model\StatusMapper::getActivityQuery($item));
41 3
    }
42
}
43