PHP Class Brotzka\DotenvEditor\DotenvEditor

Afficher le fichier Open project: brotzka/laravel-dotenv-editor Class Usage Examples

Méthodes publiques

Méthode Description
AutoBackupEnabled ( ) : boolean Checks, if Autobackup is enabled
__construct ( ) DotenvEditor constructor
addData ( array $data = [] ) : boolean Add data to the current env file.
changeEnv ( array $data = [] ) : boolean Change the given values of the current env file.
createBackup ( ) : boolean Used to create a backup of the current .env.
deleteBackup ( $timestamp ) Delete the given backup-file
deleteData ( array $data = [] ) : boolean Delete one or more entries from the env file.
getAsJson ( null $timestamp = NULL ) : string Returns the given .env as JSON array containing all entries as object with key and value
getBackupFile ( $timestamp ) : string Returns filename and path for the given timestamp
getBackupPath ( ) : mixed Returns the current backup-path
getBackupVersions ( ) : array Returns an array with all available backups.
getContent ( null $timestamp = NULL ) : array Returns the content of a given backup file or the content of the current env file.
getValue ( $key ) : mixed Returns the value matching to a given key.
keyExists ( $key ) : boolean Checks, if a given key exists in your .env-file.
restoreBackup ( null $timestamp = NULL ) : string Restores the latest backup or a backup from a given timestamp.
setAutoBackup ( $onOff ) Activate or deactivate the AutoBackup-Functionality
setBackupPath ( $path ) : boolean Set a new backup-path.

Méthodes protégées

Méthode Description
envToArray ( $file ) : array Writes the content of a env file to an array.
getFile ( $timestamp ) : string Returns the file for the given backup-timestamp
getLatestBackup ( ) : integer | mixed Returns the timestamp of the latest version.
save ( $array ) : boolean Saves the given data to the .env-file

Private Methods

Méthode Description
envToJson ( array $file = [] ) : string Converts the given .env-array to JSON

Method Details

AutoBackupEnabled() public méthode

Checks, if Autobackup is enabled
public AutoBackupEnabled ( ) : boolean
Résultat boolean

__construct() public méthode

DotenvEditor constructor
public __construct ( )

addData() public méthode

Data will be placed at the end.
public addData ( array $data = [] ) : boolean
$data array
Résultat boolean

changeEnv() public méthode

If the given key(s) is/are not found, nothing happens.
public changeEnv ( array $data = [] ) : boolean
$data array
Résultat boolean

createBackup() public méthode

Will be assigned with the current timestamp.
public createBackup ( ) : boolean
Résultat boolean

deleteBackup() public méthode

Delete the given backup-file
public deleteBackup ( $timestamp )
$timestamp

deleteData() public méthode

Delete one or more entries from the env file.
public deleteData ( array $data = [] ) : boolean
$data array
Résultat boolean

envToArray() protected méthode

Writes the content of a env file to an array.
protected envToArray ( $file ) : array
$file
Résultat array

getAsJson() public méthode

Returns the given .env as JSON array containing all entries as object with key and value
public getAsJson ( null $timestamp = NULL ) : string
$timestamp null
Résultat string

getBackupFile() public méthode

Returns filename and path for the given timestamp
public getBackupFile ( $timestamp ) : string
$timestamp
Résultat string

getBackupPath() public méthode

Returns the current backup-path
public getBackupPath ( ) : mixed
Résultat mixed

getBackupVersions() public méthode

Array contains the formatted and unformatted version of each backup. Throws exception, if no backups were found.
public getBackupVersions ( ) : array
Résultat array

getContent() public méthode

Returns the content of a given backup file or the content of the current env file.
public getContent ( null $timestamp = NULL ) : array
$timestamp null
Résultat array

getFile() protected méthode

Returns the file for the given backup-timestamp
protected getFile ( $timestamp ) : string
$timestamp
Résultat string

getLatestBackup() protected méthode

Returns the timestamp of the latest version.
protected getLatestBackup ( ) : integer | mixed
Résultat integer | mixed

getValue() public méthode

Returns false, if key does not exist.
public getValue ( $key ) : mixed
$key
Résultat mixed

keyExists() public méthode

Returns false or true
public keyExists ( $key ) : boolean
$key
Résultat boolean

restoreBackup() public méthode

Restores the latest version when no timestamp is given.
public restoreBackup ( null $timestamp = NULL ) : string
$timestamp null
Résultat string

save() protected méthode

Saves the given data to the .env-file
protected save ( $array ) : boolean
$array
Résultat boolean

setAutoBackup() public méthode

Activate or deactivate the AutoBackup-Functionality
public setAutoBackup ( $onOff )
$onOff

setBackupPath() public méthode

The new directory will be created if it doesn't exist
public setBackupPath ( $path ) : boolean
$path
Résultat boolean