Conditions | 1 |
Paths | 1 |
Total Lines | 71 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
96 | public function regex(): array |
||
97 | { |
||
98 | return [ |
||
99 | [ |
||
100 | // Windows based |
||
101 | '/microsoft\s(windows)\s(vista|xp)/i' // Windows (iTunes) |
||
102 | ], [self::NAME, self::VERSION], [ |
||
103 | '/(windows)\snt\s6\.2;\s(arm)/i', // Windows RT |
||
104 | '/(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i', // Windows Phone |
||
105 | '/(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i' |
||
106 | ], [self::NAME, [self::VERSION, '__str', 'windows.versions']], [ |
||
107 | '/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i' |
||
108 | ], [[self::NAME, 'Windows'], [self::VERSION, '__str', 'windows.version']], [ |
||
109 | |||
110 | // Mobile/Embedded OS |
||
111 | '/\((bb)(10);/i' // BlackBerry 10 |
||
112 | ], [[self::NAME, 'BlackBerry'], self::VERSION], [ |
||
113 | '/(blackberry)\w*\/?([\w\.]*)/i', // Blackberry |
||
114 | '/(tizen)[\/\s]([\w\.]+)/i', // Tizen |
||
115 | '/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|sailfish|contiki)[\/\s-]?([\w\.]*)/i' |
||
116 | // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki/Sailfish OS |
||
117 | ], [self::NAME, self::VERSION], [ |
||
118 | '/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i' // Symbian |
||
119 | ], [[self::NAME, 'Symbian'], self::VERSION], [ |
||
120 | '/\((series40);/i' // Series 40 |
||
121 | ], [self::NAME], [ |
||
122 | '/mozilla.+\(mobile;.+gecko.+firefox/i' // Firefox OS |
||
123 | ], [[self::NAME, 'Firefox OS'], self::VERSION], [ |
||
124 | |||
125 | // Console |
||
126 | '/(nintendo|playstation)\s([wids34portablevu]+)/i', // Nintendo/Playstation |
||
127 | |||
128 | // GNU/Linux based |
||
129 | '/(mint)[\/\s\(]?(\w*)/i', // Mint |
||
130 | '/(mageia|vectorlinux)[;\s]/i', // Mageia/VectorLinux |
||
131 | '/(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i', |
||
132 | // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware |
||
133 | // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus |
||
134 | '/(hurd|linux)\s?([\w\.]*)/i', // Hurd/Linux |
||
135 | '/(gnu)\s?([\w\.]*)/i' // GNU |
||
136 | ], [self::NAME, self::VERSION], [ |
||
137 | |||
138 | '/(cros)\s[\w]+\s([\w\.]+\w)/i' // Chromium OS |
||
139 | ], [[self::NAME, 'Chromium OS'], self::VERSION], [ |
||
140 | |||
141 | // Solaris |
||
142 | '/(sunos)\s?([\w\.\d]*)/i' // Solaris |
||
143 | ], [[self::NAME, 'Solaris'], self::VERSION], [ |
||
144 | |||
145 | // BSD based |
||
146 | '/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i' // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly |
||
147 | ], [self::NAME, self::VERSION], [ |
||
148 | |||
149 | '/(haiku)\s(\w+)/i' // Haiku |
||
150 | ], [self::NAME, self::VERSION], [ |
||
151 | |||
152 | '/cfnetwork\/.+darwin/i', |
||
153 | '/ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i' // iOS |
||
154 | ], [[self::VERSION, '/_/', '.'], [self::NAME, 'iOS']], [ |
||
155 | |||
156 | '/(mac\sos\sx)\s?([\w\s\.]*)/i', |
||
157 | '/(macintosh|mac(?=_powerpc)\s)/i' // Mac OS |
||
158 | ], [[self::NAME, 'Mac OS'], [self::VERSION, '/_/', '.']], [ |
||
159 | |||
160 | // Other |
||
161 | '/((?:open)?solaris)[\/\s-]?([\w\.]*)/i', // Solaris |
||
162 | '/(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i', // AIX |
||
163 | '/(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms|fuchsia)/i', |
||
164 | // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS/Fuchsia |
||
165 | '/(unix)\s?([\w\.]*)/i' // UNIX |
||
166 | ], [self::NAME, self::VERSION] |
||
167 | ]; |
||
170 |