Conditions | 1 |
Paths | 1 |
Total Lines | 64 |
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 |
||
44 | public function setUp() : void { |
||
45 | parent::setUpExtended('G'); |
||
|
|||
46 | $this->Graph->setDirected(true); |
||
47 | $graph = &$this->Graph; |
||
48 | $dic = $this->dic; |
||
49 | $graph->setAttribute(new Attribute($dic, 'rankdir', 'LR')); |
||
50 | |||
51 | $graph->addChild($nA = new Node($dic, 'a', array( |
||
52 | new Attribute($dic, 'shape', 'plaintext'), |
||
53 | new Attribute($dic, 'label', '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0"> |
||
54 | <TR><TD ROWSPAN="3" BGCOLOR="yellow">class</TD></TR> |
||
55 | <TR><TD PORT="here" BGCOLOR="lightblue">qualifier</TD></TR> |
||
56 | </TABLE>'), |
||
57 | ))); |
||
58 | |||
59 | // Note: subgraph was created after some of its children in Image_GraphViz, |
||
60 | // but Grafizzi lets you only add to existing elements, so it is created |
||
61 | // earlier in this test. |
||
62 | $graph->addChild($subgraph = new Subgraph($dic, 'subgraph', array( |
||
63 | new Attribute($dic, 'title', ''), |
||
64 | new Attribute($dic, 'rank', 'same'), |
||
65 | ))); |
||
66 | $subgraph->addChild($nB = new Node($dic, 'b', array( |
||
67 | new Attribute($dic, 'shape', 'ellipse'), |
||
68 | new Attribute($dic, 'style', 'filled'), |
||
69 | new Attribute($dic, 'label', '<TABLE BGCOLOR="bisque"> |
||
70 | <TR><TD COLSPAN="3">elephant</TD> |
||
71 | <TD ROWSPAN="2" BGCOLOR="chartreuse" |
||
72 | VALIGN="bottom" ALIGN="right">two</TD> </TR> |
||
73 | <TR><TD COLSPAN="2" ROWSPAN="2"> |
||
74 | <TABLE BGCOLOR="grey"> |
||
75 | <TR> <TD>corn</TD> </TR> |
||
76 | <TR> <TD BGCOLOR="yellow">c</TD> </TR> |
||
77 | <TR> <TD>f</TD> </TR> |
||
78 | </TABLE> </TD> |
||
79 | <TD BGCOLOR="white">penguin</TD> |
||
80 | </TR> |
||
81 | <TR> <TD COLSPAN="2" BORDER="4" ALIGN="right" PORT="there">4</TD> </TR> |
||
82 | </TABLE> |
||
83 | '), |
||
84 | ))); |
||
85 | $subgraph->addChild($nC = new Node($dic, 'c', array( |
||
86 | new Attribute($dic, 'shape', 'plaintext'), |
||
87 | new Attribute($dic, 'label', 'long line 1<BR/>line 2<BR ALIGN="LEFT"/>line 3<BR ALIGN="RIGHT"/>'), |
||
88 | ))); |
||
89 | |||
90 | $graph->addChild($edgeBC = new Edge($dic, $nC, $nB)); |
||
91 | |||
92 | $graph->addChild($nD = new Node($dic, 'd', array( |
||
93 | new Attribute($dic, 'shape', 'triangle'), |
||
94 | ))); |
||
95 | |||
96 | $graph->addChild($edgeDC = new Edge($dic, $nD, $nC, array( |
||
97 | new Attribute($dic, 'label', '<TABLE> |
||
98 | <TR><TD BGCOLOR="red" WIDTH="10"> </TD> |
||
99 | <TD>Edge labels<BR/>also</TD> |
||
100 | <TD BGCOLOR="blue" WIDTH="10"> </TD> |
||
101 | </TR> |
||
102 | </TABLE>'), |
||
103 | ))); |
||
104 | $graph->addChild($edgeAB = new Edge($dic, $nA, $nB, array( |
||
105 | new Attribute($dic, 'arrowtail', 'diamond'), |
||
106 | ), 'here', 'there')); |
||
107 | } |
||
108 | |||
156 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.