Skip to content

Commit d326a2c

Browse files
committed
Added more transaction helpers
1 parent d3c8663 commit d326a2c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Transaction.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@ public function __construct($transaction)
1111
$this->transaction = $transaction;
1212
}
1313

14+
public function removeQueryStringFromUrl()
15+
{
16+
$pathParts = explode('?', $this->transaction->fullPath);
17+
$this->transaction->fullPath = $pathParts[0];
18+
}
19+
1420
public function replaceInPath($old, $new)
1521
{
1622
$this->transaction->request->uri = str_replace($old, $new, $this->transaction->request->uri);
1723
$this->transaction->fullPath = str_replace($old, $new, $this->transaction->fullPath);
1824
}
1925

26+
public function alterBody(\Closure $closure)
27+
{
28+
$requestBody = json_decode($this->transaction->request->body);
29+
$requestBody = $closure($requestBody);
30+
$this->transaction->request->body = json_encode($requestBody);
31+
}
32+
2033
/**
2134
* Sets a HTTP header
2235
* @param $header

0 commit comments

Comments
 (0)