Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Code Lines | 36 |
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 defined('BASEPATH') OR exit('No direct script access allowed'); |
||
9 | public function up() { |
||
10 | $this->dbforge->add_field(array( |
||
11 | 'id' => array( |
||
12 | 'type' => 'MEDIUMINT', |
||
13 | 'constraint' => '8', |
||
14 | 'unsigned' => TRUE, |
||
15 | 'auto_increment' => TRUE |
||
16 | ), |
||
17 | 'chapter_id' => array( |
||
18 | 'type' => 'MEDIUMINT', |
||
19 | 'constraint' => '8', |
||
20 | 'unsigned' => TRUE |
||
21 | //FOREIGN KEY |
||
22 | ), |
||
23 | |||
24 | 'type' => array( |
||
25 | 'type' => 'TINYINT', |
||
26 | 'constraint' => '1', |
||
27 | 'unsigned' => TRUE, |
||
28 | 'null' => FALSE |
||
29 | ), |
||
30 | 'custom1' => array( |
||
31 | 'type' => 'VARCHAR', |
||
32 | 'constraint' => '255', |
||
33 | 'null' => TRUE |
||
34 | ), |
||
35 | 'custom2' => array( |
||
36 | 'type' => 'VARCHAR', |
||
37 | 'constraint' => '255', |
||
38 | 'null' => TRUE |
||
39 | ), |
||
40 | 'custom3' => array( |
||
41 | 'type' => 'VARCHAR', |
||
42 | 'constraint' => '255', |
||
43 | 'null' => TRUE |
||
44 | ), |
||
45 | |||
46 | 'updated_at' => array( |
||
47 | //Despite not actually creating the field here (it's instead done below), we still need this here so a key can be created properly. |
||
48 | // 'type' => 'TIMESTAMP', |
||
49 | // 'null' => FALSE, |
||
50 | // 'on_update' => FALSE |
||
51 | ) |
||
52 | )); |
||
53 | $this->dbforge->add_field('updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP'); //CI is annoying and auto-appends ON UPDATE which we don't want. |
||
54 | $this->dbforge->add_key('id', TRUE); |
||
55 | $this->dbforge->add_key('chapter_id'); |
||
56 | $this->dbforge->add_key('type'); |
||
57 | $this->dbforge->add_key('updated_at'); |
||
58 | $this->dbforge->create_table('tracker_user_history'); |
||
59 | |||
60 | /*** Unique/Foreign Keys ***/ |
||
61 | //For whatever reason, dbforge lacks a unique/foreign key function. |
||
62 | $this->db->query(' |
||
63 | ALTER TABLE `tracker_user_history` |
||
64 | ADD CONSTRAINT `FK_tracker_user_history_tracker_chapters` FOREIGN KEY (`chapter_id`) REFERENCES `tracker_chapters` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION;' |
||
65 | ); |
||
66 | } |
||
67 | |||
72 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.