# bit-form/3.1.0/vendor/arif-un/jcof/src/StringWriter.php

Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator &amp; Custom Form Builder, version 3.1.0. 48 lines.

- Page: https://pluginprobe.com/plugins/bit-form/3.1.0/code/vendor/arif-un/jcof/src/StringWriter.php
- Raw: https://pluginprobe.com/plugins/bit-form/3.1.0/raw/vendor/arif-un/jcof/src/StringWriter.php
- Modified: 2024-06-29T11:34:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bit-form/3.1.0/code/vendor/arif-un/jcof/src/StringWriter.php#L10-L20`.

```php
<?php

namespace BitCode\BitForm\Jcof;

class StringWriter
{
    public $str;

    public $maybeNextSep;

    public $prevCh;

    public function __construct()
    {
        $this->str = '';
        $this->maybeNextSep = null;
        $this->prevCh = null;
    }

    public function write($s)
    {
        if ($this->maybeNextSep) {
            if (! $this->isSep($this->prevCh) && ! $this->isSep(substr($s, 0, 1))) {
                $this->str .= $this->maybeNextSep;
            }
            $this->maybeNextSep = null;
        }

        $this->str .= $s;
        $this->prevCh = substr($s, strlen($s) - 1, 1);
    }

    public function maybeSep($sep)
    {
        if ($this->maybeNextSep) {
            $this->write($this->maybeNextSep);
        }

        $this->maybeNextSep = $sep;
    }

    public function isSep($ch)
    {
        return $ch == '[' || $ch == ']' || $ch == '{' || $ch == '}' ||
            $ch == '(' || $ch == ')' || $ch == ',' || $ch == ':' || $ch == '"';
    }
}

```
