File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,10 @@ public function getWorkDir(): string
240
240
*/
241
241
public function setWorkDir (string $ workDir ): static
242
242
{
243
- Assert::isDir ($ workDir , "workdir is not exists. path: $ workDir " );
243
+ if ($ workDir ) {
244
+ Assert::isDir ($ workDir , "workdir is not exists. path: $ workDir " );
245
+ }
246
+
244
247
$ this ->workDir = $ workDir ;
245
248
return $ this ;
246
249
}
Original file line number Diff line number Diff line change @@ -131,6 +131,29 @@ public function addArgs(...$args): static
131
131
return $ this ;
132
132
}
133
133
134
+ /**
135
+ * Call fn on args is not empty.
136
+ *
137
+ * Usage:
138
+ *
139
+ * ```php
140
+ * $c->withIf(fn($args) => $c->addArgs(...$args), $args)
141
+ * ```
142
+ *
143
+ * @template T
144
+ * @param callable(T): void $fn
145
+ * @param T $args
146
+ *
147
+ * @return $this
148
+ */
149
+ public function withIf (callable $ fn , mixed $ args ): static
150
+ {
151
+ if ($ args ) {
152
+ $ fn ($ this );
153
+ }
154
+ return $ this ;
155
+ }
156
+
134
157
/**
135
158
* @param bool $printOutput
136
159
*
You can’t perform that action at this time.
0 commit comments