@@ -48,7 +48,7 @@ protected function forceChecker($options = []): void
4848 {
4949 $ force = isset ($ options ['force ' ]) || isset ($ options ['f ' ]);
5050
51- if ($ this ->isProductionEnv ()) {
51+ if ($ this ->isProduction ()) {
5252 if (!$ force ) {
5353 $ this ->error ("You are in production! Use [--force|-f] flag, to run this command. " );
5454 exit (1 );
@@ -59,7 +59,7 @@ protected function forceChecker($options = []): void
5959 /**
6060 * Extracts the flag types from option keys like "drop-types" or "drop-views".
6161 */
62- protected function getFlagTypes ($ options = []): array
62+ protected function flag ($ options = []): array
6363 {
6464 $ types = [];
6565 foreach ($ options as $ key => $ value ) {
@@ -73,7 +73,7 @@ protected function getFlagTypes($options = []): array
7373 /**
7474 * Determine if the current environment is production.
7575 */
76- protected function isProductionEnv (): bool
76+ protected function isProduction (): bool
7777 {
7878 $ env = Env::env ('APP_ENV ' );
7979 $ productionAliases = ['prod ' , 'production ' , 'live ' ];
@@ -83,19 +83,36 @@ protected function isProductionEnv(): bool
8383
8484 /**
8585 * Get a specific option value from options array.
86- * Example: getOption($options, 'force', false)
87- */
88- protected function getOption (array $ options , string $ key , $ default = null )
86+ * Example: option('force', false)
87+ *
88+ * @param string $key
89+ * @param string|array|bool|null $default
90+ *
91+ * @return mixed
92+ */
93+ protected function option (string $ key , $ default = null )
8994 {
90- return $ options [$ key ] ?? $ default ;
95+ // backtrace
96+ $ trace = debug_backtrace (DEBUG_BACKTRACE_PROVIDE_OBJECT , 2 );
97+
98+ // get backtrace information about the caller's context
99+ $ args = $ trace [1 ]['args ' ][1 ] ?? [];
100+
101+ return $ args [$ key ] ?? $ default ;
91102 }
92103
93104 /**
94105 * Check if an option/flag exists and is truthy.
95106 */
96- protected function hasOption (array $ options , string $ key ): bool
107+ protected function hasOption (string $ key ): bool
97108 {
98- return !empty ($ options [$ key ]);
109+ // backtrace
110+ $ trace = debug_backtrace (DEBUG_BACKTRACE_PROVIDE_OBJECT , 2 );
111+
112+ // get backtrace information about the caller's context
113+ $ args = $ trace [1 ]['args ' ][1 ] ?? [];
114+
115+ return !empty ($ args [$ key ]);
99116 }
100117
101118 /**
0 commit comments