Conditions | 1 |
Paths | 1 |
Total Lines | 63 |
Code Lines | 42 |
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 |
||
12 | public function testBuilder(): void |
||
13 | { |
||
14 | /* Assertion 1 */ |
||
15 | $query = 'EXPLAIN SELECT * FROM test;'; |
||
16 | $parser = new Parser($query); |
||
17 | $stmt = $parser->statements[0]; |
||
18 | $this->assertEquals( |
||
19 | 'EXPLAIN SELECT * FROM test', |
||
20 | $stmt->build() |
||
21 | ); |
||
22 | |||
23 | /* Assertion 2 */ |
||
24 | $query = 'EXPLAIN ANALYZE SELECT * FROM tablename;'; |
||
25 | $parser = new Parser($query); |
||
26 | $stmt = $parser->statements[0]; |
||
27 | $this->assertEquals( |
||
28 | 'EXPLAIN ANALYZE SELECT * FROM tablename', |
||
29 | $stmt->build() |
||
30 | ); |
||
31 | |||
32 | /* Assertion 3 */ |
||
33 | $query = 'DESC ANALYZE SELECT * FROM tablename;'; |
||
34 | $parser = new Parser($query); |
||
35 | $stmt = $parser->statements[0]; |
||
36 | $this->assertEquals( |
||
37 | 'DESC ANALYZE SELECT * FROM tablename', |
||
38 | $stmt->build() |
||
39 | ); |
||
40 | |||
41 | /* Assertion 4 */ |
||
42 | $query = 'ANALYZE SELECT * FROM tablename;'; |
||
43 | $parser = new Parser($query); |
||
44 | $stmt = $parser->statements[0]; |
||
45 | $this->assertEquals( |
||
46 | 'ANALYZE SELECT * FROM tablename', |
||
47 | $stmt->build() |
||
48 | ); |
||
49 | |||
50 | /* Assertion 5 */ |
||
51 | $query = 'DESCRIBE tablename;'; |
||
52 | $parser = new Parser($query); |
||
53 | $stmt = $parser->statements[0]; |
||
54 | $this->assertEquals( |
||
55 | 'DESCRIBE tablename', |
||
56 | $stmt->build() |
||
57 | ); |
||
58 | |||
59 | /* Assertion 6 */ |
||
60 | $query = 'DESC FOR CONNECTION 458'; |
||
61 | $parser = new Parser($query); |
||
62 | $stmt = $parser->statements[0]; |
||
63 | $this->assertEquals( |
||
64 | 'DESC FOR CONNECTION 458', |
||
65 | $stmt->build() |
||
66 | ); |
||
67 | |||
68 | /* Assertion 6 */ |
||
69 | $query = 'EXPLAIN FORMAT=TREE SELECT * FROM db;'; |
||
70 | $parser = new Parser($query); |
||
71 | $stmt = $parser->statements[0]; |
||
72 | $this->assertEquals( |
||
73 | 'EXPLAIN FORMAT=TREE SELECT * FROM db', |
||
74 | $stmt->build() |
||
75 | ); |
||
78 |