| Conditions | 8 |
| Paths | 26 |
| Total Lines | 61 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 72 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 65 | public function getJoin($params, $return_array = false) |
||
| 66 | { |
||
| 67 | $join_type= ' INNER JOIN '; |
||
| 68 | if (isset($params['join_type'])) |
||
| 69 | { |
||
| 70 | $join_type = $params['join_type']; |
||
| 71 | } |
||
| 72 | $join = ''; |
||
| 73 | $bean_is_lhs=$this->_get_bean_position(); |
||
|
|
|||
| 74 | |||
| 75 | if ( |
||
| 76 | $this->_relationship->relationship_type == 'one-to-many' |
||
| 77 | && $bean_is_lhs |
||
| 78 | ) |
||
| 79 | { |
||
| 80 | $table_with_alias = $table = $this->_relationship->rhs_table; |
||
| 81 | $key = $this->_relationship->rhs_key; |
||
| 82 | $module = $this->_relationship->rhs_module; |
||
| 83 | $other_table = (empty($params['left_join_table_alias']) ? $this->_relationship->lhs_table : $params['left_join_table_alias']); |
||
| 84 | $other_key = $this->_relationship->lhs_key; |
||
| 85 | $alias_prefix = $table; |
||
| 86 | if (!empty($params['join_table_alias'])) |
||
| 87 | { |
||
| 88 | $table_with_alias = $table. " ".$params['join_table_alias']; |
||
| 89 | $table = $params['join_table_alias']; |
||
| 90 | $alias_prefix = $params['join_table_alias']; |
||
| 91 | } |
||
| 92 | |||
| 93 | $join .= ' '.$join_type.' prospect_list_campaigns '.$alias_prefix.'_plc ON'; |
||
| 94 | $join .= ' '.$alias_prefix.'_plc.'.$key.' = '.$other_table.'.'.$other_key."\n"; |
||
| 95 | |||
| 96 | // join list targets |
||
| 97 | $join .= ' '.$join_type.' prospect_lists_prospects '.$alias_prefix.'_plp ON'; |
||
| 98 | $join .= ' '.$alias_prefix.'_plp.prospect_list_id = '.$alias_prefix.'_plc.prospect_list_id AND'; |
||
| 99 | $join .= ' '.$alias_prefix.'_plp.related_type = '.$GLOBALS['db']->quoted($module)."\n"; |
||
| 100 | |||
| 101 | // join target |
||
| 102 | $join .= ' '.$join_type.' '.$table_with_alias.' ON'; |
||
| 103 | $join .= ' '.$table.'.id = '.$alias_prefix.'_plp.related_id AND'; |
||
| 104 | $join .= ' '.$table.'.deleted=0'."\n"; |
||
| 105 | |||
| 106 | if ($return_array) |
||
| 107 | { |
||
| 108 | $ret_arr = array(); |
||
| 109 | $ret_arr['join'] = $join; |
||
| 110 | $ret_arr['type'] = $this->_relationship->relationship_type; |
||
| 111 | if ($bean_is_lhs) |
||
| 112 | { |
||
| 113 | $ret_arr['rel_key'] = $this->_relationship->join_key_rhs; |
||
| 114 | } |
||
| 115 | else |
||
| 116 | { |
||
| 117 | $ret_arr['rel_key'] = $this->_relationship->join_key_lhs; |
||
| 118 | } |
||
| 119 | return $ret_arr; |
||
| 120 | } |
||
| 121 | return $join; |
||
| 122 | } else { |
||
| 123 | return parent::getJoin($params, $return_array); |
||
| 124 | } |
||
| 125 | } |
||
| 126 | } |
||
| 127 |
This method has been deprecated.