Completed
Push — 7.x-3.x ( 571444...9ff9ad )
by Devin
06:11
created

modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_flag.inc::commons_radioactivity_flag_flag()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 4
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @file
5
 * Radioactivity integration for the Flag module.
6
 */
7
8
/**
9
 * Implements hook_flag_flag().
10
 *
11
 * Trigger radioactivity incidents when a user follows a node or group.
12
 */
13 View Code Duplication
function commons_radioactivity_flag_flag($flag, $entity_id, $account, $flagging) {
0 ignored issues
show
Unused Code introduced by
The parameter $flagging is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
  if (in_array($flag->name, array('commons_follow_node', 'commons_follow_group'))) {
15
    $node = node_load($entity_id);
16
17
    // A user following their own node should not increase radioactivity.
18
    if ($node->uid != $account->uid) {
19
      commons_radioactivity_incident_node($node,  COMMONS_RADIOACTIVITY_FLAG_NODE);
20
    }
21
  }
22
}
23
24
/**
25
 * Implements hook_flag_unflag().
26
 *
27
 * Trigger radioactivity incidents when a user follows a node or group.
28
 */
29 View Code Duplication
function commons_radioactivity_flag_unflag($flag, $entity_id, $account, $flagging) {
0 ignored issues
show
Unused Code introduced by
The parameter $flagging is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
  if (in_array($flag->name, array('commons_follow_node', 'commons_follow_group'))) {
31
    $node = node_load($entity_id);
32
33
    // A user unfollowing their own node should not decrease radioactivity.
34
    if ($node->uid != $account->uid) {
35
      commons_radioactivity_incident_node($node,  -1 * COMMONS_RADIOACTIVITY_FLAG_NODE);
36
    }
37
  }
38
}
39