static function dumpString(
        string $string,
        ?int $maxLength = null,
        ?string $encoding = null,
        ?array $quotes = null,
        ?string $ellipsis = null
    ): string {
        $stringLength = $encoding === null
            ? mb_strlen($string)
            : mb_strlen($string, $encoding);

        $tooLong = $maxLength !== null && $stringLength > $maxLength;

        return
            $quotes[0]
            . addcslashes(
                $tooLong
                    ? ($encoding === null
                    ? mb_substr($string, 0, $maxLength)
                    : mb_substr($string, 0, $maxLength, $encoding)
                )
                    : $string,
                "\000..\037"
            )
            . $quotes[1]
            . ($tooLong ? $ellipsis : '');
    }