Conditions | 3 |
Paths | 4 |
Total Lines | 88 |
Code Lines | 61 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
||
27 | protected function __construct( $timezone = null ) { |
||
28 | $this->singular_item = __( 'Term Relationship', 'event_espresso' ); |
||
29 | $this->plural_item = __( 'Term Relationships', 'event_espresso' ); |
||
30 | $this->_tables = array( |
||
|
|||
31 | 'Term_Relationship' => new EE_Primary_Table( 'term_relationships' ), |
||
32 | ); |
||
33 | $models_this_can_attach_to = array_keys( EE_Registry::instance()->cpt_models() ); |
||
34 | $this->_fields = array( |
||
35 | 'Term_Relationship' => array( |
||
36 | 'object_id' => new EE_Foreign_Key_Int_Field( |
||
37 | 'object_id', |
||
38 | __( 'Object(Post) ID', 'event_espresso' ), |
||
39 | false, |
||
40 | 0, |
||
41 | $models_this_can_attach_to |
||
42 | ), |
||
43 | 'term_taxonomy_id' => new EE_Foreign_Key_Int_Field( |
||
44 | 'term_taxonomy_id', |
||
45 | __( |
||
46 | 'Term (in context of a taxonomy) ID', |
||
47 | 'event_espresso' |
||
48 | ), |
||
49 | false, |
||
50 | 0, |
||
51 | 'Term_Taxonomy' |
||
52 | ), |
||
53 | 'term_order' => new EE_Integer_Field( |
||
54 | 'term_order', __( 'Term Order', 'event_espresso' ), false, 0 |
||
55 | ), |
||
56 | ), |
||
57 | ); |
||
58 | $this->_model_relations = array( |
||
59 | 'Term_Taxonomy' => new EE_Belongs_To_Relation(), |
||
60 | ); |
||
61 | foreach ( $models_this_can_attach_to as $model_name ) { |
||
62 | $this->_model_relations[ $model_name ] = new EE_Belongs_To_Relation(); |
||
63 | } |
||
64 | $this->_indexes = array( |
||
65 | 'PRIMARY' => new EE_Primary_Key_Index( array( 'object_id', 'term_taxonomy_id' ) ), |
||
66 | ); |
||
67 | $path_to_event_model = 'Event.'; |
||
68 | $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
||
69 | $path_to_event_model |
||
70 | ); |
||
71 | $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
||
72 | $path_to_event_model |
||
73 | ); |
||
74 | $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
||
75 | $path_to_event_model |
||
76 | ); |
||
77 | $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
||
78 | $path_to_event_model, EEM_Base::caps_edit |
||
79 | ); |
||
80 | $path_to_tax_model = 'Term_Taxonomy.'; |
||
81 | //add cap restrictions for editing term relations to the "ee_assign_*" |
||
82 | //and for deleting term relations too |
||
83 | $cap_contexts_affected = array( EEM_Base::caps_edit, EEM_Base::caps_delete ); |
||
84 | foreach ( $cap_contexts_affected as $cap_context_affected ) { |
||
85 | $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_category'] = new EE_Default_Where_Conditions( |
||
86 | array( |
||
87 | $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( |
||
88 | '!=', |
||
89 | 'espresso_event_categories', |
||
90 | ), |
||
91 | ) |
||
92 | ); |
||
93 | $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_venue_category'] = new EE_Default_Where_Conditions( |
||
94 | array( |
||
95 | $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( |
||
96 | '!=', |
||
97 | 'espresso_venue_categories', |
||
98 | ), |
||
99 | ) |
||
100 | ); |
||
101 | $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
||
102 | array( |
||
103 | $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array( '!=', 'espresso_event_type' ), |
||
104 | ) |
||
105 | ); |
||
106 | } |
||
107 | parent::__construct( $timezone ); |
||
108 | add_filter( |
||
109 | 'FHEE__Read__create_model_query_params', |
||
110 | array( 'EEM_Term_Relationship', 'rest_api_query_params' ), |
||
111 | 10, |
||
112 | 3 |
||
113 | ); |
||
114 | } |
||
115 | |||
228 | // Location: /includes/models/EEM_Term_Relationship.model.php |
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..