Passed
Push — master ( 00a718...8afe66 )
by Bruno
06:41
created

Renderable_pagination::fix()   A

Complexity

Conditions 6
Paths 32

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 6
eloc 10
c 1
b 1
f 0
nc 32
nop 3
dl 0
loc 17
rs 9.2222
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\Materialize\Renderable;
4
5
use Formularium\Field;
6
use Formularium\Renderable;
7
use Formularium\HTMLElement;
8
9
class Renderable_pagination extends Renderable_constant
10
{
11
    public function viewable($value, Field $field, HTMLElement $previous): HTMLElement
12
    {
13
        return $this->fix($value, $field, $previous);
14
    }
15
    
16
    public function editable($value, Field $field, HTMLElement $previous): HTMLElement
17
    {
18
        return $this->fix($value, $field, $previous);
19
    }
20
21
    /**
22
     * @param mixed $value
23
     * @param Field $field
24
     * @param HTMLElement $previous
25
     * @return HTMLElement
26
     */
27
    protected function fix($value, Field $field, HTMLElement $previous): HTMLElement
0 ignored issues
show
Unused Code introduced by
The parameter $field is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
    protected function fix($value, /** @scrutinizer ignore-unused */ Field $field, HTMLElement $previous): HTMLElement

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
    protected function fix(/** @scrutinizer ignore-unused */ $value, Field $field, HTMLElement $previous): HTMLElement

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29
        foreach ($previous->get('.formularium-disabled') as $e) {
30
            $e->addAttribute('class', 'disabled');
31
        }
32
        foreach ($previous->get('.formularium-pagination-item') as $e) {
33
            $e->addAttribute('class', 'waves-effect');
34
        }
35
        foreach ($previous->get('.formularium-pagination-current') as $e) {
36
            $e->addAttribute('class', 'active');
37
        }
38
        foreach ($previous->get('.formularium-pagination') as $e) {
39
            $e->addAttribute('class', 'pagination');
40
        }
41
42
        $x = $previous->get('ul');
43
        return $x ? $x[0] : $previous;
44
    }
45
}
46