Code Duplication    Length = 11-12 lines in 10 locations

src/OsDetector.php 10 locations

@@ 258-268 (lines=11) @@
255
     *
256
     * @return bool
257
     */
258
    private static function checkLinux(Os $os, UserAgent $userAgent)
259
    {
260
        if (stripos($userAgent->getUserAgentString(), 'Linux') !== false) {
261
            $os->setVersion($os::VERSION_UNKNOWN);
262
            $os->setName($os::LINUX);
263
264
            return true;
265
        }
266
267
        return false;
268
    }
269
270
    /**
271
     * Determine if the user's operating system is Nokia.
@@ 278-289 (lines=12) @@
275
     *
276
     * @return bool
277
     */
278
    private static function checkNokia(Os $os, UserAgent $userAgent)
279
    {
280
        if (stripos($userAgent->getUserAgentString(), 'Nokia') !== false) {
281
            $os->setVersion($os::VERSION_UNKNOWN);
282
            $os->setName($os::NOKIA);
283
            $os->setIsMobile(true);
284
285
            return true;
286
        }
287
288
        return false;
289
    }
290
291
    /**
292
     * Determine if the user's operating system is BlackBerry.
@@ 299-310 (lines=12) @@
296
     *
297
     * @return bool
298
     */
299
    private static function checkBlackBerry(Os $os, UserAgent $userAgent)
300
    {
301
        if (stripos($userAgent->getUserAgentString(), 'BlackBerry') !== false) {
302
            $os->setVersion($os::VERSION_UNKNOWN);
303
            $os->setName($os::BLACKBERRY);
304
            $os->setIsMobile(true);
305
306
            return true;
307
        }
308
309
        return false;
310
    }
311
312
    /**
313
     * Determine if the user's operating system is Android.
@@ 347-357 (lines=11) @@
344
     *
345
     * @return bool
346
     */
347
    private static function checkFreeBSD(Os $os, UserAgent $userAgent)
348
    {
349
        if (stripos($userAgent->getUserAgentString(), 'FreeBSD') !== false) {
350
            $os->setVersion($os::VERSION_UNKNOWN);
351
            $os->setName($os::FREEBSD);
352
353
            return true;
354
        }
355
356
        return false;
357
    }
358
359
    /**
360
     * Determine if the user's operating system is OpenBSD.
@@ 367-377 (lines=11) @@
364
     *
365
     * @return bool
366
     */
367
    private static function checkOpenBSD(Os $os, UserAgent $userAgent)
368
    {
369
        if (stripos($userAgent->getUserAgentString(), 'OpenBSD') !== false) {
370
            $os->setVersion($os::VERSION_UNKNOWN);
371
            $os->setName($os::OPENBSD);
372
373
            return true;
374
        }
375
376
        return false;
377
    }
378
379
    /**
380
     * Determine if the user's operating system is SunOS.
@@ 387-397 (lines=11) @@
384
     *
385
     * @return bool
386
     */
387
    private static function checkSunOS(Os $os, UserAgent $userAgent)
388
    {
389
        if (stripos($userAgent->getUserAgentString(), 'SunOS') !== false) {
390
            $os->setVersion($os::VERSION_UNKNOWN);
391
            $os->setName($os::SUNOS);
392
393
            return true;
394
        }
395
396
        return false;
397
    }
398
399
    /**
400
     * Determine if the user's operating system is NetBSD.
@@ 407-417 (lines=11) @@
404
     *
405
     * @return bool
406
     */
407
    private static function checkNetBSD(Os $os, UserAgent $userAgent)
408
    {
409
        if (stripos($userAgent->getUserAgentString(), 'NetBSD') !== false) {
410
            $os->setVersion($os::VERSION_UNKNOWN);
411
            $os->setName($os::NETBSD);
412
413
            return true;
414
        }
415
416
        return false;
417
    }
418
419
    /**
420
     * Determine if the user's operating system is OpenSolaris.
@@ 427-437 (lines=11) @@
424
     *
425
     * @return bool
426
     */
427
    private static function checkOpenSolaris(Os $os, UserAgent $userAgent)
428
    {
429
        if (stripos($userAgent->getUserAgentString(), 'OpenSolaris') !== false) {
430
            $os->setVersion($os::VERSION_UNKNOWN);
431
            $os->setName($os::OPENSOLARIS);
432
433
            return true;
434
        }
435
436
        return false;
437
    }
438
439
    /**
440
     * Determine if the user's operating system is OS2.
@@ 447-457 (lines=11) @@
444
     *
445
     * @return bool
446
     */
447
    private static function checkOS2(Os $os, UserAgent $userAgent)
448
    {
449
        if (stripos($userAgent->getUserAgentString(), 'OS\/2') !== false) {
450
            $os->setVersion($os::VERSION_UNKNOWN);
451
            $os->setName($os::OS2);
452
453
            return true;
454
        }
455
456
        return false;
457
    }
458
459
    /**
460
     * Determine if the user's operating system is BeOS.
@@ 467-477 (lines=11) @@
464
     *
465
     * @return bool
466
     */
467
    private static function checkBeOS(Os $os, UserAgent $userAgent)
468
    {
469
        if (stripos($userAgent->getUserAgentString(), 'BeOS') !== false) {
470
            $os->setVersion($os::VERSION_UNKNOWN);
471
            $os->setName($os::BEOS);
472
473
            return true;
474
        }
475
476
        return false;
477
    }
478
}
479