Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
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 |
||
43 | public function setUp() : void { |
||
44 | // not strict by default. |
||
45 | parent::setUpExtended(); |
||
|
|||
46 | $g = $this->Graph; |
||
47 | $dic = $this->dic; |
||
48 | $g->setDirected(true); |
||
49 | $g->setAttributes(array( |
||
50 | new Attribute($dic, 'nodesep', 0.05), |
||
51 | new Attribute($dic, 'rankdir', 'LR'), |
||
52 | )); |
||
53 | |||
54 | $recordShape = new Attribute($dic, 'shape', 'record'); |
||
55 | |||
56 | $g->addChild($node0 = new Node($dic, 'node0', array( |
||
57 | $recordShape, |
||
58 | new Attribute($dic, 'label', '<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> | '), |
||
59 | new Attribute($dic, 'height', 2.5), |
||
60 | ))); |
||
61 | $g->addChild($node1 = new Node($dic, 'node1', array( |
||
62 | $recordShape, |
||
63 | new Attribute($dic, 'label', '{<n> n14 | 719 |<p> }'), |
||
64 | ))); |
||
65 | $g->addChild($node2 = new Node($dic, 'node2', array( |
||
66 | $recordShape, |
||
67 | new Attribute($dic, 'label', '{<n> a1 | 805 |<p> }'), |
||
68 | ))); |
||
69 | $g->addChild($node3 = new Node($dic, 'node3', array( |
||
70 | $recordShape, |
||
71 | new Attribute($dic, 'label', '{<n> i9 | 718 |<p> }'), |
||
72 | ))); |
||
73 | $g->addChild($node4 = new Node($dic, 'node4', array( |
||
74 | $recordShape, |
||
75 | new Attribute($dic, 'label', '{<n> e5 | 989 |<p> }'), |
||
76 | ))); |
||
77 | $g->addChild($node5 = new Node($dic, 'node5', array( |
||
78 | $recordShape, |
||
79 | new Attribute($dic, 'label', '{<n> t20 | 959 |<p> }'), |
||
80 | ))); |
||
81 | $g->addChild($node6 = new Node($dic, 'node6', array( |
||
82 | $recordShape, |
||
83 | new Attribute($dic, 'label', '{<n> o15 | 794 |<p> }'), |
||
84 | ))); |
||
85 | $g->addChild($node7 = new Node($dic, 'node7', array( |
||
86 | $recordShape, |
||
87 | new Attribute($dic, 'label', '{<n> s19 | 659 |<p> }'), |
||
88 | ))); |
||
89 | |||
90 | $nullTitle = array( |
||
91 | new Attribute($dic, 'title', null), |
||
92 | ); |
||
93 | $g->addChild(new Edge($dic, $node0, $node1, $nullTitle, 'f0', 'n')); |
||
94 | $g->addChild(new Edge($dic, $node0, $node2, $nullTitle, 'f1', 'n')); |
||
95 | $g->addChild(new Edge($dic, $node0, $node3, $nullTitle, 'f2', 'n')); |
||
96 | $g->addChild(new Edge($dic, $node0, $node4, $nullTitle, 'f5', 'n')); |
||
97 | $g->addChild(new Edge($dic, $node0, $node5, $nullTitle, 'f6', 'n')); |
||
98 | $g->addChild(new Edge($dic, $node2, $node6, $nullTitle, 'p', 'n')); |
||
99 | $g->addChild(new Edge($dic, $node4, $node7, $nullTitle, 'p', 'n')); |
||
100 | } |
||
101 | |||
132 |
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.