Completed
Pull Request — master (#51)
by Daniel
05:05 queued 02:12
created

DateTimeType::createView()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 2
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\ContentType\Standard\View;
6
7
use Psi\Component\ContentType\View\TypeInterface;
8
use Psi\Component\ContentType\View\View;
9
use Psi\Component\ContentType\View\ViewFactory;
10
use Psi\Component\ContentType\View\ViewInterface;
11
use Symfony\Component\OptionsResolver\OptionsResolver;
12
13
class DateTimeType implements TypeInterface
14
{
15 View Code Duplication
    public function createView(ViewFactory $factory, $data, array $options): ViewInterface
0 ignored issues
show
Duplication introduced by
This method 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...
16
    {
17
        if (null !== $data && !$data instanceof \DateTime) {
18
            throw new \InvalidArgumentException(sprintf(
19
                'DateTime view only accepts \DateTime objects, got "%s"',
20
                is_object($data) ? get_class($data) : gettype($data)
21
            ));
22
        }
23
24
        return new DateTimeView($data, $options['tag']);
25
    }
26
27
    public function configureOptions(OptionsResolver $options)
28
    {
29
        $options->setDefault('tag', null);
30
    }
31
}
32