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
Pull Request — master (#214)
by joseph
21:10
created

metaForBusinessIdentifierCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 1
dl 0
loc 18
ccs 0
cts 12
cp 0
crap 2
rs 9.8666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
4
5
// phpcs:disable
6
7
use Doctrine\DBAL\Types\Type;
8
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
9
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
10
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\BusinessIdentifierCodeFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
use Symfony\Component\Validator\Constraints\Bic;
13
use Symfony\Component\Validator\Constraints\Length;
14
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
15
use Symfony\Component\Validator\Exception\InvalidOptionsException;
16
use Symfony\Component\Validator\Exception\MissingOptionsException;
17
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
18
19
// phpcs:enable
20
21
/**
22
 * Trait BusinessIdentifierCodeFieldTrait
23
 *
24
 * A Business Identifier Code also known as SWIFT-BIC, BIC, SWIFT ID or SWIFT code
25
 *
26
 * @see     https://en.wikipedia.org/wiki/ISO_9362
27
 *
28
 * @package EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String
29
 */
30
trait BusinessIdentifierCodeFieldTrait
31
{
32
33
    /**
34
     * @var string|null
35
     */
36
    private $businessIdentifierCode;
37
38
    /**
39
     * @SuppressWarnings(PHPMD.StaticAccess)
40
     * @param ClassMetadataBuilder $builder
41
     */
42
    public static function metaForBusinessIdentifierCode(ClassMetadataBuilder $builder): void
43
    {
44
        $fieldBuilder = new FieldBuilder(
45
            $builder,
46
            [
47
                'fieldName' => BusinessIdentifierCodeFieldInterface::PROP_BUSINESS_IDENTIFIER_CODE,
48
                'type'      => Type::STRING,
49
                'default'   => BusinessIdentifierCodeFieldInterface::DEFAULT_BUSINESS_IDENTIFIER_CODE,
50
            ]
51
        );
52
        $fieldBuilder
53
            ->columnName(MappingHelper::getColumnNameForField(
54
                BusinessIdentifierCodeFieldInterface::PROP_BUSINESS_IDENTIFIER_CODE
55
            ))
56
            ->nullable()
57
            ->unique(false)
58
            ->length(20)
59
            ->build();
60
    }
61
62
    /**
63
     * This method sets the validation for this field.
64
     *
65
     * You should add in as many relevant property constraints as you see fit.
66
     *
67
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
68
     *
69
     * @param ValidatorClassMetaData $metadata
70
     *
71
     * @throws MissingOptionsException
72
     * @throws InvalidOptionsException
73
     * @throws ConstraintDefinitionException
74
     */
75
    protected static function validatorMetaForPropertyBusinessIdentifierCode(ValidatorClassMetaData $metadata): void
76
    {
77
        $metadata->addPropertyConstraints(
78
            BusinessIdentifierCodeFieldInterface::PROP_BUSINESS_IDENTIFIER_CODE,
79
            [
80
                new Bic(),
81
                new Length(
82
                    [
83
                        'min' => 0,
84
                        'max' => 20,
85
                    ]
86
                ),
87
            ]
88
        );
89
    }
90
91
    /**
92
     * @return string|null
93
     */
94
    public function getBusinessIdentifierCode(): ?string
95
    {
96
        if (null === $this->businessIdentifierCode) {
97
            return BusinessIdentifierCodeFieldInterface::DEFAULT_BUSINESS_IDENTIFIER_CODE;
98
        }
99
100
        return $this->businessIdentifierCode;
101
    }
102
103
    /**
104
     * @param string|null $businessIdentifierCode
105
     *
106
     * @return self
107
     */
108
    private function setBusinessIdentifierCode(?string $businessIdentifierCode): self
109
    {
110
        $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

110
        $this->/** @scrutinizer ignore-call */ 
111
               updatePropertyValue(
Loading history...
111
            BusinessIdentifierCodeFieldInterface::PROP_BUSINESS_IDENTIFIER_CODE,
112
            $businessIdentifierCode
113
        );
114
115
        return $this;
116
    }
117
}
118