Completed
Push — develop ( e649e8...88dc2a )
by
unknown
08:28
created

IndexController::dashboardAction()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 26
Code Lines 15

Duplication

Lines 26
Ratio 100 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 26
loc 26
rs 8.8571
cc 3
eloc 15
nc 4
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
/** Applications controller */
11
namespace Applications\Controller;
12
13
14
use Zend\Http\Request;
15
use Zend\Mvc\Controller\AbstractActionController;
16
use Zend\View\Model\ViewModel;
17
use Zend\View\Model\JsonModel;
18
19
20
/**
21
 * Main Action Controller for Applications module.
22
 *
23
 * @method \Core\Controller\Plugin\CreatePaginator paginator()
24
 * @method \Acl\Controller\Plugin\Acl acl()
25
 */
26
class IndexController extends AbstractActionController
27
{
28
    /**
29
     * Handles dashboard listings of applications
30
     *
31
     * @return array
32
     */
33 View Code Duplication
    public function dashboardAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        /* @var Request $request */
36
        $request = $this->getRequest();
37
        $params = $request->getQuery();
38
        $isRecruiter = $this->acl()->isRole('recruiter');
39
        if ($isRecruiter) {
40
            $params->set('by', 'me');
41
        }
42
43
         //default sorting
44
        if (!isset($params['sort'])) {
45
            $params['sort']="-date";
46
        }
47
        $params->count = 5;
0 ignored issues
show
Bug introduced by
Accessing count on the interface Zend\Stdlib\ParametersInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
48
        $params->pageRange=5;
0 ignored issues
show
Bug introduced by
Accessing pageRange on the interface Zend\Stdlib\ParametersInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
49
50
        $this->paginationParams()->setParams('Applications\Index', $params);
0 ignored issues
show
Bug introduced by
The method paginationParams() does not exist on Applications\Controller\IndexController. Did you maybe mean params()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
51
52
        $paginator = $this->paginator('Applications', $params->toArray());
0 ignored issues
show
Unused Code introduced by
The call to IndexController::paginator() has too many arguments starting with 'Applications'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
53
     
54
        return array(
55
            'script' => 'applications/index/dashboard',
56
            'applications' => $paginator
57
        );
58
    }
59
}
60