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

DateField   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 34
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getViewType() 4 4 1
A getFormType() 4 4 1
A getStorageType() 4 4 1
A configureOptions() 16 16 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 DateField 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\DateType::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
                'time_format' => 'none',
41
            ], $options);
42
43
            return $options;
44
        });
45
    }
46
}
47