Completed
Push — 1.1 ( d166b0...e7f438 )
by Patrick
11:31 queued 07:46
created

Blameable::getExtensionName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Extensions\Gedmo;
4
5
use Gedmo\Blameable\Mapping\Driver\Fluent;
6
use LaravelDoctrine\Fluent\Buildable;
7
use LaravelDoctrine\Fluent\Builders\Field;
8
use LaravelDoctrine\Fluent\Extensions\Extension;
9
use LaravelDoctrine\Fluent\Relations\ManyToOne;
10
11
class Blameable extends AbstractTrackingExtension implements Buildable, Extension
12
{
13
    const MACRO_METHOD = 'blameable';
14
15
    /**
16
     * Enable the extension.
17
     *
18
     * @return void
19
     */
20
    public static function enable()
21
    {
22
        Field::macro(self::MACRO_METHOD, function (Field $builder) {
23
            return new static($builder->getClassMetadata(), $builder->getName());
24
        });
25
26
        ManyToOne::macro(self::MACRO_METHOD, function (ManyToOne $builder) {
27
            return new static($builder->getClassMetadata(), $builder->getRelation());
28
        });
29
    }
30
31
    /**
32
     * Return the name of the actual extension.
33
     *
34
     * @return string
35
     */
36
    protected function getExtensionName()
37
    {
38
        return Fluent::EXTENSION_NAME;
39
    }
40
}
41