src/WPConfigTransformer.php
public function add( $type, $name, $value, array $options = array() ) {
		if ( ! is_string( $value ) ) {
			throw new Exception( 'Config value must be a string.' );
		}

		if ( $this->exists( $type, $name ) ) {
			return false;
		}

		$defaults = array(
			'raw'       => false, // Display value in raw format without quotes.
			'anchor'    => "/* That's all, stop editing!", // Config placement anchor string.
			'separator' => PHP_EOL, // Separator between config definition and anchor string.
			'placement' => 'before', // Config placement direction (insert before or after).
		);

		list( $raw, $anchor, $separator, $placement ) = array_values( array_merge( $defaults, $options ) );

		$raw       = (bool) $raw;
		$anchor    = (string) $anchor;
		$separator = (string) $separator;
		$placement = (string) $placement;

		if ( false === strpos( $this->wp_config_src, $anchor ) ) {
			throw new Exception( 'Unable to locate placement anchor.' );
		}

		$new_src  = $this->normalize( $type, $name, $this->format_value( $value, $raw ) );
		$new_src  = ( 'after' === $placement ) ? $anchor . $separator . $new_src : $new_src . $separator . $anchor;
		$contents = str_replace( $anchor, $new_src, $this->wp_config_src );

		return $this->save( $contents );
	}
public function add( $type, $name, $value, array $options = array() ) {
		if ( ! is_string( $value ) ) {
			throw new Exception( 'Config value must be a string.' );
		}

		if ( $this->exists( $type, $name ) ) {
			return false;
		}

		$defaults = array(
			'raw'       => false, // Display value in raw format without quotes.
			'anchor'    => "/* That's all, stop editing!", // Config placement anchor string.
			'separator' => PHP_EOL, // Separator between config definition and anchor string.
			'placement' => 'before', // Config placement direction (insert before or after).
		);

		list( $raw, $anchor, $separator, $placement ) = array_values( array_merge( $defaults, $options ) );

		$raw       = (bool) $raw;
		$anchor    = (string) $anchor;
		$separator = (string) $separator;
		$placement = (string) $placement;

		if ( false === strpos( $this->wp_config_src, $anchor ) ) {
			throw new Exception( 'Unable to locate placement anchor.' );
		}

		$new_src  = $this->normalize( $type, $name, $this->format_value( $value, $raw ) );
		$new_src  = ( 'after' === $placement ) ? $anchor . $separator . $new_src : $new_src . $separator . $anchor;
		$contents = str_replace( $anchor, $new_src, $this->wp_config_src );

		return $this->save( $contents );
	}
public function add ( $ type , $ name , $ value , array $ options = array ( ) ) { if ( ! is_string ( $ value ) ) { throw new Exception ( 'Config value must be a string.' ) ; } if ( $ this -> exists ( $ type , $ name ) ) { return false ; } $ defaults = array ( 'raw' => false , // Display value in raw format without quotes. 'anchor' => "/* That's all, stop editing!" , // Config placement anchor string. 'separator' => PHP_EOL , // Separator between config definition and anchor string. 'placement' => 'before' , // Config placement direction (insert before or after). ) ; list ( $ raw , $ anchor , $ separator , $ placement ) = array_values ( array_merge ( $ defaults , $ options ) ) ; $ raw = ( bool ) $ raw ; $ anchor = ( string ) $ anchor ; $ separator = ( string ) $ separator ; $ placement = ( string ) $ placement ; if ( false === strpos ( $ this -> wp_config_src , $ anchor ) ) { throw new Exception ( 'Unable to locate placement anchor.' ) ; } $ new_src = $ this -> normalize ( $ type , $ name , $ this -> format_value ( $ value , $ raw ) ) ; $ new_src = ( 'after' === $ placement ) ? $ anchor . $ separator . $ new_src : $ new_src . $ separator . $ anchor ; $ contents = str_replace ( $ anchor , $ new_src , $ this -> wp_config_src ) ; return $ this -> save ( $ contents ) ; }
Adds a config to the wp-config.php file.

@throws Exception If the config value provided is not a string.
@throws Exception If the config placement anchor could not be located.

@param string $type    Config type (constant or variable).
@param string $name    Config name.
@param string $value   Config value.
@param array  $options (optional) Array of special behavior options.

@return bool
Adds a config to the wp - config . php file .