Conditions | 1 |
Paths | 1 |
Total Lines | 78 |
Code Lines | 3 |
Lines | 0 |
Ratio | 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 |
||
33 | private function print_styles(){?> |
||
34 | |||
35 | <style> |
||
36 | @media screen and (min-width: 59.6875em){ |
||
37 | #main article.lesson, |
||
38 | #main article.course, |
||
39 | #main #post-entries, |
||
40 | .sensei-breadcrumb { |
||
41 | padding-top: 8.3333%; |
||
42 | margin: 0 8.3333%; |
||
43 | box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); |
||
44 | background-color: #fff; |
||
45 | padding: 1em 2em 2em; |
||
46 | } |
||
47 | |||
48 | #main .course-lessons .lesson { |
||
49 | margin: 0; |
||
50 | } |
||
51 | |||
52 | #main #post-entries { |
||
53 | padding: 1em 2em; |
||
54 | overflow: hidden; |
||
55 | } |
||
56 | |||
57 | #main article.lesson ol { |
||
58 | list-style-position: inside; |
||
59 | } |
||
60 | |||
61 | .sensei-course-filters { |
||
62 | margin: 0 8.3333%; |
||
63 | padding: 0; |
||
64 | box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); |
||
65 | background: white; |
||
66 | padding: 2%; |
||
67 | } |
||
68 | |||
69 | .sensei-ordering { |
||
70 | text-align: right; |
||
71 | float: right; |
||
72 | margin: 0 8.3333%; |
||
73 | padding: 2%; |
||
74 | } |
||
75 | .archive-header h1{ |
||
76 | padding: 2%; |
||
77 | background: white; |
||
78 | margin: 2% 8.3333%; |
||
79 | } |
||
80 | |||
81 | nav.sensei-pagination, .post-type-archive .course-container li{ |
||
82 | padding: 2% !important; |
||
83 | background: white !important; |
||
84 | margin: 2% 8.3333% !important; |
||
85 | width: 83.333% !important |
||
86 | } |
||
87 | |||
88 | nav.sensei-pagination{ |
||
89 | text-align: center; |
||
90 | } |
||
91 | |||
92 | nav.sensei-pagination .page-numbers{ |
||
93 | margin-bottom: 0; |
||
94 | } |
||
95 | nav.sensei-pagination li a, |
||
96 | nav.sensei-pagination li span.current { |
||
97 | display: block; |
||
98 | border: 2px solid #ddd; |
||
99 | margin-right: 2px; |
||
100 | padding: 0.2em 0.5em; |
||
101 | background: #eee; |
||
102 | } |
||
103 | |||
104 | nav.sensei-pagination li span.current{ |
||
105 | background: white; |
||
106 | } |
||
107 | } |
||
108 | </style> |
||
109 | |||
110 | <?php } |
||
111 | |||
113 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: