TestWidgetController::doAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 6
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace SilverStripe\Widgets\Tests\WidgetControllerTest;
4
5
use SilverStripe\Dev\TestOnly;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\Form;
8
use SilverStripe\Forms\FormAction;
9
use SilverStripe\Forms\TextField;
10
use SilverStripe\Widgets\Model\WidgetController;
11
12
/**
13
 * @package widgets
14
 * @subpackage tests
15
 */
16
class TestWidgetController extends WidgetController implements TestOnly
17
{
18
    private static $allowed_actions = array(
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
19
        'Form'
20
    );
21
22
    public function Form()
23
    {
24
        $widgetform = new Form(
25
            $this,
26
            __FUNCTION__,
27
            new FieldList(
28
                new TextField('TestValue')
29
            ),
30
            new FieldList(
31
                new FormAction('doAction')
32
            )
33
        );
34
35
        return $widgetform;
36
    }
37
38
    public function doAction($data, $form)
0 ignored issues
show
Unused Code introduced by
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

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