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 ( 51c99d...a4bf8a )
by joseph
24s queued 11s
created

DefaultsNullFieldTrait::setDefaultsNull()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
cc 2
nc 2
nop 1
crap 2
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
        if (null === $this->defaultsNull) {
65 1
            return DefaultsNullFieldInterface::DEFAULT_DEFAULTS_NULL;
66
        }
67
68 2
        return $this->defaultsNull;
69
    }
70
71
    /**
72
     * @param bool|null $defaultsNull
73
     *
74
     * @return self
75
     */
76 2
    public function setDefaultsNull(?bool $defaultsNull): self
77
    {
78 2
        $this->defaultsNull = $defaultsNull;
79 2
        if ($this instanceof ValidatedEntityInterface) {
80 2
            $this->validateProperty(DefaultsNullFieldInterface::PROP_DEFAULTS_NULL);
81
        }
82
83 2
        return $this;
84
    }
85
}
86