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

Timestamps   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 17
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A enable() 0 7 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