Prepare formatted constant array.

@param array $constants

@return array
434842
protected function prepareConstants(array $constants)
    {
        // My kingdom for a generator.
        $ret = [];

        $names = \array_keys($constants);
        \natcasesort($names);

        foreach ($names as $name) {
            if ($this->showItem($name)) {
                $ret[$name] = [
                    'name'  => $name,
                    'style' => self::IS_CONSTANT,
                    'value' => $this->presentRef($constants[$name]),
                ];
            }
        }

        return $ret;
    }
1039906
public function prepareValues($values)
    {
        if (empty($values)) {
            return [];
        }

        if (!is_array($values)) {
            $values = (array)$values;
        }

        $values = array_filter($values, 'is_scalar');
        $values = array_map('self::quoteValue', $values);

        return $values;
    }
957880
public function prepareBindings(array $bindings)
    {
        $grammar = $this->getQueryGrammar();

        foreach ($bindings as $key => $value) {
            // We need to transform all instances of DateTimeInterface into the actual
            // date string. Each query grammar maintains its own date string format
            // so we'll just ask the grammar for the format to get from the date.
            if ($value instanceof DateTimeInterface) {
                $bindings[$key] = $value->format($grammar->getDateFormat());
            } elseif (is_bool($value)) {
                $bindings[$key] = (int) $value;
            }
        }

        return $bindings;
    }
313903
private function makeConstantStatements(): array
  {
    $width1    = 0;
    $width2    = 0;
    $constants = [];

    foreach ($this->constants as $constant => $value)
    {
      $width1 = max(mb_strlen($constant), $width1);
      $width2 = max(mb_strlen((string)$value), $width2);
    }

    $line_format = sprintf('  const %%-%ds = %%%dd;', $width1, $width2);
    foreach ($this->constants as $constant => $value)
    {
      $constants[] = sprintf($line_format, $constant, $value);
    }

    return $constants;
  }
1188034
protected function prepareConfiguration(array $options=null)
    {
        $configuration = clone $this->configuration;
        if (is_array($options)) {
            $options = array_replace($configuration->all(), $options);
            $configuration = new Configuration($options);
        }
        return $configuration;
    }
1267215
protected function prepareParams(array $params)
    {
        $result = $params;

        foreach ($result as $key => $val) {
            if (is_bool($val)) {
                $result[$key] = $val ? 1 : 0;
            }
        }

        return $result;
    }
843224
protected function prepareParams($params)
    {
        $data = [];
        foreach ($params as $key => $value) {
            if (is_object($value) && Str::is('Illuminate\*\Events\*', get_class($value))) {
                $value = $this->prepareParams(get_object_vars($value));
            }
            $data[$key] = htmlentities($this->exporter->exportValue($value), ENT_QUOTES, 'UTF-8', false);
        }

        return $data;
    }
1064618
public function prepareProjection(array $fields) : array
    {
        $preparedFields = [];

        foreach ($fields as $key => $value) {
            $preparedFields[$this->prepareFieldName($key)] = $value;
        }

        return $preparedFields;
    }
123991
protected function prepareFrom($froms) {
        $_froms = [];
        if ($froms) {
            foreach ($froms as $from) {
                $table     = $this->dialect->getTableName($from [0]);
                $alias     = empty ($from [1]) ? $table : $from [1];
                $_froms [] = [$table, $alias];
            }
        }

        return $_froms;
    }
150213
public function writeConstants(array $constants)
	{
		
		//common checks
		if(!file_exists($this->file)){
			throw new tao_install_utils_Exception("Unable to write constants: $this->file don't exists!");
		}
		if(!is_readable($this->file) || !is_writable($this->file)){
			throw new tao_install_utils_Exception("Unable to write constants: $this->file must have read and write permissions!");
		}

		$content = file_get_contents($this->file);
		if(!empty($content)){
			foreach($constants as $name => $val){
				
				if(is_string($val)){
					$val = addslashes((string)$val);
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1,\''.addslashes($val).'\');',$content);
				}
				else if(is_bool($val)){
					($val === true) ? $val = 'true' : $val = 'false';
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1, '.$val.');',$content);
				}
				else if(is_numeric($val)){
					$content = preg_replace('/(\''.$name.'\')(.*?)$/ms','$1, '.$val.');',$content);
				}
			}
			file_put_contents($this->file, $content);
		}
	}
90676
protected function prepare_form_fields(array $fields) {

        $formdata = new stdclass();
        $key = 0;
        foreach ($fields as $field) {
            $formdata->{'dimensionid__idx_' . $key}             = $field->id;
            $formdata->{'description__idx_' . $key}             = $field->description;
            $formdata->{'description__idx_' . $key.'format'}    = $field->descriptionformat;
            $formdata->{'numoflevels__idx_' . $key}             = count($field->levels);
            $lev = 0;
            foreach ($field->levels as $level) {
                $formdata->{'levelid__idx_' . $key . '__idy_' . $lev} = $level->id;
                $formdata->{'grade__idx_' . $key . '__idy_' . $lev} = $level->grade;
                $formdata->{'definition__idx_' . $key . '__idy_' . $lev} = $level->definition;
                $formdata->{'definition__idx_' . $key . '__idy_' . $lev . 'format'} = $level->definitionformat;
                $lev++;
            }
            $key++;
        }
        return $formdata;
    }
1155870
protected function prepareArray(array $conditions)
    {
        switch (count($conditions)) {
            case 1:
                $result = $conditions[0];
                break;
            case 2:
                if (is_array($conditions[1])) {
                    $result = $conditions[0].' IN ('.implode(',', $conditions[1]).')';
                } elseif (is_null($conditions[1])) {
                    $result = $conditions[0].' IS NULL';
                } elseif ($conditions[1] instanceof \pwf\components\querybuilder\interfaces\SelectBuilder) {
                    $result = $conditions[0].' IN ('.$conditions[1]->generate().')';
                    $this->setParams(array_merge($this->getParams(),
                            $conditions[1]->getParams()));
                } else {
                    $result = $conditions[0].'=?';//.$conditions[0];
                    $this->addParam($conditions[0], $conditions[1]);
                }
                break;
            case 3:
                $left   = is_array($conditions[1]) ? $this->prepareConditions($conditions[1])
                        : $conditions[1];
                $right  = is_array($conditions[2]) ? $this->prepareConditions($conditions[2])
                        : $conditions[2];
                $result = '(('.$left.') '.$conditions[0].' ('.$right.'))';
                break;
            default:
                throw new \Exception('Wrong condition configuration');
        }

        return $result;
    }
645853
protected function prepareFieldsValues($fields)
    {
        return array_map(function ($value) {
            if ($value instanceof \DateTime) {
                return $value->format('Y-m-d H:i:s');
            }

            return $value;
        }, $fields);
    }
1218706
protected function prepareTags($tags)
    {
        if (is_string($tags) && mb_strpos($tags, static::getTagsDelimiter()) !== false) {
            $delimiter = preg_quote(static::getTagsDelimiter(), '#');
            $tags = array_map('trim', preg_split("#[{$delimiter}]#", $tags, -1, PREG_SPLIT_NO_EMPTY));
        }

        return $tags;
    }
1294939
public function transformParams(array $params): array
    {
        $newParams = [];
        foreach ($params as $key => $value) {
            $newParams['%' . $key . '%'] = $value;
        }

        return $newParams;
    }
779874
protected function prepareAttributes(array $attributes)
    {
        return array_map(function ($attribute) {
            return ($attribute instanceof DateTime)
                ? $this->fromDateTime($attribute)
                : (string) $attribute;
        }, $attributes);
    }
1082781
protected function prepareAttributes(array $attributes)
    {
        foreach ($attributes as $key => $attribute) {
            if (in_array($key, $this->getDates()) && ! is_null($attribute)) {
                $attribute = $this->asDateTime($attribute);
            }
            if ($attribute instanceof DateTime) {
                $attribute = $this->fromDateTime($attribute);
            }
            $attributes[$key] = (string) $attribute;
        }
        return $attributes;
    }