Conditions | 1 |
Paths | 1 |
Total Lines | 88 |
Code Lines | 67 |
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 |
||
24 | public function getForeignKeysProvider() |
||
25 | { |
||
26 | return [ |
||
27 | [ |
||
28 | 'CREATE USER test', |
||
29 | [], |
||
30 | ], |
||
31 | [ |
||
32 | 'CREATE TABLE `payment` ( |
||
33 | `payment_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
||
34 | `customer_id` smallint(5) unsigned NOT NULL, |
||
35 | `staff_id` tinyint(3) unsigned NOT NULL, |
||
36 | `rental_id` int(11) DEFAULT NULL, |
||
37 | `amount` decimal(5,2) NOT NULL, |
||
38 | `payment_date` datetime NOT NULL, |
||
39 | `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
||
40 | PRIMARY KEY (`payment_id`), |
||
41 | KEY `idx_fk_staff_id` (`staff_id`), |
||
42 | KEY `idx_fk_customer_id` (`customer_id`), |
||
43 | KEY `fk_payment_rental` (`rental_id`), |
||
44 | CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) |
||
45 | REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE, |
||
46 | CONSTRAINT `fk_payment_rental` FOREIGN KEY (`rental_id`) |
||
47 | REFERENCES `rental` (`rental_id`) ON DELETE SET NULL ON UPDATE CASCADE, |
||
48 | CONSTRAINT `fk_payment_staff` FOREIGN KEY (`staff_id`) |
||
49 | REFERENCES `staff` (`staff_id`) ON UPDATE CASCADE |
||
50 | ) ENGINE=InnoDB AUTO_INCREMENT=16050 DEFAULT CHARSET=utf8', |
||
51 | [ |
||
52 | [ |
||
53 | 'constraint' => 'fk_payment_customer', |
||
54 | 'index_list' => ['customer_id'], |
||
55 | 'ref_db_name' => null, |
||
56 | 'ref_table_name' => 'customer', |
||
57 | 'ref_index_list' => ['customer_id'], |
||
58 | 'on_update' => 'CASCADE', |
||
59 | ], |
||
60 | [ |
||
61 | 'constraint' => 'fk_payment_rental', |
||
62 | 'index_list' => ['rental_id'], |
||
63 | 'ref_db_name' => null, |
||
64 | 'ref_table_name' => 'rental', |
||
65 | 'ref_index_list' => ['rental_id'], |
||
66 | 'on_delete' => 'SET_NULL', |
||
67 | 'on_update' => 'CASCADE', |
||
68 | ], |
||
69 | [ |
||
70 | 'constraint' => 'fk_payment_staff', |
||
71 | 'index_list' => ['staff_id'], |
||
72 | 'ref_db_name' => null, |
||
73 | 'ref_table_name' => 'staff', |
||
74 | 'ref_index_list' => ['staff_id'], |
||
75 | 'on_update' => 'CASCADE', |
||
76 | ], |
||
77 | ], |
||
78 | ], |
||
79 | [ |
||
80 | 'CREATE TABLE `actor` ( |
||
81 | `actor_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
||
82 | `first_name` varchar(45) NOT NULL, |
||
83 | `last_name` varchar(45) NOT NULL, |
||
84 | `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
||
85 | PRIMARY KEY (`actor_id`), |
||
86 | KEY `idx_actor_last_name` (`last_name`) |
||
87 | ) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8', |
||
88 | [], |
||
89 | ], |
||
90 | [ |
||
91 | 'CREATE TABLE `address` ( |
||
92 | `address_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
||
93 | `address` varchar(50) NOT NULL, |
||
94 | `address2` varchar(50) DEFAULT NULL, |
||
95 | `district` varchar(20) NOT NULL, |
||
96 | `city_id` smallint(5) unsigned NOT NULL, |
||
97 | `postal_code` varchar(10) DEFAULT NULL, |
||
98 | `phone` varchar(20) NOT NULL, |
||
99 | `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
||
100 | PRIMARY KEY (`address_id`), |
||
101 | KEY `idx_fk_city_id` (`city_id`), |
||
102 | CONSTRAINT `fk_address_city` FOREIGN KEY (`city_id`) REFERENCES `city` (`city_id`) ON UPDATE CASCADE |
||
103 | ) ENGINE=InnoDB AUTO_INCREMENT=606 DEFAULT CHARSET=utf8', |
||
104 | [ |
||
105 | [ |
||
106 | 'constraint' => 'fk_address_city', |
||
107 | 'index_list' => ['city_id'], |
||
108 | 'ref_db_name' => null, |
||
109 | 'ref_table_name' => 'city', |
||
110 | 'ref_index_list' => ['city_id'], |
||
111 | 'on_update' => 'CASCADE', |
||
112 | ], |
||
223 |