@@ -22,14 +22,14 @@ abstract class Operation
2222 /**
2323 * Determines which environment to run on.
2424 *
25- * @deprecated Will be removed in 7.x version. Use `shouldEnvironment ` method instead.
25+ * @deprecated Will be removed in 7.x version. Use `shouldRun ` method instead.
2626 */
2727 protected array |string |null $ environment = null ;
2828
2929 /**
3030 * Determines in which environment it should not run.
3131 *
32- * @deprecated Will be removed in 7.x version. Use `shouldEnvironment ` method instead.
32+ * @deprecated Will be removed in 7.x version. Use `shouldRun ` method instead.
3333 */
3434 protected array |string |null $ exceptEnvironment = null ;
3535
@@ -103,7 +103,7 @@ public function transactionAttempts(): int
103103 /**
104104 * Determines which environment to run on.
105105 *
106- * @deprecated Will be removed in 7.x version. Use `shouldEnvironment ` method instead.
106+ * @deprecated Will be removed in 7.x version. Use `shouldRun ` method instead.
107107 */
108108 public function onEnvironment (): array
109109 {
@@ -113,20 +113,13 @@ public function onEnvironment(): array
113113 /**
114114 * Determines in which environment it should not run.
115115 *
116- * @deprecated Will be removed in 7.x version. Use `shouldEnvironment ` method instead.
116+ * @deprecated Will be removed in 7.x version. Use `shouldRun ` method instead.
117117 */
118118 public function exceptEnvironment (): array
119119 {
120120 return Arr::wrap ($ this ->exceptEnvironment );
121121 }
122122
123- public function shouldBeEnvironment (): bool
124- {
125- $ env = $ this ->onEnvironment ();
126-
127- return empty ($ env ) || in_array (app ()->environment (), $ env , true );
128- }
129-
130123 /**
131124 * Determines whether the given operation can be called conditionally.
132125 *
@@ -142,7 +135,14 @@ public function allow(): bool
142135 */
143136 public function shouldRun (): bool
144137 {
145- return $ this ->allow ();
138+ $ env = app ()->environment ();
139+
140+ $ on = $ this ->onEnvironment ();
141+ $ except = $ this ->exceptEnvironment ();
142+
143+ return $ this ->allow ()
144+ && (empty ($ on ) || in_array ($ env , $ on , true ))
145+ && (empty ($ except ) || ! in_array ($ env , $ except , true ));
146146 }
147147
148148 /**
0 commit comments