Conditions | 2 |
Paths | 2 |
Total Lines | 58 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 1 | Features | 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 |
||
92 | public static function addStatusField(Schema $schema, ExtendExtension $extendExtension, QueryBag $queries) |
||
93 | { |
||
94 | $enumTable = $extendExtension->addEnumField( |
||
95 | $schema, |
||
96 | 'orocrm_sales_opportunity', |
||
97 | 'status', |
||
98 | Opportunity::INTERNAL_STATUS_CODE, |
||
99 | false, |
||
100 | false, |
||
101 | [ |
||
102 | 'extend' => ['owner' => ExtendScope::OWNER_SYSTEM], |
||
103 | 'datagrid' => ['is_visible' => DatagridScope::IS_VISIBLE_TRUE], |
||
104 | 'dataaudit' => ['auditable' => true], |
||
105 | 'importexport' => ["order" => 90, "short" => true] |
||
106 | ] |
||
107 | ); |
||
108 | |||
109 | $options = new OroOptions(); |
||
110 | $options->set( |
||
111 | 'enum', |
||
112 | 'immutable_codes', |
||
113 | [ |
||
114 | 'in_progress', |
||
115 | 'won', |
||
116 | 'lost' |
||
117 | ] |
||
118 | ); |
||
119 | |||
120 | $enumTable->addOption(OroOptions::KEY, $options); |
||
|
|||
121 | $statuses = [ |
||
122 | 'identification_alignment' => 'Identification & Alignment', |
||
123 | 'needs_analysis' => 'Needs Analysis', |
||
124 | 'solution_development' => 'Solution Development', |
||
125 | 'negotiation' => 'Negotiation', |
||
126 | 'in_progress' => 'In Progress', |
||
127 | 'won' => 'Closed Won', |
||
128 | 'lost' => 'Closed Lost' |
||
129 | ]; |
||
130 | $defaultValue = 'in_progress'; |
||
131 | $query = 'INSERT INTO oro_enum_opportunity_status (id, name, priority, is_default) |
||
132 | VALUES (:id, :name, :priority, :is_default)'; |
||
133 | $i = 1; |
||
134 | foreach ($statuses as $key => $value) { |
||
135 | $dropFieldsQuery = new ParametrizedSqlMigrationQuery(); |
||
136 | $dropFieldsQuery->addSql( |
||
137 | $query, |
||
138 | ['id' => $key, 'name' => $value, 'priority' => $i, 'is_default' => $defaultValue === $key], |
||
139 | [ |
||
140 | 'id' => Type::STRING, |
||
141 | 'name' => Type::STRING, |
||
142 | 'priority' => Type::INTEGER, |
||
143 | 'is_default' => Type::BOOLEAN |
||
144 | ] |
||
145 | ); |
||
146 | $queries->addQuery($dropFieldsQuery); |
||
147 | $i++; |
||
148 | } |
||
149 | } |
||
150 | } |
||
151 |
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: