October\Rain\Config\ConfigWriter

Source: ~/vendor/october/rain/src/Config/ConfigWriter.php

Configuration rewriter

https://github.com/daftspunk/laravel-config-writer

This class lets you rewrite array values inside a basic configuration file that returns a single array definition (a Laravel config file) whilst maintaining the integrity of the file, leaving comments and advanced settings intact.

The following value types are supported for writing:

  • strings
  • integers
  • booleans
  • nulls
  • single-dimension arrays

To do:

  • When an entry does not exist, provide a way to create it

Pro Regextip: Use [\s\S] instead of . for multiline support

Public methods

public void toContent($contents, $newValues, $useValidation=true)
Parameters
  • $contents
  • $newValues
  • $useValidation

public void toFile($filePath, $newValues, $useValidation=true)
Parameters
  • $filePath
  • $newValues
  • $useValidation

Protected methods

protected void buildArrayExpression($targetKey, $arrayItems=array())

Single level arrays only

Parameters
  • $targetKey
  • $arrayItems

protected void buildArrayOpeningExpression($arrayItems)
Parameters
  • $arrayItems

protected void buildConstantExpression($targetKey, $arrayItems=array())

Common constants only (true, false, null, integers)

Parameters
  • $targetKey
  • $arrayItems

protected void buildStringExpression($targetKey, $arrayItems=array(), $quoteChar='\'')
Parameters
  • $targetKey
  • $arrayItems
  • $quoteChar

protected void parseContent($contents, $newValues)
Parameters
  • $contents
  • $newValues

protected void parseContentValue($contents, $path, $value)
Parameters
  • $contents
  • $path
  • $value

protected void writeArrayToPhp($array)
Parameters
  • $array

protected void writeValueToPhp($value)
Parameters
  • $value