@@ -130,18 +130,33 @@ public function __construct()
130130 foreach ($ properties as $ property ) {
131131 $ this ->initEnvValue ($ this ->{$ property }, $ property , $ prefix , $ shortPrefix );
132132
133- if ($ this instanceof Encryption && $ property === 'key ' ) {
134- if (str_starts_with ($ this ->{$ property }, 'hex2bin: ' )) {
135- // Handle hex2bin prefix
136- $ this ->{$ property } = hex2bin (substr ($ this ->{$ property }, 8 ));
137- } elseif (str_starts_with ($ this ->{$ property }, 'base64: ' )) {
138- // Handle base64 prefix
139- $ this ->{$ property } = base64_decode (substr ($ this ->{$ property }, 7 ), true );
133+ if ($ this instanceof Encryption) {
134+ if ($ property === 'key ' ) {
135+ $ this ->{$ property } = $ this ->parseEncryptionKey ($ this ->{$ property });
136+ } else if ($ property === 'previousKeysFallbackEnabled ' ) {
137+ // previousKeysFallbackEnabled must be boolean
138+ $ this ->{$ property } = (bool ) $ this ->{$ property };
139+ } else if ($ property === 'previousKeys ' ) {
140+ // previousKeys must be an array
141+ if (is_string ($ this ->{$ property })) {
142+ $ this ->{$ property } = array_map (fn ($ item ) => $ this ->parseEncryptionKey ($ item ), explode (', ' , $ this ->{$ property }));
143+ }
140144 }
141145 }
142146 }
143147 }
144148
149+ protected function parseEncryptionKey (string $ key ): string
150+ {
151+ if (str_starts_with ($ key , 'hex2bin: ' )) {
152+ return hex2bin (substr ($ key , 8 ));
153+ } elseif (str_starts_with ($ key , 'base64: ' )) {
154+ return base64_decode (substr ($ key , 7 ), true );
155+ }
156+
157+ return $ key ;
158+ }
159+
145160 /**
146161 * Initialization an environment-specific configuration setting
147162 *
0 commit comments