Failed Conditions
Push — master ( f185a6...047620 )
by Guilherme
09:26
created

FieldMetadataBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 29
ccs 0
cts 15
cp 0
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A withComponentMetadata() 0 5 1
A __construct() 0 3 1
A build() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping\Builder;
6
7
use Doctrine\ORM\Annotation;
0 ignored issues
show
introduced by
Type Doctrine\ORM\Annotation is not used in this file.
Loading history...
8
use Doctrine\ORM\Mapping;
9
use function assert;
10
use function constant;
0 ignored issues
show
introduced by
Type constant is not used in this file.
Loading history...
11
use function sprintf;
0 ignored issues
show
introduced by
Type sprintf is not used in this file.
Loading history...
12
use function str_replace;
0 ignored issues
show
introduced by
Type str_replace is not used in this file.
Loading history...
13
use function strtolower;
0 ignored issues
show
introduced by
Type strtolower is not used in this file.
Loading history...
14
use function strtoupper;
0 ignored issues
show
introduced by
Type strtoupper is not used in this file.
Loading history...
15
16
class FieldMetadataBuilder
17
{
18
    /** @var Mapping\ClassMetadataBuildingContext */
19
    private $metadataBuildingContext;
20
21
    /** @var Mapping\ClassMetadata */
22
    private $componentMetadata;
23
24
    public function __construct(Mapping\ClassMetadataBuildingContext $metadataBuildingContext)
25
    {
26
        $this->metadataBuildingContext = $metadataBuildingContext;
27
    }
28
29
    public function withComponentMetadata(Mapping\ClassMetadata $componentMetadata) : FieldMetadataBuilder
30
    {
31
        $this->componentMetadata = $componentMetadata;
32
33
        return $this;
34
    }
35
36
    public function build() : Mapping\FieldMetadata
37
    {
38
        // Validate required fields
39
        assert($this->componentMetadata !== null);
40
        assert($this->cacheAnnotation !== null);
0 ignored issues
show
Bug Best Practice introduced by
The property cacheAnnotation does not exist on Doctrine\ORM\Mapping\Builder\FieldMetadataBuilder. Did you maybe forget to declare it?
Loading history...
41
42
        $fieldMetadata = new Mapping\FieldMetadata();
0 ignored issues
show
Bug introduced by
The call to Doctrine\ORM\Mapping\FieldMetadata::__construct() has too few arguments starting with name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        $fieldMetadata = /** @scrutinizer ignore-call */ new Mapping\FieldMetadata();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
introduced by
Useless variable $fieldMetadata.
Loading history...
43
44
        return $fieldMetadata;
45
    }
46
}
47