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

IsbnFieldTrait::setIsbn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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

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