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.
Passed
Pull Request — master (#154)
by joseph
25:46
created

IndexedAutoIncrementFieldTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 43
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIndexedAutoIncrement() 0 3 1
A metaForIndexedAutoIncrement() 0 19 1
A initIndexedAutoIncrement() 0 3 1
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