private function buildArrayLiteral(array $value, array $requiredSizes): string
    {
        $requiredCount = array_shift($requiredSizes);
        if ($requiredCount !== count($value)) {
            throw TypeConversionException::unexpectedValue(
                $this,
                'output',
                "array with {$requiredCount} value(s)",
                $value
            );
        }

        $parts = [];
        if (empty($requiredSizes)) {
            foreach ($value as $v) {
                $item    = $this->itemConverter->output($v);
                $parts[] = ($item === null) ? 'NULL' : '"' . addcslashes($item, "\"\\") . '"';
            }

        } else {
            foreach ($value as $v) {
                if (!is_array($v)) {
                    throw TypeConversionException::unexpectedValue($this, 'output', 'array', $v);
                }
                $parts[] = $this->buildArrayLiteral($v, $requiredSizes);
            }
        }

        return '{' . implode(',', $parts) . '}';
    }
private function buildArrayLiteral(array $value, array $requiredSizes): string
    {
        $requiredCount = array_shift($requiredSizes);
        if ($requiredCount !== count($value)) {
            throw TypeConversionException::unexpectedValue(
                $this,
                'output',
                "array with {$requiredCount} value(s)",
                $value
            );
        }

        $parts = [];
        if (empty($requiredSizes)) {
            foreach ($value as $v) {
                $item    = $this->itemConverter->output($v);
                $parts[] = ($item === null) ? 'NULL' : '"' . addcslashes($item, "\"\\") . '"';
            }

        } else {
            foreach ($value as $v) {
                if (!is_array($v)) {
                    throw TypeConversionException::unexpectedValue($this, 'output', 'array', $v);
                }
                $parts[] = $this->buildArrayLiteral($v, $requiredSizes);
            }
        }

        return '{' . implode(',', $parts) . '}';
    }
private function buildArrayLiteral ( array $ value , array $ requiredSizes ) : string { $ requiredCount = array_shift ( $ requiredSizes ) ; if ( $ requiredCount !== count ( $ value ) ) { throw TypeConversionException :: unexpectedValue ( $ this , 'output' , "array with {$requiredCount} value(s)" , $ value ) ; } $ parts = [ ] ; if ( empty ( $ requiredSizes ) ) { foreach ( $ value as $ v ) { $ item = $ this -> itemConverter -> output ( $ v ) ; $ parts [ ] = ( $ item === null ) ? 'NULL' : '"' . addcslashes ( $ item , "\"\\" ) . '"' ; } } else { foreach ( $ value as $ v ) { if ( ! is_array ( $ v ) ) { throw TypeConversionException :: unexpectedValue ( $ this , 'output' , 'array' , $ v ) ; } $ parts [ ] = $ this -> buildArrayLiteral ( $ v , $ requiredSizes ) ; } } return '{' . implode ( ',' , $ parts ) . '}' ; }
Builds an array literal checking the required sizes for sub-arrays

@param array $value
@param array $requiredSizes
@return string
@throws TypeConversionException
Builds an array literal checking the required sizes for sub - arrays