@param object $object
@param string $format
@param array  $context

@return array
552010
public function normalize($object, $format = null, array $context = array())
    {
        $data = parent::normalize($object, $format, $context);

        if (!is_array($data)) {
            return $data;
        }

        return array_merge($this->getHintFromObject($object), $data);
    }
69696
public function normalize($object, $format = null, array $context = array())
    {
        if (!$object instanceof \DateTimeInterface) {
            throw new InvalidArgumentException('The object must implement the "\DateTimeInterface".');
        }

        $format = isset($context[static::CONTEXT_FORMAT]) ? $context[self::CONTEXT_FORMAT] : $this->format;

        return $object->format($format);
    }
225733
public function getAttributes($objectOrClass, $format = null, array $context)
    {
        $class = is_object($objectOrClass) ? get_class($objectOrClass) : $objectOrClass;

        /** @var ClassMetadata $meta */
        $meta = $this->entityMetadataFactory->getMetadataFor($class);

        $fields = array_keys($meta->fieldMappings);
        $fields = array_filter($fields, function ($name) { return strpos($name, '.') === false; });
        $embedded = array_keys($meta->embeddedClasses);
        $associations = array_keys($meta->associationMappings);

        return array_merge($fields, $embedded, $associations);
    }
923504
public function normalize($object, $format = null, array $context = [])
    {
        if (isset($context['api_resource'])) {
            $originalResource = $context['api_resource'];
            unset($context['api_resource']);
        }

        $data = $this->decorated->normalize($object, $format, $context);
        if (!\is_array($data)) {
            throw new UnexpectedValueException('Expected data to be an array');
        }

        // when using an output class, get the IRI from the resource
        if (isset($originalResource) && isset($data['id'])) {
            $data['_id'] = $data['id'];
            $data['id'] = $this->iriConverter->getIriFromItem($originalResource);
        }

        $data[self::ITEM_RESOURCE_CLASS_KEY] = $this->getObjectClass($object);
        $data[self::ITEM_IDENTIFIERS_KEY] = $this->identifiersExtractor->getIdentifiersFromItem($object);

        return $data;
    }
821186
public static function filter(&$object, array $fields, $mode = 'allow')
    {
        if('allow' === $mode)
        {
            $unsetKeys = [];
            foreach($object as $field => $value)
            {
                if(!in_array($field, $fields))
                {
                    $unsetKeys[] = $field;
                }
            }
            foreach($unsetKeys as $key)
            {
                static::remove($object, $key);
            }
        }
        else if('deny' === $mode)
        {
            foreach($fields as $field)
            {
                static::remove($object, $field);
            }
        }
        else
        {
            throw new \InvalidArgumentException(sprintf('Unknow mode %s', $mode));
        }
    }
609476
protected function getShortReference($object, $format, array $context)
    {
        return [
            'code' => $object->getCode(),
            'type' => $object->getType()->getCode(),
            'collection' => $object->isCollection(),
        ];
    }
258688
public function normalize($object, $format = null, array $context = []): array
    {
        if (!$object instanceof RelationInterface && !$object instanceof ActionInterface) {
            throw new \InvalidArgumentException(sprintf(
                'The normalizer support only "%s" or "%s" but "%s" given.',
                RelationInterface::class,
                ActionInterface::class,
                is_object($object) ? get_class($object) : gettype($object)
            ));
        }

        $data = [
            'href' => $object->getHref()->getPath(),
        ];

        if ($object->getHref()->isTemplated()) {
            $data['templated'] = true;
        }

        if (count($object->getAttributes())) {
            $data['attributes'] = $object->getAttributes();
        }

        return $data;
    }
922033
public function normalize($object, $format = null, array $context = [])
    {
        $normalized = (array) parent::normalize($object, $format, $context);

        // Do not send redundant API product information to Apigee Edge, the
        // id of a referenced API product is enough.
        foreach ($normalized['product'] as $id => $data) {
            $normalized['product'][$id] = (object) ['id' => $data->id];
        }

        return (object) $normalized;
    }
520891
public function normalize($object, $format = null, array $context = [])
    {
        /** @var object $normalized */
        $normalized = parent::normalize($object, $format, $context);
        // Taking special care of null as a credential's expiresAt property value.
        // @see \Apigee\Edge\Api\Management\Entity\AppCredential::$expiresAt
        if (!isset($normalized->expiresAt)) {
            $normalized->expiresAt = -1;
        }

        return $normalized;
    }
1208781
public function normalize($string, $format = null, array $context = array())
    {
        $mime = isset($context[static::CONTEXT_MIME]) ? $context[static::CONTEXT_MIME] : 'application/octet-stream';
        $charset = isset($context[static::CONTEXT_CHARSET]) ? $context[static::CONTEXT_CHARSET] : null;
        $gzip = isset($context[static::CONTEXT_GZIP]) ? $context[static::CONTEXT_GZIP] : null;
        $base64 = isset($context[static::CONTEXT_BASE64]) ? $context[static::CONTEXT_BASE64] : null;
        $base64 = ($base64 !== null) ? $base64 : strpos($mime, '/octet-stream') !== false;
        $urlencode = isset($context[static::CONTEXT_URLENCODE]) ? $context[static::CONTEXT_URLENCODE] : null;
        $urlencode = ($urlencode !== null) ? $urlencode : strpos($mime, 'text/') !== false;

        if ($gzip) {
            $string = gzencode($string);
            $mime = 'application/x-gzip';
        }
        if ($urlencode and !$base64) {
            $string = urlencode($string);
        }
        if ($base64 or !$urlencode) {
            $string = base64_encode($string);
        }

        $options = $mime;
        if ($charset and $mime) {
            $options .= ';charset='.$charset;
        }
        if ($base64) {
            $options .= ';base64';
        }

        return sprintf('data:%s,%s', $options, $string);
    }
1260397
public function normalize($object, $format = null, array $context = [])
    {
        $normalized = [
            'developer' => [],
        ];
        /** @var \Apigee\Edge\Api\Management\Structure\CompanyMembership $object */
        foreach ($object->getMembers() as $member => $role) {
            $normalized['developer'][] = (object) ['email' => $member, 'role' => $role];
        }

        return (object) $normalized;
    }
380444
public function normalize($object, $format = null, array $context = []): array
    {
        $normalized = [
            'page' => $object->getPage(),
            'limit' => $object->getLimit(),
            'total' => $object->getTotal(),
            'items' => [],
        ];

        foreach ($object as $item) {
            $normalized['items'][] = $this->normalizer->normalize($item, $format, $context);
        }

        return $normalized;
    }
1150882
protected function extractEAVAttributes(DataInterface $object, $format = null, array $context = [])
    {
        $allowedAttributes = [];
        foreach ($object->getFamily()->getAttributes() as $attribute) {
            if ($this->isAllowedEAVAttribute($object, $attribute, $format, $context)) {
                $allowedAttributes[] = $attribute;
            }
        }

        return $allowedAttributes;
    }
38802
public function extract($object)
    {
        $pdfConverterHydrator = new PdfConverterHydrator();

        return [
            'responseStatus' => $object->getResponseStatus(),
            'sourceContainer' => $pdfConverterHydrator->extract($object->getSourceContainer()),
            'url' => $object->getUrl(),
        ];
    }
1270510
public function encode($data, $format, array $context = [])
    {
        $jsonEncodeOptions = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
        $encodedJson = json_encode($data, $jsonEncodeOptions);

        if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($jsonEncodeOptions & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
            throw new NotEncodableValueException(json_last_error_msg());
        }

        return $encodedJson;
    }
1255283
private function getRelatedResources($object, ?string $format, array $context, array $relationships): array
    {
        if (!isset($context['api_included'])) {
            return [];
        }

        $included = [];
        foreach ($relationships as $relationshipDataArray) {
            if (!\in_array($relationshipDataArray['name'], $context['api_included'], true)) {
                continue;
            }

            $relationshipName = $relationshipDataArray['name'];
            $relationContext = $context;
            $attributeValue = $this->getAttributeValue($object, $relationshipName, $format, $relationContext);

            if (!$attributeValue) {
                continue;
            }

            // Many to one relationship
            if ('one' === $relationshipDataArray['cardinality']) {
                $included[] = $attributeValue['data'];

                continue;
            }
            // Many to many relationship
            foreach ($attributeValue as $attributeValueElement) {
                if (isset($attributeValueElement['data'])) {
                    $included[] = $attributeValueElement['data'];
                }
            }
        }

        return $included;
    }
194413
private function getDecoder(string $format, array $context): DecoderInterface
    {
        if (isset($this->decoderByFormat[$format])
            && isset($this->decoders[$this->decoderByFormat[$format]])
        ) {
            return $this->decoders[$this->decoderByFormat[$format]];
        }

        foreach ($this->decoders as $i => $decoder) {
            if ($decoder->supportsDecoding($format, $context)) {
                $this->decoderByFormat[$format] = $i;

                return $decoder;
            }
        }

        throw new RuntimeException(sprintf('No decoder found for format "%s".', $format));
    }