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

BusinessIdentifierCodeFieldTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 77
rs 10
c 0
b 0
f 0
ccs 25
cts 25
cp 1

4 Methods

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