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
Pull Request — master (#221)
by joseph
19:29
created

metaForUpdatedAtTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 17
ccs 10
cts 10
cp 1
crap 1
rs 9.9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\TimeStamp;
6
7
use DateTimeImmutable;
8
use Doctrine\DBAL\Types\Type;
9
use Doctrine\ORM\Events;
10
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
11
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
12
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\TimeStamp\UpdatedAtTimestampFieldInterface;
13
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
14
use Exception;
15
16
/**
17
 * Trait TimestampFieldTrait
18
 *
19
 * An Immutable creation timestamp. It is null until it is saved (and reloaded)
20
 *
21
 * Notice the use of a lifecyle event to handle setting the pre persist creation timestamp
22
 *
23
 * @package EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\DateTime
24
 */
25
trait UpdatedAtTimestampFieldTrait
26
{
27
    /**
28
     * @var DateTimeImmutable|null
29
     */
30
    private $updatedAtTimestamp;
31
32
    /**
33
     * @SuppressWarnings(PHPMD.StaticAccess)
34
     * @param ClassMetadataBuilder $builder
35
     */
36 3
    public static function metaForUpdatedAtTimestamp(ClassMetadataBuilder $builder): void
37
    {
38 3
        $builder->addLifecycleEvent('prePersistUpdatedAtTimestamp', Events::preUpdate);
39 3
        $builder->addLifecycleEvent('prePersistUpdatedAtTimestamp', Events::prePersist);
40 3
        $fieldBuilder = new FieldBuilder(
41 3
            $builder,
42
            [
43 3
                'fieldName' => UpdatedAtTimestampFieldInterface::PROP_UPDATED_AT_TIMESTAMP,
44
                'type'      => Type::DATETIME_IMMUTABLE,
45
            ]
46
        );
47
        $fieldBuilder
48 3
            ->columnName(MappingHelper::getColumnNameForField(
49 3
                UpdatedAtTimestampFieldInterface::PROP_UPDATED_AT_TIMESTAMP
50
            ))
51 3
            ->nullable(false)
52 3
            ->build();
53 3
    }
54
55
    /**
56
     * @throws Exception
57
     */
58 3
    public function prePersistUpdatedAtTimestamp(): void
59
    {
60 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

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