YetiForceCompany/YetiForceCRM

View on GitHub
api/webservice/WebservicePremium/BaseModule/Dashboard.php

Summary

Maintainability
A
0 mins
Test Coverage
A
90%

Avoid using static access to class '\Settings_WidgetsManagement_Module_Model' in method 'get'.
Open

            $defaultDbId = \Settings_WidgetsManagement_Module_Model::getDefaultDashboard();

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\Api\WebservicePremium\Dashboard' in method 'get'.
Open

        $dashboardInstance = \Api\WebservicePremium\Dashboard::getInstance($moduleName, 0, $this->controller->app['id']);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

        } else {
            $dashBoardId = $this->controller->request->getInteger('record');
        }

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

Possibly zero references to use statement for classlike/namespace OA (\OpenApi\Annotations)
Open

use OpenApi\Annotations as OA;

Call to undeclared function \array_key_first()
Open

            $dashBoardId = isset($tabs[$defaultDbId]) ? $defaultDbId : (int) array_key_first($tabs);

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

Spaces must be used for alignment; tabs are not allowed
Open

     *        title="Base module - Dashboard response schema",

Spaces must be used for alignment; tabs are not allowed
Open

     *            description="Tabs and widgets data",

Spaces must be used for alignment; tabs are not allowed
Open

     *                title="Tabs list",

Spaces must be used for alignment; tabs are not allowed
Open

     *                    description="Tab menu item",

Spaces must be used for alignment; tabs are not allowed
Open

     *                 ),

Spaces must be used for alignment; tabs are not allowed
Open

     *             ),

Spaces must be used for alignment; tabs are not allowed
Open

     *                title="Tabs list",

Spaces must be used for alignment; tabs are not allowed
Open

     *                    description="Tree item",

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="data", type="object", title="Widget data"),

Spaces must be used for alignment; tabs are not allowed
Open

     *        description="Supported widget types: Mini List , Chart Filter",

Spaces must be used for alignment; tabs are not allowed
Open

     *        description="Supported widget types: Mini List , Chart Filter",

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="name", type="string", example="Dashboard"),

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="id", type="integer", example=1),

Spaces must be used for alignment; tabs are not allowed
Open

     *                 ),

Spaces must be used for alignment; tabs are not allowed
Open

     *             ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *                    type="object",

Spaces must be used for alignment; tabs are not allowed
Open

            $dashBoardId = isset($tabs[$defaultDbId]) ? $defaultDbId : (int) array_key_first($tabs);

Spaces must be used for alignment; tabs are not allowed
Open

     *        summary="Gets widgets' data from the dashboard",

Spaces must be used for alignment; tabs are not allowed
Open

     *        type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *            property="result",

Spaces must be used for alignment; tabs are not allowed
Open

     *                property="types",

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="name", type="string", example="Dashboard"),

Spaces must be used for alignment; tabs are not allowed
Open

     *                 ),

Spaces must be used for alignment; tabs are not allowed
Open

     *    ),

Spaces must be used for alignment; tabs are not allowed
Open

            $dashBoardId = $this->controller->request->getInteger('record');

Spaces must be used for alignment; tabs are not allowed
Open

     *        summary="Gets widgets' data from the dashboard",

Spaces must be used for alignment; tabs are not allowed
Open

     *        security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},

Spaces must be used for alignment; tabs are not allowed
Open

     *        type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="system", type="integer", example=1),

Spaces must be used for alignment; tabs are not allowed
Open

     *                @OA\AdditionalProperties(

Spaces must be used for alignment; tabs are not allowed
Open

        $dashboardInstance = \Api\WebservicePremium\Dashboard::getInstance($moduleName, 0, $this->controller->app['id']);

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(response=200, description="Privileges details",

Spaces must be used for alignment; tabs are not allowed
Open

     *        schema="BaseModule_Get_Dashboard_Response",

Spaces must be used for alignment; tabs are not allowed
Open

     *            property="result",

Spaces must be used for alignment; tabs are not allowed
Open

     *                type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *                type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *                @OA\AdditionalProperties(

Spaces must be used for alignment; tabs are not allowed
Open

     *                    description="Tab menu item",

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="id", type="integer", example=1),

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="type", type="string", example="ChartFilter"),

Spaces must be used for alignment; tabs are not allowed
Open

        $moduleName = $this->controller->request->getModule();

Spaces must be used for alignment; tabs are not allowed
Open

     *        tags={"BaseModule"},

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Contacts"),

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\XmlContent(ref="#/components/schemas/BaseModule_Get_Dashboard_Response"),

Spaces must be used for alignment; tabs are not allowed
Open

     * ),

Spaces must be used for alignment; tabs are not allowed
Open

     *            description="Tabs and widgets data",

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="data", type="object", title="Widget data"),

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

        $dashboardInstance->setDashboard($dashBoardId);

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Contacts"),

Spaces must be used for alignment; tabs are not allowed
Open

     *                    type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="system", type="integer", example=1),

Spaces must be used for alignment; tabs are not allowed
Open

     *                property="widgets",

Spaces must be used for alignment; tabs are not allowed
Open

     *        security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

        } else {

Spaces must be used for alignment; tabs are not allowed
Open

    }

Spaces must be used for alignment; tabs are not allowed
Open

            'types' => $tabs,

Spaces must be used for alignment; tabs are not allowed
Open

            'widgets' => $dashboardInstance->getData(),

Spaces must be used for alignment; tabs are not allowed
Open

     *            type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *             ),

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *                type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *                     @OA\Property(property="type", type="string", example="ChartFilter"),

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *    ),

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\JsonContent(ref="#/components/schemas/BaseModule_Get_Dashboard_Response"),

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\XmlContent(ref="#/components/schemas/BaseModule_Get_Dashboard_Response"),

Spaces must be used for alignment; tabs are not allowed
Open

     *                title="Tabs list",

Spaces must be used for alignment; tabs are not allowed
Open

     *                @OA\AdditionalProperties(

Spaces must be used for alignment; tabs are not allowed
Open

        if ($this->controller->request->isEmpty('record', true)) {

Spaces must be used for alignment; tabs are not allowed
Open

     *        tags={"BaseModule"},

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\JsonContent(ref="#/components/schemas/BaseModule_Get_Dashboard_Response"),

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *                title="Tabs list",

Spaces must be used for alignment; tabs are not allowed
Open

     *                    description="Tree item",

Spaces must be used for alignment; tabs are not allowed
Open

     *                    type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

Spaces must be used for alignment; tabs are not allowed
Open

     *            type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *                property="types",

Spaces must be used for alignment; tabs are not allowed
Open

    public function get(): array

Spaces must be used for alignment; tabs are not allowed
Open

            $defaultDbId = \Settings_WidgetsManagement_Module_Model::getDefaultDashboard();

Spaces must be used for alignment; tabs are not allowed
Open

        }

Spaces must be used for alignment; tabs are not allowed
Open

     *        path="/webservice/WebservicePremium/{moduleName}/Dashboard",

Spaces must be used for alignment; tabs are not allowed
Open

     * @OA\Schema(

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *                type="object",

Spaces must be used for alignment; tabs are not allowed
Open

        $tabs = $dashboardInstance->getTabs();

Spaces must be used for alignment; tabs are not allowed
Open

     *        title="Base module - Dashboard response schema",

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *                    type="object",

Spaces must be used for alignment; tabs are not allowed
Open

        return [

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(response=200, description="Privileges details",

Spaces must be used for alignment; tabs are not allowed
Open

     *        schema="BaseModule_Get_Dashboard_Response",

Spaces must be used for alignment; tabs are not allowed
Open

     *                property="widgets",

Spaces must be used for alignment; tabs are not allowed
Open

     *                @OA\AdditionalProperties(

Spaces must be used for alignment; tabs are not allowed
Open

     *                 ),

Spaces must be used for alignment; tabs are not allowed
Open

     *             ),

Spaces must be used for alignment; tabs are not allowed
Open

        ];

Spaces must be used for alignment; tabs are not allowed
Open

     */

Spaces must be used for alignment; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get method - Gets widgets' data from the dashboard.

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc}  */

Line exceeds 120 characters; contains 121 characters
Open

        $dashboardInstance = \Api\WebservicePremium\Dashboard::getInstance($moduleName, 0, $this->controller->app['id']);

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Line exceeds 120 characters; contains 145 characters
Open

     *        @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Contacts"),

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    public $allowedMethod = ['GET'];

Line exceeds 120 characters; contains 131 characters
Open

     *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *        path="/webservice/WebservicePremium/{moduleName}/Dashboard",

Spaces must be used to indent lines; tabs are not allowed
Open

     * @OA\Get(

Line exceeds 120 characters; contains 189 characters
Open

     *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

There are no issues that match your filters.

Category
Status