chamilo/chamilo-lms

View on GitHub
public/plugin/ai_helper/src/openai/OpenAi.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '66', column '27').
Open

                throw new Exception('Please provide a stream function.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method sendRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->headers[0] = $this->contentTypes["application/json"];
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Missing function doc comment
Open

    public function __construct(

Missing parameter name
Open

     * @param $opts

Missing parameter name
Open

     * @param $opts

Variable "curl_info" is not in valid camel caps format
Open

            unset($curl_info[CURLOPT_POSTFIELDS]);

Missing parameter name
Open

     * @param $opts

Variable "curl_info" is not in valid camel caps format
Open

        curl_setopt_array($curl, $curl_info);

Variable "post_fields" is not in valid camel caps format
Open

        $post_fields = json_encode($opts);

Variable "post_fields" is not in valid camel caps format
Open

            $post_fields = $opts;

Missing parameter name
Open

     * @param $model

Missing parameter name
Open

     * @param $opts

Missing parameter name
Open

     * @param $fileId

Missing parameter name
Open

     * @param $opts

Missing parameter name
Open

     * @param $fineTuneId

Missing parameter name
Open

     * @param $fileId

Variable "curl_info" is not in valid camel caps format
Open

            $curl_info[CURLOPT_WRITEFUNCTION] = $this->streamMethod;

Missing function doc comment
Open

    public function setTimeout(int $timeout)

Missing parameter name
Open

     * @param $fineTuneId

Missing class doc comment
Open

class OpenAi

Missing parameter name
Open

     * @param $fileId

Missing parameter name
Open

     * @param $opts

Missing parameter name
Open

     * @param $fineTuneId

Missing parameter name
Open

     * @param $opts

Missing parameter name
Open

     * @param $opts

Missing parameter name
Open

     * @param $fineTuneId

Variable "curl_info" is not in valid camel caps format
Open

        $curl_info = [

Missing parameter name
Open

     * @param $opts

Variable "post_fields" is not in valid camel caps format
Open

            CURLOPT_POSTFIELDS => $post_fields,

The variable $post_fields is not named in camelCase.
Open

    private function sendRequest(
        string $url,
        string $method,
        array $opts = []
    ) {

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $curl_info is not named in camelCase.
Open

    private function sendRequest(
        string $url,
        string $method,
        array $opts = []
    ) {

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $curl_info is not named in camelCase.
Open

    private function sendRequest(
        string $url,
        string $method,
        array $opts = []
    ) {

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $post_fields is not named in camelCase.
Open

    private function sendRequest(
        string $url,
        string $method,
        array $opts = []
    ) {

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $post_fields is not named in camelCase.
Open

    private function sendRequest(
        string $url,
        string $method,
        array $opts = []
    ) {

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $curl_info is not named in camelCase.
Open

    private function sendRequest(
        string $url,
        string $method,
        array $opts = []
    ) {

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $curl_info is not named in camelCase.
Open

    private function sendRequest(
        string $url,
        string $method,
        array $opts = []
    ) {

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status