Conditions | 1 |
Paths | 1 |
Total Lines | 89 |
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 |
||
55 | public function ua_provider() { |
||
56 | return array( |
||
57 | |||
58 | // Nokia 6300, dumb phone. |
||
59 | array( |
||
60 | 'Nokia6300/2.0 (05.00) Profile/MIDP-2.0 Configuration/CLDC-1.1', |
||
61 | array( |
||
62 | 'is_phone', |
||
63 | 'is_handheld', |
||
64 | ), |
||
65 | 'nokia', |
||
66 | ), |
||
67 | |||
68 | // Samsung Galaxy S8 smart phone. |
||
69 | array( |
||
70 | 'Mozilla/5.0 (Linux; Android 9; SM-G950F Build/PPR1.180610.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.157 Mobile Safari/537.36', |
||
71 | array( |
||
72 | 'is_phone', |
||
73 | 'is_smartphone', |
||
74 | 'is_handheld', |
||
75 | ), |
||
76 | 'android', |
||
77 | ), |
||
78 | |||
79 | // iPhone X smart phone. |
||
80 | array( |
||
81 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1', |
||
82 | array( |
||
83 | 'is_phone', |
||
84 | 'is_smartphone', |
||
85 | 'is_handheld', |
||
86 | ), |
||
87 | 'iphone', |
||
88 | ), |
||
89 | |||
90 | // iPad 2 10.5 tablet. |
||
91 | array( |
||
92 | 'Mozilla/5.0 (iPad; CPU OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15G77 [FBAN/FBIOS;FBDV/iPad7,3;FBMD/iPad;FBSN/iOS;FBSV/11.4.1;FBSS/2;FBCR/;FBID/tablet;FBLC/en_US;FBOP/5;FBRV/0]', |
||
93 | array( |
||
94 | 'is_tablet', |
||
95 | 'is_handheld', |
||
96 | ), |
||
97 | false, |
||
98 | ), |
||
99 | |||
100 | // Kindle 3. |
||
101 | array( |
||
102 | 'Mozilla/5.0 (X11; U; Linux armv7l like Android; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/533.2+ Kindle/3.0+', |
||
103 | array( |
||
104 | 'is_phone', |
||
105 | 'is_smartphone', |
||
106 | 'is_tablet', |
||
107 | 'is_handheld', |
||
108 | ), |
||
109 | 'android', |
||
110 | ), |
||
111 | |||
112 | // Huawei p20 smartphone. |
||
113 | array( |
||
114 | 'Mozilla/5.0 (Linux; Android 8.1.0; CLT-L09 Build/HUAWEICLT-L09) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36', |
||
115 | array( |
||
116 | 'is_phone', |
||
117 | 'is_smartphone', |
||
118 | 'is_handheld', |
||
119 | ), |
||
120 | 'android', |
||
121 | ), |
||
122 | |||
123 | // Googlebot smartphone. |
||
124 | array( |
||
125 | 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z‡ Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', |
||
126 | array( |
||
127 | 'is_phone', |
||
128 | 'is_smartphone', |
||
129 | 'is_handheld', |
||
130 | ), |
||
131 | 'android', |
||
132 | ), |
||
133 | |||
134 | // Googlebot desktop. |
||
135 | array( |
||
136 | 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', |
||
137 | array( |
||
138 | 'is_desktop', |
||
139 | ), |
||
140 | false, |
||
141 | ), |
||
142 | ); |
||
143 | } |
||
144 | } |
||
145 |