@@ -22,14 +22,14 @@ abstract class Operation
22
22
/**
23
23
* Determines which environment to run on.
24
24
*
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.
26
26
*/
27
27
protected array |string |null $ environment = null ;
28
28
29
29
/**
30
30
* Determines in which environment it should not run.
31
31
*
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.
33
33
*/
34
34
protected array |string |null $ exceptEnvironment = null ;
35
35
@@ -103,7 +103,7 @@ public function transactionAttempts(): int
103
103
/**
104
104
* Determines which environment to run on.
105
105
*
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.
107
107
*/
108
108
public function onEnvironment (): array
109
109
{
@@ -113,20 +113,13 @@ public function onEnvironment(): array
113
113
/**
114
114
* Determines in which environment it should not run.
115
115
*
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.
117
117
*/
118
118
public function exceptEnvironment (): array
119
119
{
120
120
return Arr::wrap ($ this ->exceptEnvironment );
121
121
}
122
122
123
- public function shouldBeEnvironment (): bool
124
- {
125
- $ env = $ this ->onEnvironment ();
126
-
127
- return empty ($ env ) || in_array (app ()->environment (), $ env , true );
128
- }
129
-
130
123
/**
131
124
* Determines whether the given operation can be called conditionally.
132
125
*
@@ -142,7 +135,14 @@ public function allow(): bool
142
135
*/
143
136
public function shouldRun (): bool
144
137
{
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 ));
146
146
}
147
147
148
148
/**
0 commit comments