Code Duplication    Length = 13-16 lines in 3 locations

src/DeviceDetector.php 1 location

@@ 66-78 (lines=13) @@
63
     * @param UserAgent $userAgent
64
     * @return bool
65
     */
66
    private static function checkWindowsPhone(Device $device, UserAgent $userAgent)
67
    {
68
        if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) {
69
            if (preg_match('/Microsoft; (Lumia [^)]*)\)/', $userAgent->getUserAgentString(), $matches)) {
70
                $device->setName($matches[1]);
71
                return true;
72
            }
73
74
            $device->setName($device::WINDOWS_PHONE);
75
            return true;
76
        }
77
        return false;
78
    }
79
}
80

src/OsDetector.php 2 locations

@@ 123-137 (lines=15) @@
120
     *
121
     * @return bool
122
     */
123
    private static function checkOSX(Os $os, UserAgent $userAgent)
124
    {
125
        if (stripos($userAgent->getUserAgentString(), 'OS X') !== false) {
126
            $os->setName($os::OSX);
127
            if (preg_match('/OS X ([\d\._]*)/i', $userAgent->getUserAgentString(), $matches)) {
128
                if (isset($matches[1])) {
129
                    $os->setVersion(str_replace('_', '.', $matches[1]));
130
                }
131
            }
132
133
            return true;
134
        }
135
136
        return false;
137
    }
138
139
    /**
140
     * Determine if the user's operating system is Windows.
@@ 224-239 (lines=16) @@
221
     *
222
     * @return bool
223
     */
224
    private static function checkWindowsPhone(Os $os, UserAgent $userAgent)
225
    {
226
        if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) {
227
            $os->setIsMobile(true);
228
            $os->setName($os::WINDOWS_PHONE);
229
            // Windows version
230
            if (preg_match('/Windows Phone ([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) {
231
                if (isset($matches[1])) {
232
                    $os->setVersion((float)$matches[1]);
233
                }
234
            }
235
    
236
            return true;
237
        }
238
        return false;
239
    }
240
241
    /**
242
     * Determine if the user's operating system is SymbOS.