SerializationInterface.php

Same filename in other branches
  1. 8.9.x core/lib/Drupal/Component/Serialization/SerializationInterface.php
  2. 10 core/lib/Drupal/Component/Serialization/SerializationInterface.php
  3. 11.x core/lib/Drupal/Component/Serialization/SerializationInterface.php

Namespace

Drupal\Component\Serialization

File

core/lib/Drupal/Component/Serialization/SerializationInterface.php

View source
<?php

namespace Drupal\Component\Serialization;


/**
 * Defines an interface for serialization formats.
 */
interface SerializationInterface {
    
    /**
     * Encodes data into the serialization format.
     *
     * @param mixed $data
     *   The data to encode.
     *
     * @return string
     *   The encoded data.
     *
     * @throws \Drupal\Component\Serialization\Exception\InvalidDataTypeException
     */
    public static function encode($data);
    
    /**
     * Decodes data from the serialization format.
     *
     * @param string $raw
     *   The raw data string to decode.
     *
     * @return mixed
     *   The decoded data.
     *
     * @throws \Drupal\Component\Serialization\Exception\InvalidDataTypeException
     */
    public static function decode($raw);
    
    /**
     * Gets the file extension for this serialization format.
     *
     * @return string
     *   The file extension, without leading dot.
     */
    public static function getFileExtension();

}

Interfaces

Title Deprecated Summary
SerializationInterface Defines an interface for serialization formats.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.