Completed
Push — master ( 9e983e...31750b )
by Ryan
07:18
created

AssignmentFormFields   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 63
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 54 2
1
<?php namespace Anomaly\Streams\Platform\Assignment\Form;
2
3
/**
4
 * Class AssignmentFormFields
5
 *
6
 * @link          http://anomaly.is/streams-platform
7
 * @author        AnomalyLabs, Inc. <[email protected]>
8
 * @author        Ryan Thompson <[email protected]>
9
 * @package       Anomaly\Streams\Platform\Assignment\Form
10
 */
11
class AssignmentFormFields
12
{
13
14
    /**
15
     * Handle the form fields.
16
     *
17
     * @param AssignmentFormBuilder $builder
18
     */
19
    public function handle(AssignmentFormBuilder $builder)
20
    {
21
        $builder->setFields(
22
            [
23
                'label'        => [
24
                    'label'        => 'streams::assignment.label.name',
25
                    'instructions' => 'streams::assignment.label.instructions',
26
                    'type'         => 'anomaly.field_type.text'
27
                ],
28
                'placeholder'  => [
29
                    'label'        => 'streams::assignment.placeholder.name',
30
                    'instructions' => 'streams::assignment.placeholder.instructions',
31
                    'type'         => 'anomaly.field_type.text'
32
                ],
33
                'instructions' => [
34
                    'label'        => 'streams::assignment.instructions.name',
35
                    'instructions' => 'streams::assignment.instructions.instructions',
36
                    'type'         => 'anomaly.field_type.textarea'
37
                ],
38
                'warning'      => [
39
                    'label'        => 'streams::assignment.warning.name',
40
                    'instructions' => 'streams::assignment.warning.instructions',
41
                    'type'         => 'anomaly.field_type.text'
42
                ],
43
                'required'     => [
44
                    'label'        => 'streams::assignment.required.label',
45
                    'instructions' => 'streams::assignment.required.instructions',
46
                    'type'         => 'anomaly.field_type.boolean'
47
                ],
48
                'unique'       => [
49
                    'label'        => 'streams::assignment.unique.label',
50
                    'instructions' => 'streams::assignment.unique.instructions',
51
                    'type'         => 'anomaly.field_type.boolean'
52
                ],
53
                'translatable' => [
54
                    'label'        => 'streams::assignment.translatable.label',
55
                    'instructions' => 'streams::assignment.translatable.instructions',
56
                    'type'         => 'anomaly.field_type.boolean',
57
                    'warning'      => function (AssignmentFormBuilder $builder) {
58
59
                        $type = $builder->getFieldType();
60
61
                        return $type->getColumnType() == null ? 'streams::assignment.translatable.warning' : null;
62
                    },
63
                    'disabled'     => function (AssignmentFormBuilder $builder) {
64
65
                        $type = $builder->getFieldType();
66
67
                        return $type->getColumnType() == null;
68
                    }
69
                ]
70
            ]
71
        );
72
    }
73
}
74