Completed
Push — extensions-support ( f3b32a...74d037 )
by Patrick
03:10
created

Timestamps::enable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Extensions\Gedmo;
4
5
use LaravelDoctrine\Fluent\Builders\Builder;
6
use LaravelDoctrine\Fluent\Fluent;
7
8
class Timestamps
9
{
10
    const MACRO_METHOD = 'timestamps';
11
12
    /**
13
     * Enable the extension.
14
     *
15
     * @return void
16
     */
17
    public static function enable()
18
    {
19 2
        Builder::macro(self::MACRO_METHOD, function (Fluent $builder, $createdAt = 'createdAt', $updatedAt = 'updatedAt', $type = 'dateTime') {
20 1
            $builder->{$type}($createdAt)->timestampable()->onCreate();
21 1
            $builder->{$type}($updatedAt)->timestampable()->onUpdate();
22 2
        });
23 2
    }
24
}
25