| Conditions | 1 |
| Paths | 1 |
| Total Lines | 53 |
| Code Lines | 44 |
| 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 |
||
| 9 | public function testImmutability() |
||
| 10 | { |
||
| 11 | $old = new EndOfCentralDirectory(0,0,0,0,0,0); |
||
| 12 | $number = 12345; |
||
| 13 | |||
| 14 | $new = $old->setNumberOfThisDisk($number); |
||
| 15 | $this->assertNotSame($old, $new); |
||
| 16 | $this->assertNotSame($old->getNumberOfThisDisk(), $new->getNumberOfThisDisk()); |
||
| 17 | $this->assertSame($number, $new->getNumberOfThisDisk()); |
||
| 18 | $old = $new; |
||
| 19 | $number += 123; |
||
| 20 | |||
| 21 | $new = $old->setNumberOfTheDiskWithTheStartOfTheCentralDirectory($number); |
||
| 22 | $this->assertNotSame($old, $new); |
||
| 23 | $this->assertNotSame($old->getNumberOfTheDiskWithTheStartOfTheCentralDirectory(), $new->getNumberOfTheDiskWithTheStartOfTheCentralDirectory()); |
||
| 24 | $this->assertSame($number, $new->getNumberOfTheDiskWithTheStartOfTheCentralDirectory()); |
||
| 25 | $old = $new; |
||
| 26 | $number += 123; |
||
| 27 | |||
| 28 | $new = $old->setTotalNumberOfEntriesInTheCentralDirectoryOnThisDisk($number); |
||
| 29 | $this->assertNotSame($old, $new); |
||
| 30 | $this->assertNotSame($old->getTotalNumberOfEntriesInTheCentralDirectoryOnThisDisk(), $new->getTotalNumberOfEntriesInTheCentralDirectoryOnThisDisk()); |
||
| 31 | $this->assertSame($number, $new->getTotalNumberOfEntriesInTheCentralDirectoryOnThisDisk()); |
||
| 32 | $old = $new; |
||
| 33 | $number += 123; |
||
| 34 | |||
| 35 | $new = $old->setTotalNumberOfEntriesInTheCentralDirectory($number); |
||
| 36 | $this->assertNotSame($old, $new); |
||
| 37 | $this->assertNotSame($old->getTotalNumberOfEntriesInTheCentralDirectory(), $new->getTotalNumberOfEntriesInTheCentralDirectory()); |
||
| 38 | $this->assertSame($number, $new->getTotalNumberOfEntriesInTheCentralDirectory()); |
||
| 39 | $old = $new; |
||
| 40 | $number += 123; |
||
| 41 | |||
| 42 | $new = $old->setSizeOfTheCentralDirectory($number); |
||
| 43 | $this->assertNotSame($old, $new); |
||
| 44 | $this->assertNotSame($old->getSizeOfTheCentralDirectory(), $new->getSizeOfTheCentralDirectory()); |
||
| 45 | $this->assertSame($number, $new->getSizeOfTheCentralDirectory()); |
||
| 46 | $old = $new; |
||
| 47 | $number += 123; |
||
| 48 | |||
| 49 | $new = $old->setOffsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber($number); |
||
| 50 | $this->assertNotSame($old, $new); |
||
| 51 | $this->assertNotSame($old->getOffsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber(), $new->getOffsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber()); |
||
| 52 | $this->assertSame($number, $new->getOffsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber()); |
||
| 53 | $old = $new; |
||
| 54 | |||
| 55 | $fileComment = "a comment"; |
||
| 56 | $new = $old->setZipFileComment($fileComment); |
||
| 57 | $this->assertNotSame($old, $new); |
||
| 58 | $this->assertNotSame($old->getZipFileComment(), $new->getZipFileComment()); |
||
| 59 | $this->assertSame($fileComment, $new->getZipFileComment()); |
||
| 60 | $this->assertSame(\strlen($fileComment), $new->getZipFileCommentLength()); |
||
| 61 | } |
||
| 62 | } |
||
| 63 |