Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
param
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 to_array
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;
20
21/**
22 * One parameter a node takes, as shown in the editor's form for that node.
23 *
24 * Labels are not here: the Moodle layer reads them from language strings, so the
25 * engine stays free of Moodle APIs.
26 *
27 * @package    tool_autoflow
28 * @copyright  2026 DevLMS <contact@devlms.com>
29 * @license    https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 */
31final class param {
32    /**
33     * Describe a parameter.
34     *
35     * @param string $name Key in the node's params.
36     * @param string $kind Input to show: text, textarea, number, select, event or user.
37     * @param bool $required Whether the node needs it.
38     * @param string[] $options Choices for a select.
39     */
40    public function __construct(
41        /** @var string Key in the node's params. */
42        public readonly string $name,
43        /** @var string Input kind. */
44        public readonly string $kind,
45        /** @var bool Required. */
46        public readonly bool $required,
47        /** @var string[] Choices for a select. */
48        public readonly array $options = [],
49    ) {
50    }
51
52    /**
53     * As a plain array for the editor.
54     *
55     * @return array
56     */
57    public function to_array(): array {
58        return ['name' => $this->name, 'kind' => $this->kind, 'required' => $this->required, 'options' => $this->options];
59    }
60}