GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PaginationControl::__invoke()   C
last analyzed

Complexity

Conditions 12
Paths 98

Size

Total Lines 32
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 32
rs 5.1612
cc 12
eloc 20
nc 98
nop 4

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * Paginator view helper.
5
 *
6
 * Long description for file (if any)...
7
 *
8
 * @author     Leandro Silva <[email protected]>
9
 *
10
 * @category   LosUi
11
 *
12
 * @license    https://github.com/Lansoweb/LosUi/blob/master/LICENSE MIT License
13
 *
14
 * @link       http://github.com/LansoWeb/LosUi
15
 * @link       http://getbootstrap.com/components/#pagination
16
 */
17
namespace LosUi\View\Helper;
18
19
use Zend\View\Helper\PaginationControl as ZfPaginationControl;
20
use Zend\Paginator;
21
22
/**
23
 * Paginator view helper.
24
 *
25
 * Long description for file (if any)...
26
 *
27
 * @author     Leandro Silva <[email protected]>
28
 *
29
 * @category   LosUi
30
 *
31
 * @license    https://github.com/Lansoweb/LosUi/blob/master/LICENSE MIT License
32
 *
33
 * @link       http://github.com/LansoWeb/LosUi
34
 * @link       http://getbootstrap.com/components/#pagination
35
 */
36
class PaginationControl extends ZfPaginationControl
37
{
38
    protected static $defaultViewPartial = 'paginator/control.phtml';
39
    protected static $nextLabel = 'Next &rarr;';
40
    protected static $previousLabel = '&larr; Previous';
41
42
    public function __invoke(
43
        Paginator\Paginator $paginator = null,
44
        $scrollingStyle = null,
45
        $partial = null,
46
        $params = null
47
    ) {
48
        if (is_string($params)) {
49
            $params = (array) $params;
50
        }
51
52
        if (isset($params['size'])) {
53
            if ($params['size'] != 'sm' && $params['size'] != 'lg') {
54
                throw new \RuntimeException('Size parameter must be either "sm" or "lg"');
55
            }
56
        }
57
        if ($partial === null && isset($params['type'])) {
58
            if ($params['type'] == 'pager') {
59
                $partial = 'paginator/pager.phtml';
60
            }
61
        }
62
        if (! isset($params['aligned']) || ! is_bool($params['aligned'])) {
63
            $params['aligned'] = true;
64
        }
65
        if (! isset($params['nextLabel'])) {
66
            $params['nextLabel'] = self::$nextLabel;
67
        }
68
        if (! isset($params['previousLabel'])) {
69
            $params['previousLabel'] = self::$previousLabel;
70
        }
71
72
        return parent::__invoke($paginator, $scrollingStyle, $partial, $params);
73
    }
74
}
75