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 ( 2a6b46...0d82f1 )
by joseph
20s queued 14s
created

DateTimeSettableNoDefaultFieldTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 46
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDateTimeSettableNoDefault() 0 7 2
A metaForDateTimeSettableNoDefault() 0 6 1
A setDateTimeSettableNoDefault() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\DateTime;
6
7
// phpcs:disable Generic.Files.LineLength.TooLong
8
use DateTimeImmutable;
9
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
10
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\DateTime\DateTimeSettableNoDefaultFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
13
// phpcs:enable
14
/**
15
 * Trait DateTimeSettableNoDefaultFieldTrait
16
 *
17
 * This field is a dateTime that you can set and update the value as you see fit with no defaults
18
 *
19
 * @package EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\DateTime
20
 */
21
trait DateTimeSettableNoDefaultFieldTrait
22
{
23
24
    /**
25
     * @var DateTimeImmutable|null
26
     */
27
    private $dateTimeSettableNoDefault;
28
29
    /**
30
     * @SuppressWarnings(PHPMD.StaticAccess)
31
     * @param ClassMetadataBuilder $builder
32
     */
33
    public static function metaForDateTimeSettableNoDefault(ClassMetadataBuilder $builder): void
34
    {
35
        MappingHelper::setSimpleDatetimeFields(
36
            [DateTimeSettableNoDefaultFieldInterface::PROP_DATE_TIME_SETTABLE_NO_DEFAULT],
37
            $builder,
38
            DateTimeSettableNoDefaultFieldInterface::DEFAULT_DATE_TIME_SETTABLE_NO_DEFAULT
39
        );
40
    }
41
42
    /**
43
     * @return DateTimeImmutable|null
44
     */
45
    public function getDateTimeSettableNoDefault(): ?DateTimeImmutable
46
    {
47
        if (null === $this->dateTimeSettableNoDefault) {
48
            return DateTimeSettableNoDefaultFieldInterface::DEFAULT_DATE_TIME_SETTABLE_NO_DEFAULT;
49
        }
50
51
        return $this->dateTimeSettableNoDefault;
52
    }
53
54
    /**
55
     * @param DateTimeImmutable|null $dateTimeSettableNoDefault
56
     *
57
     * @return self
58
     */
59
    private function setDateTimeSettableNoDefault(?DateTimeImmutable $dateTimeSettableNoDefault): self
60
    {
61
        $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

61
        $this->/** @scrutinizer ignore-call */ 
62
               updatePropertyValue(
Loading history...
62
            DateTimeSettableNoDefaultFieldInterface::PROP_DATE_TIME_SETTABLE_NO_DEFAULT,
63
            $dateTimeSettableNoDefault
64
        );
65
66
        return $this;
67
    }
68
}
69