- Added some more method to filter properties
This commit is contained in:
1 parent
2a6ec3cd1b
commit
0cdc2dc3d8
5 files changed
+60
-13
No files matched your search
@@ -56,4 +56,31 @@ abstract class Reflected
|
||||
}
|
||||
}
|
||||
|
||||
public function getAttributes(?string $attributeType = null): array
|
||||
{
|
||||
if ($attributeType) {
|
||||
$list = [];
|
||||
|
||||
foreach($this->attributes as $attribute) {
|
||||
if ($attribute->object instanceof $attributeType) {
|
||||
$list[] = $attribute;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
public function getAttribute(string $attributeType): ?object
|
||||
{
|
||||
foreach($this->getAttributes($attributeType) as $attribute) {
|
||||
if ($attribute->object instanceof $attributeType) {
|
||||
return $attribute;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user