FormModelSelectOption   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 67
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A callbackSubmit() 0 12 1
A __construct() 0 35 1
1
<?php
2
3
namespace Anax\HTMLForm;
4
5
use Psr\Container\ContainerInterface;
6
7
/**
8
 * Example of FormModel implementation.
9
 */
10
class FormModelSelectOption extends FormModel
11
{
12
    /**
13
     * Constructor injects with DI container.
14
     *
15
     * @param Anax\DI\DIInterface $di a service container
0 ignored issues
show
Bug introduced by
The type Anax\HTMLForm\Anax\DI\DIInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
     */
17
    public function __construct(ContainerInterface $di)
18
    {
19
        parent::__construct($di);
20
        $this->form->create(
21
            [
22
                "id" => __CLASS__,
23
                "legend" => "Legend"
24
            ],
25
            [
26
                "expmonth" => [
27
                    "type" => "select",
28
                    "label" => "Expiration month:",
29
                    
30
                    "options" => [
31
                        "default" => "Select credit card expiration month...",
32
                        "01" => "January",
33
                        "02" => "February",
34
                        "03" => "March",
35
                        "04" => "April",
36
                        "05" => "May",
37
                        "06" => "June",
38
                        "07" => "July",
39
                        "08" => "August",
40
                        "09" => "September",
41
                        "10" => "October",
42
                        "11" => "November",
43
                        "12" => "December",
44
                    ],
45
                    //"value"   => "8",
46
                ],
47
                
48
                "doPay" => [
49
                    "type" => "submit",
50
                    "value" => "Perform payment",
51
                    "callback" => [$this, "callbackSubmit"]
52
                ],
53
            ]
54
        );
55
    }
56
57
58
59
    /**
60
     * Callback for submit-button which should return true if it could
61
     * carry out its work and false if something failed.
62
     *
63
     * @return boolean true if okey, false if something went wrong.
64
     */
65
    public function callbackSubmit()
66
    {
67
        $this->form->addOutput(
68
            "<p>Selected month is: "
69
            . $this->form->value("expmonth")
70
            . "</p>"
71
        );
72
73
        // Remember values during resubmit, for sake of the example
74
        $this->form->rememberValues();
75
76
        return true;
77
    }
78
}
79