| Conditions | 1 |
| Paths | 1 |
| Total Lines | 130 |
| Code Lines | 88 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | 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 |
||
| 34 | public function seed() |
||
| 35 | { |
||
| 36 | $now = date('Y-m-d H:i:s', time()); |
||
| 37 | |||
| 38 | $configs = new stdClass(); |
||
| 39 | $names = new stdClass(); |
||
| 40 | |||
| 41 | $configs->user = serialize([ |
||
| 42 | 'registrationType' => 1, // 0 = invites, 1 = validation via email, 2 = full open without validation |
||
| 43 | 'captchaOnLogin' => 0, |
||
| 44 | 'captchaOnRegister' => 1 |
||
| 45 | ]); |
||
| 46 | |||
| 47 | $configs->profile = serialize([ |
||
| 48 | 'guestView' => 1, |
||
| 49 | 'wallPostOnPage' => 5, |
||
| 50 | 'wallPostOnFeed' => 10, |
||
| 51 | 'delayBetweenPost' => 30, |
||
| 52 | 'rating' => 1, |
||
| 53 | 'ratingDelay' => 60 * 60 * 24, |
||
| 54 | 'usersOnPage' => 10 |
||
| 55 | ]); |
||
| 56 | |||
| 57 | $configs->content = serialize([ |
||
| 58 | 'itemPerCategory' => 10, |
||
| 59 | 'userAdd' => 0, |
||
| 60 | 'multiCategories' => 1, |
||
| 61 | 'rss' => 1, |
||
| 62 | 'gallerySize' => 500, |
||
| 63 | 'galleryResize' => 250 |
||
| 64 | ]); |
||
| 65 | |||
| 66 | $configs->feedback = serialize([ |
||
| 67 | 'useCaptcha' => 1, |
||
| 68 | 'guestAdd' => 1 |
||
| 69 | ]); |
||
| 70 | |||
| 71 | $configs->comments = serialize([ |
||
| 72 | 'perPage' => 10, |
||
| 73 | 'delay' => 60, |
||
| 74 | 'minLength' => 10, |
||
| 75 | 'maxLength' => 5000, |
||
| 76 | 'guestAdd' => 0, |
||
| 77 | 'guestModerate' => 1, |
||
| 78 | 'onlyLocale' => 0 |
||
| 79 | ]); |
||
| 80 | |||
| 81 | $configs->newcontent = serialize([ |
||
| 82 | 'categories' => ['2','3'], |
||
| 83 | 'count' => '5', |
||
| 84 | 'cache' => '60' |
||
| 85 | ]); |
||
| 86 | |||
| 87 | $configs->contenttag = serialize([ |
||
| 88 | 'count' => 10, |
||
| 89 | 'cache' => 120 |
||
| 90 | ]); |
||
| 91 | |||
| 92 | $configs->newcomment = serialize([ |
||
| 93 | 'snippet' => 50, |
||
| 94 | 'count' => 5, |
||
| 95 | 'cache' => 60 |
||
| 96 | ]); |
||
| 97 | |||
| 98 | $configs->search = serialize([ |
||
| 99 | 'itemPerApp' => 10, |
||
| 100 | 'minLength' => 3 |
||
| 101 | ]); |
||
| 102 | |||
| 103 | $names->user = serialize([ |
||
| 104 | 'en' => 'User identity', |
||
| 105 | 'ru' => 'Идентификация пользователя' |
||
| 106 | ]); |
||
| 107 | |||
| 108 | $names->profile = serialize([ |
||
| 109 | 'en' => 'User profiles', |
||
| 110 | 'ru' => 'Профили пользователей' |
||
| 111 | ]); |
||
| 112 | |||
| 113 | $names->content = serialize([ |
||
| 114 | 'en' => 'Content', |
||
| 115 | 'ru' => 'Контент' |
||
| 116 | ]); |
||
| 117 | |||
| 118 | $names->feedback = serialize([ |
||
| 119 | 'en' => 'Feedback', |
||
| 120 | 'ru' => 'Обратная связь' |
||
| 121 | ]); |
||
| 122 | |||
| 123 | $names->comments = serialize([ |
||
| 124 | 'en' => 'Comments', |
||
| 125 | 'ru' => 'Комментарии' |
||
| 126 | ]); |
||
| 127 | |||
| 128 | $names->newcontent = serialize([ |
||
| 129 | 'en' => 'New content', |
||
| 130 | 'ru' => 'Новый контент' |
||
| 131 | ]); |
||
| 132 | |||
| 133 | $names->contenttag = serialize([ |
||
| 134 | 'en' => 'Content tags', |
||
| 135 | 'ru' => 'Метки контента' |
||
| 136 | ]); |
||
| 137 | |||
| 138 | $names->newcomment = serialize([ |
||
| 139 | 'en' => 'New comments', |
||
| 140 | 'ru' => 'Новые комментарии' |
||
| 141 | ]); |
||
| 142 | |||
| 143 | $names->search = serialize([ |
||
| 144 | 'en' => 'Search', |
||
| 145 | 'ru' => 'Поиск' |
||
| 146 | ]); |
||
| 147 | |||
| 148 | $names->sitemap = serialize([ |
||
| 149 | 'en' => 'Sitemap', |
||
| 150 | 'ru' => 'Карта сайта' |
||
| 151 | ]); |
||
| 152 | |||
| 153 | $this->getConnection()->table('apps')->insert([ |
||
| 154 | ['type' => 'app', 'sys_name' => 'User', 'name' => $names->user, 'configs' => $configs->user, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 155 | ['type' => 'app', 'sys_name' => 'Profile', 'name' => $names->profile, 'configs' => $configs->profile, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 156 | ['type' => 'app', 'sys_name' => 'Content', 'name' => $names->content, 'configs' => $configs->content, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 157 | ['type' => 'app', 'sys_name' => 'Feedback', 'name' => $names->feedback, 'configs' => $configs->feedback, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 158 | ['type' => 'app', 'sys_name' => 'Search', 'name' => $names->search, 'configs' => $configs->search, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 159 | ['type' => 'app', 'sys_name' => 'Sitemap', 'name' => $names->sitemap, 'configs' => '', 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 160 | ['type' => 'widget', 'sys_name' => 'Comments', 'name' => $names->comments, 'configs' => $configs->comments, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 161 | ['type' => 'widget', 'sys_name' => 'Newcontent', 'name' => $names->newcontent, 'configs' => $configs->newcontent, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 162 | ['type' => 'widget', 'sys_name' => 'Contenttag', 'name' => $names->contenttag, 'configs' => $configs->contenttag, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now], |
||
| 163 | ['type' => 'widget', 'sys_name' => 'Newcomment', 'name' => $names->newcomment, 'configs' => $configs->newcomment, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now] |
||
| 164 | ]); |
||
| 177 | } |