| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 24 | public function testDumpCreatesMergedClasses() |
||
| 25 | { |
||
| 26 | $dumper = new ClassDumper(); |
||
| 27 | $classes = [ |
||
| 28 | UserInterface::class, |
||
| 29 | Admin::class, |
||
| 30 | ProductInterface::class, |
||
| 31 | Customer::class, |
||
| 32 | ]; |
||
| 33 | $cache = $dumper->dump($classes); |
||
| 34 | $this->assertEquals('namespace UserLib { |
||
| 35 | interface UserInterface |
||
| 36 | { |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | namespace UserLib\Admin { |
||
| 41 | use UserLib\UserInterface; |
||
| 42 | class Admin implements UserInterface |
||
| 43 | { |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | namespace UserLib\Product { |
||
| 48 | interface ProductInterface |
||
| 49 | { |
||
| 50 | public function getName(); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | namespace UserLib\Customer { |
||
| 55 | use UserLib\Admin\Admin; |
||
| 56 | use UserLib\Product\ProductInterface as Product; |
||
| 57 | interface CustomerInterface |
||
| 58 | { |
||
| 59 | public function buy(Product $product); |
||
| 60 | |||
| 61 | public function sendMessageToAdmin(Admin $admin); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | namespace UserLib\Customer { |
||
| 66 | use UserLib\Admin\Admin; |
||
| 67 | use UserLib\UserInterface; |
||
| 68 | use UserLib\Product\ProductInterface; |
||
| 69 | class Customer implements CustomerInterface, UserInterface |
||
| 70 | { |
||
| 71 | public function buy(ProductInterface $product) |
||
| 72 | { |
||
| 73 | } |
||
| 74 | |||
| 75 | public function sendMessageToAdmin(Admin $admin) |
||
| 76 | { |
||
| 77 | } |
||
| 78 | } |
||
| 79 | } |
||
| 80 | ', $cache); |
||
| 81 | } |
||
| 82 | |||
| 182 |