| Conditions | 3 |
| Paths | 4 |
| Total Lines | 57 |
| Code Lines | 37 |
| 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 |
||
| 22 | public function up(Schema $schema) |
||
| 23 | { |
||
| 24 | $connection = $this->connection; |
||
| 25 | $sql = "SELECT id FROM extra_field WHERE variable = 'skype' AND extra_field_type = 1"; |
||
| 26 | $result = $connection->executeQuery($sql)->fetchAll(); |
||
| 27 | |||
| 28 | if (empty($result)) { |
||
| 29 | $this->addSql(" |
||
| 30 | INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) |
||
| 31 | VALUES (1, 1, 'skype', 'Skype', 1, 1, NOW()) |
||
| 32 | "); |
||
| 33 | } |
||
| 34 | |||
| 35 | $sql = "SELECT id FROM extra_field WHERE variable = 'skype' AND extra_field_type = 1"; |
||
| 36 | $result = $connection->executeQuery($sql)->fetchAll(); |
||
| 37 | if (empty($result)) { |
||
| 38 | $this->addSql(" |
||
| 39 | INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) |
||
| 40 | VALUES (1, 1, 'linkedin_url', 'LinkedInUrl', 1, 1, NOW())" |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | $this->addSettingCurrent( |
||
| 45 | 'allow_show_skype_account', |
||
| 46 | null, |
||
| 47 | 'radio', |
||
| 48 | 'Platform', |
||
| 49 | 'true', |
||
| 50 | 'AllowShowSkypeAccountTitle', |
||
| 51 | 'AllowShowSkypeAccountComment', |
||
| 52 | null, |
||
| 53 | null, |
||
| 54 | 1, |
||
| 55 | true, |
||
| 56 | false, |
||
| 57 | [ |
||
| 58 | ['value' => 'false', 'text' => 'No'], |
||
| 59 | ['value' => 'true', 'text' => 'Yes'] |
||
| 60 | ] |
||
| 61 | ); |
||
| 62 | |||
| 63 | $this->addSettingCurrent( |
||
| 64 | 'allow_show_linkedin_url', |
||
| 65 | null, |
||
| 66 | 'radio', |
||
| 67 | 'Platform', |
||
| 68 | 'true', |
||
| 69 | 'AllowShowLinkedInUrlTitle', |
||
| 70 | 'AllowShowLinkedInUrlComment', |
||
| 71 | null, |
||
| 72 | null, |
||
| 73 | 1, |
||
| 74 | true, |
||
| 75 | false, |
||
| 76 | [ |
||
| 77 | ['value' => 'false', 'text' => 'No'], |
||
| 78 | ['value' => 'true', 'text' => 'Yes'] |
||
| 79 | ] |
||
| 93 |