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

validatorMetaForPropertyIntegerWithinRange()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 10
ccs 0
cts 8
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\Numeric;
6
7
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Numeric\IntegerWithinRangeFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
10
use Symfony\Component\Validator\Constraints\Range;
11
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
12
use Symfony\Component\Validator\Exception\InvalidOptionsException;
13
use Symfony\Component\Validator\Exception\MissingOptionsException;
14
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
15
16
trait IntegerWithinRangeFieldTrait
17
{
18
19
    /**
20
     * @var int|null
21
     */
22
    private $integerWithinRange;
23
24
    /**
25
     * @SuppressWarnings(PHPMD.StaticAccess)
26
     * @param ClassMetadataBuilder $builder
27
     */
28
    public static function metaForIntegerWithinRange(ClassMetadataBuilder $builder): void
29
    {
30
        MappingHelper::setSimpleIntegerFields(
31
            [IntegerWithinRangeFieldInterface::PROP_INTEGER_WITHIN_RANGE],
32
            $builder,
33
            IntegerWithinRangeFieldInterface::DEFAULT_INTEGER_WITHIN_RANGE
34
        );
35
    }
36
37
    /**
38
     * This method sets the validation for this field.
39
     *
40
     * You should add in as many relevant property constraints as you see fit.
41
     *
42
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
43
     *
44
     * @param ValidatorClassMetaData $metadata
45
     *
46
     * @throws MissingOptionsException
47
     * @throws InvalidOptionsException
48
     * @throws ConstraintDefinitionException
49
     */
50
    protected static function validatorMetaForPropertyIntegerWithinRange(ValidatorClassMetaData $metadata): void
51
    {
52
        $metadata->addPropertyConstraint(
53
            IntegerWithinRangeFieldInterface::PROP_INTEGER_WITHIN_RANGE,
54
            new Range(
55
                [
56
                    'min'        => IntegerWithinRangeFieldInterface::MIN_INTEGER_WITHIN_RANGE,
57
                    'max'        => IntegerWithinRangeFieldInterface::MAX_INTEGER_WITHIN_RANGE,
58
                    'minMessage' => IntegerWithinRangeFieldInterface::MIN_MESSAGE_INTEGER_WITHIN_RANGE,
59
                    'maxMessage' => IntegerWithinRangeFieldInterface::MAX_MESSAGE_INTEGER_WITHIN_RANGE
60
                ]
61
            )
62
        );
63
    }
64
65
    /**
66
     * @return int|null
67
     */
68
    public function getIntegerWithinRange(): ?int
69
    {
70
        if (null === $this->integerWithinRange) {
71
            return IntegerWithinRangeFieldInterface::DEFAULT_INTEGER_WITHIN_RANGE;
72
        }
73
74
        return $this->integerWithinRange;
75
    }
76
77
    /**
78
     * @param int|null $integerWithinRange
79
     *
80
     * @return self
81
     */
82
    private function setIntegerWithinRange(?int $integerWithinRange): self
83
    {
84
        $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

84
        $this->/** @scrutinizer ignore-call */ 
85
               updatePropertyValue(
Loading history...
85
            IntegerWithinRangeFieldInterface::PROP_INTEGER_WITHIN_RANGE,
86
            $integerWithinRange
87
        );
88
89
        return $this;
90
    }
91
}
92