GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 49d6e8...d5b92a )
by Cyril
12s
created

DateTimeColumn   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 27
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureOptions() 0 6 1
A formatCell() 0 14 3
1
<?php
2
3
4
namespace CrossKnowledge\DataTableBundle\DataTable\Table\Element\Column;
5
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
class DateTimeColumn extends Column
9
{
10
    /**
11
     * @param OptionsResolver $resolver
12
     */
13 4
    public function configureOptions(OptionsResolver $resolver)
14
    {
15 4
        parent::configureOptions($resolver);
16 4
        $resolver->setDefault('input_format', 'Y-m-d H:i:s');
17 4
        $resolver->setRequired('output_format');
18 4
    }
19
20 4
    public function formatCell($value, array $row, $context)
21
    {
22 4
        if (empty($value)) {
23 1
            return '';
24
        }
25 3
        $inputFormat = $this->getOptions()['input_format'];
26 3
        if ($inputFormat == 'object') {
27 1
            $dateTime = $value;
28 1
        } else {
29 2
            $dateTime = \DateTime::createFromFormat($inputFormat, $value);
30
        }
31
32 3
        return $dateTime->format($this->getOptions()['output_format']);
33
    }
34
}
35