AsCreatedAt   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A onPreSave() 0 6 2
1
<?php
2
/**
3
 * File was created 05.10.2015 17:01
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Annotation\Slumber\Store;
7
8
use Doctrine\Common\Annotations\Annotation;
9
use PeekAndPoke\Component\Slumber\Annotation\PropertyPreSaveVisitorMarker;
10
use PeekAndPoke\Component\Slumber\Annotation\SlumberAnnotation;
11
use Psr\Container\ContainerInterface;
12
13
/**
14
 * @Annotation
15
 * @Annotation\Target("PROPERTY")
16
 *
17
 * @author Karsten J. Gerber <[email protected]>
18
 */
19
class AsCreatedAt extends SlumberAnnotation implements PropertyPreSaveVisitorMarker
20
{
21
    /**
22
     * @param ContainerInterface  $provider
23
     * @param mixed               $subject
24
     * @param \ReflectionProperty $property
25
     */
26 27
    public function onPreSave(ContainerInterface $provider, $subject, \ReflectionProperty $property)
27
    {
28 27
        if ($property->getValue($subject) === null) {
29 27
            $property->setValue($subject, new \DateTime());
30
        }
31 27
    }
32
}
33