'object', 'properties' => [ 'text' => ['type' => 'string', 'description' => 'Текст для хеширования.'], 'algo' => [ 'type' => 'string', 'enum' => self::ALGOS, 'description' => 'Алгоритм, по умолчанию sha256.', ], ], 'required' => ['text'], 'additionalProperties' => false, ]; } public function handle(array $args): string { $text = (string) ($args['text'] ?? ''); $algo = strtolower(trim((string) ($args['algo'] ?? 'sha256'))); if ($algo === '') { $algo = 'sha256'; } if (!in_array($algo, self::ALGOS, true)) { return 'Неизвестный алгоритм: ' . $algo . '. Доступно: ' . implode(', ', self::ALGOS) . '.'; } return $algo . ': ' . hash($algo, $text); } }