Completed
Push — master ( 699dc6...d8f60e )
by Changwan
05:50
created

CarbonCaster::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
namespace Wandu\Caster\Caster;
3
4
use Carbon\Carbon;
5
use Wandu\Caster\CasterInterface;
6
7
class CarbonCaster implements CasterInterface
8
{
9
    /** @var string */
10
    protected $timezone;
11
12
    /**
13
     * @param string $timezone
14
     */
15 1
    public function __construct($timezone = null)
16
    {
17 1
        $this->timezone = $timezone;
18 1
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    public function cast($value)
24
    {
25 1
        return new Carbon($value, $this->timezone);
26
    }
27
}
28