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

metaForFloatWithinRange()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 5
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\FloatWithinRangeFieldInterface;
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 FloatWithinRangeFieldTrait
17
{
18
19
    /**
20
     * @var float|null
21
     */
22
    private $floatWithinRange;
23
24
    /**
25
     * @SuppressWarnings(PHPMD.StaticAccess)
26
     * @param ClassMetadataBuilder $builder
27
     */
28
    public static function metaForFloatWithinRange(ClassMetadataBuilder $builder): void
29
    {
30
        MappingHelper::setSimpleFloatFields(
31
            [FloatWithinRangeFieldInterface::PROP_FLOAT_WITHIN_RANGE],
32
            $builder,
33
            FloatWithinRangeFieldInterface::DEFAULT_FLOAT_WITHIN_RANGE
34
        );
35
    }
36
37
    /**
38
     * @return float|null
39
     */
40
    public function getFloatWithinRange(): ?float
41
    {
42
        if (null === $this->floatWithinRange) {
43
            return FloatWithinRangeFieldInterface::DEFAULT_FLOAT_WITHIN_RANGE;
44
        }
45
46
        return $this->floatWithinRange;
47
    }
48
49
    /**
50
     * This method sets the validation for this field.
51
     *
52
     * You should add in as many relevant property constraints as you see fit.
53
     *
54
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
55
     *
56
     * @param ValidatorClassMetaData $metadata
57
     *
58
     * @throws MissingOptionsException
59
     * @throws InvalidOptionsException
60
     * @throws ConstraintDefinitionException
61
     */
62
    protected static function validatorMetaForPropertyFloatWithinRange(ValidatorClassMetaData $metadata): void
63
    {
64
        $metadata->addPropertyConstraint(
65
            FloatWithinRangeFieldInterface::PROP_FLOAT_WITHIN_RANGE,
66
            new Range(
67
                [
68
                    'min'        => FloatWithinRangeFieldInterface::MIN_FLOAT_WITHIN_RANGE,
69
                    'max'        => FloatWithinRangeFieldInterface::MAX_FLOAT_WITHIN_RANGE,
70
                    'minMessage' => FloatWithinRangeFieldInterface::MIN_MESSAGE_FLOAT_WITHIN_RANGE,
71
                    'maxMessage' => FloatWithinRangeFieldInterface::MAX_MESSAGE_FLOAT_WITHIN_RANGE,
72
                ]
73
            )
74
        );
75
    }
76
77
    /**
78
     * @param float|null $floatWithinRange
79
     *
80
     * @return self
81
     */
82
    private function setFloatWithinRange(?float $floatWithinRange): 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
            FloatWithinRangeFieldInterface::PROP_FLOAT_WITHIN_RANGE,
86
            $floatWithinRange
87
        );
88
89
        return $this;
90
    }
91
}
92