@throws \LogicException

@param mixed $data

@return string
170987
public function getLinkForFill($data)
    {
        if (!($this->router instanceof Router)) {
            throw new \LogicException('Link cannot be built without a Router');
        }

        return $this->router->generate(
            'fill_filler',
            [
                'plugin' => $this->getName(),
                $this->getForm()->getName() => ['url' => $data],
            ]
        );
    }
894568
public function encode($data): string
    {
        $encoded = @json_encode($data, $this->getEncodeOptions());

        if ($encoded === false && json_last_error() !== JSON_ERROR_NONE) {
            throw new \RuntimeException('Encoding JSON failed: ' . json_last_error_msg());
        }

        return $encoded;
    }
696302
static function smartUnserialize(string $data)
    {
        try {
            $value = @unserialize($data);
        } catch (\Throwable $e) {
            throw new DeserializationFailedException('An exception was thrown during unserialization', 0, $e);
        }

        // distinguish between "false on error" and a serialized FALSE value
        if ($value === false && $data !== self::getSerializedFalse()) {
            throw new DeserializationFailedException('Unserialization failed - data possibly malformed');
        }

        return $value;
    }
487834
protected function encodeMessage($data)
    {
        return $this->server->getBean(\Imi\Server\DataParser\DataParser::class)->encode($data);
    }
816474
public static function convertToString($data)
    {
        if (is_string($data)) {
            //Nothing
        } elseif (is_int($data) || is_float($data)) {
            $data = (string) $data;
        } elseif (is_bool($data)) {
            $data = $data ? '1' : '0';
        } elseif (is_object($data)) {
            if (method_exists($data, '__toString')) {
                $data = (string) $data;
            } else {
                throw new \InvalidArgumentException('_toString() method doesn\'t exist for the "data" object');
            }
        } else {
            throw new \InvalidArgumentException('Encryption is not supported for the "' . gettype($data) . '" type');
        }

        return $data;
    }
223879
public function read($len)
    {
        // happy path to return empty string for zero length string
        if ($len === 0) {
            return '';
        }

        // happy path for single byte strings without using substrings
        if ($len === 1 && isset($this->buffer[$this->bufferPos])) {
            return $this->buffer[$this->bufferPos++];
        }

        // ensure buffer size contains $len bytes by checking target buffer position
        if ($len < 0 || !isset($this->buffer[$this->bufferPos + $len - 1])) {
            throw new \LogicException('Not enough data in buffer to read ' . $len . ' bytes');
        }
        $buffer = \substr($this->buffer, $this->bufferPos, $len);
        $this->bufferPos += $len;

        return $buffer;
    }
553740
public function serialize($data)
    {
        if (is_string($data) === true) {
            return $data;
        } else {
            $data = json_encode($data);
            if ($data === '[]') {
                return '{}';
            } else {
                return $data;
            }
        }


    }
487141
public static function encode($data, $options = 0): string
    {
        $json = json_encode($data, $options);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonEncodeException(json_last_error_msg());
        }

        return $json;
    }
1203570
public static function encode($data): string
    {
        if (PHP_VERSION_ID >= 50400) {
            return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        }

        return json_encode($data);
    }
401820
public function makeThrowable(Data $data): ?ExceptionFormat
    {
        if (!$data->isThrowable()) {
            return null;
        }

        return ExceptionFormat::make($data->getValue());
    }
851758
public function reverseTransform($data)
    {
        if (is_null($data) || empty($data)) {
            return '';
        }

        $formatter = $this->getFormatter();

        $value = $formatter->parse($data);

        if (intl_is_failure($formatter->getErrorCode())) {
            throw new DataTransformerException($formatter->getErrorMessage());
        }

        return $value;
    }
1153794
public function update(DataAbstract $data)
    {
        if (!$data->isUpdated()) {
            return false;
        }

        //~ Reset binded fields
        $this->binds = array();

        foreach ($this->primaryKeys as $key) {
            $this->addWhere($key, $this->getDataValue($data, $key));
        }

        $set = $this->getQueryFieldsSet($data);
        if (empty($set)) {
            return false;
        }

        $where = $this->getQueryWhere();
        if (empty($where)) {
            throw new \LogicException(__METHOD__ . '|Where clause is empty!');
        }

        $query     = 'UPDATE ' . $this->getTable() . ' ' . $set . ' ' . $where;
        $statement = $this->db->prepare($query);
        $statement->execute($this->binds);

        //~ Reset some data
        $data->resetUpdated();

        //~ Clear
        $this->clear();
        $this->deleteCache($data);

        return true;
    }
917928
public static function encode($data)
    {
        switch (gettype($data)) {
            case 'array':
                return self::encodeArray($data);
            case 'object':
                return self::encodeObject($data);
            case 'string':
                return self::encodeString($data);
            case 'integer':
                return self::encodeInteger($data);
            case 'boolean':
                return self::encodeBoolean($data);
            case 'double':
                return self::encodeDouble($data);
            case 'NULL':
                return self::encodeNull($data);
            case 'resource':
                // TODO
                break;
            default:
                throw new UnencodeableException('Contains unencodeable type', 3);
        }
    }
80647
final private static function encodeString(string $data): string
    {
        $buf = '';
        self::encodeUnsigned($buf, strlen($data));
        return $buf . $data;
    }
138413
public function setData($data)
    {
        if (!isset($data[0])) {
            throw new \LogicException('Aucune donnée soumise');
        }
        $k = array_keys($data[0]); // Check the first key  from the first line
        $objectize = is_string($k[0]) ? true : false;
        $n = count($data);
        for ($i = 0;$i<$n;++$i) {
            $data[$i] = $objectize ? (object) $data[$i] : $data[$i];
        }
        $this->setJsInitParam('data',  $data);
        $this->renderFilterOperators = false;

        return $this;
    }
1319035
public function data()
    {

        if( isset( $this->filePath ) ) {

            return file_get_contents( $this->filePath );

        } elseif( $this->oid ) {

            $pg = $this->oid->pg;
            $pg->query( new Query( 'BEGIN' ) );

            $handle = pg_lo_open( $pg->resource->get(), $this->oid->oid, 'r' );

            $result = '';
            while( ( $data = pg_lo_read( $handle ) ) ){
                $result .= $data;
            }

            pg_lo_close( $handle );

            $pg->query( new Query( 'COMMIT' ) );

            return $result;

        }

        throw \LogicException("Shouldn't ever get tripped");

    }
1164711
public static function decode($data)
    {
        if (!is_string($data)) {
            throw new InvalidArgumentException('data must be string');
        }
        if (1 === strlen($data) % 4) {
            throw new InvalidArgumentException('invalid base64 string length');
        }
        $result = base64_decode($data, true);
        if (false === $result) {
            throw new InvalidArgumentException('invalid base64 string');
        }

        return $result;
    }