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 ( 69b831...bd71a5 )
by joseph
20:49 queued 13s
created

IntegerWithinRangeFieldTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 95.83%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 74
ccs 23
cts 24
cp 0.9583
rs 10
c 2
b 0
f 0
wmc 5

4 Methods

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

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