private function formatCell($cell)
    {
        // Cast cell data to a string.
        $cell = (string) $cell;

        // Enclose the cell in double quotes, if necessary.
        if (strpbrk($cell, '"' . $this->lineBreak . $this->delimiter) !== false) {
            $cell = '"' . str_replace('"', '""', $cell) . '"';
        }

        // Standardize line breaks.
        $cell = preg_replace('/\R/u', $this->lineBreak, $cell);

        return $cell;
    }