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