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

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