Conditions | 8 |
Paths | 12 |
Total Lines | 59 |
Code Lines | 39 |
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 |
||
33 | public function invokeTest() |
||
34 | { |
||
35 | $configuration = $this->getConfiguration(); |
||
36 | |||
37 | switch ($this->store) { |
||
38 | case 'phpsession': |
||
39 | switch (ini_get('session.save_handler')) { |
||
40 | case 'files': |
||
41 | $input = [ |
||
42 | 'path' => session_save_path(), |
||
43 | 'category' => 'Session storage' |
||
44 | ]; |
||
45 | $testData = new TestData($input); |
||
46 | $test = new TestCase\FileSystem\FreeSpace($testData); |
||
47 | $results = array($test->getTestResult()); |
||
48 | break; |
||
49 | case 'memcache': |
||
50 | case 'memcached': |
||
51 | $configuration = \SimpleSAML_Configuration::setPreLoadedConfig( |
||
|
|||
52 | \SimpleSAML_Configuration::loadFromArray( |
||
53 | array( |
||
54 | 'memcache_store.servers' => $this->parsePhpMemcachedConfiguration(session_save_path()) |
||
55 | ) |
||
56 | ) |
||
57 | ); |
||
58 | |||
59 | $test = new Store\Memcache($configuration); |
||
60 | $results = $test->getTestResults(); |
||
61 | break; |
||
62 | // TODO: |
||
63 | // case 'sqlite': |
||
64 | // case 'mm': |
||
65 | default: |
||
66 | Logger::warning("Not implemented; $this->store - Skipping Store TestSuite."); |
||
67 | return; |
||
68 | } |
||
69 | break; |
||
70 | case 'memcache': |
||
71 | $test = new Store\Memcache($configuration); |
||
72 | $results = $test->getTestResults(); |
||
73 | break; |
||
74 | // TODO: |
||
75 | // case 'redis': |
||
76 | // case 'redissentinel': |
||
77 | // $test = new Store\Redis($configuration); |
||
78 | // break; |
||
79 | case 'sql': |
||
80 | $test = new Store\Sql($configuration); |
||
81 | $results = $test->getTestResults(); |
||
82 | break; |
||
83 | default: |
||
84 | Logger::warning("Not implemented; $this->store - Skipping Store TestSuite."); |
||
85 | return; |
||
86 | |||
87 | } |
||
88 | foreach ($results as $result) { |
||
89 | $this->addTestResult($result); |
||
90 | } |
||
91 | $this->calculateState(); |
||
92 | } |
||
126 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.