File ChatAjax.php
has 351 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Action to get Chat data.
*
The class Chat_ChatAjax_Action has an overall complexity of 62 which is very high. The configured complexity threshold is 50. Open
class Chat_ChatAjax_Action extends \App\Controller\Action
{
use \App\Controller\ExposeMethod;
/**
- Exclude checks
Method setMessagesResult
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setMessagesResult(App\Request $request)
{
if ($request->has('roomType') && $request->has('recordId')) {
$roomType = $request->getByType('roomType');
$recordId = $request->getInteger('recordId');
Function setMessagesResult
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function setMessagesResult(App\Request $request)
{
if ($request->has('roomType') && $request->has('recordId')) {
$roomType = $request->getByType('roomType');
$recordId = $request->getInteger('recordId');
- 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
Function getRoomsMessages
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getRoomsMessages(App\Request $request)
{
$result = [];
$roomList = \App\Chat::getRoomsByUser();
$areNewEntries = false;
- 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
Method getRoomsMessages
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getRoomsMessages(App\Request $request)
{
$result = [];
$roomList = \App\Chat::getRoomsByUser();
$areNewEntries = false;
Method getChatConfig
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getChatConfig(App\Request $request)
{
$userRealID = \App\User::getCurrentUserRealId();
$userRoomPin = \App\Config::module('Chat', 'userRoomPin');
if (!$userRoomPin) {
Method send
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function send(App\Request $request)
{
$roomType = $request->getByType('roomType');
$recordId = $request->getInteger('recordId');
$chat = \App\Chat::getInstance($roomType, $recordId);
Function send
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function send(App\Request $request)
{
$roomType = $request->getByType('roomType');
$recordId = $request->getInteger('recordId');
$chat = \App\Chat::getInstance($roomType, $recordId);
- 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
The method setMessagesResult() has an NPath complexity of 448. The configured NPath complexity threshold is 200. Open
public function setMessagesResult(App\Request $request)
{
if ($request->has('roomType') && $request->has('recordId')) {
$roomType = $request->getByType('roomType');
$recordId = $request->getInteger('recordId');
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method getRoomsMessages() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function getRoomsMessages(App\Request $request)
{
$result = [];
$roomList = \App\Chat::getRoomsByUser();
$areNewEntries = false;
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method setMessagesResult() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
public function setMessagesResult(App\Request $request)
{
if ($request->has('roomType') && $request->has('recordId')) {
$roomType = $request->getByType('roomType');
$recordId = $request->getInteger('recordId');
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The class Chat_ChatAjax_Action has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
class Chat_ChatAjax_Action extends \App\Controller\Action
{
use \App\Controller\ExposeMethod;
/**
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '53', column '14'). Open
throw new \App\Exceptions\NoPermitted('ERR_NOT_ACCESSIBLE', 406);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '94', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '312', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '205', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '329', column '14'). Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '227', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '253', column '44'). Open
'data' => $this->setMessagesResult(new App\Request(['roomType' => $defaultRoom['roomType'], 'recordId' => $defaultRoom['recordId']]))
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '295', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '106', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '247', column '14'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '182', column '15'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '335', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '268', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '440', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '378', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '457', column '14'). Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '136', column '14'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '422', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '360', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '461', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '396', column '14'). Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '352', column '14'). Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '407', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '487', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Avoid using static access to class '\App\Chat' in method 'setMessagesResult'. Open
$defaultRoom = \App\Chat::setCurrentRoomDefault();
- 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\Config' in method 'getChatConfig'. Open
'isDefaultSoundNotification' => \App\Config::module('Chat', 'DEFAULT_SOUND_NOTIFICATION'),
- 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\Chat' in method 'getChatConfig'. Open
'defaultRoom' => \App\Chat::getDefaultRoom(),
- 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\Config' in method 'getChatConfig'. Open
'refreshMessageTime' => \App\Config::module('Chat', 'REFRESH_MESSAGE_TIME'),
- 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\Chat' in method 'setMessagesResult'. Open
\App\Chat::setCurrentRoom($roomType, $recordId);
- 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\Chat' in method 'setMessagesResult'. Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- 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\Chat' in method 'setMessagesResult'. Open
$result['currentRoom'] = \App\Chat::getCurrentRoom();
- 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\Chat' in method 'getChatConfig'. Open
'activeRoomTypes' => \App\Chat::getActiveRoomTypes(),
- 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\Chat' in method 'getChatConfig'. Open
$result['config']['chatModules'] = \App\Chat::getChatModules();
- 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\Chat' in method 'getRoomsMessages'. Open
$roomList = \App\Chat::getRoomsByUser();
- 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\Config' in method 'getRoomsMessages'. Open
if (App\Config::module('Chat', 'SHOW_NUMBER_OF_NEW_MESSAGES')) {
- 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\Chat' in method 'addPrivateRoom'. Open
$chat = \App\Chat::getInstance();
- 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\Config' in method 'getChatConfig'. Open
'showNumberOfNewMessages' => \App\Config::module('Chat', 'SHOW_NUMBER_OF_NEW_MESSAGES'),
- 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\Config' in method 'setMessagesResult'. Open
if (App\Config::module('Chat', 'SHOW_NUMBER_OF_NEW_MESSAGES')) {
- 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\Chat' in method 'getMoreMessages'. Open
'currentRoom' => \App\Chat::getCurrentRoom(),
- 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\Chat' in method 'search'. Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- 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\Chat' in method 'getMoreMessages'. Open
$chat = \App\Chat::getInstance($request->getByType('roomType'), $request->getInteger('recordId'));
- 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\Chat' in method 'send'. Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- 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\Chat' in method 'getChatConfig'. Open
'roomList' => \App\Chat::getRoomsByUser(),
- 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\Chat' in method 'setMessagesResult'. Open
$currentRoom = \App\Chat::getCurrentRoom();
- 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\Chat' in method 'send'. Open
$defaultRoom = \App\Chat::setCurrentRoomDefault();
- 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
The method send uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$chat->addMessage(\App\Utils\Completions::encodeAll($request->getForHtml('message')));
$chatEntries = $chat->getEntries($request->isEmpty('mid') ? null : $request->getInteger('mid'));
$isNextPage = $this->isNextPage(\count($chatEntries));
if ($isNextPage) {
- Read upRead up
- Exclude checks
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
Avoid using static access to class '\App\Utils\Completions' in method 'send'. Open
$chat->addMessage(\App\Utils\Completions::encodeAll($request->getForHtml('message')));
- 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\Config' in method 'getChatConfig'. Open
'maxLengthMessage' => \App\Config::module('Chat', 'MAX_LENGTH_MESSAGE'),
- 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\Chat' in method 'getRoomsMessages'. Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- 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\Chat' in method 'archivePrivateRoom'. Open
$chat = \App\Chat::getInstance('private', $recordId);
- 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\Chat' in method 'archivePrivateRoom'. Open
\App\Chat::setCurrentRoomDefault();
- 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\Chat' in method 'setMessagesResult'. Open
$result['amountOfNewMessages'] = \App\Chat::getNumberOfNewMessages();
- 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 'getChatConfig'. Open
$userRealID = \App\User::getCurrentUserRealId();
- 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\Chat' in method 'getChatConfig'. Open
\App\Chat::pinAllUsers($userRealID);
- 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\Config' in method 'getChatConfig'. Open
'showRoleName' => \App\Config::module('Users', 'SHOW_ROLE_NAME'),
- 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
The method setMessagesResult uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$currentRoom = \App\Chat::getCurrentRoom();
if (!$currentRoom || !isset($currentRoom['roomType']) || !isset($currentRoom['recordId'])) {
return false;
}
- Read upRead up
- Exclude checks
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
Avoid using static access to class '\Users_Privileges_Model' in method 'checkPermission'. Open
$userPrivileges = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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\Chat' in method 'getRoomsMessages'. Open
$result['amountOfNewMessages'] = \App\Chat::getNumberOfNewMessages($roomList);
- 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\Config' in method 'getChatConfig'. Open
$userRoomPin = \App\Config::module('Chat', 'userRoomPin');
- 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 'getChatConfig'. Open
'isChatAllowed' => $userRealID === \App\User::getCurrentUserId(),
- 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\Chat' in method 'archivePrivateRoom'. Open
}
- 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
The method search uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$chatEntries = $chat->getEntries(null, '>', $searchVal);
}
- Read upRead up
- Exclude checks
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
Avoid using static access to class '\App\Chat' in method 'addPrivateRoom'. Open
$response->setResult(\App\Chat::getRoomsByUser());
- 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\Chat' in method 'getRooms'. Open
'roomList' => \App\Chat::getRoomsByUser()
- 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\Chat' in method 'getUnread'. Open
$unreadMessages[$roomType] = \App\Chat::getUnreadByType($roomType);
- 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\Config' in method 'isNextPage'. Open
return $numberOfMessages >= \App\Config::module('Chat', 'CHAT_ROWS_LIMIT') + 1;
- 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\Config' in method 'getChatConfig'. Open
'refreshRoomTime' => \App\Config::module('Chat', 'REFRESH_ROOM_TIME'),
- 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\Config' in method 'getChatConfig'. Open
'dynamicAddingRooms' => \App\Config::module('Chat', 'dynamicAddingRooms'),
- 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\Config' in method 'getChatConfig'. Open
'refreshTimeGlobal' => \App\Config::module('Chat', 'REFRESH_TIME_GLOBAL'),
- 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\Chat' in method 'getChatConfig'. Open
'currentRoom' => \App\Chat::getCurrentRoom()
- 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\Chat' in method 'setMessagesResult'. Open
$roomList = \App\Chat::getRoomsByUser();
- 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\Config' in method 'getRecordRoom'. Open
'showMoreButton' => \count($chatEntries) > \App\Config::module('Chat', 'CHAT_ROWS_LIMIT')
- 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\Chat' in method 'getRoomPrivateUnpinnedUsers'. Open
$response->setResult(\App\Chat::getRoomPrivateUnpinnedUsers($request->getInteger('roomId')));
- 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
The method addParticipant uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$result = $chat->getParticipants();
}
- Read upRead up
- Exclude checks
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
Avoid using static access to class '\App\Chat' in method 'getHistory'. Open
$chat = \App\Chat::getInstance();
- 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\Chat' in method 'getUnread'. Open
foreach (\App\Chat::getActiveRoomTypes() as $roomType) {
- 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\Chat' in method 'getRoomsUnpinned'. Open
$response->setResult(\App\Chat::{$methodName}());
- 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\Chat' in method 'getRecordRoom'. Open
$chat = \App\Chat::getInstance('crm', $recordId);
- 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\Chat' in method 'addParticipant'. Open
$chat = \App\Chat::getInstance('private', $recordId);
- 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
The method getHistory uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$chatEntries = $chat->getHistoryByType($groupHistory, $request->getInteger('mid'));
}
- Read upRead up
- Exclude checks
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
Avoid using static access to class 'Vtiger_Record_Model' in method 'getRecordRoom'. Open
$recordModel = Vtiger_Record_Model::getInstanceById($recordId);
- 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
Define a constant instead of duplicating this literal "roomType" 13 times. Open
if ($request->has('roomType') && $request->has('recordId')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "roomList" 5 times. Open
'roomList' => \App\Chat::getRoomsByUser(),
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "ERR_NOT_ALLOWED_VALUE" 3 times. Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "chatEntries" 9 times. Open
$roomList[$roomType][$recordId]['chatEntries'] = $chatEntries;
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "config" 3 times. Open
'config' => [
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "currentRoom" 3 times. Open
'currentRoom' => \App\Chat::getCurrentRoom()
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "message" 3 times. Open
'message' => 'JS_CHAT_ROOM_NOT_ALLOWED',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "participants" 4 times. Open
$roomList[$roomType][$recordId]['participants'] = $chat->getParticipants();
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "showMoreButton" 7 times. Open
$roomList[$roomType][$recordId]['showMoreButton'] = $isNextPage;
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "dynamicAddingRooms" 3 times. Open
'dynamicAddingRooms' => \App\Config::module('Chat', 'dynamicAddingRooms'),
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "lastId" 4 times. Open
$chatEntries = $chat->getEntries($request->has('lastId') ? $request->getInteger('lastId') : 0);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "private" 4 times. Open
if ('private' === $roomType && !$chat->isPrivateRoomAllowed($recordId)) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "SHOW_NUMBER_OF_NEW_MESSAGES" 3 times. Open
'showNumberOfNewMessages' => \App\Config::module('Chat', 'SHOW_NUMBER_OF_NEW_MESSAGES'),
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "recordId" 13 times. Open
if ($request->has('roomType') && $request->has('recordId')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "ERR_NO_PERMISSIONS_FOR_THE_RECORD" 4 times. Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Avoid unused parameters such as '$request'. Open
public function getUnread(App\Request $request)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$request'. Open
public function getChatConfig(App\Request $request)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$request'. Open
public function getRooms(App\Request $request)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Call to method getCurrentUserRealId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$userRealID = \App\User::getCurrentUserRealId();
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
'isChatAllowed' => $userRealID === \App\User::getCurrentUserId(),
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- Exclude checks
Call to method getRoomPrivateUnpinnedUsers
from undeclared class \App\Chat
Open
$response->setResult(\App\Chat::getRoomPrivateUnpinnedUsers($request->getInteger('roomId')));
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance('crm', $recordId);
- Exclude checks
Call to method getActiveRoomTypes
from undeclared class \App\Chat
Open
'activeRoomTypes' => \App\Chat::getActiveRoomTypes(),
- Exclude checks
Call to method getCurrentRoom
from undeclared class \App\Chat
Open
$currentRoom = \App\Chat::getCurrentRoom();
- Exclude checks
Call to method getRoomsByUser
from undeclared class \App\Chat
Open
$roomList = \App\Chat::getRoomsByUser();
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance();
- Exclude checks
Call to method getChatModules
from undeclared class \App\Chat
Open
$result['config']['chatModules'] = \App\Chat::getChatModules();
- Exclude checks
Call to method encodeAll
from undeclared class \App\Utils\Completions
Open
$chat->addMessage(\App\Utils\Completions::encodeAll($request->getForHtml('message')));
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance();
- Exclude checks
Call to method setCurrentRoomDefault
from undeclared class \App\Chat
Open
\App\Chat::setCurrentRoomDefault();
- Exclude checks
Call to method getRoomsByUser
from undeclared class \App\Chat
Open
$roomList = \App\Chat::getRoomsByUser();
- Exclude checks
Call to method getCurrentRoom
from undeclared class \App\Chat
Open
if (\App\Chat::getCurrentRoom()['recordId'] === $recordId) {
- Exclude checks
Call to method getActiveRoomTypes
from undeclared class \App\Chat
Open
foreach (\App\Chat::getActiveRoomTypes() as $roomType) {
- Exclude checks
Reference to constant ALLOWED_ROOM_TYPES
from undeclared class \App\Chat
Open
if (!\in_array($groupHistory, \App\Chat::ALLOWED_ROOM_TYPES)) {
- Exclude checks
Call to method setCurrentRoom
from undeclared class \App\Chat
Open
\App\Chat::setCurrentRoom($roomType, $recordId);
- Exclude checks
@throws type of getMoreMessages
has undeclared type \yii\db\Exception
(Did you mean class \Exception) Open
public function getMoreMessages(App\Request $request)
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance($request->getByType('roomType'), $request->getInteger('recordId'));
- Exclude checks
Call to method getNumberOfNewMessages
from undeclared class \App\Chat
Open
$result['amountOfNewMessages'] = \App\Chat::getNumberOfNewMessages();
- Exclude checks
Call to method setCurrentRoomDefault
from undeclared class \App\Chat
Open
$defaultRoom = \App\Chat::setCurrentRoomDefault();
- Exclude checks
Call to method getCurrentRoom
from undeclared class \App\Chat
Open
$result['currentRoom'] = \App\Chat::getCurrentRoom();
- Exclude checks
Argument 1 (mixed)
is string
but \Users_Privileges_Model::hasModulePermission()
takes int
defined at /code/modules/Users/models/Privileges.php:101
Open
if (!$userPrivileges->hasModulePermission($request->getModule()) || $userPrivileges->getId() !== $userPrivileges->getRealId()) {
- Exclude checks
Call to method getNumberOfNewMessages
from undeclared class \App\Chat
Open
$result['amountOfNewMessages'] = \App\Chat::getNumberOfNewMessages($roomList);
- Exclude checks
Call to method setCurrentRoomDefault
from undeclared class \App\Chat
Open
$defaultRoom = \App\Chat::setCurrentRoomDefault();
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance('private', $recordId);
- Exclude checks
Call to method getCurrentRoom
from undeclared class \App\Chat
Open
'currentRoom' => \App\Chat::getCurrentRoom(),
- Exclude checks
Call to method getCurrentRoom
from undeclared class \App\Chat
Open
'currentRoom' => \App\Chat::getCurrentRoom()
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- Exclude checks
Call to method getInstance
from undeclared class \App\Chat
Open
$chat = \App\Chat::getInstance('private', $recordId);
- Exclude checks
Call to method getDefaultRoom
from undeclared class \App\Chat
Open
'defaultRoom' => \App\Chat::getDefaultRoom(),
- Exclude checks
Call to method getRoomsByUser
from undeclared class \App\Chat
Open
'roomList' => \App\Chat::getRoomsByUser(),
- Exclude checks
Call to method pinAllUsers
from undeclared class \App\Chat
Open
\App\Chat::pinAllUsers($userRealID);
- Exclude checks
Call to method getRoomsByUser
from undeclared class \App\Chat
Open
$response->setResult(\App\Chat::getRoomsByUser());
- Exclude checks
Call to method getUnreadByType
from undeclared class \App\Chat
Open
$unreadMessages[$roomType] = \App\Chat::getUnreadByType($roomType);
- Exclude checks
Call to method getRoomsByUser
from undeclared class \App\Chat
Open
'roomList' => \App\Chat::getRoomsByUser()
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Chat_ChatAjax_Action extends \App\Controller\Action
- Exclude checks
The class Chat_ChatAjax_Action is not named in CamelCase. Open
class Chat_ChatAjax_Action extends \App\Controller\Action
{
use \App\Controller\ExposeMethod;
/**
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used for alignment; tabs are not allowed Open
* Set messages result.
- 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
$recordId = $request->getInteger('recordId');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$request->getBoolean('recordRoom')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($request->has('roomType') && $request->has('recordId')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currentRoom = \App\Chat::getCurrentRoom();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordId = $currentRoom['recordId'];
- 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
$areNewEntries = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$result['areNewEntries'] = $areNewEntries;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Search meassages.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!isset($roomList[$roomType][$recordId])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($isNextPage) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomList[$roomType][$recordId]['participants'] = $chat->getParticipants();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chat = \App\Chat::getInstance($request->getByType('roomType'), $request->getInteger('recordId'));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function send(App\Request $request)
- 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
return $result;
- 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
* Get rooms messages from chat.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$result = [];
- 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
$roomType = $request->getByType('roomType');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ('private' === $roomType && !$chat->isPrivateRoomAllowed($recordId)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
array_shift($chatEntries);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$defaultRoom = \App\Chat::setCurrentRoomDefault();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$result['roomList'] = $roomList;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'currentRoom' => \App\Chat::getCurrentRoom(),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Send message function.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- 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
* @throws \App\Exceptions\IllegalValue
- 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 setMessagesResult(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordId = $defaultRoom['recordId'];
- 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
$result['roomList'] = $roomList;
- 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
continue;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomList[$roomType][$recordId]['showMoreButton'] = $isNextPage;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (App\Config::module('Chat', 'SHOW_NUMBER_OF_NEW_MESSAGES')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$result['amountOfNewMessages'] = \App\Chat::getNumberOfNewMessages($roomList);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$isNextPage = $this->isNextPage(\count($chatEntries));
- 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
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomType = $request->getByType('roomType');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomList = \App\Chat::getRoomsByUser();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomList[$roomType][$recordId]['chatEntries'] = $chatEntries;
- 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 ($request->getArray('rooms') as $room) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chatEntries = $chat->getEntries($lastEntries ? $lastEntries['id'] : 0);
- 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
array_shift($chatEntries);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult($result);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- 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
$roomList[$roomType][$recordId]['participants'] = $chat->getParticipants();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$chat->isRoomExists()) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ('private' === $roomType && !$chat->isPrivateRoomAllowed($recordId)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomList[$roomType][$recordId]['chatEntries'] = $chatEntries;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$areNewEntries = \count($chatEntries) > 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'chatEntries' => $chatEntries,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$defaultRoom = \App\Chat::setCurrentRoomDefault();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chatEntries = $chat->getEntries($request->isEmpty('mid') ? null : $request->getInteger('mid'));
- 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
\App\Chat::setCurrentRoom($roomType, $recordId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chatEntries = $chat->getEntries($request->has('lastId') ? $request->getInteger('lastId') : 0);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @throws \App\Exceptions\IllegalValue
- 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
$result = [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$currentRoom || !isset($currentRoom['roomType']) || !isset($currentRoom['recordId'])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (App\Config::module('Chat', 'SHOW_NUMBER_OF_NEW_MESSAGES')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getRoomsMessages(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- 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
$lastEntries = !empty($room['chatEntries']) ? array_pop($room['chatEntries']) : false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$areNewEntries) {
- 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
$chat->addMessage(\App\Utils\Completions::encodeAll($request->getForHtml('message')));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response = new Vtiger_Response();
- 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
$result = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$request->has('lastId')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
array_shift($chatEntries);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- 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
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'data' => $this->setMessagesResult(new App\Request(['roomType' => $defaultRoom['roomType'], 'recordId' => $defaultRoom['recordId']]))
- 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
\App\Chat::setCurrentRoomDefault();
- 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
$chat->archivePrivateRoom($recordId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$result = $chat->getParticipants();
- 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 ($request->isEmpty('mid')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get rooms function.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getRooms(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordId = $room['recordid'];
- 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
$chatEntries = $chat->getEntries($request->getInteger('lastId'), '<');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($isNextPage) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$result = [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- 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 (!\in_array($groupHistory, \App\Chat::ALLOWED_ROOM_TYPES)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chatEntries = $chat->getHistoryByType($groupHistory);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$chat->isRoomExists()) {
- 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
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get more messages from chat.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getMoreMessages(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'chatEntries' => $chatEntries,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordId = $request->getInteger('recordId');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$isNextPage = $this->isNextPage(\count($chatEntries));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function addPrivateRoom(App\Request $request)
- 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
$chat->createPrivateRoom($request->getByType('name', 'Text'));
- 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
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'roomList' => \App\Chat::getRoomsByUser()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomType = $currentRoom['roomType'];
- 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
$result['currentRoom'] = \App\Chat::getCurrentRoom();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomList[$roomType][$recordId]['showMoreButton'] = $isNextPage;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$result['amountOfNewMessages'] = \App\Chat::getNumberOfNewMessages();
- 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
'showMoreButton' => $isNextPage,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'message' => 'JS_CHAT_ROOM_NOT_ALLOWED',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$isNextPage = $this->isNextPage(\count($chatEntries));
- 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
$response = new Vtiger_Response();
- 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
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- 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
$chatEntries = $chat->getHistoryByType($groupHistory, $request->getInteger('mid'));
- 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
* @param App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return void
- 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
$isNextPage = $this->isNextPage(\count($chatEntries));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($isNextPage) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$isNextPage = $this->isNextPage(\count($chatEntries));
- 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
* @throws \yii\db\Exception
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($isNextPage) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult([
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'showMoreButton' => $isNextPage
- 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
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
array_shift($chatEntries);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'chatEntries' => $chatEntries,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult(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
$isNextPage = $this->isNextPage(\count($chatEntries));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordModel = Vtiger_Record_Model::getInstanceById($recordId);
- 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
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult([
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Archive rooms.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$chat->isRoomModerator($recordId)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$alreadyInvited = $chat->addParticipantToPrivate($request->getInteger('userId'));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get all unread messages.
- 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
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chat = \App\Chat::getInstance();
- 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
$roomType = $defaultRoom['roomType'];
- 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
$roomList = \App\Chat::getRoomsByUser();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chat = \App\Chat::getInstance($roomType, $recordId);
- 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
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- 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
$chat = \App\Chat::getInstance($roomType, $recordId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$chat->isRoomExists()) {
- 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 (!$request->isEmpty('mid')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$result = ['message' => 'JS_CHAT_PARTICIPANT_INVITED'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$unreadMessages = [];
- 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
'chatEntries' => $chatEntries,
- 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
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Check if there are more messages.
- 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 ($isNextPage) {
- 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
$response->emit();
- 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
* Add participant.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function addParticipant(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult([
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomType = $request->getByType('roomType');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Show chat for record.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$roomType = $request->getByType('roomType');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$chat->isRoomModerator($recordId)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chat = \App\Chat::getInstance('private', $recordId);
- 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
$unreadMessages[$roomType] = \App\Chat::getUnreadByType($roomType);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- 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 getRoomsUnpinned(App\Request $request)
- 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
} else {
- 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
* @throws \App\Exceptions\IllegalValue
- 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
$roomType = $room['roomType'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult($result);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
array_shift($chatEntries);
- 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
$recordId = $request->getInteger('recordId');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'participants' => $chat->getParticipants(),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- 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 search(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult(\App\Chat::getRoomsByUser());
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get history.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($isNextPage) {
- 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
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult(\App\Chat::{$methodName}());
- 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
$chat = \App\Chat::getInstance('crm', $recordId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'recordid' => $recordId,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'participants' => $chat->getParticipants(),
- 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 getRoomPrivateUnpinnedUsers(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private function isNextPage(int $numberOfMessages): bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $numberOfMessages >= \App\Config::module('Chat', 'CHAT_ROWS_LIMIT') + 1;
- 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
$response = new Vtiger_Response();
- 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
* @throws \App\Exceptions\AppException
- 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
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult($unreadMessages);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$groupHistory = $request->getByType('groupHistory', 2);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'showMoreButton' => $isNextPage
- 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
'showMoreButton' => \count($chatEntries) > \App\Config::module('Chat', 'CHAT_ROWS_LIMIT')
- 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
$searchVal = $request->getByType('searchVal', 'Text');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'showMoreButton' => $isNextPage
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Add private room.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult($result);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- 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 (\App\Chat::getActiveRoomTypes() as $roomType) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getHistory(App\Request $request)
- 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
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'roomType' => 'crm',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chatEntries = $chat->getEntries(null, '>', $searchVal);
- 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
$recordId = $request->getInteger('recordId');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chat = \App\Chat::getInstance('private', $recordId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($alreadyInvited) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response = new Vtiger_Response();
- 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
public function getRecordRoom(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chatEntries = $chat->getEntries();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'recordRoom' => true,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- 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
} else {
- 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
$response = new Vtiger_Response();
- 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
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- 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
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'crm' => [
- 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
$chatEntries = $chat->getEntries($request->getInteger('mid'), '<', $searchVal);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$chat = \App\Chat::getInstance();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- 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\Chat::getCurrentRoom()['recordId'] === $recordId) {
- 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
$recordId = $request->getInteger('recordId');
- 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 getUnread(App\Request $request)
- 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
$response->setResult([
- 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
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response = new Vtiger_Response();
- 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
$response->setResult(\App\Chat::getRoomPrivateUnpinnedUsers($request->getInteger('roomId')));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function archivePrivateRoom(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
array_shift($chatEntries);
- 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
* Get rooms unpinned.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'active' => 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
$response = new Vtiger_Response();
- 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
$recordId => [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'chatEntries' => $chatEntries,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get room private unpinned users.
- 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
$response->setResult([
- 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
$methodName = 'getRooms' . ucfirst($roomType) . 'Unpinned';
- 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 (!$recordModel->isViewable()) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'roomList' => [
- 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
$recordId = $request->getInteger('id');
- 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
* @throws \App\Exceptions\NoPermittedToRecord
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int $numberOfMessages
- 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
$this->exposeMethod('getMessages');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('addPrivateRoom');
- 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
'isChatAllowed' => $userRealID === \App\User::getCurrentUserId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'defaultRoom' => \App\Chat::getDefaultRoom(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'showRoleName' => \App\Config::module('Users', 'SHOW_ROLE_NAME'),
- 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
$userRoomPin = \App\Config::module('Chat', 'userRoomPin');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$userRoomPin) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'config' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'userRoomPin' => $userRoomPin
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('getRecordRoom');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('search');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPrivileges = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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
$userRealID = \App\User::getCurrentUserRealId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dynamicAddingRooms' => \App\Config::module('Chat', 'dynamicAddingRooms'),
- 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
'showNumberOfNewMessages' => \App\Config::module('Chat', 'SHOW_NUMBER_OF_NEW_MESSAGES'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($result['config']['dynamicAddingRooms']) {
- 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
* Get messages from chat.
- 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
$this->exposeMethod('getRoomsMessages');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('addParticipant');
- 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
$result = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'maxLengthMessage' => \App\Config::module('Chat', 'MAX_LENGTH_MESSAGE'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result['config']['chatModules'] = \App\Chat::getChatModules();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- 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
parent::__construct();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('getMoreMessages');
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
if (!$userPrivileges->hasModulePermission($request->getModule()) || $userPrivileges->getId() !== $userPrivileges->getRealId()) {
- 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
'isAdmin' => \Users_Privileges_Model::getCurrentUserPrivilegesModel()->isAdminUser(),
- 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
$response->setResult($result);
- 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
* Get chat init data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'roomList' => \App\Chat::getRoomsByUser(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- 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
$this->exposeMethod('getRooms');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('getRoomPrivateUnpinnedUsers');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermitted('ERR_NOT_ACCESSIBLE', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'isDefaultSoundNotification' => \App\Config::module('Chat', 'DEFAULT_SOUND_NOTIFICATION'),
- 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
public function getMessages(App\Request $request)
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
'data' => $this->setMessagesResult(new App\Request(['roomType' => $defaultRoom['roomType'], 'recordId' => $defaultRoom['recordId']]))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
use \App\Controller\ExposeMethod;
- 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
public function isSessionExtend(App\Request $request)
- 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
'refreshRoomTime' => \App\Config::module('Chat', 'REFRESH_ROOM_TIME'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'activeRoomTypes' => \App\Chat::getActiveRoomTypes(),
- 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
public function getChatConfig(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('getUnread');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('send');
- 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
'currentRoom' => \App\Chat::getCurrentRoom()
- 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
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('getChatConfig');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'draggableButton' => false,
- 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
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkPermission(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$userPrivileges->hasModulePermission($request->getModule()) || $userPrivileges->getId() !== $userPrivileges->getRealId()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param App\Request $request
- 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
'refreshTimeGlobal' => \App\Config::module('Chat', 'REFRESH_TIME_GLOBAL'),
- 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
* Set messages result.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('getRoomsUnpinned');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('archivePrivateRoom');
- 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
$this->exposeMethod('getHistory');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Chat::pinAllUsers($userRealID);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'refreshMessageTime' => \App\Config::module('Chat', 'REFRESH_MESSAGE_TIME'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult($this->setMessagesResult($request));
- Exclude checks
Class name "Chat_ChatAjax_Action" is not in camel caps format Open
class Chat_ChatAjax_Action extends \App\Controller\Action
- Exclude checks