private function fromStringToArray( $str )
    {

        $p = 0;

        // Leading spaces.
        $c = $this->charAfterSpaces( $str, $p );
        if( $c === false ) {
            return array();
        }

        $result = [];

        while (true) {

            $c = $this->charAfterSpaces($str, $p);

            // end of string
            if ($c === false) {
                break;
            }

            // next element
            if ($c == ',') {
                $p++;
                continue;
            }

            // key
            $key = $this->readKeyValue($str, $p);

            // '=>' sequence.
            $this->charAfterSpaces($str, $p);
            if (substr($str, $p, 2) != '=>') {
                throw new \Exception("Was expecting a `=>` {$str} when passing hstore's value");
            }
            $p += 2;
            $this->charAfterSpaces($str, $p);

            // value, null safe
            $value = $this->readKeyValue($str, $p);
            if (!strcasecmp($value, "null")) {
                $result[$key] = null;
            } else {
                $result[$key] = $value;
            }

        }

        return $result;
    }