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 ( 08e101...6f7bef )
by joseph
23:56 queued 01:38
created

initShortIndexedRequiredString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

96
        $this->/** @scrutinizer ignore-call */ 
97
               updatePropertyValue(
Loading history...
97
            ShortIndexedRequiredStringFieldInterface::PROP_SHORT_INDEXED_REQUIRED_STRING,
98
            $shortIndexedRequiredString
99
        );
100
101
        return $this;
102
    }
103
104
    private function initShortIndexedRequiredString(): void
105
    {
106
        $this->shortIndexedRequiredString =
107
            ShortIndexedRequiredStringFieldInterface::DEFAULT_SHORT_INDEXED_REQUIRED_STRING;
108
    }
109
}
110