Conditions | 12 |
Paths | 13 |
Total Lines | 33 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 |
||
30 | public function get($version = null) |
||
31 | { |
||
32 | $currentVersion = $this->schemaTable->getCurrentVersion(); |
||
33 | if (null !== $version && (int) $version === (int) $currentVersion) { |
||
34 | return null; |
||
35 | } |
||
36 | $migrateUp = null === $version || $version >= $currentVersion; |
||
37 | $migrationFiles = array(); |
||
38 | foreach ($this->getFiles($migrateUp) as $file) { |
||
39 | $filenameParser = new FileNameParser($file->getFileName()); |
||
40 | |||
41 | $isMigrated = in_array($filenameParser->getVersion(), $this->schemaTable->getVersions()); |
||
42 | |||
43 | $migrationFile = new MigrationFile($filenameParser->getMigrationName(), $file->getRealpath(), |
||
44 | $filenameParser->getVersion(), $filenameParser->getMigrationClassName(), $isMigrated); |
||
45 | |||
46 | if (false === $this->statusIntention) { |
||
47 | if ($migrateUp && $isMigrated |
||
48 | || !$migrateUp && !$isMigrated) { |
||
49 | continue; |
||
50 | } |
||
51 | if ($version == $migrationFile->getVersion()) { |
||
52 | if ($migrateUp) { |
||
53 | $migrationFiles[] = $migrationFile; |
||
54 | } |
||
55 | break; |
||
56 | } |
||
57 | } |
||
58 | $migrationFiles[] = $migrationFile; |
||
59 | } |
||
60 | |||
61 | return $migrationFiles; |
||
62 | } |
||
63 | |||
98 |