Completed
Branch FET-9113-extra-joins-table (dff12c)
by
unknown
630:44 queued 613:03
created

EEM_Extra_Join   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7
Metric Value
wmc 2
lcom 0
cbo 7
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 2
1
<?php
2
3
/**
4
 *
5
 * Class EEM_Extra_Join
6
 *
7
 * Description here
8
 *
9
 * @package         Event Espresso
10
 * @subpackage    
11
 * @author				Mike Nelson
12
 * @since		 	   $VID:$
13
 *
14
 */
15
if (!defined('EVENT_ESPRESSO_VERSION')) {
16
	exit('No direct script access allowed');
17
}
18
19
class EEM_Extra_Join extends EEM_Base{
20
	// private instance of the Extra Join object
21
	protected static $_instance = NULL;
22
	
23
	public function __construct($timezone = NULL) {
24
		$models_this_can_join = array_keys( EE_Registry::instance()->non_abstract_db_models );
25
		$this->_tables = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array('Extra_Join' => ne...extra_join', 'EXJ_ID')) of type array<string,object<EE_P...ct<EE_Primary_Table>"}> is incompatible with the declared type array<integer,object<EE_Table_Base>> of property $_tables.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
26
			'Extra_Join' => new EE_Primary_Table( 'esp_extra_join', 'EXJ_ID' ),
27
		);
28
		$this->_fields = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array('Extra_Join' => ar...models_this_can_join))) of type array<string,array<strin...odel_Name_Field>\"}>"}> is incompatible with the declared type array<integer,object<EE_Model_Field_Base>> of property $_fields.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
29
			'Extra_Join' => array(
30
				'EXJ_ID' => new EE_Primary_Key_Int_Field( 'EXJ_ID', __( 'Extra Join ID', 'event_espresso' ) ),
31
				'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_first_model_ID', __( 'First Model ID', 'event_espresso' ), true, 0, $models_this_can_join ),
0 ignored issues
show
Documentation introduced by
$models_this_can_join is of type array<integer,integer|string>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
32
				'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_first_model_name', __( 'First Model Name', 'event_espresso'), true, '', $models_this_can_join ),
0 ignored issues
show
Documentation introduced by
$models_this_can_join is of type array<integer,integer|string>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
				'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_second_model_ID', __( 'Second Model ID', 'event_espresso' ), true, 0, $models_this_can_join ),
0 ignored issues
show
Documentation introduced by
$models_this_can_join is of type array<integer,integer|string>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
34
				'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_second_model_name', __( 'Second Model Name', 'event_espresso'), true, '', $models_this_can_join ),
0 ignored issues
show
Documentation introduced by
$models_this_can_join is of type array<integer,integer|string>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
				
36
			)
37
		);
38
		foreach($models_this_can_join as $model){
39
			$this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
40
		}
41
		parent::__construct($timezone);
42
	}
43
}
44