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 (#86)
by joseph
23:00
created

metaForShortIndexedRequiredString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

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

85
        $this->/** @scrutinizer ignore-call */ 
86
               updatePropertyValueThenValidateAndNotify(
Loading history...
86 2
            ShortIndexedRequiredStringFieldInterface::PROP_SHORT_INDEXED_REQUIRED_STRING,
87 2
            $shortIndexedRequiredString
88
        );
89
90 2
        return $this;
91
    }
92
93 2
    private function initShortIndexedRequiredString()
94
    {
95 2
        $this->shortIndexedRequiredString =
96
            ShortIndexedRequiredStringFieldInterface::DEFAULT_SHORT_INDEXED_REQUIRED_STRING;
97 2
    }
98
}
99