public static function serialize($value)
    {
        if (is_resource($value)) {
            throw SerializationFailedException::forValue($value);
        }

        try {
            $serialized = serialize($value);
        } catch (Exception $e) {
            throw SerializationFailedException::forValue($value, $e->getMessage(), $e->getCode(), $e);
        }

        return $serialized;
    }