Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. GetSetMethodNormalizer.php

function GetSetMethodNormalizer::getAttributeValue

Overrides AbstractObjectNormalizer::getAttributeValue

File

vendor/symfony/serializer/Normalizer/GetSetMethodNormalizer.php, line 129

Class

GetSetMethodNormalizer
Converts between objects with getter and setter methods and arrays.

Namespace

Symfony\Component\Serializer\Normalizer

Code

protected function getAttributeValue(object $object, string $attribute, ?string $format = null, array $context = []) : mixed {
    $getter = 'get' . $attribute;
    if (method_exists($object, $getter) && \is_callable([
        $object,
        $getter,
    ])) {
        return $object->{$getter}();
    }
    $isser = 'is' . $attribute;
    if (method_exists($object, $isser) && \is_callable([
        $object,
        $isser,
    ])) {
        return $object->{$isser}();
    }
    $haser = 'has' . $attribute;
    if (method_exists($object, $haser) && \is_callable([
        $object,
        $haser,
    ])) {
        return $object->{$haser}();
    }
    return null;
}
RSS feed
Powered by Drupal