Function get
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function get(): array
{
$privileges = [];
if (\App\User::isExists($this->getUserData('user_id'))) {
$moduleName = $this->controller->request->getModule('module');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid using static access to class '\App\User' in method 'get'. Open
if (\App\User::isExists($this->getUserData('user_id'))) {
- Read upRead up
- Exclude checks
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 '\App\Module' in method 'get'. Open
$moduleId = \App\Module::getModuleId($moduleName);
- Read upRead up
- Exclude checks
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 '\App\User' in method 'get'. Open
$actionPermissions = \App\User::getPrivilegesFile($this->getUserData('user_id'));
- Read upRead up
- Exclude checks
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 '\Vtiger_Action_Model' in method 'get'. Open
$actions = array_merge(\Vtiger_Action_Model::getAllBasic(true), \Vtiger_Action_Model::getAllUtility(true));
- Read upRead up
- Exclude checks
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 '\Vtiger_Action_Model' in method 'get'. Open
$actions = array_merge(\Vtiger_Action_Model::getAllBasic(true), \Vtiger_Action_Model::getAllUtility(true));
- Read upRead up
- Exclude checks
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
Possibly zero references to use statement for classlike/namespace OA
(\OpenApi\Annotations)
Open
use OpenApi\Annotations as OA;
- Exclude checks
Argument 1 (raw)
is 'module'
but \Api\Core\Request::getModule()
takes bool|true
defined at /code/app/Request.php:548
Open
$moduleName = $this->controller->request->getModule('module');
- Exclude checks
Call to method isExists
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
if (\App\User::isExists($this->getUserData('user_id'))) {
- Exclude checks
Call to method getPrivilegesFile
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$actionPermissions = \App\User::getPrivilegesFile($this->getUserData('user_id'));
- Exclude checks
Suspicious array access to false
Open
$privileges[$action->getName()] = $isAdmin || (isset($permission[$action->getId()]) && \Settings_Profiles_Module_Model::IS_PERMITTED_VALUE === $permission[$action->getId()]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* title="Base module - Privileges response schema",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* type="object",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* schema="BaseModule_Privileges_ResponseBody",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* title="Base module - Privileges response schema",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* summary="Privileges for module actions",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Schema(
- Exclude checks
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"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* schema="BaseModule_Privileges_ResponseBody",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="Gets the list of actions that the user has access to in the module",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(response=200, description="Privileges details",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* type="object",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* summary="Privileges for module actions",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\XmlContent(ref="#/components/schemas/BaseModule_Privileges_ResponseBody"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\XmlContent(ref="#/components/schemas/BaseModule_Privileges_ResponseBody"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
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),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\JsonContent(ref="#/components/schemas/BaseModule_Privileges_ResponseBody"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* path="/webservice/WebserviceStandard/{moduleName}/Privileges",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="Gets the list of actions that the user has access to in the module",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(response=200, description="Privileges details",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* tags={"BaseModule"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\JsonContent(ref="#/components/schemas/BaseModule_Privileges_ResponseBody"),
- Exclude checks
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"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Property(property="result", type="object", description="List of module privileges",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* tags={"BaseModule"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* example={"EditView" : true, "Delete" : true, "DetailView" : true, "CreateView" : true},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
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),
- Exclude checks
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"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Property(property="result", type="object", description="List of module privileges",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\AdditionalProperties(type="boolean", description="Action"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$privileges[$action->getName()] = $isAdmin || (isset($permission[$action->getId()]) && \Settings_Profiles_Module_Model::IS_PERMITTED_VALUE === $permission[$action->getId()]);
- Exclude checks
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"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($actions as $action) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\AdditionalProperties(type="boolean", description="Action"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$privileges = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$actionPermissions = \App\User::getPrivilegesFile($this->getUserData('user_id'));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* example={"EditView" : true, "Delete" : true, "DetailView" : true, "CreateView" : true},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (\App\User::isExists($this->getUserData('user_id'))) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$isAdmin = $actionPermissions['is_admin'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$moduleName = $this->controller->request->getModule('module');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($permission || $isAdmin) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $privileges;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$permission = $actionPermissions['profile_action_permission'][$moduleId] ?? false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$actions = array_merge(\Vtiger_Action_Model::getAllBasic(true), \Vtiger_Action_Model::getAllUtility(true));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$moduleId = \App\Module::getModuleId($moduleName);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function get(): array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
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"),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* path="/webservice/WebserviceStandard/{moduleName}/Privileges",
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get privileges for module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $allowedMethod = ['GET'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @OA\Get(
- Exclude checks
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"),
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
* @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @api
- Exclude checks
Line exceeds 120 characters; contains 194 characters Open
$privileges[$action->getName()] = $isAdmin || (isset($permission[$action->getId()]) && \Settings_Profiles_Module_Model::IS_PERMITTED_VALUE === $permission[$action->getId()]);
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$actions = array_merge(\Vtiger_Action_Model::getAllBasic(true), \Vtiger_Action_Model::getAllUtility(true));
- Exclude checks