@param mixed  $data
@param string $format
@param array  $context

@return string
558767
public function encode($data, $format, array $context = array())
    {
        if ($this->native) {
            return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
        }

        return $this->encoder->dump($data);
    }
1013808
protected static function encode($data, array $context)
    {
        $result = json_encode(
            $data,
            $context['json_encode_options'],
            $context['json_encode_depth']
        );

        if (false === $result) {
            static::throwEncodingException($data);
        }

        return $result;
    }
1090793
public function normalize($object, $format = null, array $context = [])
    {
        /** @var object $normalized */
        $normalized = parent::normalize($object, $format, $context);
        $normalized->type = RatePlanInterface::TYPE_DEVELOPER;

        return $normalized;
    }
748707
public static function getFormattedDate($date, $format)
    {
        if (StringUtils::isEmpty($date) || StringUtils::isEmpty($format)) {
            return null;
        }

        return date($format, strtotime($date));
    }
954032
protected static function decode($data, array $context)
    {
        if ($context['base64_decode_url_safe']) {
            $data = static::getUrlSafeData($data);
        }

        $result = base64_decode($data, $context['base64_decode_strict']);

        if (false === $result) {
            static::throwDecodingException($data);
        }

        return $result;
    }
551917
public function dateFormat($date, string $format = 'M d Y'): string
    {
        if ($date instanceof DateTime) {
            return $date->format($format);
        } elseif (is_int($date)) {
            return date($format, $date);
        }

        return date($format, strtotime($date));
    }
1036059
public static function loadString($data, $format = Format::JSON, $options = [])
    {
        // Load a string into the given namespace [or default namespace if not given]
        $class = static::getFormatClass($format);

        return $class::stringToStruct($data, $options);
    }
1121900
public function formatPage(FormatContext $formatContext): string
    {
        $this->arrayLoader->setTemplate(
            $formatContext->templateId(),
            $this->massageTemplate($formatContext)
        );

        $data = $formatContext->data()->export();

        return $this->twig->render($formatContext->templateId(), $data);
    }
820324
public function denormalize($string, $class, $format = null, array $context = array())
    {
        if (!preg_match(static::FULL_REGEX, $string, $matches)) {
            throw new \InvalidArgumentException('The provided "data:" URI is not valid.');
        }

        $mime = !empty($matches[static::CONTEXT_MIME]) ? $matches[static::CONTEXT_MIME] : 'application/octet-stream';
        $charset = !empty($matches[static::CONTEXT_CHARSET]) ? $matches[static::CONTEXT_CHARSET] : null;
        $gzip = strpos($mime, 'gzip') !== false;
        $base64 = !empty($matches[static::CONTEXT_BASE64]) ? $matches[static::CONTEXT_BASE64] : null;
        $urldecode = strpos($mime, 'text/') !== false;

        $string = $matches[static::CONTEXT_DATA];

        if ($base64) {
            $string = base64_decode($string);
        }
        if ($gzip) {
            $string = gzdecode($string);
        }
        if ($urldecode or !$base64) {
            $string = urldecode($string);
        }

        return $string;
    }
20359
public function normalize($object, $format = null, array $context = [])
    {
        $asArray = $this->objectNormalizer->normalize($object, $this->format, $context);
        // Exclude null values from the output, even if PATCH is not supported on Apigee Edge
        // sending a smaller portion of data in POST/PUT is always a good practice.
        $asArray = array_filter($asArray, function ($value) {
            return !is_null($value);
        });
        ksort($asArray);

        return (object) $asArray;
    }
1143938
public function denormalize($data, $class, $format = null, array $context = array())
    {
        if (isset($data['@references'])) {
            $context['@references'] = &$data['@references'];

            $ids = $this->getIdentifierFromArray($class, $data);
            $objectId = $class.'#'.$this->getIdentifiersAsString($ids);

            $context['@references'][$objectId] = $data;
            unset($context['@references'][$objectId]['@references']);
        }

        if (!isset($context['cache_key'])) {
            $context['cache_key'] = md5(serialize($context));
        }
        $class = $class ?: $this->getClassFromArray($data);
        $context['entityMeta'] = $this->entityMetadataFactory->getMetadataFor($class);
        $rc = new \ReflectionClass($class);
        $object = $this->instantiateObject($data, $class, $context, $rc, false);

        return $this->hydrateObject($object, $data, $class, $format, $context);
    }
1229801
public static function encode($data, array $context = [])
    {
        $context = array_merge(static::$defaultEncodeContext, $context);

        return static::encodeData($data, $context);
    }
446106
public function denormalize($data, $class, $format = null, array $context = array())
    {
        /** @var \ReflectionParameter[] $params */
        $params = $context['params'];
        $indexBy = isset($context['indexBy']) ? $context['indexBy'] : 'name';

        $arguments = [];
        foreach ($params as $param) {
            $index = $param->getPosition();

            $arguments[$index] = $this->denormalizeParam($data, $param, $format, $context);
        }
        ksort($arguments);

        $output = [];
        foreach ($params as $param) {
            $name = $param->getName();
            $index = $param->getPosition();
            $key = $indexBy === 'name' ? $name : $index;

            $output[$key] = $arguments[$index];
        }

        return $output;
    }
454522
public function toString(string $format = self::FORMAT_XML, bool $gzip = false): string
    {
        switch ($format) {
            case self::FORMAT_XML:
                return $this->toXmlString($gzip);
            case self::FORMAT_TXT:
                return $this->toTxtString($gzip);
            default:
                throw new \InvalidArgumentException('Unknown format');

        }
    }
975309
private function formatJsonData(array $data, $format)
    {
        if (self::JSON_DEFINITION_FORMAT === $format || self::JSON_CONCISE_FORMAT === $format) {
            unset($data['state'], $data['created'], $data['modified'], $data['revision']);
        }

        if (self::JSON_INFO_FORMAT === $format || self::JSON_CONCISE_FORMAT === $format) {
            unset($data['accept'], $data['label'], $data['minentry'], $data['maxentry']);
        }

        if (self::JSON_DEFINITION_FORMAT === $format || self::JSON_INFO_FORMAT === $format) {
            unset($data['elements'], $data['extra']);
        }

        if (self::JSON_DEFINITION_FORMAT === $format) {
            unset($data['uid']);
        } elseif (self::JSON_INFO_FORMAT === $format) {
            unset($data['parameters']);
        }

        return $data;
    }
138104
private function formatMessage($format, $context = []) {
        $format = $this->translate($format);

        $msg = preg_replace_callback('`({[^{}]+})`', function ($m) use ($context) {
            $args = array_filter(array_map('trim', explode(',', trim($m[1], '{}'))));
            $field = array_shift($args);

            switch ($field) {
                case 'value':
                    return $this->formatValue($context[$field] ?? null);
                case 'field':
                    $field = $context['field'] ?: 'value';
                    return $this->formatFieldName($field);
                default:
                    return $this->formatField(isset($context[$field]) ? $context[$field] : null, $args);
            }
        }, $format);
        return $msg;
    }
1212787
public function getDataOcorrencia($format = 'd/m/Y')
    {
        return $this->dataOcorrencia instanceof Carbon
        ? $format === false ? $this->dataOcorrencia : $this->dataOcorrencia->format($format)
        : null;
    }