AbstractTransformer::formatDate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace NwLaravel\Transformer;
3
4
use League\Fractal\TransformerAbstract;
5
use \DateTime;
6
7
/**
8
 * Class AbstractTransformer
9
 * @abstract
10
 */
11
abstract class AbstractTransformer extends TransformerAbstract
12
{
13
    /**
14
     * Format Date
15
     *
16
     * @param DateTime $date   Date Time
17
     * @param string   $format String Format
18
     *
19
     * @return string
20
     */
21 1
    public function formatDate($date, $format)
22
    {
23 1
        if ($date instanceof DateTime) {
24 1
            return $date->format($format);
25
        }
26
27 1
        return null;
28
    }
29
}
30