Returns a string array to csv and removes empty items.

params:
- value - array or delimited string
- delimiter - string, defaults to ","
- lowercase - bool, defaults to false

@return string
346386
public function stringArrayToCsv()
    {
        $value = $this->getParameter('value');
        if (!is_array($value)) {
            $value = explode($this->getParameter('delimiter', ','), $value);
        }

        $value = array_map('trim', $value);
        if (empty($value)) {
            return '';
        }
        $value = array_filter($value, 'strlen');

        if ($this->getParameter('lowercase', false)) {
            $value = array_map('strtolower', $value);
            if ($this->getParameter('unique', true)) {
                $value = array_keys(array_flip($value));
            }
        } else {
            if ($this->getParameter('unique', true)) {
                $value = array_values(array_intersect_key($value, array_unique(array_map('strtolower', $value))));
            }
        }

        return implode(',', $value);
    }
1008376
public static function toString($value): string
    {
        if ($value === null) {
            return 'NULL';
        }

        if ($value === true) {
            return 'TRUE';
        }

        if ($value === false) {
            return 'FALSE';
        }

        if (is_object($value)) {
            return static::readObject($value);
        }

        if (is_array($value)) {
            return static::readArray($value);
        }

        if (is_resource($value)) {
            return static::readResource($value);
        }

        return (string) $value;
    }
339158
public static function cleanValue($value)
    {
        if (is_array($value)) {
            $new_value = [];

            foreach ($value as $k => $v) {
                $new_value[$k] = self::cleanValue($v);
            }

            return $new_value;
        }

        return stripslashes($value);
    }
728673
public static String[][] parse(String s) throws IOException {
        if (s == null) {
            throw new IllegalArgumentException("Null argument not allowed.");
        }
        String[][] result = (new CSVParser(new StringReader(s), CSVStrategy.DEFAULT_STRATEGY)).getAllValues();
        if (result == null) {
            // since CSVStrategy ignores empty lines an empty array is returned
            // (i.e. not "result = new String[][] {{""}};")
            result = EMPTY_DOUBLE_STRING_ARRAY;
        }
        return result;
    }
219134
private function tostring($value)
    {
        if (!isset($value)) {
            return 'null';
        }
        if ($value === true) {
            return 'true';
        }
        if ($value === false) {
            return 'false';
        }
        if (is_array($value)) {
            $out = '[';
            $i = 0;
            foreach ($value as $key => $entry) {
                if ($i) {
                    $out .= ', ';
                }
                $out .= $key.' => '.$this->tostring($entry);
                $i++;
            }
            $out .= ']';
            return $out;
        }
    }
719436
public static function sanitize($value)
    {
        if (is_array($value) || is_object($value))
        {
            foreach ($value as $key => $val)
            {
                $value[$key] = self::sanitize($val);
            }
        }
        elseif (is_string($value))
        {
            $value = stripslashes($value);
            if (false !== strpos($value, "\r"))
            {
                $value = str_replace([
                    "\r\n",
                    "\r"
                ], "\n", $value);
            }
        }

        return $value;
    }
460373
function formatCSV(values) {
    if (values instanceof Array) {
        return values.map(v => formatValue(v)).join();
    }
    if (typeof values === 'object' && values !== null) {
        return Object.keys(values).map(v => formatValue(values[v])).join();
    }
    return values === undefined ? '' : formatValue(values);
}
1332711
public function valuelize($value)
    {
        switch (true) {
            case $value === 'true':
                $value = true;
                break;
            case $value === 'false':
                $value = false;
                break;
            case is_string($value) && strtolower($value) === 'null':
                $value = null;
                break;
            case is_array($value):
                foreach ($value as $k => $v) {
                    $value[$k] = $this->valuelize($v);
                }
                break;
        }
        return $value;
    }
612877
public function getString($value)
    {
        $output = '[';
        for ($i = 0; $i < count($value); $i++) {
            $output .= $value[$i];
            if ($i < (count($value) - 1)) {
                $output .= ', ';
            }
        }
        $output .= ']';
        return $output;
    }
1132703
static function _toString($value) 
    {
        $vtype = 'string';
        if (is_array($value)) {
            $value = serialize($value);
            $vtype = 'array';
        } elseif (is_object($value)) {
            $value = serialize($value);
            $vtype = 'object';
        }
        return array($vtype, $value);
    }
337631
private String clean(final Collection<String> values) {
    if (values == null || values.size() == 0) {
      return "";
    }

    final List<String> strs = Lists.newArrayList();
    for (String v : values) {
      final String tmp = v.replaceAll("\\{.*\\}", "");
      final int ix = tmp.lastIndexOf(':');
      if (ix < 0) {
        strs.add(tmp);
      } else {
        strs.add(tmp.substring(ix+1));
      }
    }

    return DOUBLE_COMMA_JOINER.join(strs);
  }
563831
public function toCsv($data = null, $delimiter = null)
	{
		// csv format settings
		$newline = Arr::get($this->config, 'csv.newline', "\n");
		$delimiter or $delimiter = Arr::get($this->config, 'csv.delimiter', ',');
		$enclosure = Arr::get($this->config, 'csv.enclosure', '"');
		$escape = Arr::get($this->config, 'csv.escape', '\\');

		// escape function
		$escaper = function($items) use($enclosure, $escape) {
			return array_map(function($item) use($enclosure, $escape){
				return str_replace($enclosure, $escape.$enclosure, $item);
			}, $items);
		};

		if ($data === null)
		{
			$data = $this->data;
		}

		if (is_object($data) and ! $data instanceof \Iterator)
		{
			$data = $this->toArray($data);
		}

		// Multi-dimensional array
		if (is_array($data) and Arr::isMulti($data))
		{
			$data = array_values($data);

			if (Arr::isAssoc($data[0]))
			{
				$headings = array_keys($data[0]);
			}
			else
			{
				$headings = array_shift($data);
			}
		}
		// Single array
		else
		{
			$headings = array_keys((array) $data);
			$data = array($data);
		}

		$output = $enclosure.implode($enclosure.$delimiter.$enclosure, $escaper($headings)).$enclosure.$newline;

		foreach ($data as $row)
		{
			$output .= $enclosure.implode($enclosure.$delimiter.$enclosure, $escaper((array) $row)).$enclosure.$newline;
		}

		return rtrim($output, $newline);
	}
1244366
protected function _emptyValue($value)
    {
        if ($value === true) {
            return ['' => ''];
        }
        if (is_scalar($value)) {
            return ['' => $value];
        }
        if (is_array($value)) {
            return $value;
        }

        return [];
    }
487682
public static final Set<String> fromCommaSeparatedValues(String csv) {
        if (csv == null || csv.isEmpty()) {
            return Collections.EMPTY_SET;
        }
        String[] tokens = csv.split(",");
        return new HashSet<String>(Arrays.asList(tokens));
    }
1274164
protected function _exportParamValue($value = null, $length = 0) {
		$truncateOpt = [
			'ellipsis' => '...',
			'exact' => false,
			'html' => false
		];

		$valueText = var_export($value, true);
		$valueType = Debugger::getType($value);
		switch ($valueType) {
			case 'string':
				if (ctype_digit($value)) {
					$valueText = (int)$value;
				}
				break;
			case 'resource':
			case 'unknown':
				$valueText = 'null';
				break;
		}
		if ($length > 0) {
			$valueText = CakeText::truncate($valueText, $length, $truncateOpt);
		}

		return $valueText;
	}
204211
public function _prepValues($value)
    {
        if (is_array($value)) {
            if (isset($value["func"])) {
                return $value["func"];
            }
            foreach ($value as &$param) {
                $this->params[] = $param;
                $param = "?";
            }
            unset($param);
            return $value;
        }
        if (in_array(is_string($value) ? strtolower($value) : $value, [null, "null"]) === false) {
            $this->params[] = $value;
            $value = "?";
        }
        return $value;
    }
486028
private function _extractValue()
    {
        $value = Resources::EMPTY_STRING;

        if ($this->_pos < strlen($this->_value)) {
            $ch = $this->_value[$this->_pos];

            if ($ch == '"' || $ch == '\'') {
                // Value is contained between double quotes or skipped single quotes.
                ++$this->_pos;
                $value = $this->_extractString($ch);
            } else {
                $firstPos = $this->_pos;
                $isFound = false;

                while ($this->_pos < strlen($this->_value) && !$isFound) {
                    $ch = $this->_value[$this->_pos];

                    if ($ch == ';') {
                        $isFound = true;
                    } else {
                        ++$this->_pos;
                    }
                }

                $value = rtrim(
                    substr($this->_value, $firstPos, $this->_pos - $firstPos)
                );
            }
        }

        return $value;
    }