Convert a single element array to a string.

@param array $value

@return null|string
350008
public function reverseTransform($value)
    {
        if (!is_array($value)) {
            throw new TransformationFailedException('Expected an array.');
        }

        return empty($value) ? null : (string)array_pop($value);
    }
1303951
public function setXmlValue(array $value)
    {
        $value = array_map(
            function ($value) {
                return 'true' === $value;
            },
            $value
        );
        parent::setXmlValue($value);
    }
1222027
public static function decode($value)
    {
        if (empty($value)) {
            return null;
        }

        if (!is_string($value)) {
            throw new \InvalidArgumentException(sprintf(
                "Value type '%s' is not a PHP string so it cannot be unserialized.",
                gettype($value)
            ));
        }

        $data = unserialize($value);

        return $data;
    }
292780
public static function format(string $value)
    {
        $value = explode(',', $value);
        if (!is_array($value)) {
            $value = [$value];
        }
        return $value;
    }
1022868
protected function toString($value, array $exclude)
  {
    switch (gettype($value))
    {
      case ConversionEnum::ARRAY_CONVERSION:
        return $this->arrayToString($this->prepareArray($value, $exclude));
      case ConversionEnum::STRING_CONVERSION:
        return $value;
      case ConversionEnum::OBJECT_CONVERSION:
        $rc = new \ReflectionObject($value);
        if ($rc->hasMethod('__toString'))
        {
          return $rc->getMethod('__toString')->invoke($value);
        }

        return json_encode($this->objectToPublicObject($value));
    }
    throw new TransformerException(
      sprintf(
        'Value of type %s can not be converted to String by this method.',
        gettype($value)
      )
    );
  }
443382
protected function valueToString($value): string
    {
        if ($value === false) {
            return 'false';
        }
        if ($value === true) {
            return 'true';
        }
        if ($value === null) {
            return 'null';
        }
        if (is_string($value)) {
            if (call_user_func(function_exists('mb_strlen') ? 'mb_strlen' : 'strlen', $value) > 100) {
                $value = call_user_func(function_exists('mb_substr') ? 'mb_substr' : 'substr', $value, 0, 97).'...';
            }
            return '"'.$value.'"';
        }
        if (is_object($value)) {
            return 'a '.get_class($value).' instance';
        }
        if (is_array($value)) {
            $keys = array_keys($value);
            $isAssociative = $keys !== array_keys($keys);
            $valuesStrings = [];

            foreach ($value as $key => $subValue) {
                $valuesStrings[] = ($isAssociative ? $this->valueToString($key).' => ' : '')
                    . $this->valueToString($subValue);
            }

            return '['.implode(', ', $valuesStrings).']';
        }
        if (is_resource($value)) {
            return 'a resource';
        }
        return (string)$value;
    }
1149776
public function marshal($value)
    {
        if ($value === null || $value === '' || is_array($value)) {
            return null;
        }

        return (string)$value;
    }
1142801
protected function _encodeArrayFieldValue(array $value)
    {
        $result = array();
        foreach ($value as $triplet) {
            $currency = (isset($triplet[0])) ? $triplet[0] : "";
            $boundary = (isset($triplet[1])) ? $triplet[1] : "";
            $frequency = (isset($triplet[2])) ? $triplet[2] : "";
            $interest = (isset($triplet[3])) ? $triplet[3] : "";

            $_id = Mage::helper('core')->uniqHash('_');
            $result[$_id] = array(
                'installment_currency' => $currency,
                'installment_boundary' => $boundary,
                'installment_frequency' => $frequency,
                'installment_interest' => $interest
            );
        }

        return $result;
    }
503605
protected static function export(array $value)
	{
		$pairs = [];
		foreach ($value as $k => $v)
		{
			$pairs[] = var_export($k, true) . '=>' . var_export($v, true);
		}

		return '[' . implode(',', $pairs) . ']';
	}
1053989
public function convertJsonToArray($value) {

		if(true === $this -> convert_json) {

			if(true === is_string($value)) {

				$tmp = @json_decode($value, true);

				if(true === (json_last_error() == JSON_ERROR_NONE)) {
					$value = $tmp;
				}
			}
		}

		return $value;
	}
1233346
private function convertValue($value)
    {
        if (empty($value)) {
            return null;
        }

        if (\is_array($value)) {
            return $value;
        }

        switch ($this->fieldType) {
            case 'radio':
                return $value;
            case 'checkbox':
                $delimiter = (false !== \stripos($value, "\t")) ? "\t" : ',';

                return StringUtil::trimsplit($delimiter, $value);
            default:
        }
        throw new \RuntimeException('Unknown field type encountered: ' . $this->fieldType);
    }
945116
protected function resolveValue($value)
    {
        if (is_array($value)) {
            foreach ($value as $index => $val) {
                $value[$index] = $this->resolveValue($val);
            }

            return $value;
        }

        if (is_string($value) && '@' == $value[0]) {
            return $this->offsetGet(substr($value, 1));
        }

        return $value;
    }
6104
public function commands(array $value = null)
    {
        if (null === $value) {
            return $this->commands;
        }
        $this->commands = [];
        foreach ($value as $name => $command) {
            $this->command($name, $command);
        }
        return $this;
    }
822059
protected function valueToString($value) : string
    {
        if ($value === null) {
            $def_value = 'null';
        } elseif ($value === false) {
            $def_value = 'false';
        } elseif ($value === true) {
            $def_value = 'true';
        } elseif (is_string($value)) {
            $def_value = '"' . str_replace('"', '\\"', $value) . '"';
        } elseif (is_numeric($value)) {
            $def_value = '' . $value;
        }

        return $def_value;
    }
791017
protected function encode($value)
    {
        if (is_array($value)) {
            return array_map([$this, 'encode'], $value);
        } else {
            return str_replace(['+', '%7E'], [' ', '~'], rawurlencode($value));
        }
    }
732661
public static function toArray($value)
    {
        if (is_array($value)) {
            return $value;
        }

        if ($value instanceof Collection) {
            return $value->all();
        }

        return [$value];
    }
1310957
public function transform($value): ?string
    {
        /** TODO add sanity check is array of Location object? */
        if (!is_array($value) || empty($value)) {
            return null;
        }

        return implode(',', array_column($value, 'id'));
    }