PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
convertkit / vendor / wordpress / php-mcp-schema / src / Client / Sampling / DTO / ToolChoice.php

ToolChoice.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.3, at vendor/wordpress/php-mcp-schema/src/Client/Sampling/DTO/ToolChoice.php

89 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Client\Sampling\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Controls tool selection behavior for sampling requests.
12 *
13 * @since 2025-11-25
14 *
15 * @mcp-domain Client
16 * @mcp-subdomain Sampling
17 * @mcp-version 2025-11-25
18 */
19 class ToolChoice extends AbstractDataTransferObject
20 {
21 use ValidatesRequiredFields;
22
23 /**
24 * Controls the tool use ability of the model:
25 * - "auto": Model decides whether to use tools (default)
26 * - "required": Model MUST use at least one tool before completing
27 * - "none": Model MUST NOT use any tools
28 *
29 * @since 2025-11-25
30 *
31 * @var 'auto'|'required'|'none'|null
32 */
33 protected ?string $mode;
34
35 /**
36 * @param 'auto'|'required'|'none'|null $mode @since 2025-11-25
37 */
38 public function __construct(
39 ?string $mode = null
40 ) {
41 $this->mode = $mode;
42 }
43
44 /**
45 * Creates an instance from an array.
46 *
47 * @param array{
48 * mode?: 'auto'|'required'|'none'|null
49 * } $data
50 * @phpstan-param array<string, mixed> $data
51 * @return self
52 */
53 public static function fromArray(array $data): self
54 {
55 /** @var 'auto'|'required'|'none'|null $mode */
56 $mode = isset($data['mode'])
57 ? self::asStringOrNull($data['mode'])
58 : null;
59
60 return new self(
61 $mode
62 );
63 }
64
65 /**
66 * Converts the instance to an array.
67 *
68 * @return array<string, mixed>
69 */
70 public function toArray(): array
71 {
72 $result = [];
73
74 if ($this->mode !== null) {
75 $result['mode'] = $this->mode;
76 }
77
78 return $result;
79 }
80
81 /**
82 * @return 'auto'|'required'|'none'|null
83 */
84 public function getMode(): ?string
85 {
86 return $this->mode;
87 }
88 }
89