Documentation

ConfigWriter
in package

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

Table of Contents

toContent()  : mixed
toFile()  : mixed
buildArrayExpression()  : mixed
Single level arrays only
buildArrayOpeningExpression()  : mixed
buildConstantExpression()  : mixed
Common constants only (true, false, null, integers)
buildStringExpression()  : mixed
parseContent()  : mixed
parseContentValue()  : mixed
writeArrayToPhp()  : mixed
writeValueToPhp()  : mixed

Methods

toContent()

public toContent(mixed $contents, mixed $newValues[, mixed $useValidation = true ]) : mixed
Parameters
$contents : mixed
$newValues : mixed
$useValidation : mixed = true
Return values
mixed

toFile()

public toFile(mixed $filePath, mixed $newValues[, mixed $useValidation = true ]) : mixed
Parameters
$filePath : mixed
$newValues : mixed
$useValidation : mixed = true
Return values
mixed

buildArrayExpression()

Single level arrays only

protected buildArrayExpression(mixed $targetKey[, mixed $arrayItems = [] ]) : mixed
Parameters
$targetKey : mixed
$arrayItems : mixed = []
Return values
mixed

buildArrayOpeningExpression()

protected buildArrayOpeningExpression(mixed $arrayItems) : mixed
Parameters
$arrayItems : mixed
Return values
mixed

buildConstantExpression()

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

protected buildConstantExpression(mixed $targetKey[, mixed $arrayItems = [] ]) : mixed
Parameters
$targetKey : mixed
$arrayItems : mixed = []
Return values
mixed

buildStringExpression()

protected buildStringExpression(mixed $targetKey[, mixed $arrayItems = [] ][, mixed $quoteChar = "'" ]) : mixed
Parameters
$targetKey : mixed
$arrayItems : mixed = []
$quoteChar : mixed = "'"
Return values
mixed

parseContent()

protected parseContent(mixed $contents, mixed $newValues) : mixed
Parameters
$contents : mixed
$newValues : mixed
Return values
mixed

parseContentValue()

protected parseContentValue(mixed $contents, mixed $path, mixed $value) : mixed
Parameters
$contents : mixed
$path : mixed
$value : mixed
Return values
mixed

writeArrayToPhp()

protected writeArrayToPhp(mixed $array) : mixed
Parameters
$array : mixed
Return values
mixed

writeValueToPhp()

protected writeValueToPhp(mixed $value) : mixed
Parameters
$value : mixed
Return values
mixed

Search results