for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace STS\EnvSecurity\Console\Concerns;
/**
* Class HandlesEnvFiles
* @package STS\EnvSecurity\Console\Concerns
*/
trait HandlesEnvFiles
{
* @param $environment
*
* @return bool|null|string
protected function loadEncrypted($environment)
$path = $this->getFilePathForEnvironment($environment);
if (file_exists($path) && is_readable($path)) {
return file_get_contents($path);
}
return null;
* @param $ciphertext
* @return bool
protected function saveEncrypted($ciphertext, $environment)
return file_put_contents($path, $ciphertext) !== false;
* @param $plaintext
* @param null $output
$output
null
protected function saveDecrypted($plaintext, $output = null)
if (!$output) {
false
$output = config('env-security.destination');
return file_put_contents($output, $plaintext) !== false;
* @return string
protected function getFilePathForEnvironment($environment)
return config('env-security.store') . '/' . $environment . '.env.enc';