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

ActivityController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 16
c 2
b 0
f 0
dl 0
loc 38
rs 10
ccs 18
cts 18
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 23 5
A init() 0 11 1
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