GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 84e592...894b2c )
by joseph
127:56 queued 125:09
created

UpdatedAtTimestampFieldTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 64.29%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 47
ccs 18
cts 28
cp 0.6429
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prePersistUpdatedAtTimestamp() 0 5 1
A metaForUpdatedAtTimestamp() 0 17 1
A getUpdatedAtTimestamp() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\TimeStamp;
4
5
use Doctrine\DBAL\Types\Type;
6
use Doctrine\ORM\Events;
7
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
8
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\TimeStamp\UpdatedAtTimestampFieldInterface;
10
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
11
12
/**
13
 * Trait TimestampFieldTrait
14
 *
15
 * An Immutable creation timestamp. It is null until it is saved (and reloaded)
16
 *
17
 * Notice the use of a lifecyle event to handle setting the pre persist creation timestamp
18
 *
19
 * @package EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\DateTime
20
 */
21
trait UpdatedAtTimestampFieldTrait
22
{
23
    /**
24
     * @var \DateTimeImmutable|null
25
     */
26
    private $updatedAtTimestamp;
27
28
    /**
29
     * @SuppressWarnings(PHPMD.StaticAccess)
30
     * @param ClassMetadataBuilder $builder
31
     */
32 3
    public static function metaForUpdatedAtTimestamp(ClassMetadataBuilder $builder): void
33
    {
34 3
        $builder->addLifecycleEvent('prePersistUpdatedAtTimestamp', Events::preUpdate);
35 3
        $builder->addLifecycleEvent('prePersistUpdatedAtTimestamp', Events::prePersist);
36 3
        $fieldBuilder = new FieldBuilder(
37 3
            $builder,
38
            [
39 3
                'fieldName' => UpdatedAtTimestampFieldInterface::PROP_UPDATED_AT_TIMESTAMP,
40
                'type'      => Type::DATETIME_IMMUTABLE,
41
            ]
42
        );
43
        $fieldBuilder
44 3
            ->columnName(MappingHelper::getColumnNameForField(
45 3
                UpdatedAtTimestampFieldInterface::PROP_UPDATED_AT_TIMESTAMP
46
            ))
47 3
            ->nullable(false)
48 3
            ->build();
49 3
    }
50
51
    /**
52
     * @throws \Exception
53
     */
54 3
    public function prePersistUpdatedAtTimestamp(): void
55
    {
56 3
        $this->updatePropertyValue(
0 ignored issues
show
Bug introduced by
It seems like updatePropertyValue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
        $this->/** @scrutinizer ignore-call */ 
57
               updatePropertyValue(
Loading history...
57 3
            UpdatedAtTimestampFieldInterface::PROP_UPDATED_AT_TIMESTAMP,
58 3
            new \DateTimeImmutable()
59
        );
60 3
    }
61
62
    /**
63
     * @return \DateTimeImmutable|null
64
     */
65 3
    public function getUpdatedAtTimestamp(): ?\DateTimeImmutable
66
    {
67 3
        return $this->updatedAtTimestamp;
68
    }
69
}
70