EnumDefinition::hasProperties()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Code;
7
8
use PhUml\Code\Methods\Method;
9
use PhUml\Code\Properties\Constant;
10
use PhUml\Code\Properties\EnumCase;
11
use PhUml\Code\Properties\HasConstants;
12
use PhUml\Code\Properties\WithConstants;
13
14
final class EnumDefinition extends Definition implements HasConstants, UseTraits, ImplementsInterfaces
15
{
16
    use WithConstants;
17
    use WithTraits;
18
    use WithInterfaces;
19
20
    /**
21
     * @param Method[] $methods
22
     * @param EnumCase[] $cases
23
     * @param Constant[] $constants
24
     * @param Name[] $interfaces
25
     * @param Name[] $traits
26
     */
27 27
    public function __construct(
28
        Name $name,
29
        private readonly array $cases,
30
        array $methods = [],
31
        array $constants = [],
32
        array $interfaces = [],
33
        array $traits = [],
34
    ) {
35 27
        parent::__construct($name, $methods);
36 27
        $this->constants = $constants;
37 27
        $this->traits = $traits;
38 27
        $this->interfaces = $interfaces;
0 ignored issues
show
Bug introduced by
The property interfaces is declared read-only in PhUml\Code\EnumDefinition.
Loading history...
39
    }
40
41 11
    public function hasProperties(): bool
42
    {
43 11
        return $this->cases !== [] || $this->constants !== [];
44
    }
45
46
    /** @return EnumCase[] */
47 10
    public function cases(): array
48
    {
49 10
        return $this->cases;
50
    }
51
}
52