| Total Complexity | 6 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class Answer |
||
| 9 | { |
||
| 10 | private Command $command; |
||
| 11 | private string $question; |
||
| 12 | private string $answer; |
||
| 13 | |||
| 14 | public function __construct(string|array $prompt, string $question, string $answer, string $name = '') |
||
| 15 | { |
||
| 16 | if (!$name) { |
||
| 17 | $name = 'forrest-ai'; |
||
| 18 | } |
||
| 19 | |||
| 20 | if (is_string($prompt)) { |
||
|
|
|||
| 21 | $this->command = CommandFactory::fromArray([ |
||
| 22 | CommandFactory::CONFIG_FIELD_NAME => $name, |
||
| 23 | CommandFactory::CONFIG_FIELD_DESCRIPTION => 'Answer to: ' . $question, |
||
| 24 | CommandFactory::CONFIG_FIELD_PROMPT => $prompt |
||
| 25 | ]); |
||
| 26 | } else { |
||
| 27 | $this->command = CommandFactory::fromArray($prompt); |
||
| 28 | } |
||
| 29 | $this->command->setFullyQualifiedIdentifier('forrest:' . $name); |
||
| 30 | |||
| 31 | $this->question = $question; |
||
| 32 | $this->answer = $answer; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function getCommand(): Command |
||
| 36 | { |
||
| 37 | return $this->command; |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getQuestion(): string |
||
| 41 | { |
||
| 42 | return $this->question; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function getAnswer(): string |
||
| 48 | } |
||
| 49 | } |
||
| 50 |