ClassProperty::getTypes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Spiral Framework, IDE Helper
4
 *
5
 * @author    Dmitry Mironov <[email protected]>
6
 * @licence   MIT
7
 */
8
9
namespace Spiral\IdeHelper\Model;
10
11
/**
12
 * Class ClassProperty
13
 *
14
 * @package Spiral\IdeHelper\Model
15
 */
16
class ClassProperty extends ClassMember
17
{
18
    /**
19
     * @var string
20
     */
21
    private $name;
22
23
    /**
24
     * @var string[]
25
     */
26
    private $types;
27
28
    /**
29
     * ClassProperty constructor.
30
     *
31
     * @param string       $name
32
     * @param string|array $types
33
     */
34
    public function __construct(string $name, $types)
35
    {
36
        $this->name = $name;
37
        if (is_string($types)) {
38
            $this->types = [$types];
39
        } elseif (is_array($types)) {
40
            $this->types = $types;
41
        } else {
42
            $this->types = [self::DEFAULT_TYPE];
43
        }
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getName(): string
50
    {
51
        return $this->name;
52
    }
53
54
    /**
55
     * @return \string[]
56
     */
57
    public function getTypes(): array
58
    {
59
        return $this->types;
60
    }
61
}
62