CarbonConverter::toDto()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Cerbero\LaravelDto\Manipulators;
4
5
use Carbon\Carbon;
6
use Cerbero\Dto\Manipulators\ValueConverter;
7
8
/**
9
 * The date time converter.
10
 *
11
 */
12
class CarbonConverter implements ValueConverter
13
{
14
    /**
15
     * Convert the given value to be exported from a DTO.
16
     *
17
     * @param mixed $value
18
     * @return mixed
19
     */
20 1
    public function fromDto($value)
21
    {
22 1
        return $value->toAtomString();
23
    }
24
25
    /**
26
     * Convert the given value to be imported into a DTO.
27
     *
28
     * @param mixed $value
29
     * @return mixed
30
     */
31 4
    public function toDto($value)
32
    {
33 4
        return Carbon::parse($value);
34
    }
35
}
36