@@ -36,14 +36,13 @@ public function seal(string $name, string $value): void
3636 {
3737 $ this ->lastMessage = null ;
3838 $ this ->validateName ($ name );
39- $ k = $ name .'_SECRET ' ;
4039 $ v = str_replace ("' " , "' \\'' " , $ value );
4140
4241 $ content = file_exists ($ this ->dotenvFile ) ? file_get_contents ($ this ->dotenvFile ) : '' ;
43- $ content = preg_replace ("/^ $ k =(( \\\\'|'[^']++')++|.*)/m " , "$ k =' $ v' " , $ content , -1 , $ count );
42+ $ content = preg_replace ("/^ $ name =(( \\\\'|'[^']++')++|.*)/m " , "$ name =' $ v' " , $ content , -1 , $ count );
4443
4544 if (!$ count ) {
46- $ content .= "$ k =' $ v' \n" ;
45+ $ content .= "$ name =' $ v' \n" ;
4746 }
4847
4948 file_put_contents ($ this ->dotenvFile , $ content );
@@ -55,8 +54,7 @@ public function reveal(string $name): ?string
5554 {
5655 $ this ->lastMessage = null ;
5756 $ this ->validateName ($ name );
58- $ k = $ name .'_SECRET ' ;
59- $ v = \is_string ($ _SERVER [$ k ] ?? null ) ? $ _SERVER [$ k ] : ($ _ENV [$ k ] ?? null );
57+ $ v = \is_string ($ _SERVER [$ name ] ?? null ) ? $ _SERVER [$ name ] : ($ _ENV [$ name ] ?? null );
6058
6159 if (null === $ v ) {
6260 $ this ->lastMessage = sprintf ('Secret "%s" not found in "%s". ' , $ name , $ this ->getPrettyPath ($ this ->dotenvFile ));
@@ -71,10 +69,9 @@ public function remove(string $name): bool
7169 {
7270 $ this ->lastMessage = null ;
7371 $ this ->validateName ($ name );
74- $ k = $ name .'_SECRET ' ;
7572
7673 $ content = file_exists ($ this ->dotenvFile ) ? file_get_contents ($ this ->dotenvFile ) : '' ;
77- $ content = preg_replace ("/^ $ k =(( \\\\'|'[^']++')++|.*) \n?/m " , '' , $ content , -1 , $ count );
74+ $ content = preg_replace ("/^ $ name =(( \\\\'|'[^']++')++|.*) \n?/m " , '' , $ content , -1 , $ count );
7875
7976 if ($ count ) {
8077 file_put_contents ($ this ->dotenvFile , $ content );
@@ -94,14 +91,14 @@ public function list(bool $reveal = false): array
9491 $ secrets = [];
9592
9693 foreach ($ _ENV as $ k => $ v ) {
97- if (preg_match ('/^( \w+)_SECRET $/D ' , $ k, $ m )) {
98- $ secrets [$ m [ 1 ] ] = $ reveal ? $ v : null ;
94+ if (preg_match ('/^\w+$/D ' , $ k )) {
95+ $ secrets [$ k ] = $ reveal ? $ v : null ;
9996 }
10097 }
10198
10299 foreach ($ _SERVER as $ k => $ v ) {
103- if (\is_string ($ v ) && preg_match ('/^( \w+)_SECRET $/D ' , $ k, $ m )) {
104- $ secrets [$ m [ 1 ] ] = $ reveal ? $ v : null ;
100+ if (\is_string ($ v ) && preg_match ('/^\w+$/D ' , $ k )) {
101+ $ secrets [$ k ] = $ reveal ? $ v : null ;
105102 }
106103 }
107104
0 commit comments