Completed
Push — master ( cefc4c...542ee6 )
by Daniel
06:07 queued 01:38
created

TimeField::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\ContentType\Standard\Field;
6
7
use Psi\Component\ContentType\FieldInterface;
8
use Psi\Component\ContentType\OptionsResolver\FieldOptionsResolver;
9
use Psi\Component\ContentType\Standard\Storage;
10
use Psi\Component\ContentType\Standard\View;
11
use Symfony\Component\Form\Extension\Core\Type as Form;
12
13 View Code Duplication
class TimeField implements FieldInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    public function getViewType(): string
16
    {
17
        return View\DateTimeType::class;
18
    }
19
20
    public function getFormType(): string
21
    {
22
        return Form\TimeType::class;
23
    }
24
25
    public function getStorageType(): string
26
    {
27
        return Storage\DateTimeType::class;
28
    }
29
30
    public function configureOptions(FieldOptionsResolver $options)
31
    {
32
        $options->setFormMapper(function ($options, $shared) {
0 ignored issues
show
Unused Code introduced by
The parameter $shared is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
            $options['input'] = 'datetime';
34
35
            return $options;
36
        });
37
38
        $options->setViewMapper(function ($options, $shared) {
0 ignored issues
show
Unused Code introduced by
The parameter $shared is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
            $options = array_merge([
40
                'date_format' => 'none',
41
            ], $options);
42
43
            return $options;
44
        });
45
    }
46
}
47