The method send() has an NPath complexity of 324. The configured NPath complexity threshold is 200. Open
public function send($sendToUsersInSession = false, $sendToDrhUsers = false, $senderId = 0, $directMessage = false)
{
$senderId = empty($senderId) ? api_get_user_id() : (int) $senderId;
$subject = $this->subject($directMessage);
- 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 all_users uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$userList = GroupManager::get_users($group_id);
}
- 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
The method subject uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$result = $this->course['title'].' - '.$title;
}
- 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
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 {
if (!empty($this->logger)) {
$this->logger->addInfo(
'Message "'.$subject.'" was already sent. Announcement: #'.$this->announcement->getIid().'.
User: #'.$userId
- 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
The method all_users uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
$this->session_id
);
- 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 unused local variables such as '$course_id'. Open
$course_id = $this->course['real_id'];
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The property $session_id is not named in camelCase. Open
class AnnouncementEmail
{
public $session_id;
public $logger;
protected $course;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Variable "session_id" is not in valid camel caps format Open
$this->session_id = empty($sessionId) ? api_get_session_id() : (int) $sessionId;
- Exclude checks
Variable "sent_to" is not in valid camel caps format Open
$sent_to = $this->announcement->getUsersAndGroupSubscribedToResource();
- Exclude checks
Variable "sent_to" is not in valid camel caps format Open
$groups = $sent_to['groups'] ?? [];
- Exclude checks
Missing function doc comment Open
public function __construct(array $courseInfo, $sessionId, CAnnouncement $announcement, Monolog\Logger $logger = null)
- Exclude checks
Variable "group_id" is not in valid camel caps format Open
$userList = GroupManager::get_users($group_id);
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
$this->session_id
- Exclude checks
Member variable "session_id" is not in valid camel caps format Open
public $session_id;
- Exclude checks
Method name "AnnouncementEmail::all_users" is not in camel caps format Open
public function all_users()
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
if (empty($this->session_id)) {
- Exclude checks
Variable "group_id" is not in valid camel caps format Open
$group_id = api_get_group_id();
- Exclude checks
Method name "AnnouncementEmail::sent_to" is not in camel caps format Open
public function sent_to()
- Exclude checks
Variable "group_id" is not in valid camel caps format Open
if (empty($group_id)) {
- Exclude checks
Variable "sent_to" is not in valid camel caps format Open
$users = $sent_to['users'] ?? [];
- Exclude checks
Variable "course_id" is not in valid camel caps format Open
$course_id = $this->course['real_id'];
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
$course_param = 'cid='.$this->course['real_id'].'&sid='.$session_id.'&gid='.api_get_group_id();
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
$session_id = $this->session_id;
- Exclude checks
Variable "course_param" is not in valid camel caps format Open
$course_param = 'cid='.$this->course['real_id'].'&sid='.$session_id.'&gid='.api_get_group_id();
- Exclude checks
Variable "course_param" is not in valid camel caps format Open
$result .= '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.$course_param.'">'.$course_name.'</a><br/>';
- Exclude checks
Variable "course_name" is not in valid camel caps format Open
$result .= '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.$course_param.'">'.$course_name.'</a><br/>';
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
$session_id = $this->session_id;
- Exclude checks
Variable "course_name" is not in valid camel caps format Open
$course_name = $this->course['title'];
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
$session_id
- Exclude checks
The variable $course_name is not named in camelCase. Open
public function message($receiverUserId)
{
$content = $this->announcement->getContent();
$session_id = $this->session_id;
$courseCode = $this->course['code'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $course_name is not named in camelCase. Open
public function message($receiverUserId)
{
$content = $this->announcement->getContent();
$session_id = $this->session_id;
$courseCode = $this->course['code'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $course_id is not named in camelCase. Open
public function attachment()
{
$result = [];
$table = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
$id = $this->announcement->getIid();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $sent_to is not named in camelCase. Open
public function sent_to()
{
$sent_to = $this->announcement->getUsersAndGroupSubscribedToResource();
$users = $sent_to['users'] ?? [];
$groups = $sent_to['groups'] ?? [];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $session_id is not named in camelCase. Open
public function message($receiverUserId)
{
$content = $this->announcement->getContent();
$session_id = $this->session_id;
$courseCode = $this->course['code'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $group_id is not named in camelCase. Open
public function all_users()
{
$courseCode = $this->course['code'];
if (empty($this->session_id)) {
$group_id = api_get_group_id();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $session_id is not named in camelCase. Open
public function message($receiverUserId)
{
$content = $this->announcement->getContent();
$session_id = $this->session_id;
$courseCode = $this->course['code'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $sent_to is not named in camelCase. Open
public function sent_to()
{
$sent_to = $this->announcement->getUsersAndGroupSubscribedToResource();
$users = $sent_to['users'] ?? [];
$groups = $sent_to['groups'] ?? [];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $group_id is not named in camelCase. Open
public function all_users()
{
$courseCode = $this->course['code'];
if (empty($this->session_id)) {
$group_id = api_get_group_id();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $course_param is not named in camelCase. Open
public function message($receiverUserId)
{
$content = $this->announcement->getContent();
$session_id = $this->session_id;
$courseCode = $this->course['code'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $group_id is not named in camelCase. Open
public function all_users()
{
$courseCode = $this->course['code'];
if (empty($this->session_id)) {
$group_id = api_get_group_id();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $session_id is not named in camelCase. Open
public function message($receiverUserId)
{
$content = $this->announcement->getContent();
$session_id = $this->session_id;
$courseCode = $this->course['code'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $sent_to is not named in camelCase. Open
public function sent_to()
{
$sent_to = $this->announcement->getUsersAndGroupSubscribedToResource();
$users = $sent_to['users'] ?? [];
$groups = $sent_to['groups'] ?? [];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $course_param is not named in camelCase. Open
public function message($receiverUserId)
{
$content = $this->announcement->getContent();
$session_id = $this->session_id;
$courseCode = $this->course['code'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method all_users is not named in camelCase. Open
public function all_users()
{
$courseCode = $this->course['code'];
if (empty($this->session_id)) {
$group_id = api_get_group_id();
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method sent_to is not named in camelCase. Open
public function sent_to()
{
$sent_to = $this->announcement->getUsersAndGroupSubscribedToResource();
$users = $sent_to['users'] ?? [];
$groups = $sent_to['groups'] ?? [];
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}