Code Duplication    Length = 11-12 lines in 10 locations

src/OsDetector.php 10 locations

@@ 265-275 (lines=11) @@
262
     *
263
     * @return bool
264
     */
265
    private static function checkLinux(Os $os, UserAgent $userAgent)
266
    {
267
        if (stripos($userAgent->getUserAgentString(), 'Linux') !== false) {
268
            $os->setVersion($os::VERSION_UNKNOWN);
269
            $os->setName($os::LINUX);
270
271
            return true;
272
        }
273
274
        return false;
275
    }
276
277
    /**
278
     * Determine if the user's operating system is Nokia.
@@ 285-296 (lines=12) @@
282
     *
283
     * @return bool
284
     */
285
    private static function checkNokia(Os $os, UserAgent $userAgent)
286
    {
287
        if (stripos($userAgent->getUserAgentString(), 'Nokia') !== false) {
288
            $os->setVersion($os::VERSION_UNKNOWN);
289
            $os->setName($os::NOKIA);
290
            $os->setIsMobile(true);
291
292
            return true;
293
        }
294
295
        return false;
296
    }
297
298
    /**
299
     * Determine if the user's operating system is BlackBerry.
@@ 306-317 (lines=12) @@
303
     *
304
     * @return bool
305
     */
306
    private static function checkBlackBerry(Os $os, UserAgent $userAgent)
307
    {
308
        if (stripos($userAgent->getUserAgentString(), 'BlackBerry') !== false) {
309
            $os->setVersion($os::VERSION_UNKNOWN);
310
            $os->setName($os::BLACKBERRY);
311
            $os->setIsMobile(true);
312
313
            return true;
314
        }
315
316
        return false;
317
    }
318
319
    /**
320
     * Determine if the user's operating system is Android.
@@ 354-364 (lines=11) @@
351
     *
352
     * @return bool
353
     */
354
    private static function checkFreeBSD(Os $os, UserAgent $userAgent)
355
    {
356
        if (stripos($userAgent->getUserAgentString(), 'FreeBSD') !== false) {
357
            $os->setVersion($os::VERSION_UNKNOWN);
358
            $os->setName($os::FREEBSD);
359
360
            return true;
361
        }
362
363
        return false;
364
    }
365
366
    /**
367
     * Determine if the user's operating system is OpenBSD.
@@ 374-384 (lines=11) @@
371
     *
372
     * @return bool
373
     */
374
    private static function checkOpenBSD(Os $os, UserAgent $userAgent)
375
    {
376
        if (stripos($userAgent->getUserAgentString(), 'OpenBSD') !== false) {
377
            $os->setVersion($os::VERSION_UNKNOWN);
378
            $os->setName($os::OPENBSD);
379
380
            return true;
381
        }
382
383
        return false;
384
    }
385
386
    /**
387
     * Determine if the user's operating system is SunOS.
@@ 394-404 (lines=11) @@
391
     *
392
     * @return bool
393
     */
394
    private static function checkSunOS(Os $os, UserAgent $userAgent)
395
    {
396
        if (stripos($userAgent->getUserAgentString(), 'SunOS') !== false) {
397
            $os->setVersion($os::VERSION_UNKNOWN);
398
            $os->setName($os::SUNOS);
399
400
            return true;
401
        }
402
403
        return false;
404
    }
405
406
    /**
407
     * Determine if the user's operating system is NetBSD.
@@ 414-424 (lines=11) @@
411
     *
412
     * @return bool
413
     */
414
    private static function checkNetBSD(Os $os, UserAgent $userAgent)
415
    {
416
        if (stripos($userAgent->getUserAgentString(), 'NetBSD') !== false) {
417
            $os->setVersion($os::VERSION_UNKNOWN);
418
            $os->setName($os::NETBSD);
419
420
            return true;
421
        }
422
423
        return false;
424
    }
425
426
    /**
427
     * Determine if the user's operating system is OpenSolaris.
@@ 434-444 (lines=11) @@
431
     *
432
     * @return bool
433
     */
434
    private static function checkOpenSolaris(Os $os, UserAgent $userAgent)
435
    {
436
        if (stripos($userAgent->getUserAgentString(), 'OpenSolaris') !== false) {
437
            $os->setVersion($os::VERSION_UNKNOWN);
438
            $os->setName($os::OPENSOLARIS);
439
440
            return true;
441
        }
442
443
        return false;
444
    }
445
446
    /**
447
     * Determine if the user's operating system is OS2.
@@ 454-464 (lines=11) @@
451
     *
452
     * @return bool
453
     */
454
    private static function checkOS2(Os $os, UserAgent $userAgent)
455
    {
456
        if (stripos($userAgent->getUserAgentString(), 'OS\/2') !== false) {
457
            $os->setVersion($os::VERSION_UNKNOWN);
458
            $os->setName($os::OS2);
459
460
            return true;
461
        }
462
463
        return false;
464
    }
465
466
    /**
467
     * Determine if the user's operating system is BeOS.
@@ 474-484 (lines=11) @@
471
     *
472
     * @return bool
473
     */
474
    private static function checkBeOS(Os $os, UserAgent $userAgent)
475
    {
476
        if (stripos($userAgent->getUserAgentString(), 'BeOS') !== false) {
477
            $os->setVersion($os::VERSION_UNKNOWN);
478
            $os->setName($os::BEOS);
479
480
            return true;
481
        }
482
483
        return false;
484
    }
485
}
486