Code Duplication    Length = 11-12 lines in 10 locations

src/OsDetector.php 10 locations

@@ 235-245 (lines=11) @@
232
     *
233
     * @return bool
234
     */
235
    private static function checkLinux(Os $os, UserAgent $userAgent)
236
    {
237
        if (stripos($userAgent->getUserAgentString(), 'Linux') !== false) {
238
            $os->setVersion($os::VERSION_UNKNOWN);
239
            $os->setName($os::LINUX);
240
241
            return true;
242
        }
243
244
        return false;
245
    }
246
247
    /**
248
     * Determine if the user's operating system is Nokia.
@@ 255-266 (lines=12) @@
252
     *
253
     * @return bool
254
     */
255
    private static function checkNokia(Os $os, UserAgent $userAgent)
256
    {
257
        if (stripos($userAgent->getUserAgentString(), 'Nokia') !== false) {
258
            $os->setVersion($os::VERSION_UNKNOWN);
259
            $os->setName($os::NOKIA);
260
            $os->setIsMobile(true);
261
262
            return true;
263
        }
264
265
        return false;
266
    }
267
268
    /**
269
     * Determine if the user's operating system is BlackBerry.
@@ 276-287 (lines=12) @@
273
     *
274
     * @return bool
275
     */
276
    private static function checkBlackBerry(Os $os, UserAgent $userAgent)
277
    {
278
        if (stripos($userAgent->getUserAgentString(), 'BlackBerry') !== false) {
279
            $os->setVersion($os::VERSION_UNKNOWN);
280
            $os->setName($os::BLACKBERRY);
281
            $os->setIsMobile(true);
282
283
            return true;
284
        }
285
286
        return false;
287
    }
288
289
    /**
290
     * Determine if the user's operating system is Android.
@@ 324-334 (lines=11) @@
321
     *
322
     * @return bool
323
     */
324
    private static function checkFreeBSD(Os $os, UserAgent $userAgent)
325
    {
326
        if (stripos($userAgent->getUserAgentString(), 'FreeBSD') !== false) {
327
            $os->setVersion($os::VERSION_UNKNOWN);
328
            $os->setName($os::FREEBSD);
329
330
            return true;
331
        }
332
333
        return false;
334
    }
335
336
    /**
337
     * Determine if the user's operating system is OpenBSD.
@@ 344-354 (lines=11) @@
341
     *
342
     * @return bool
343
     */
344
    private static function checkOpenBSD(Os $os, UserAgent $userAgent)
345
    {
346
        if (stripos($userAgent->getUserAgentString(), 'OpenBSD') !== false) {
347
            $os->setVersion($os::VERSION_UNKNOWN);
348
            $os->setName($os::OPENBSD);
349
350
            return true;
351
        }
352
353
        return false;
354
    }
355
356
    /**
357
     * Determine if the user's operating system is SunOS.
@@ 364-374 (lines=11) @@
361
     *
362
     * @return bool
363
     */
364
    private static function checkSunOS(Os $os, UserAgent $userAgent)
365
    {
366
        if (stripos($userAgent->getUserAgentString(), 'SunOS') !== false) {
367
            $os->setVersion($os::VERSION_UNKNOWN);
368
            $os->setName($os::SUNOS);
369
370
            return true;
371
        }
372
373
        return false;
374
    }
375
376
    /**
377
     * Determine if the user's operating system is NetBSD.
@@ 384-394 (lines=11) @@
381
     *
382
     * @return bool
383
     */
384
    private static function checkNetBSD(Os $os, UserAgent $userAgent)
385
    {
386
        if (stripos($userAgent->getUserAgentString(), 'NetBSD') !== false) {
387
            $os->setVersion($os::VERSION_UNKNOWN);
388
            $os->setName($os::NETBSD);
389
390
            return true;
391
        }
392
393
        return false;
394
    }
395
396
    /**
397
     * Determine if the user's operating system is OpenSolaris.
@@ 404-414 (lines=11) @@
401
     *
402
     * @return bool
403
     */
404
    private static function checkOpenSolaris(Os $os, UserAgent $userAgent)
405
    {
406
        if (stripos($userAgent->getUserAgentString(), 'OpenSolaris') !== false) {
407
            $os->setVersion($os::VERSION_UNKNOWN);
408
            $os->setName($os::OPENSOLARIS);
409
410
            return true;
411
        }
412
413
        return false;
414
    }
415
416
    /**
417
     * Determine if the user's operating system is OS2.
@@ 424-434 (lines=11) @@
421
     *
422
     * @return bool
423
     */
424
    private static function checkOS2(Os $os, UserAgent $userAgent)
425
    {
426
        if (stripos($userAgent->getUserAgentString(), 'OS\/2') !== false) {
427
            $os->setVersion($os::VERSION_UNKNOWN);
428
            $os->setName($os::OS2);
429
430
            return true;
431
        }
432
433
        return false;
434
    }
435
436
    /**
437
     * Determine if the user's operating system is BeOS.
@@ 444-454 (lines=11) @@
441
     *
442
     * @return bool
443
     */
444
    private static function checkBeOS(Os $os, UserAgent $userAgent)
445
    {
446
        if (stripos($userAgent->getUserAgentString(), 'BeOS') !== false) {
447
            $os->setVersion($os::VERSION_UNKNOWN);
448
            $os->setName($os::BEOS);
449
450
            return true;
451
        }
452
453
        return false;
454
    }
455
}
456