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 ( 810b23...1b23c8 )
by joseph
12s
created

DefaultsNullFieldTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 66
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A validatorMetaForDefaultsNull() 0 2 1
A metaForDefaultsNull() 0 6 1
A setDefaultsNull() 0 8 1
A isDefaultsNull() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\Boolean;
4
5
// phpcs:disable
6
7
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Boolean\DefaultsNullFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\ValidatedEntityInterface;
10
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
11
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
12
13
// phpcs:enable
14
trait DefaultsNullFieldTrait
15
{
16
17
    /**
18
     * @var bool|null
19
     */
20
    private $defaultsNull;
21
22
    /**
23
     * @SuppressWarnings(PHPMD.StaticAccess)
24
     * @param ClassMetadataBuilder $builder
25
     */
26 1
    public static function metaForDefaultsNull(ClassMetadataBuilder $builder): void
27
    {
28 1
        MappingHelper::setSimpleBooleanFields(
29 1
            [DefaultsNullFieldInterface::PROP_DEFAULTS_NULL],
30 1
            $builder,
31 1
            DefaultsNullFieldInterface::DEFAULT_DEFAULTS_NULL
32
        );
33 1
    }
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
     * Remove the PHPMD suppressed warning once you start setting constraints
41
     *
42
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
43
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
44
     *
45
     * @param ValidatorClassMetaData $metadata
46
     *
47
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
48
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
49
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
50
     */
51 2
    protected static function validatorMetaForDefaultsNull(ValidatorClassMetaData $metadata)
0 ignored issues
show
Unused Code introduced by
The parameter $metadata is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

51
    protected static function validatorMetaForDefaultsNull(/** @scrutinizer ignore-unused */ ValidatorClassMetaData $metadata)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53
        //        $metadata->addPropertyConstraint(
54
        //            DefaultsNullFieldInterface::PROP_DEFAULTS_NULL,
55
        //            new NotBlank()
56
        //        );
57 2
    }
58
59
    /**
60
     * @return bool|null
61
     */
62 2
    public function isDefaultsNull(): ?bool
63
    {
64 2
        return $this->defaultsNull;
65
    }
66
67
    /**
68
     * @param bool|null $defaultsNull
69
     *
70
     * @return self
71
     */
72 2
    public function setDefaultsNull(?bool $defaultsNull): self
73
    {
74 2
        $this->updatePropertyValueThenValidateAndNotify(
0 ignored issues
show
Bug introduced by
It seems like updatePropertyValueThenValidateAndNotify() 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

74
        $this->/** @scrutinizer ignore-call */ 
75
               updatePropertyValueThenValidateAndNotify(
Loading history...
75 2
            DefaultsNullFieldInterface::PROP_DEFAULTS_NULL,
76 2
            $defaultsNull
77
        );
78
79 2
        return $this;
80
    }
81
}
82