Completed
Push — master ( 8c9c54...6d4889 )
by Elf
44:15
created

FreshCreatedAt   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
setCreatedAt() 0 1 ?
freshTimestamp() 0 1 ?
A bootFreshCreatedAt() 0 6 1
1
<?php
2
3
namespace ElfSundae\Support\Traits\Eloquent;
4
5
trait FreshCreatedAt
6
{
7
    /**
8
     * Set the value of the "created at" attribute.
9
     *
10
     * @param  mixed  $value
11
     * @return $this
12
     */
13
    abstract public function setCreatedAt($value);
14
15
    /**
16
     * Get a fresh timestamp for the model.
17
     *
18
     * @return \Carbon\Carbon
19
     */
20
    abstract public function freshTimestamp();
21
22
    /**
23
     * Boot the trait.
24
     *
25
     * Add a creating observer, set the value of the "created_at" attribute.
26
     */
27
    protected static function bootFreshCreatedAt()
28
    {
29
        static::creating(function ($model) {
30
            $model->setCreatedAt($model->freshTimestamp());
31
        });
32
    }
33
}
34