for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace LineMob\Core\Mocky\Auth\Middleware;
use League\Tactician\Middleware;
use LineMob\Core\Mocky\Auth\AuthenticationWorkflow;
use LineMob\Core\Mocky\Auth\Command\LoginCommand;
use LineMob\Core\Template\TextTemplate;
class AuthenticationMiddleware implements Middleware
{
/**
* @var AuthenticationWorkflow
*/
private $workflow;
public function __construct(AuthenticationWorkflow $workflow)
$this->workflow = $workflow;
}
* {@inheritdoc}
public function execute($command, callable $next)
if (!$command->storage) {
throw new \LogicException("Require storage before using this AuthenticationMiddleware!");
if (!$command instanceof LoginCommand) {
return $next($command);
$command->active = true;
$command->message = new TextTemplate();
if ($this->workflow->doApplyStart($command)) {
if ($this->workflow->doApplyEnterUsernameAndPassword($command)) {
if ($this->workflow->doApplyEnterUsername($command)) {
if ($this->workflow->doApplyEnterPassword($command)) {
throw new \LogicException("Unknown case!");