Conditions | 1 |
Paths | 1 |
Total Lines | 113 |
Lines | 47 |
Ratio | 41.59 % |
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 |
||
38 | public static function load() |
||
39 | { |
||
40 | $container = new static(); |
||
41 | |||
42 | $container['zip.inflator'] = null; |
||
43 | $container['zip.deflator'] = null; |
||
44 | |||
45 | $container['resource-manager'] = function($container) { |
||
46 | return new ResourceManager( |
||
47 | $container['request-mapper'], |
||
48 | $container['resource-teleporter'], |
||
49 | $container['filesystem'] |
||
50 | ); |
||
51 | }; |
||
52 | |||
53 | $container['executable-finder'] = function($container) { |
||
|
|||
54 | return new ExecutableFinder(); |
||
55 | }; |
||
56 | |||
57 | $container['request-mapper'] = function($container) { |
||
58 | return new RequestMapper($container['target-locator']); |
||
59 | }; |
||
60 | |||
61 | $container['target-locator'] = function() { |
||
62 | return new TargetLocator(); |
||
63 | }; |
||
64 | |||
65 | $container['teleporter-container'] = function($container) { |
||
66 | return TeleporterContainer::load(); |
||
67 | }; |
||
68 | |||
69 | $container['resource-teleporter'] = function($container) { |
||
70 | return new ResourceTeleporter($container['teleporter-container']); |
||
71 | }; |
||
72 | |||
73 | $container['filesystem'] = function() { |
||
74 | return new Filesystem(); |
||
75 | }; |
||
76 | |||
77 | $container['Alchemy\\Zippy\\Adapter\\ZipAdapter'] = function($container) { |
||
78 | return ZipAdapter::newInstance( |
||
79 | $container['executable-finder'], |
||
80 | $container['resource-manager'], |
||
81 | $container['zip.inflator'], |
||
82 | $container['zip.deflator'] |
||
83 | ); |
||
84 | }; |
||
85 | |||
86 | $container['gnu-tar.inflator'] = null; |
||
87 | $container['gnu-tar.deflator'] = null; |
||
88 | |||
89 | View Code Duplication | $container['Alchemy\\Zippy\\Adapter\\GNUTar\\TarGNUTarAdapter'] = function($container) { |
|
90 | return TarGNUTarAdapter::newInstance( |
||
91 | $container['executable-finder'], |
||
92 | $container['resource-manager'], |
||
93 | $container['gnu-tar.inflator'], |
||
94 | $container['gnu-tar.deflator'] |
||
95 | ); |
||
96 | }; |
||
97 | |||
98 | View Code Duplication | $container['Alchemy\\Zippy\\Adapter\\GNUTar\\TarGzGNUTarAdapter'] = function($container) { |
|
99 | return TarGzGNUTarAdapter::newInstance( |
||
100 | $container['executable-finder'], |
||
101 | $container['resource-manager'], |
||
102 | $container['gnu-tar.inflator'], |
||
103 | $container['gnu-tar.deflator'] |
||
104 | ); |
||
105 | }; |
||
106 | |||
107 | View Code Duplication | $container['Alchemy\\Zippy\\Adapter\\GNUTar\\TarBz2GNUTarAdapter'] = function($container) { |
|
108 | return TarBz2GNUTarAdapter::newInstance( |
||
109 | $container['executable-finder'], |
||
110 | $container['resource-manager'], |
||
111 | $container['gnu-tar.inflator'], |
||
112 | $container['gnu-tar.deflator'] |
||
113 | ); |
||
114 | }; |
||
115 | |||
116 | $container['bsd-tar.inflator'] = null; |
||
117 | $container['bsd-tar.deflator'] = null; |
||
118 | |||
119 | View Code Duplication | $container['Alchemy\\Zippy\\Adapter\\BSDTar\\TarBSDTarAdapter'] = function($container) { |
|
120 | return TarBSDTarAdapter::newInstance( |
||
121 | $container['executable-finder'], |
||
122 | $container['resource-manager'], |
||
123 | $container['bsd-tar.inflator'], |
||
124 | $container['bsd-tar.deflator'] |
||
125 | ); |
||
126 | }; |
||
127 | |||
128 | View Code Duplication | $container['Alchemy\\Zippy\\Adapter\\BSDTar\\TarGzBSDTarAdapter'] = function($container) { |
|
129 | return TarGzBSDTarAdapter::newInstance( |
||
130 | $container['executable-finder'], |
||
131 | $container['resource-manager'], |
||
132 | $container['bsd-tar.inflator'], |
||
133 | $container['bsd-tar.deflator'] |
||
134 | ); |
||
135 | }; |
||
136 | |||
137 | View Code Duplication | $container['Alchemy\\Zippy\\Adapter\\BSDTar\\TarBz2BSDTarAdapter'] = function($container) { |
|
138 | return TarBz2BSDTarAdapter::newInstance( |
||
139 | $container['executable-finder'], |
||
140 | $container['resource-manager'], |
||
141 | $container['bsd-tar.inflator'], |
||
142 | $container['bsd-tar.deflator']); |
||
143 | }; |
||
144 | |||
145 | $container['Alchemy\\Zippy\\Adapter\\ZipExtensionAdapter'] = function() { |
||
146 | return ZipExtensionAdapter::newInstance(); |
||
147 | }; |
||
148 | |||
149 | return $container; |
||
150 | } |
||
151 | |||
223 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.