| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare (strict_types=1); 4 namespace WordPress\AiClient\Tools\DTO; 5 6 use WordPress\AiClient\Common\AbstractDataTransferObject; 7 /** 8 * Represents web search configuration for AI models. 9 * 10 * This DTO defines constraints for web searches that AI models can perform, 11 * including allowed and disallowed domains. 12 * 13 * @since 0.1.0 14 * 15 * @phpstan-type WebSearchArrayShape array{allowedDomains?: string[], disallowedDomains?: string[]} 16 * 17 * @extends AbstractDataTransferObject<WebSearchArrayShape> 18 */ 19 class WebSearch extends AbstractDataTransferObject 20 { 21 public const KEY_ALLOWED_DOMAINS = 'allowedDomains'; 22 public const KEY_DISALLOWED_DOMAINS = 'disallowedDomains'; 23 /** 24 * @var string[] List of domains that are allowed for web search. 25 */ 26 private array $allowedDomains; 27 /** 28 * @var string[] List of domains that are disallowed for web search. 29 */ 30 private array $disallowedDomains; 31 /** 32 * Constructor. 33 * 34 * @since 0.1.0 35 * 36 * @param string[] $allowedDomains List of domains that are allowed for web search. 37 * @param string[] $disallowedDomains List of domains that are disallowed for web search. 38 */ 39 public function __construct(array $allowedDomains = [], array $disallowedDomains = []) 40 { 41 $this->allowedDomains = $allowedDomains; 42 $this->disallowedDomains = $disallowedDomains; 43 } 44 /** 45 * Gets the allowed domains. 46 * 47 * @since 0.1.0 48 * 49 * @return string[] The allowed domains. 50 */ 51 public function getAllowedDomains(): array 52 { 53 return $this->allowedDomains; 54 } 55 /** 56 * Gets the disallowed domains. 57 * 58 * @since 0.1.0 59 * 60 * @return string[] The disallowed domains. 61 */ 62 public function getDisallowedDomains(): array 63 { 64 return $this->disallowedDomains; 65 } 66 /** 67 * {@inheritDoc} 68 * 69 * @since 0.1.0 70 */ 71 public static function getJsonSchema(): array 72 { 73 return ['type' => 'object', 'properties' => [self::KEY_ALLOWED_DOMAINS => ['type' => 'array', 'items' => ['type' => 'string'], 'description' => 'List of domains that are allowed for web search.'], self::KEY_DISALLOWED_DOMAINS => ['type' => 'array', 'items' => ['type' => 'string'], 'description' => 'List of domains that are disallowed for web search.']], 'required' => []]; 74 } 75 /** 76 * {@inheritDoc} 77 * 78 * @since 0.1.0 79 * 80 * @return WebSearchArrayShape 81 */ 82 public function toArray(): array 83 { 84 return [self::KEY_ALLOWED_DOMAINS => $this->allowedDomains, self::KEY_DISALLOWED_DOMAINS => $this->disallowedDomains]; 85 } 86 /** 87 * {@inheritDoc} 88 * 89 * @since 0.1.0 90 */ 91 public static function fromArray(array $array): self 92 { 93 return new self($array[self::KEY_ALLOWED_DOMAINS] ?? [], $array[self::KEY_DISALLOWED_DOMAINS] ?? []); 94 } 95 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Jun 13 09:38:55 2026 | Cross-referenced by PHPXref |