Completed
Push — master ( d88694...1943e9 )
by Bram
01:18
created

UserEmailField::createField()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
3
/**
4
 * Class UserEmailField
5
 *
6
 * @author Bram de Leeuw
7
 * @package UserTextField
8
 */
9
class UserEmailField extends Broarm\EventTickets\UserField
10
{
11
    /**
12
     * @var FormField
13
     */
14
    protected $fieldType = 'EmailField';
15
16
    /**
17
     * Create a default text field
18
     *
19
     * @param string  $fieldName
20
     * @param null    $defaultValue
21
     * @param boolean $main check if the field is for the main attendee
22
     *
23
     * @return NumericField|FormField
24
     */
25
    public function createField($fieldName, $defaultValue = null, $main = false)
26
    {
27
        $field = parent::createField($fieldName, $defaultValue, $main);
28
29
        // If we have the main booker account, we create a
30
        if ($main) {
31
            $field = CompositeField::create([
32
                EmailField::create("{$fieldName}[_Email]", $this->Title, $defaultValue),
33
                EmailField::create(
34
                    "{$fieldName}[_ConfirmedEmail]",
35
                    _t(__CLASS__ . '.ConfirmedEmail', 'Confirm {title}', null, ['title' => $this->Title]),
0 ignored issues
show
Documentation introduced by
array('title' => $this->Title) is of type array<string,string,{"title":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36
                    $defaultValue
37
                ),
38
            ]);
39
            $field->addExtraClass($this->ExtraClass);
40
        }
41
42
        return $field;
43
    }
44
}
45