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

IsbnFieldTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A metaForIsbn() 0 7 1
A getIsbn() 0 7 2
A setIsbn() 0 8 1
A validatorMetaForIsbn() 0 5 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\Entity\Interfaces\ValidatedEntityInterface;
10
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
11
use Symfony\Component\Validator\Constraints\Isbn;
12
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
13
14
// phpcs:enable
15
trait IsbnFieldTrait
16
{
17
18
    /**
19
     * @var string|null
20
     */
21
    private $isbn;
22
23
    /**
24
     * @SuppressWarnings(PHPMD.StaticAccess)
25
     * @param ClassMetadataBuilder $builder
26
     */
27 1
    public static function metaForIsbn(ClassMetadataBuilder $builder): void
28
    {
29 1
        MappingHelper::setSimpleStringFields(
30 1
            [IsbnFieldInterface::PROP_ISBN],
31 1
            $builder,
32 1
            IsbnFieldInterface::DEFAULT_ISBN,
33 1
            true
34
        );
35 1
    }
36
37
    /**
38
     * This method sets the validation for this field.
39
     *
40
     * You should add in as many relevant property constraints as you see fit.
41
     *
42
     * @param ValidatorClassMetaData $metadata
43
     *
44
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
45
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
46
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
47
     */
48 4
    protected static function validatorMetaForIsbn(ValidatorClassMetaData $metadata)
49
    {
50 4
        $metadata->addPropertyConstraint(
51 4
            IsbnFieldInterface::PROP_ISBN,
52 4
            new Isbn()
53
        );
54 4
    }
55
56
    /**
57
     * @return string|null
58
     */
59 3
    public function getIsbn(): ?string
60
    {
61 3
        if (null === $this->isbn) {
62 1
            return IsbnFieldInterface::DEFAULT_ISBN;
63
        }
64
65 3
        return $this->isbn;
66
    }
67
68
    /**
69
     * @param string|null $isbn
70
     *
71
     * @return self
72
     */
73 4
    public function setIsbn(?string $isbn): self
74
    {
75 4
        $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

75
        $this->/** @scrutinizer ignore-call */ 
76
               updatePropertyValueThenValidateAndNotify(
Loading history...
76 4
            IsbnFieldInterface::PROP_ISBN,
77 4
            $isbn
78
        );
79
80 3
        return $this;
81
    }
82
}
83