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 (#154)
by joseph
33:02
created

metaForIndexedAutoIncrement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
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 19
ccs 0
cts 19
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\Numeric;
4
5
// phpcs:disable Generic.Files.LineLength.TooLong
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\Numeric\IndexedAutoIncrementFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
13
// phpcs:enable
14
15
/**
16
 *
17
 * ########### WARNING ############
18
 *
19
 * IF you want to access the auto increment values immediately after persisting the Entity, you will need to flush the
20
 * Entity from the unit of work before loading it from your repository
21
 *
22
 * Eg something like:
23
 * $this->getEntityManager()->getUnitOfWork()->clear(EntityFqn);
24
 * $withAutoIncValueSet=$this->getRepostitory()->loadEntity();
25
 *
26
 *
27
 */
28
trait IndexedAutoIncrementFieldTrait
29
{
30
    /**
31
     * @var int
32
     */
33
    private $indexedAutoIncrement;
34
35
    /**
36
     * @SuppressWarnings(PHPMD.StaticAccess)
37
     * @param ClassMetadataBuilder $builder
38
     */
39
    public static function metaForIndexedAutoIncrement(ClassMetadataBuilder $builder): void
40
    {
41
        $fieldBuilder = new FieldBuilder(
42
            $builder,
43
            [
44
                'fieldName' => IndexedAutoIncrementFieldInterface::PROP_INDEXED_AUTO_INCREMENT,
45
                'type'      => Type::INTEGER,
46
            ]
47
        );
48
        $fieldBuilder
49
            ->columnName(
50
                MappingHelper::getColumnNameForField(
51
                    IndexedAutoIncrementFieldInterface::PROP_INDEXED_AUTO_INCREMENT
52
                )
53
            )
54
            ->nullable(false)
55
            ->unique(false)
56
            ->columnDefinition('INT AUTO_INCREMENT UNIQUE')
57
            ->build();
58
    }
59
60
    /**
61
     * @return int
62
     */
63
    public function getIndexedAutoIncrement(): ?int
64
    {
65
        return $this->indexedAutoIncrement;
66
    }
67
68
    private function initIndexedAutoIncrement()
69
    {
70
        $this->indexedAutoIncrement = IndexedAutoIncrementFieldInterface::DEFAULT_INDEXED_AUTO_INCREMENT;
71
    }
72
}
73