addDescription('Test AI Review'); $this->addArg('text', 'Text to review', false); $this->addOption('file', 'File to review', false, true); } public function execute() { $text = ''; if ($this->hasOption('file')) { $file = $this->getOption('file'); if (!file_exists($file)) { $this->error("File not found." . PHP_EOL); return false; } $text = file_get_contents($file); } if ($this->hasArg(0)) { $text = $this->getArg(0); } if (empty($text)) { $this->error("Text to review is empty." . PHP_EOL); return false; } $aiReview = new AliyunAIReview(); /** @var \AlibabaCloud\Client\Result\Result $response */ $response = $aiReview->reviewText($text, true); $this->output("Response Status: " . $response->getReasonPhrase() . PHP_EOL); $this->output("Response Body: "); var_dump($response->toArray()); $this->output(PHP_EOL); $parsedResponse = $aiReview->parseResponse($response->toArray()); $this->output("Parsed response: "); var_dump($parsedResponse); return true; } } $maintClass = TryAIReview::class; require_once RUN_MAINTENANCE_IF_MAIN;