Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 39 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
30 | public function testProxyAction() |
||
31 | { |
||
32 | $client = static::createRestClient(); |
||
33 | $headers = array( |
||
34 | 'Content_Type' => 'application/json', |
||
35 | ); |
||
36 | |||
37 | $testApp = new \stdClass(); |
||
38 | $testApp->id = "testapp"; |
||
39 | $testApp->showInMenu = false; |
||
40 | $testApp->order = 33; |
||
41 | $testApp->name = new \stdClass(); |
||
42 | $testApp->name->en = "testapp"; |
||
43 | |||
44 | $client->request( |
||
45 | 'PUT', |
||
46 | self::REQUEST_URL.'/'.$testApp->id, |
||
47 | array(), |
||
48 | array(), |
||
49 | $headers, |
||
50 | json_encode($testApp) |
||
51 | ); |
||
52 | |||
53 | $response = $client->getResponse(); |
||
54 | |||
55 | $this->assertEquals(204, $response->getStatusCode()); |
||
56 | $this->assertEmpty($response->getContent()); |
||
57 | |||
58 | $client->request( |
||
59 | 'GET', |
||
60 | self::REQUEST_URL.'/'.$testApp->id, |
||
61 | array(), |
||
62 | array(), |
||
63 | $headers |
||
64 | ); |
||
65 | $response = $client->getResponse(); |
||
66 | $content = json_decode($response->getContent()); |
||
67 | $this->assertEquals(200, $response->getStatusCode()); |
||
68 | $this->assertEquals($testApp, $content); |
||
69 | |||
70 | $client->request( |
||
71 | 'DELETE', |
||
72 | self::REQUEST_URL.'/'.$testApp->id, |
||
73 | array(), |
||
74 | array(), |
||
75 | $headers |
||
76 | ); |
||
77 | $response = $client->getResponse(); |
||
78 | $this->assertEquals(204, $response->getStatusCode()); |
||
79 | $this->assertEmpty($response->getContent()); |
||
80 | } |
||
81 | |||
103 |