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 |
||
37 | private function print_styles(){?> |
||
38 | |||
39 | <style> |
||
40 | @media screen and (min-width: 59.6875em){ |
||
41 | #main article.lesson, |
||
42 | #main article.course, |
||
43 | #main #post-entries, |
||
44 | .sensei-breadcrumb { |
||
45 | padding-top: 8.3333%; |
||
46 | margin: 0 8.3333%; |
||
47 | box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); |
||
48 | background-color: #fff; |
||
49 | padding: 1em 2em 2em; |
||
50 | } |
||
51 | |||
52 | #main .course-lessons .lesson { |
||
53 | margin: 0; |
||
54 | } |
||
55 | |||
56 | #main #post-entries { |
||
57 | padding: 1em 2em; |
||
58 | overflow: hidden; |
||
59 | } |
||
60 | |||
61 | #main article.lesson ol { |
||
62 | list-style-position: inside; |
||
63 | } |
||
64 | |||
65 | .sensei-course-filters { |
||
66 | margin: 0 8.3333%; |
||
67 | padding: 0; |
||
68 | box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); |
||
69 | background: white; |
||
70 | padding: 2%; |
||
71 | } |
||
72 | |||
73 | .sensei-ordering { |
||
74 | text-align: right; |
||
75 | float: right; |
||
76 | margin: 0 8.3333%; |
||
77 | padding: 2%; |
||
78 | } |
||
79 | .archive-header h1{ |
||
80 | padding: 2%; |
||
81 | background: white; |
||
82 | margin: 2% 8.3333%; |
||
83 | } |
||
84 | |||
85 | nav.sensei-pagination, .post-type-archive .course-container li{ |
||
86 | padding: 2% !important; |
||
87 | background: white !important; |
||
88 | margin: 2% 8.3333% !important; |
||
89 | width: 83.333% !important |
||
90 | } |
||
91 | |||
92 | nav.sensei-pagination{ |
||
93 | text-align: center; |
||
94 | } |
||
95 | |||
96 | nav.sensei-pagination .page-numbers{ |
||
97 | margin-bottom: 0; |
||
98 | } |
||
99 | nav.sensei-pagination li a, |
||
100 | nav.sensei-pagination li span.current { |
||
101 | display: block; |
||
102 | border: 2px solid #ddd; |
||
103 | margin-right: 2px; |
||
104 | padding: 0.2em 0.5em; |
||
105 | background: #eee; |
||
106 | } |
||
107 | |||
108 | nav.sensei-pagination li span.current{ |
||
109 | background: white; |
||
110 | } |
||
111 | } |
||
112 | </style> |
||
113 | |||
114 | <?php } |
||
115 | |||
117 |
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: