Completed
Push — master ( 6afe7c...34b094 )
by Woody
59:49 queued 43:17
created

DateAwareTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 26
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A date() 0 4 1
A dateString() 0 4 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