Skip to content

Commit

Permalink
Add @success matcher
Browse files Browse the repository at this point in the history
simonhamp authored Feb 26, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 75cf048 commit cf84de3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Compiler.php
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ class Compiler
'AfterStop',
'Finished',
'FinishedStop',
'Success',
'SuccessStop',
'Error',
'ErrorStop',
'Slack',
@@ -378,6 +380,30 @@ protected function compileFinishedStop($value)
{
return preg_replace($this->createPlainMatcher('endfinished'), '$1}); ?>$2', $value);
}

/**
* Compile Envoy success statements into valid PHP.
*
* @param string $value
* @return string
*/
protected function compileSuccess($value)
{
$pattern = $this->createPlainMatcher('success');

return preg_replace($pattern, '$1<?php $_vars = get_defined_vars(); $__container->success(function() use ($_vars) { extract($_vars); $2', $value);
}

/**
* Compile Envoy success stop statements into valid PHP.
*
* @param string $value
* @return string
*/
protected function compileSuccessStop($value)
{
return preg_replace($this->createPlainMatcher('endsuccess'), '$1}); ?>$2', $value);
}

/**
* Compile Envoy error statements into valid PHP.

0 comments on commit cf84de3

Please sign in to comment.