Passed
Push — master ( a1de92...1a465b )
by Robbie
03:52
created

TestElementController::doAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace DNADesign\Elemental\Tests\Src;
4
5
use DNADesign\Elemental\Controllers\ElementController;
6
use SilverStripe\Dev\TestOnly;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\Form;
9
use SilverStripe\Forms\FormAction;
10
use SilverStripe\Forms\TextField;
11
12
class TestElementController extends ElementController implements TestOnly
13
{
14
    private static $url_segment = 'test-page';
0 ignored issues
show
introduced by Will Rossiter
The private property $url_segment is not used, and could be removed.
Loading history...
15
16
    private static $allowed_actions = array(
0 ignored issues
show
introduced by Julian Thomson
The private property $allowed_actions is not used, and could be removed.
Loading history...
17
        'Form'
18
    );
19
20
    public function Form()
21
    {
22
        $elementform = new Form(
23
            $this,
24
            'Form',
25
            new FieldList(
26
                new TextField('TestValue')
27
            ),
28
            new FieldList(
29
                new FormAction('doAction')
30
            )
31
        );
32
33
        return $elementform;
34
    }
35
36
    public function doAction($data, $form)
0 ignored issues
show
Unused Code introduced by Robbie Averill
The parameter $form 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

36
    public function doAction($data, /** @scrutinizer ignore-unused */ $form)

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...
37
    {
38
        return sprintf(
39
            'TestValue: %s\nElement ID: %d',
40
            $data['TestValue'],
41
            $this->element->ID
42
        );
43
    }
44
}
45