DateAwareTrait::dateString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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 3
    public function date($key)
17
    {
18 3
        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 1
    public function dateString($key)
29
    {
30 1
        return $this->date($key)->format('r');
31
    }
32
}
33