Conditions | 6 |
Paths | 32 |
Total Lines | 73 |
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 compile($pharFile = 'bowerphp.phar') |
||
42 | { |
||
43 | if (file_exists($pharFile)) { |
||
44 | unlink($pharFile); |
||
45 | } |
||
46 | |||
47 | $phar = new \Phar($pharFile, 0, 'bowerphp.phar'); |
||
48 | $phar->setSignatureAlgorithm(\Phar::SHA1); |
||
49 | |||
50 | $phar->startBuffering(); |
||
51 | |||
52 | $finder = new Finder(); |
||
53 | $finder->files() |
||
54 | ->ignoreVCS(true) |
||
55 | ->name('*.php') |
||
56 | ->notName('Compiler.php') |
||
57 | ->notName('ClassLoader.php') |
||
58 | ->in(__DIR__ . '/..') |
||
59 | ; |
||
60 | |||
61 | foreach ($finder as $file) { |
||
62 | $this->addFile($phar, $file); |
||
63 | } |
||
64 | |||
65 | $finder = new Finder(); |
||
66 | $finder->files() |
||
67 | ->ignoreVCS(true) |
||
68 | ->name('*.php') |
||
69 | ->name('*.pem') |
||
70 | ->name('*.pem.md5') |
||
71 | ->exclude('Tests') |
||
72 | ->in(__DIR__ . '/../../vendor/symfony/') |
||
73 | ->in(__DIR__ . '/../../vendor/guzzle/guzzle/src/') |
||
74 | ->in(__DIR__ . '/../../vendor/ircmaxell/password-compat/lib/') |
||
75 | ->in(__DIR__ . '/../../vendor/paragonie/random_compat/lib/') |
||
76 | ->in(__DIR__ . '/../../vendor/knplabs/github-api/lib/') |
||
77 | ->in(__DIR__ . '/../../vendor/samsonasik/package-versions/src/PackageVersions/') |
||
78 | ->in(__DIR__ . '/../../vendor/vierbergenlars/php-semver/src/vierbergenlars/LibJs/') |
||
79 | ->in(__DIR__ . '/../../vendor/vierbergenlars/php-semver/src/vierbergenlars/SemVer/') |
||
80 | ->in(__DIR__ . '/../../vendor/hamcrest/hamcrest-php/hamcrest/') |
||
81 | ; |
||
82 | |||
83 | foreach ($finder as $file) { |
||
84 | $this->addFile($phar, $file); |
||
85 | } |
||
86 | |||
87 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/autoload.php')); |
||
88 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_psr4.php')); |
||
89 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_files.php')); |
||
90 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_namespaces.php')); |
||
91 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_classmap.php')); |
||
92 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_real.php')); |
||
93 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_static.php')); |
||
94 | if (file_exists(__DIR__ . '/../../vendor/composer/include_paths.php')) { |
||
95 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/include_paths.php')); |
||
96 | } |
||
97 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/ClassLoader.php')); |
||
98 | $this->addBin($phar); |
||
99 | |||
100 | // Stubs |
||
101 | $phar->setStub($this->getStub()); |
||
102 | |||
103 | $phar->stopBuffering(); |
||
104 | |||
105 | if ($this->gz) { |
||
106 | $phar->compressFiles(\Phar::GZ); |
||
107 | } |
||
108 | |||
109 | $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../LICENSE'), false); |
||
110 | |||
111 | unset($phar); |
||
112 | chmod('bowerphp.phar', 0700); |
||
113 | } |
||
114 | |||
207 |