m000000_000001_option::up()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 71
Code Lines 59

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 71
rs 9.1369
cc 2
eloc 59
nc 2
nop 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
use yii\db\Schema;
4
5
/**
6
 * Class m000000_000001_option.
7
 * Migration for table option.
8
 *
9
 * @author Agiel K. Saputra <[email protected]>
10
 * @since 0.1.0
11
 */
12
class m000000_000001_option extends \yii\db\Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
{
14
    /**
15
     * @inheritdoc
16
     */
17
    public function up()
18
    {
19
        $tableOptions = null;
20
        if ($this->db->driverName === 'mysql') {
21
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
22
        }
23
24
        $this->createTable('{{%option}}', [
25
            'id' => Schema::TYPE_PK,
26
            'name' => Schema::TYPE_STRING . '(64) NOT NULL',
27
            'value' => Schema::TYPE_TEXT . ' NOT NULL',
28
            'label' => Schema::TYPE_STRING . '(64)',
29
            'group' => Schema::TYPE_STRING . '(64)',
30
        ], $tableOptions);
31
32
        $this->batchInsert('{{%option}}', ['name', 'value', 'label', 'group'], [
33
            ['sitetitle', 'WritesDown', 'Site Title', 'general'],
34
            ['tagline', 'CMS Built with Yii Framework', 'Tagline', 'general'],
35
            ['admin_email', '[email protected]', 'E-mail Address', 'general'],
36
            ['allow_signup', '0', 'Membership', 'general'],
37
            ['default_role', 'subscriber', 'New User Default Role', 'general'],
38
            ['time_zone', 'Asia/Jakarta', 'Timezone', 'general'],
39
            ['date_format', 'F d, Y', 'Date Format', 'general'],
40
            ['time_format', 'g:i:s a', 'Time Format', 'general'],
41
            /* READING */
42
            ['show_on_front', 'posts', 'Front page displays', 'reading'],
43
            ['front_post_type', 'all', 'Post type on front page', 'reading'],
44
            ['front_page', '', 'Front page', 'reading'],
45
            ['posts_page', '', 'Posts page', 'reading'],
46
            ['posts_per_page', '10', 'Posts Per Page', 'reading'],
47
            ['posts_per_rss', '10', 'Posts Per RSS', 'reading'],
48
            ['rss_use_excerpt', '0', 'For each article in a feed, show ', 'reading'],
49
            ['disable_site_indexing', '0', 'Search Engine Visibility ', 'reading'],
50
            /* DISCUSSION */
51
            ['default_comment_status', 'open', 'Default article settings', 'discussion'],
52
            ['require_name_email', '1', 'Comment author must fill out name and e-mail ', 'discussion'],
53
            ['comment_registration', '0', 'Users must be registered and logged in to comment ', 'discussion'],
54
            ['close_comments_for_old_posts', '0', 'Automatically close comments on articles older', 'discussion'],
55
            ['close_comments_days_old', '14', 'Days when the comments of the article is closed', 'discussion'],
56
            ['thread_comments', '1', 'Enable threaded (nested) comments', 'discussion'],
57
            ['page_comments', '5', 'Break comments into pages with', 'discussion'],
58
            ['thread_comments_depth', '5', 'Thread Comments Depth', 'discussion'],
59
            ['comments_per_page', '10', 'Top level comments per page', 'discussion'],
60
            [
61
                'default_comments_page',
62
                'newest',
63
                'page displayed by default\nComments should be displayed with the',
64
                'discussion',
65
            ],
66
            ['comments_notify', '1', 'Notify when anyone posts a comment', 'discussion'],
67
            ['moderation_notify', '0', 'Notify when a comment is held for moderation', 'discussion'],
68
            ['comment_moderation', '1', 'Comment must be manually approved', 'discussion'],
69
            ['comment_whitelist', '0', 'Comment author must have a previously approved comment', 'discussion'],
70
            ['show_avatars', '1', 'Show Avatars', 'discussion'],
71
            ['avatar_rating', 'G', 'Maximum Rating', 'discussion'],
72
            ['avatar_default', 'mystery', 'Default Avatar', 'discussion'],
73
            ['comment_order', 'asc', 'comments at the top of each page', 'discussion'],
74
            /* MEDIA */
75
            ['thumbnail_width', '150', 'Width', 'media'],
76
            ['thumbnail_height', '150', 'Height', 'media'],
77
            ['thumbnail_crop', '1', 'Crop thumbnail to exact dimensions', 'media'],
78
            ['medium_width', '300', 'Max Width', 'media'],
79
            ['medium_height', '300', 'Max Height', 'media'],
80
            ['large_width', '1024', 'Max Width', 'media'],
81
            ['large_height', '1024', 'Max Height', 'media'],
82
            ['uploads_yearmonth_based', '1', 'Organize my uploads into month- and year-based folders', 'media'],
83
            ['uploads_username_based', '0', 'Organize my uploads into username-based folders', 'media'],
84
            /* APPEARANCE */
85
            ['theme', 'default', 'Theme', null],
86
        ]);
87
    }
88
89
    /**
90
     * @inheritdoc
91
     */
92
    public function down()
93
    {
94
        $this->dropTable('{{%option}}');
95
    }
96
}
97