PHP Classes

File: demo/chevere.php

Recommend this page to a friend!
  Classes of Rodolfo Berrios Arce   Workflow   demo/chevere.php   Download  
File: demo/chevere.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Workflow
Create and run action workflows
Author: By
Last change:
Date: 25 days ago
Size: 917 bytes
 

Contents

Class file image Download
<?php

/*
 * This file is part of Chevere.
 *
 * (c) Rodolfo Berrios <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

use function
Chevere\Workflow\{response,run,sync,variable,workflow};

require
'loader.php';

/*
 * php demo/chevere.php
 */

use Chevere\Action\Action;

class
MyAction extends Action
{
    protected function
main(string $foo): string
   
{
        return
"Hello, {$foo}";
    }
}

$workflow = workflow(
   
greet: sync(
        new
MyAction(),
       
foo: variable('super'),
    ),
   
capo: sync(
        new
MyAction(),
       
foo: response('greet'),
    ),
);
$hello = run(
   
$workflow,
   
super: 'Chevere',
);
echo
$hello->response('greet')->string() . PHP_EOL;
// Hello, Chevere
echo $hello->response('capo')->string() . PHP_EOL;
// Hello, Hello, Chevere