-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_sub_recipe.php
99 lines (83 loc) · 1.97 KB
/
simple_sub_recipe.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/*
* Recipe.
*
* LICENSE
*
* This source file is subject to the MIT license
* it is available in LICENSE file at the root of this package
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
*
* @copyright Copyright (c) EIRL Richard Déloge (https://deloge.io - [email protected])
* @copyright Copyright (c) SASU Teknoo Software (https://teknoo.software - [email protected])
*
* @link https://teknoo.software/libraries/recipe Project website
*
* @license https://teknoo.software/license/mit MIT License
* @author Richard Déloge <[email protected]>
*/
declare(strict_types=1);
namespace Acme;
use Teknoo\Recipe\Chef;
use Teknoo\Recipe\ChefInterface;
use Teknoo\Recipe\Recipe;
use function sort;
require __DIR__ . '/../vendor/autoload.php';
$subRecipe = new Recipe();
$subRecipe = $subRecipe->cook(
static function (ChefInterface $chef, array $values): void {
sort($values);
$chef->updateWorkPlan(['values' => $values]);
},
'sort',
);
$subRecipe = $subRecipe->cook(
static function (array $values): void {
print_r($values);
},
'displayInSub',
);
$recipe = new Recipe();
$recipe = $recipe->cook(
static function (ChefInterface $chef): void {
$chef->updateWorkPlan([
'values' => [5, 3, 7, 1, 10]
]);
},
'createArray',
);
$recipe = $recipe->execute(
$subRecipe,
'subrecipeCall',
);
$recipe = $recipe->cook(
static function (array $values): void {
print_r($values);
},
'displayInMain',
);
$chef = new Chef;
$chef->read($recipe);
$chef->process([]);
/*
* Will show
* Array
* (
* [0] => 1
* [1] => 3
* [2] => 5
* [3] => 7
* [4] => 10
* )
* Array
* (
* [0] => 5
* [1] => 3
* [2] => 7
* [3] => 1
* [4] => 10
* )
*/