name = $n; $this->type = $t; $this->description = $d; $this->required = $r; $this->children = []; $this->enum = []; } public function add_enum($e) { $this->enum[] = $e; } public function add_child($n, $t, $d, $r = false) { $p = new GeminiParameter($n, $t, $d, $r); $this->children[$n] = $p; return $p; } public function get_object() { $o = new stdClass; $o->type = $this->type; $o->description = $this->description; switch ($this->type) { case "string": if (count($this->enum) > 0) { $o->format = "enum"; $o->enum = $this->enum; } break; case "object": $o->properties = []; $o->required = []; foreach ($this->children as $cn=>$c) { $o->properties[$cn] = $c->get_object(); if ($c->required) { $o->required[] = $cn; } } break; } return $o; } }