Conditions | 1 |
Paths | 1 |
Total Lines | 91 |
Code Lines | 48 |
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 |
||
63 | public function __construct() |
||
64 | { |
||
65 | $this->userAgent = get_request()->getHeaderLine('user-agent'); |
||
66 | |||
67 | $this->allowedList = [ |
||
68 | |||
69 | // Search engline: Google. |
||
70 | 'google_1' => [ |
||
71 | 'userAgent' => 'google', |
||
72 | 'rdns' => '.googlebot.com', |
||
73 | ], |
||
74 | |||
75 | 'google_2' => [ |
||
76 | 'userAgent' => 'google', |
||
77 | 'rdns' => '.google.com', |
||
78 | ], |
||
79 | |||
80 | // Search engline: Mircosoft. |
||
81 | 'bing_1' => [ |
||
82 | 'userAgent' => 'live', |
||
83 | 'rdns' => '.live.com', |
||
84 | ], |
||
85 | |||
86 | 'bing_2' => [ |
||
87 | 'userAgent' => 'msn', |
||
88 | 'rdns' => '.msn.com', |
||
89 | ], |
||
90 | |||
91 | 'bing_3' => [ |
||
92 | 'userAgent' => 'bing', |
||
93 | 'rdns' => '.bing.com', |
||
94 | ], |
||
95 | |||
96 | // Search engline: Yahoo. |
||
97 | 'yahoo_1' => [ |
||
98 | 'userAgent' => 'inktomisearch', |
||
99 | 'rdns' => '.inktomisearch.com', |
||
100 | ], |
||
101 | |||
102 | 'yahoo_2' => [ |
||
103 | 'userAgent' => 'yahoo', |
||
104 | 'rdns' => '.yahoo.com', |
||
105 | ], |
||
106 | |||
107 | 'yahoo_3' => [ |
||
108 | 'userAgent' => 'yahoo', |
||
109 | 'rdns' => '.yahoo.net', |
||
110 | ], |
||
111 | |||
112 | // Search engine: Yandex. |
||
113 | 'yandex_1' => [ |
||
114 | 'userAgent' => 'yandex', |
||
115 | 'rdns' => '.yandex.com', |
||
116 | ], |
||
117 | |||
118 | 'yandex_2' => [ |
||
119 | 'userAgent' => 'yandex', |
||
120 | 'rdns' => '.yandex.net', |
||
121 | ], |
||
122 | |||
123 | 'yandex_3' => [ |
||
124 | 'userAgent' => 'yandex', |
||
125 | 'rdns' => '.yandex.ru', |
||
126 | ], |
||
127 | |||
128 | // Facebook crawlers. |
||
129 | 'facebook' => [ |
||
130 | 'userAgent' => 'facebook', |
||
131 | 'rdns' => '.fbsv.net', |
||
132 | ], |
||
133 | |||
134 | // Twitter crawlers. |
||
135 | 'twitter' => [ |
||
136 | 'userAgent' => 'Twitterbot', |
||
137 | 'rdns' => '.twttr.com', // (not twitter.com) |
||
138 | ], |
||
139 | |||
140 | // W3C validation services. |
||
141 | 'w3' => [ |
||
142 | 'userAgent' => 'w3.org', |
||
143 | 'rdns' => '.w3.org', |
||
144 | ], |
||
145 | |||
146 | // Ask.com crawlers. |
||
147 | 'ask' => [ |
||
148 | 'userAgent' => 'ask', |
||
149 | 'rdns' => '.ask.com', |
||
150 | ], |
||
151 | ]; |
||
152 | |||
153 | $this->deniedList = []; |
||
154 | } |
||
304 | } |