File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -101,4 +101,11 @@ public function transactionRollback();
101101 * @throws \Exception
102102 */
103103 public function transaction ($ tries = 1 , $ callback = null );
104+
105+ /**
106+ * @param callable|null $callback
107+ * @return mixed
108+ * @throws \Exception
109+ */
110+ public function dryRun ($ callback = null );
104111}
Original file line number Diff line number Diff line change @@ -256,6 +256,28 @@ public function transactionRollback() {
256256 });
257257 }
258258
259+ /**
260+ * @param callable|null $callback
261+ * @return mixed
262+ * @throws \Exception
263+ * @throws null
264+ */
265+ public function dryRun ($ callback = null ) {
266+ $ result = null ;
267+ $ exception = null ;
268+ $ this ->transactionStart ();
269+ try {
270+ $ result = call_user_func ($ callback , $ this );
271+ } catch (\Exception $ e ) {
272+ $ exception = $ e ;
273+ }
274+ $ this ->transactionRollback ();
275+ if ($ exception !== null ) {
276+ throw $ exception ;
277+ }
278+ return $ result ;
279+ }
280+
259281 /**
260282 * @param int|callable $tries
261283 * @param callable|null $callback
You can’t perform that action at this time.
0 commit comments