| Conditions | 3 |
| Paths | 3 |
| Total Lines | 91 |
| Code Lines | 28 |
| 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 |
||
| 11 | public static function setUpBeforeClass() |
||
| 12 | { |
||
| 13 | parent::setUpBeforeClass(); |
||
| 14 | |||
| 15 | /** @noinspection SqlResolve */ |
||
| 16 | /** @noinspection SqlNoDataSourceInspection */ |
||
| 17 | foreach ( |
||
| 18 | [ |
||
| 19 | 'src/Acme/Combinator.php' => '<?php namespace Acme; class Combinator {}', |
||
| 20 | 'src/Acme/Comparator.php' => '<?php namespace Acme; class Comparator {}', |
||
| 21 | 'README' => 'Please read me!', |
||
| 22 | 'sql/AA-000-init.sql' => <<<'SQL' |
||
| 23 | SET NAMES utf8; |
||
| 24 | SET TIME_ZONE='+00:00'; |
||
| 25 | SET character set 'utf8'; |
||
| 26 | DROP DATABASE IF EXISTS world; |
||
| 27 | CREATE DATABASE world; |
||
| 28 | SQL |
||
| 29 | , |
||
| 30 | 'sql/EB-000-schema.sql' => <<<'SQL' |
||
| 31 | CREATE TABLE `City` ( |
||
| 32 | `ID` int(11) NOT NULL, |
||
| 33 | `Name` char(35) NOT NULL DEFAULT '', |
||
| 34 | `CountryCode` char(3) NOT NULL DEFAULT '', |
||
| 35 | `District` char(20) NOT NULL DEFAULT '', |
||
| 36 | `Population` int(11) NOT NULL DEFAULT '0' |
||
| 37 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
||
| 38 | SQL |
||
| 39 | , |
||
| 40 | 'sql/EB-001-data.sql' => <<<'SQL' |
||
| 41 | INSERT INTO `City` (`ID`, `Name`, `CountryCode`, `District`, `Population`) VALUES |
||
| 42 | (1, 'Kabul', 'AFG', 'Kabol', 1780000), |
||
| 43 | (2, 'Qandahar', 'AFG', 'Qandahar', 237500), |
||
| 44 | (3, 'Herat', 'AFG', 'Herat', 186800), |
||
| 45 | (4, 'Mazar-e-Sharif', 'AFG', 'Balkh', 127800), |
||
| 46 | (5, 'Amsterdam', 'NLD', 'Noord-Holland', 731200), |
||
| 47 | (6, 'Rotterdam', 'NLD', 'Zuid-Holland', 593321), |
||
| 48 | (7, 'Haag', 'NLD', 'Zuid-Holland', 440900), |
||
| 49 | (8, 'Utrecht', 'NLD', 'Utrecht', 234323), |
||
| 50 | (9, 'Eindhoven', 'NLD', 'Noord-Brabant', 201843); |
||
| 51 | SQL |
||
| 52 | , |
||
| 53 | 'sql/EB-002-keys-and-fix.sql' => <<<SQL |
||
| 54 | ALTER TABLE `City` ADD PRIMARY KEY (`ID`); |
||
| 55 | UPDATE `City` SET `Name` = "کندهار" WHERE `ID` = 2; |
||
| 56 | SQL |
||
| 57 | , |
||
| 58 | 'sql/EB-003-more-data.sql' => <<<'SQL' |
||
| 59 | INSERT INTO `City` (`ID`, `Name`, `CountryCode`, `District`, `Population`) VALUES |
||
| 60 | (10,'Tilburg','NLD','Noord-Brabant',193238), |
||
| 61 | (11,'Groningen','NLD','Groningen',172701), |
||
| 62 | (12,'Breda','NLD','Noord-Brabant',160398), |
||
| 63 | (13,'Apeldoorn','NLD','Gelderland',153491); |
||
| 64 | SQL |
||
| 65 | , |
||
| 66 | 'sql/EB-004-much-more-data.sql' => <<<'SQL' |
||
| 67 | BEGIN; |
||
| 68 | INSERT INTO `City` (`ID`, `Name`, `CountryCode`, `District`, `Population`) VALUES |
||
| 69 | (14,'Nijmegen','NLD','Gelderland',152463), |
||
| 70 | (15,'Enschede','NLD','Overijssel',149544), |
||
| 71 | (16,'Haarlem','NLD','Noord-Holland',148772), |
||
| 72 | (17,'Almere','NLD','Flevoland',142465), |
||
| 73 | (18,'Arnhem','NLD','Gelderland',138020), |
||
| 74 | (19,'Zaanstad','NLD','Noord-Holland',135621), |
||
| 75 | (20,'´s-Hertogenbosch','NLD','Noord-Brabant',129170), |
||
| 76 | (21,'Amersfoort','NLD','Utrecht',126270), |
||
| 77 | (22,'Maastricht','NLD','Limburg',122087), |
||
| 78 | (23,'Dordrecht','NLD','Zuid-Holland',119811), |
||
| 79 | (24,'Leiden','NLD','Zuid-Holland',117196), |
||
| 80 | (25,'Haarlemmermeer','NLD','Noord-Holland',110722), |
||
| 81 | (26,'Zoetermeer','NLD','Zuid-Holland',110214), |
||
| 82 | (27,'Emmen','NLD','Drenthe',105853), |
||
| 83 | (28,'Zwolle','NLD','Overijssel',105819), |
||
| 84 | (29,'Ede','NLD','Gelderland',101574), |
||
| 85 | (30,'Delft','NLD','Zuid-Holland',95268), |
||
| 86 | (31,'Heerlen','NLD','Limburg',95052), |
||
| 87 | (32,'Alkmaar','NLD','Noord-Holland',92713), |
||
| 88 | (33,'Willemstad','ANT','Curaçao',2345), |
||
| 89 | (34,'Tirana','ALB','Tirana',270000), |
||
| 90 | (35,'Alger','DZA','Alger',2168000); |
||
| 91 | COMMIT; |
||
| 92 | SQL |
||
| 93 | , |
||
| 94 | ] as $filename => $content |
||
| 95 | ) { |
||
| 96 | if (!is_dir(dirname($filename))) { |
||
| 97 | mkdir(dirname($filename), 0755, true); |
||
| 98 | } |
||
| 99 | file_put_contents($filename, $content); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 196 |