Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
11 | public function testCommandStack() |
||
12 | { |
||
13 | $stack = new CommandStack(); |
||
14 | |||
15 | $command1 = $this->createCommand(); |
||
16 | $command2 = $this->createCommand(); |
||
17 | $command3 = $this->createCommand(); |
||
18 | |||
19 | $this->assertEquals(null, $stack->getCurrentCommand()); |
||
20 | $this->assertEquals(null, $stack->getMasterCommand()); |
||
21 | $this->assertEquals(null, $stack->getParentCommand()); |
||
22 | $this->assertEquals(null, $stack->pop()); |
||
23 | |||
24 | $stack->push($command1); |
||
25 | |||
26 | $this->assertEquals($command1, $stack->getCurrentCommand()); |
||
27 | $this->assertEquals($command1, $stack->getMasterCommand()); |
||
28 | $this->assertEquals(null, $stack->getParentCommand()); |
||
29 | |||
30 | $stack->push($command2); |
||
31 | |||
32 | $this->assertEquals($command2, $stack->getCurrentCommand()); |
||
33 | $this->assertEquals($command1, $stack->getMasterCommand()); |
||
34 | $this->assertEquals($command1, $stack->getParentCommand()); |
||
35 | |||
36 | $stack->push($command3); |
||
37 | |||
38 | $this->assertEquals($command3, $stack->getCurrentCommand()); |
||
39 | $this->assertEquals($command1, $stack->getMasterCommand()); |
||
40 | $this->assertEquals($command2, $stack->getParentCommand()); |
||
41 | |||
42 | $this->assertEquals($command3, $stack->pop()); |
||
43 | $this->assertEquals($command2, $stack->getCurrentCommand()); |
||
44 | $this->assertEquals($command1, $stack->getMasterCommand()); |
||
45 | $this->assertEquals($command1, $stack->getParentCommand()); |
||
46 | |||
47 | $this->assertEquals($command2, $stack->pop()); |
||
48 | $this->assertEquals($command1, $stack->getCurrentCommand()); |
||
49 | $this->assertEquals($command1, $stack->getMasterCommand()); |
||
50 | $this->assertEquals(null, $stack->getParentCommand()); |
||
51 | |||
52 | $this->assertEquals($command1, $stack->pop()); |
||
53 | $this->assertEquals(null, $stack->getCurrentCommand()); |
||
54 | $this->assertEquals(null, $stack->getMasterCommand()); |
||
55 | $this->assertEquals(null, $stack->getParentCommand()); |
||
56 | |||
57 | $this->assertEquals(null, $stack->pop()); |
||
58 | $this->assertEquals(null, $stack->getCurrentCommand()); |
||
59 | $this->assertEquals(null, $stack->getMasterCommand()); |
||
60 | $this->assertEquals(null, $stack->getParentCommand()); |
||
61 | } |
||
62 | |||
72 |