Completed
Push — work-fleets ( d7065d...1ee481 )
by SuperNova.WS
08:22
created

DBStaticSurvey   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 10
cp 0
rs 10
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A db_survey_delete_by_id() 0 3 1
A db_survey_insert() 0 7 1
1
<?php
2
3
namespace DBStatic;
4
use classSupernova;
5
6
class DBStaticSurvey {
7
8
  public static function db_survey_delete_by_id($announce_id) {
9
    classSupernova::$gc->db->doDeleteWhere(TABLE_SURVEY, array('survey_announce_id' => $announce_id));
0 ignored issues
show
Bug introduced by
The method doDeleteWhere does only exist in db_mysql, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
10
  }
11
12
  public static function db_survey_insert($announce_id, $survey_question_unsafe, $survey_until) {
13
    classSupernova::$db->doInsertSet(TABLE_SURVEY, array(
14
      'survey_announce_id' => $announce_id,
15
      'survey_question'    => $survey_question_unsafe,
16
      'survey_until'       => $survey_until,
17
    ));
18
  }
19
20
}