Failed Conditions
Push — master ( 6971e7...b11528 )
by Guilherme
08:44
created

JoinTableMetadata   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 88.24%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 47
ccs 15
cts 17
cp 0.8824
rs 10
c 0
b 0
f 0
wmc 9

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getInverseJoinColumns() 0 3 1
A getJoinColumns() 0 3 1
A addInverseJoinColumn() 0 3 1
A addJoinColumn() 0 3 1
A __clone() 0 8 3
A hasColumns() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping;
6
7
final class JoinTableMetadata extends TableMetadata
8
{
9
    /** @var JoinColumnMetadata[] */
10
    protected $joinColumns = [];
11
12
    /** @var JoinColumnMetadata[] */
13
    protected $inverseJoinColumns = [];
14
15
    public function hasColumns() : bool
16
    {
17
        return $this->joinColumns || $this->inverseJoinColumns;
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->joinColumns of type Doctrine\ORM\Mapping\JoinColumnMetadata[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
Bug Best Practice introduced by
The expression $this->inverseJoinColumns of type Doctrine\ORM\Mapping\JoinColumnMetadata[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
18
    }
19
20
    /**
21
     * @return JoinColumnMetadata[]
22
     */
23 464
    public function getJoinColumns() : array
24
    {
25 464
        return $this->joinColumns;
26
    }
27
28 90
    public function addJoinColumn(JoinColumnMetadata $joinColumn) : void
29
    {
30 90
        $this->joinColumns[] = $joinColumn;
31 90
    }
32
33
    /**
34
     * @return JoinColumnMetadata[]
35
     */
36 458
    public function getInverseJoinColumns() : array
37
    {
38 458
        return $this->inverseJoinColumns;
39
    }
40
41 90
    public function addInverseJoinColumn(JoinColumnMetadata $joinColumn) : void
42
    {
43 90
        $this->inverseJoinColumns[] = $joinColumn;
44 90
    }
45
46 7
    public function __clone()
47
    {
48 7
        foreach ($this->joinColumns as $index => $joinColumn) {
49 7
            $this->joinColumns[$index] = clone $joinColumn;
50
        }
51
52 7
        foreach ($this->inverseJoinColumns as $index => $inverseJoinColumn) {
53 7
            $this->inverseJoinColumns[$index] = clone $inverseJoinColumn;
54
        }
55 7
    }
56
}
57