-
Notifications
You must be signed in to change notification settings - Fork 0
/
VarProperty.php
101 lines (82 loc) · 2.18 KB
/
VarProperty.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/*
* This file is part of the awesomite/var-dumper package.
*
* (c) Bartłomiej Krukowski <bartlomiej@krukowski.me>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Awesomite\VarDumper\Properties;
/**
* @internal
*/
class VarProperty implements PropertyInterface
{
const VISIBILITY_PUBLIC = 'public';
const VISIBILITY_PROTECTED = 'protected';
const VISIBILITY_PRIVATE = 'private';
private $name;
private $value;
private $static;
private $virtual;
private $visibility;
private $declaringClass;
/**
* @param string $name
* @param $value
* @param string $visibility
* @param string $declaringClass
* @param bool $static
* @param bool $virtual
*/
public function __construct($name, $value, $visibility, $declaringClass, $static = false, $virtual = false)
{
$visibilityOptions = array(
static::VISIBILITY_PUBLIC,
static::VISIBILITY_PROTECTED,
static::VISIBILITY_PRIVATE,
);
if (!\in_array($visibility, $visibilityOptions, true)) {
throw new \InvalidArgumentException('Invalid value of $visibility!');
}
$this->name = $name;
$this->value = $value;
$this->visibility = $visibility;
$this->declaringClass = $declaringClass;
$this->static = $static;
$this->virtual = $virtual;
}
public function getName()
{
return $this->name;
}
public function getValue()
{
return $this->value;
}
public function isStatic()
{
return $this->static;
}
public function isVirtual()
{
return $this->virtual;
}
public function isPublic()
{
return static::VISIBILITY_PUBLIC === $this->visibility;
}
public function isProtected()
{
return static::VISIBILITY_PROTECTED === $this->visibility;
}
public function isPrivate()
{
return static::VISIBILITY_PRIVATE === $this->visibility;
}
public function getDeclaringClass()
{
return $this->declaringClass;
}
}