function GetSetMethodNormalizer::extractAttributes
Overrides AbstractObjectNormalizer::extractAttributes
File
-
vendor/
symfony/ serializer/ Normalizer/ GetSetMethodNormalizer.php, line 108
Class
- GetSetMethodNormalizer
- Converts between objects with getter and setter methods and arrays.
Namespace
Symfony\Component\Serializer\NormalizerCode
protected function extractAttributes(object $object, ?string $format = null, array $context = []) : array {
$reflectionObject = new \ReflectionObject($object);
$reflectionMethods = $reflectionObject->getMethods(\ReflectionMethod::IS_PUBLIC);
$attributes = [];
foreach ($reflectionMethods as $method) {
if (!$this->isGetMethod($method)) {
continue;
}
$attributeName = lcfirst(substr($method->name, str_starts_with($method->name, 'is') ? 2 : 3));
if ($this->isAllowedAttribute($object, $attributeName, $format, $context)) {
$attributes[] = $attributeName;
}
}
return $attributes;
}