Passed
Push — master ( 20c7a2...113399 )
by Stephen
02:33 queued 01:07
created

CarbonCast::castAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

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
rs 10
1
<?php
2
3
4
namespace Sfneal\Casts;
5
6
use Carbon\Carbon;
7
use Exception;
8
use Vkovic\LaravelCustomCasts\CustomCastBase;
9
10
class CarbonCast extends CustomCastBase
11
{
12
    /**
13
     * Store value as time code string
14
     *
15
     * @param string $value
16
     * @return string
17
     */
18
    public function setAttribute($value)
19
    {
20
        return $value;
21
    }
22
23
    /**
24
     * Retrieve value as Carbon instance
25
     *
26
     * @param string $value
27
     * @return Carbon
28
     * @throws Exception
29
     */
30
    public function castAttribute($value)
31
    {
32
        return (new Carbon($value));
33
    }
34
}
35