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 ( b7113a...02ec9b )
by Ross
25s queued 16s
created

metaForShortIndexedRequiredString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 1
dl 0
loc 21
ccs 0
cts 20
cp 0
crap 2
rs 9.7998
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
4
5
use Doctrine\DBAL\Types\Type;
6
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
7
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\ShortIndexedRequiredStringFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
10
use Symfony\Component\Validator\Constraints\NotBlank;
11
use Symfony\Component\Validator\Constraints\NotEqualTo;
12
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
13
14
/**
15
 * This trait provides a short (50 characters) string which is non uniquely indexed and is required
16
 *
17
 * Trait ShortIndexedRequiredStringFieldTrait
18
 *
19
 * @package EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String
20
 */
21
trait ShortIndexedRequiredStringFieldTrait
22
{
23
24
    /**
25
     * @var string
26
     */
27
    private $shortIndexedRequiredString;
28
29
    /**
30
     * @SuppressWarnings(PHPMD.StaticAccess)
31
     * @param ClassMetadataBuilder $builder
32
     */
33
    public static function metaForShortIndexedRequiredString(ClassMetadataBuilder $builder): void
34
    {
35
        $columnName   = MappingHelper::getColumnNameForField(
36
            ShortIndexedRequiredStringFieldInterface::PROP_SHORT_INDEXED_REQUIRED_STRING
37
        );
38
        $fieldBuilder = new FieldBuilder(
39
            $builder,
40
            [
41
                'fieldName' => ShortIndexedRequiredStringFieldInterface::PROP_SHORT_INDEXED_REQUIRED_STRING,
42
                'type'      => Type::STRING,
43
                'default'   => ShortIndexedRequiredStringFieldInterface::DEFAULT_SHORT_INDEXED_REQUIRED_STRING,
44
            ]
45
        );
46
        $fieldBuilder
47
            ->columnName($columnName)
48
            ->nullable(false)
49
            ->unique(false)
50
            ->length(50)
51
            ->build();
52
53
        $builder->addIndex([$columnName], $columnName . '_idx');
54
    }
55
56
    /**
57
     * @param ValidatorClassMetaData $metadata
58
     */
59
    protected static function validatorMetaForPropertyShortIndexedRequiredString(ValidatorClassMetaData $metadata): void
60
    {
61
        $metadata->addPropertyConstraints(
62
            ShortIndexedRequiredStringFieldInterface::PROP_SHORT_INDEXED_REQUIRED_STRING,
63
            [
64
                new NotEqualTo(ShortIndexedRequiredStringFieldInterface::DEFAULT_SHORT_INDEXED_REQUIRED_STRING),
65
                new NotBlank(),
66
            ]
67
        );
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getShortIndexedRequiredString(): string
74
    {
75
        if (null === $this->shortIndexedRequiredString) {
76
            return ShortIndexedRequiredStringFieldInterface::DEFAULT_SHORT_INDEXED_REQUIRED_STRING;
77
        }
78
79
        return $this->shortIndexedRequiredString;
80
    }
81
82
    /**
83
     * @param string|null $shortIndexedRequiredString
84
     *
85
     * @return self
86
     */
87
    private function setShortIndexedRequiredString(string $shortIndexedRequiredString): 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
            ShortIndexedRequiredStringFieldInterface::PROP_SHORT_INDEXED_REQUIRED_STRING,
91
            $shortIndexedRequiredString
92
        );
93
94
        return $this;
95
    }
96
97
    private function initShortIndexedRequiredString(): void
98
    {
99
        $this->shortIndexedRequiredString =
100
            ShortIndexedRequiredStringFieldInterface::DEFAULT_SHORT_INDEXED_REQUIRED_STRING;
101
    }
102
}
103