Turns data into string,

@param array|string|\stdClass $data

@return string
768184
protected static function dataToString($data)
    {
        if (!is_string($data))
        {
            try
            {
                $data = \GuzzleHttp\json_encode($data);
            }
            catch (\InvalidArgumentException $e)
            {

            }
        }

        return $data;
    }
638453
public function optimize (stdClass $data)
    {
        $data->formName = $data->serviceName . 'Form';
        $data->formNameSpace = str_replace ('\\http\\controllers', '\\forms', $data->controllerNamespace);
        $data->formDestination = str_replace ('/http/controllers', '/forms', $data->controllerDestination) . '/' . $data->formName . '.php';
        $data->formID = $this->stringWithDash ($data->serviceURL);

        return $data;
    }
330207
protected function deserializeDataRecursive($data)
	{
		foreach ($data as $key => $value) {
			if (is_string($value) && trim($value)) {
				if (is_object($data)) {
					$data->$key = \StringUtil::deserialize($value);
				}
				else {
					$data[$key] = \StringUtil::deserialize($value);
				}
			}
			else if (is_array($value) || is_object($value)) {
				if (is_object($data)) {
					$data->$key = $this->deserializeDataRecursive($value);
				}
				else {
					$data[$key] = $this->deserializeDataRecursive($value);
				}
			}
		}

		return $data;
	}
813594
private function encodeString($data = null)
    {
        $data = is_null($data) ? $this->data : $data;
        return sprintf("%d:%s", strlen($data), $data);
    }
582948
protected function _toString($data) {
		foreach ($data as $key => $val) {
			switch (true) {
				case is_object($val) && !$val instanceof \Closure:
					try {
						$data[$key] = (string) $val;
					} catch (Exception $e) {
						$data[$key] = '';
					}
				break;
				case is_array($val):
					$data = array_merge($data, Set::flatten($val));
				break;
			}
		}
		return $data;
	}
1061286
public function encode($data, $delimiter = null): string
    {
        if (count($data) === 0) {
            return '';
        }
        $delimiter = $delimiter ?? $this->getDelimiter();
        $header = array_keys(reset($data));

        // Encode the field names
        $string = implode($delimiter, $header). "\n";

        // Encode the data
        foreach ($data as $row) {
            $string .=  implode($delimiter, $row). "\n";
        }

        return $string;
    }
513234
public function getData() : \stdClass
    {
        $output = new \stdClass();

        foreach ($this->data as $key => $property) {
            if ($this->options['lowercase']) {
                $key = strtolower($key);
            }

            $output->{$key} = $property;
        }

        return $output;
    }
88444
protected function encode($data)
    {
        $data = [
            '<?php',
            '',
            'return ' . $this->render($data, 0) . ';',
        ];

        return implode(Data::LE, $data);
    }
563252
public function transform($data)
    {
        $output = $data;
        if (is_array($data)) {
            $output = "<ul>";
            foreach ($data as $item) {
                $output .= "<li>" . $this->transform($item) . "</li>";
            }
            $output .= "</ul>";
        }

        return $output;
    }
580835
public function encode($data): string
    {
        try {
            $data = \serialize($data);
        } catch (\Throwable $exception) {
            throw new SerializationException(
                "The given data cannot be sent because it is not serializable.",
                0,
                $exception
            );
        }

        return \pack("CL", 0, \strlen($data)) . $data;
    }
856053
static public function encode($data)
	{
	    if (is_array($data)) {
	        foreach ($data as $k=>$v) {
	            if (is_array($v)) {
	                if (empty($v)) {
	                    $data[$k] = null;
	                } else {
	                    $data[$k] = implode('|', $v);
	                }
	            }
	        }
	        $data = implode(",", $data);
	    } elseif ((is_object($data) && !method_exists($data, '_toString'))) {
	        throw new \InvalidArgumentException(__CLASS__ . ' can not handle an array or non-stringable object.');
	    }

		return $data;
	}
917928
public static function encode($data)
    {
        switch (gettype($data)) {
            case 'array':
                return self::encodeArray($data);
            case 'object':
                return self::encodeObject($data);
            case 'string':
                return self::encodeString($data);
            case 'integer':
                return self::encodeInteger($data);
            case 'boolean':
                return self::encodeBoolean($data);
            case 'double':
                return self::encodeDouble($data);
            case 'NULL':
                return self::encodeNull($data);
            case 'resource':
                // TODO
                break;
            default:
                throw new UnencodeableException('Contains unencodeable type', 3);
        }
    }
1148135
protected function formatData(array $data) : string {
    $data_string = '';

    foreach ($data as $column => $value) {
      $data_string .= "`{$column}` = :{$column}";

      if (next($data) !== false) {
        $data_string .= ', ';
      }
    }

    return $data_string;
  }
413386
protected function stringArray(Array $data)
    {
        $str = EOL . HT . '[' . EOL;

        foreach( $data as $key => $val )
        {
            $str .= HT . HT . "'" . $key . "' => '" . $val . "'," . EOL;
        }

        $str  = Base::removeSuffix($str, ',' . EOL);
        $str .= EOL . HT . ']';

        return $str;
    }
77746
public function name($data) {
		if (is_object($data) && isset($data->type)) {
			return $data->value;
		}
		if ($data === '*') {
			return '*';
		}
		if (is_array($data)) {
			foreach ($data as $i => $dataItem) {
				$data[$i] = $this->name($dataItem);
			}
			return $data;
		}
		return (string)$data;
	}
1071382
public function serialize($data)
    {
        if (is_array($data) || (is_object($data) && !method_exists($data, '_toString'))) {
            throw new \InvalidArgumentException(__CLASS__ . ' can not handle an array or non-stringable object.');
        }

        return $data;
    }
94442
public static function toString($data, bool $dump = true): string
    {
        if (is_callable($data)) {
            return static::toString($data());
        }

        if (is_stringable($data)) {
            return (string) $data;
        }

        if (is_array($data)) {
            $data = $dump ? Arr::dump($data) : 'Array()';
        }

        if (is_object($data)) {
            $data = $dump ? Arr::dump($data) : sprintf('[Object %s]', get_class($data));
        }

        return (string) $data;
    }