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

JoinTableMetadata::hasColumns()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 6
rs 10
c 0
b 0
f 0
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