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

IsbnFieldTrait::validatorMetaForPropertyIsbn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
6
7
// phpcs:disable
8
9
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
10
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\IsbnFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
use EdmondsCommerce\DoctrineStaticMeta\Schema\Database;
13
use Symfony\Component\Validator\Constraints\Isbn;
14
use Symfony\Component\Validator\Constraints\Length;
15
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
16
use Symfony\Component\Validator\Exception\InvalidOptionsException;
17
use Symfony\Component\Validator\Exception\MissingOptionsException;
18
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
19
20
// phpcs:enable
21
trait IsbnFieldTrait
22
{
23
24
    /**
25
     * @var string|null
26
     */
27
    private $isbn;
28
29
    /**
30
     * @SuppressWarnings(PHPMD.StaticAccess)
31
     * @param ClassMetadataBuilder $builder
32
     */
33
    public static function metaForIsbn(ClassMetadataBuilder $builder): void
34
    {
35
        MappingHelper::setSimpleStringFields(
36
            [IsbnFieldInterface::PROP_ISBN],
37
            $builder,
38
            IsbnFieldInterface::DEFAULT_ISBN,
39
            true
40
        );
41
    }
42
43
    /**
44
     * This method sets the validation for this field.
45
     *
46
     * You should add in as many relevant property constraints as you see fit.
47
     *
48
     * @param ValidatorClassMetaData $metadata
49
     *
50
     * @throws MissingOptionsException
51
     * @throws InvalidOptionsException
52
     * @throws ConstraintDefinitionException
53
     */
54
    protected static function validatorMetaForPropertyIsbn(ValidatorClassMetaData $metadata): void
55
    {
56
        $metadata->addPropertyConstraints(
57
            IsbnFieldInterface::PROP_ISBN,
58
            [
59
                new Isbn(),
60
                new Length(
61
                    [
62
                        'min' => 0,
63
                        'max' => Database::MAX_VARCHAR_LENGTH,
64
                    ]
65
                ),
66
            ]
67
        );
68
    }
69
70
    /**
71
     * @return string|null
72
     */
73
    public function getIsbn(): ?string
74
    {
75
        if (null === $this->isbn) {
76
            return IsbnFieldInterface::DEFAULT_ISBN;
77
        }
78
79
        return $this->isbn;
80
    }
81
82
    /**
83
     * @param string|null $isbn
84
     *
85
     * @return self
86
     */
87
    private function setIsbn(?string $isbn): self
88
    {
89
        $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

89
        $this->/** @scrutinizer ignore-call */ 
90
               updatePropertyValue(
Loading history...
90
            IsbnFieldInterface::PROP_ISBN,
91
            $isbn
92
        );
93
94
        return $this;
95
    }
96
}
97