Completed
Push — master ( 09494e...ad2be9 )
by Woody
17:38
created

DateAwareTrait::dateString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Equip\Data\Traits;
4
5
use Carbon\Carbon;
6
7
trait DateAwareTrait
8
{
9
    /**
10
     * Get a date object for a property
11
     *
12
     * @param string $key
13
     *
14
     * @return Carbon
15
     */
16
    public function date($key)
17
    {
18
        return new Carbon($this->$key);
19
    }
20
21
    /**
22
     * Get a storage-friendly date string for a property
23
     *
24
     * @param string $key
25
     *
26
     * @return string
27
     */
28
    public function dateString($key)
29
    {
30
        return $this->date($key)->format('r');
31
    }
32
}
33