| Conditions | 3 | 
| Paths | 2 | 
| Total Lines | 60 | 
| 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  | 
            ||
| 41 | public function testPackExtract($archiveType)  | 
            ||
| 42 |     { | 
            ||
| 43 |         if ((version_compare(PHP_VERSION, '7.4.0') >= 0) && (getenv('TRAVIS'))) { | 
            ||
| 44 |           $this->markTestSkipped('Zip libraries apparently not available on Travis CI with PHP 7.4 image.'); | 
            ||
| 45 | }  | 
            ||
| 46 | |||
| 47 | // Archive directory and then extract it again with Archive and Extract tasks  | 
            ||
| 48 | $this->fixtures->createAndCdToSandbox();  | 
            ||
| 49 | |||
| 50 | // Assert fixture was created correctly  | 
            ||
| 51 |         $this->assertDirectoryExists('some/deeply/nested'); | 
            ||
| 52 |         $this->assertFileExists('some/deeply/nested/structu.re'); | 
            ||
| 53 |         $this->assertFileExists('some/deeply/existing_file'); | 
            ||
| 54 | |||
| 55 | // First, take everything from the folder 'some/deeply' and make  | 
            ||
| 56 | // an archive for it located in 'deep'  | 
            ||
| 57 |         $this->taskPack("deeply.$archiveType") | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 58 | ->add(['deep' => 'some/deeply'])  | 
            ||
| 59 | ->run();  | 
            ||
| 60 |         $this->assertFileExists("deeply.$archiveType"); | 
            ||
| 61 | // We are next going to extract the archive we created, this time  | 
            ||
| 62 | // putting it into a folder called "extracted-$archiveType" (different  | 
            ||
| 63 | // for each archive type we test). We rely on the default behavior  | 
            ||
| 64 | // of our extractor to remove the top-level directory in the archive  | 
            ||
| 65 |         // ("deeply"). | 
            ||
| 66 |         $this->taskExtract("deeply.$archiveType") | 
            ||
| 67 |             ->to("extracted-$archiveType") | 
            ||
| 68 | ->preserveTopDirectory(false) // this is the default  | 
            ||
| 69 | ->run();  | 
            ||
| 70 |         $this->assertDirectoryExists("extracted-$archiveType"); | 
            ||
| 71 |         $this->assertDirectoryExists("extracted-$archiveType/nested"); | 
            ||
| 72 |         $this->assertFileExists("extracted-$archiveType/nested/structu.re"); | 
            ||
| 73 | // Next, we'll extract the same archive again, this time preserving  | 
            ||
| 74 | // the top-level folder.  | 
            ||
| 75 |         $this->taskExtract("deeply.$archiveType") | 
            ||
| 76 |             ->to("preserved-$archiveType") | 
            ||
| 77 | ->preserveTopDirectory()  | 
            ||
| 78 | ->run();  | 
            ||
| 79 |         $this->assertDirectoryExists("preserved-$archiveType"); | 
            ||
| 80 |         $this->assertDirectoryExists("preserved-$archiveType/deep/nested"); | 
            ||
| 81 |         $this->assertFileExists("preserved-$archiveType/deep/nested/structu.re"); | 
            ||
| 82 | // Make another archive, this time composed of fanciful locations  | 
            ||
| 83 |         $this->taskPack("composed.$archiveType") | 
            ||
| 84 | ->add(['a/b/existing_file' => 'some/deeply/existing_file'])  | 
            ||
| 85 | ->add(['x/y/z/structu.re' => 'some/deeply/nested/structu.re'])  | 
            ||
| 86 | ->run();  | 
            ||
| 87 |         $this->assertFileExists("composed.$archiveType"); | 
            ||
| 88 | // Extract our composed archive, and see if the resulting file  | 
            ||
| 89 | // structure matches expectations.  | 
            ||
| 90 |         $this->taskExtract("composed.$archiveType") | 
            ||
| 91 |             ->to("decomposed-$archiveType") | 
            ||
| 92 | ->preserveTopDirectory()  | 
            ||
| 93 | ->run();  | 
            ||
| 94 |         $this->assertDirectoryExists("decomposed-$archiveType"); | 
            ||
| 95 |         $this->assertDirectoryExists("decomposed-$archiveType/x/y/z"); | 
            ||
| 96 |         $this->assertFileExists("decomposed-$archiveType/x/y/z/structu.re"); | 
            ||
| 97 |         $this->assertDirectoryExists("decomposed-$archiveType/a/b"); | 
            ||
| 98 |         $this->assertFileExists("decomposed-$archiveType/a/b/existing_file"); | 
            ||
| 99 | |||
| 100 | }  | 
            ||
| 101 | }  | 
            ||
| 102 | 
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: