Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 40 |
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 |
||
37 | public function testValidateMinWordLength() |
||
38 | { |
||
39 | $in = '+test -fooo'; |
||
40 | $S = new SimpleSearchString($in); |
||
41 | $result = $S->validateLength(); |
||
42 | $this->assertTrue($result); |
||
43 | |||
44 | $in = '+tes -foo'; |
||
45 | $S = new SimpleSearchString($in); |
||
46 | $result = $S->validateLength(); |
||
47 | $this->assertFalse($result); |
||
48 | |||
49 | $in = 'test +foo'; |
||
50 | $S = new SimpleSearchString($in); |
||
51 | $result = $S->validateLength(); |
||
52 | $this->assertFalse($result); |
||
53 | |||
54 | $in = 'wm-foo'; |
||
55 | $S = new SimpleSearchString($in); |
||
56 | $result = $S->validateLength(); |
||
57 | $this->assertTrue($result); |
||
58 | |||
59 | $in = 'w-m'; |
||
60 | $S = new SimpleSearchString($in); |
||
61 | $result = $S->validateLength(); |
||
62 | $this->assertFalse($result); |
||
63 | |||
64 | $in = 'wmf'; |
||
65 | $S = new SimpleSearchString($in); |
||
66 | $result = $S->validateLength(); |
||
67 | $this->assertFalse($result); |
||
68 | |||
69 | $in = ''; |
||
70 | $S = new SimpleSearchString($in); |
||
71 | $result = $S->validateLength(); |
||
72 | $this->assertFalse($result); |
||
73 | |||
74 | $in = 'wm foo'; |
||
75 | $S = new SimpleSearchString($in); |
||
76 | $result = $S->validateLength(); |
||
77 | $this->assertFalse($result); |
||
78 | |||
79 | $in = '"wm foo'; |
||
80 | $S = new SimpleSearchString($in); |
||
81 | $result = $S->validateLength(); |
||
82 | $this->assertFalse($result); |
||
83 | |||
84 | $in = '"wm foo"'; |
||
85 | $S = new SimpleSearchString($in); |
||
86 | $result = $S->validateLength(); |
||
87 | $this->assertTrue($result); |
||
88 | } |
||
90 |