- Added some more method to filter properties

This commit is contained in:
Dave Mc Nicoll committed 2024-05-27 18:06:56 +00:00
1 parent 2a6ec3cd1b
commit 0cdc2dc3d8
5 files changed
+60 -13

No files matched your search

+27
View File
@@ -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;
}
}