Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
log_node
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 type
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 params
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 branches
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2// This file is part of Moodle - https://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle.  If not, see <https://www.gnu.org/licenses/>.
16
17declare(strict_types=1);
18
19namespace tool_autoflow\local\engine\nodes;
20
21use tool_autoflow\local\engine\node_result;
22use tool_autoflow\local\engine\node_type;
23use tool_autoflow\local\engine\param;
24
25/**
26 * Writes a message to the run log. Useful for checking what a workflow sees.
27 *
28 * @package    tool_autoflow
29 * @copyright  2026 DevLMS <contact@devlms.com>
30 * @license    https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31 */
32final class log_node implements node_type {
33    /**
34     * Type name.
35     *
36     * @return string
37     */
38    public function type(): string {
39        return 'action.log';
40    }
41
42    /**
43     * Parameters.
44     *
45     * @return param[]
46     */
47    public function params(): array {
48        return [new param('message', 'textarea', true)];
49    }
50
51    /**
52     * Branches.
53     *
54     * @return string[]
55     */
56    public function branches(): array {
57        return [];
58    }
59
60    /**
61     * Record the message.
62     *
63     * @param array $params message
64     * @param array $context
65     * @return node_result
66     */
67    public function execute(array $params, array $context): node_result {
68        return new node_result(['message' => (string) ($params['message'] ?? '')]);
69    }
70}