repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
lisachenko/protocol-fcgi
src/FCGI/Record/UnknownType.php
UnknownType.unpackPayload
public static function unpackPayload($self, string $data): void { [$self->type1, $self->reserved1] = array_values(unpack("Ctype/a7reserved", $data)); }
php
public static function unpackPayload($self, string $data): void { [$self->type1, $self->reserved1] = array_values(unpack("Ctype/a7reserved", $data)); }
[ "public", "static", "function", "unpackPayload", "(", "$", "self", ",", "string", "$", "data", ")", ":", "void", "{", "[", "$", "self", "->", "type1", ",", "$", "self", "->", "reserved1", "]", "=", "array_values", "(", "unpack", "(", "\"Ctype/a7reserved\...
{@inheritdoc} @param static $self
[ "{" ]
train
https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/Record/UnknownType.php#L55-L58
lisachenko/protocol-fcgi
src/FCGI/Record/BeginRequest.php
BeginRequest.unpackPayload
protected static function unpackPayload($self, string $data): void { [ $self->role, $self->flags, $self->reserved1 ] = array_values(unpack("nrole/Cflags/a5reserved", $data)); }
php
protected static function unpackPayload($self, string $data): void { [ $self->role, $self->flags, $self->reserved1 ] = array_values(unpack("nrole/Cflags/a5reserved", $data)); }
[ "protected", "static", "function", "unpackPayload", "(", "$", "self", ",", "string", "$", "data", ")", ":", "void", "{", "[", "$", "self", "->", "role", ",", "$", "self", "->", "flags", ",", "$", "self", "->", "reserved1", "]", "=", "array_values", "...
{@inheritdoc} @param static $self
[ "{" ]
train
https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/Record/BeginRequest.php#L88-L95
lisachenko/protocol-fcgi
src/FCGI/Record/EndRequest.php
EndRequest.unpackPayload
protected static function unpackPayload($self, string $data): void { [ $self->appStatus, $self->protocolStatus, $self->reserved1 ] = array_values(unpack("NappStatus/CprotocolStatus/a3reserved", $data)); }
php
protected static function unpackPayload($self, string $data): void { [ $self->appStatus, $self->protocolStatus, $self->reserved1 ] = array_values(unpack("NappStatus/CprotocolStatus/a3reserved", $data)); }
[ "protected", "static", "function", "unpackPayload", "(", "$", "self", ",", "string", "$", "data", ")", ":", "void", "{", "[", "$", "self", "->", "appStatus", ",", "$", "self", "->", "protocolStatus", ",", "$", "self", "->", "reserved1", "]", "=", "arra...
{@inheritdoc} @param static $self
[ "{" ]
train
https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/Record/EndRequest.php#L89-L96
lisachenko/protocol-fcgi
src/FCGI/FrameParser.php
FrameParser.hasFrame
public static function hasFrame(string $buffer): bool { $bufferLength = strlen($buffer); if ($bufferLength < FCGI::HEADER_LEN) { return false; } $fastInfo = unpack(FCGI::HEADER_FORMAT, $buffer); if ($bufferLength < FCGI::HEADER_LEN + $fastInfo['contentLength'] + $fastInfo['paddingLength']) { return false; } return true; }
php
public static function hasFrame(string $buffer): bool { $bufferLength = strlen($buffer); if ($bufferLength < FCGI::HEADER_LEN) { return false; } $fastInfo = unpack(FCGI::HEADER_FORMAT, $buffer); if ($bufferLength < FCGI::HEADER_LEN + $fastInfo['contentLength'] + $fastInfo['paddingLength']) { return false; } return true; }
[ "public", "static", "function", "hasFrame", "(", "string", "$", "buffer", ")", ":", "bool", "{", "$", "bufferLength", "=", "strlen", "(", "$", "buffer", ")", ";", "if", "(", "$", "bufferLength", "<", "FCGI", "::", "HEADER_LEN", ")", "{", "return", "fal...
Checks if the buffer contains a valid frame to parse @param string $buffer Binary buffer @return bool
[ "Checks", "if", "the", "buffer", "contains", "a", "valid", "frame", "to", "parse" ]
train
https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/FrameParser.php#L41-L54
lisachenko/protocol-fcgi
src/FCGI/FrameParser.php
FrameParser.parseFrame
public static function parseFrame(string &$buffer): Record { $bufferLength = strlen($buffer); if ($bufferLength < FCGI::HEADER_LEN) { throw new \RuntimeException("Not enough data in the buffer to parse"); } $recordHeader = unpack(FCGI::HEADER_FORMAT, $buffer); $recordType = $recordHeader['type']; if (!isset(self::$classMapping[$recordType])) { throw new \DomainException("Invalid FCGI record type {$recordType} received"); } /** @var Record $className */ $className = self::$classMapping[$recordType]; $record = $className::unpack($buffer); $offset = FCGI::HEADER_LEN + $record->getContentLength() + $record->getPaddingLength(); $buffer = substr($buffer, $offset); return $record; }
php
public static function parseFrame(string &$buffer): Record { $bufferLength = strlen($buffer); if ($bufferLength < FCGI::HEADER_LEN) { throw new \RuntimeException("Not enough data in the buffer to parse"); } $recordHeader = unpack(FCGI::HEADER_FORMAT, $buffer); $recordType = $recordHeader['type']; if (!isset(self::$classMapping[$recordType])) { throw new \DomainException("Invalid FCGI record type {$recordType} received"); } /** @var Record $className */ $className = self::$classMapping[$recordType]; $record = $className::unpack($buffer); $offset = FCGI::HEADER_LEN + $record->getContentLength() + $record->getPaddingLength(); $buffer = substr($buffer, $offset); return $record; }
[ "public", "static", "function", "parseFrame", "(", "string", "&", "$", "buffer", ")", ":", "Record", "{", "$", "bufferLength", "=", "strlen", "(", "$", "buffer", ")", ";", "if", "(", "$", "bufferLength", "<", "FCGI", "::", "HEADER_LEN", ")", "{", "thro...
Parses a frame from the binary buffer @param string $buffer Binary buffer @return Record One of the corresponding FCGI record
[ "Parses", "a", "frame", "from", "the", "binary", "buffer" ]
train
https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/FrameParser.php#L63-L84
lisachenko/protocol-fcgi
src/FCGI/Record/Params.php
Params.unpackPayload
protected static function unpackPayload($self, string $data): void { $currentOffset = 0; do { [$nameLengthHigh] = array_values(unpack('CnameLengthHigh', $data)); $isLongName = ($nameLengthHigh >> 7 == 1); $valueOffset = $isLongName ? 4 : 1; [$valueLengthHigh] = array_values(unpack('CvalueLengthHigh', substr($data, $valueOffset))); $isLongValue = ($valueLengthHigh >> 7 == 1); $dataOffset = $valueOffset + ($isLongValue ? 4 : 1); $formatParts = [ $isLongName ? 'NnameLength' : 'CnameLength', $isLongValue ? 'NvalueLength' : 'CvalueLength', ]; $format = join('/', $formatParts); [$nameLength, $valueLength] = array_values(unpack($format, $data)); // Clear top bit for long record $nameLength &= ($isLongName ? 0x7fffffff : 0x7f); $valueLength &= ($isLongValue ? 0x7fffffff : 0x7f); [$nameData, $valueData] = array_values( unpack( "a{$nameLength}nameData/a{$valueLength}valueData", substr($data, $dataOffset) ) ); $self->values[$nameData] = $valueData; $keyValueLength = $dataOffset + $nameLength + $valueLength; $data = substr($data, $keyValueLength); $currentOffset += $keyValueLength; } while ($currentOffset < $self->getContentLength()); }
php
protected static function unpackPayload($self, string $data): void { $currentOffset = 0; do { [$nameLengthHigh] = array_values(unpack('CnameLengthHigh', $data)); $isLongName = ($nameLengthHigh >> 7 == 1); $valueOffset = $isLongName ? 4 : 1; [$valueLengthHigh] = array_values(unpack('CvalueLengthHigh', substr($data, $valueOffset))); $isLongValue = ($valueLengthHigh >> 7 == 1); $dataOffset = $valueOffset + ($isLongValue ? 4 : 1); $formatParts = [ $isLongName ? 'NnameLength' : 'CnameLength', $isLongValue ? 'NvalueLength' : 'CvalueLength', ]; $format = join('/', $formatParts); [$nameLength, $valueLength] = array_values(unpack($format, $data)); // Clear top bit for long record $nameLength &= ($isLongName ? 0x7fffffff : 0x7f); $valueLength &= ($isLongValue ? 0x7fffffff : 0x7f); [$nameData, $valueData] = array_values( unpack( "a{$nameLength}nameData/a{$valueLength}valueData", substr($data, $dataOffset) ) ); $self->values[$nameData] = $valueData; $keyValueLength = $dataOffset + $nameLength + $valueLength; $data = substr($data, $keyValueLength); $currentOffset += $keyValueLength; } while ($currentOffset < $self->getContentLength()); }
[ "protected", "static", "function", "unpackPayload", "(", "$", "self", ",", "string", "$", "data", ")", ":", "void", "{", "$", "currentOffset", "=", "0", ";", "do", "{", "[", "$", "nameLengthHigh", "]", "=", "array_values", "(", "unpack", "(", "'CnameLeng...
{@inheritdoc} @param static $self
[ "{" ]
train
https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/Record/Params.php#L47-L83
lisachenko/protocol-fcgi
src/FCGI/Record/Params.php
Params.packPayload
protected function packPayload(): string { $payload = ''; foreach ($this->values as $nameData => $valueData) { $nameLength = strlen($nameData); $valueLength = strlen((string) $valueData); $isLongName = $nameLength > 127; $isLongValue = $valueLength > 127; $formatParts = [ $isLongName ? 'N' : 'C', $isLongValue ? 'N' : 'C', "a{$nameLength}", "a{$valueLength}", ]; $format = join('', $formatParts); $payload .= pack( $format, $isLongName ? ($nameLength | 0x80000000) : $nameLength, $isLongValue ? ($valueLength | 0x80000000) : $valueLength, $nameData, $valueData ); } return $payload; }
php
protected function packPayload(): string { $payload = ''; foreach ($this->values as $nameData => $valueData) { $nameLength = strlen($nameData); $valueLength = strlen((string) $valueData); $isLongName = $nameLength > 127; $isLongValue = $valueLength > 127; $formatParts = [ $isLongName ? 'N' : 'C', $isLongValue ? 'N' : 'C', "a{$nameLength}", "a{$valueLength}", ]; $format = join('', $formatParts); $payload .= pack( $format, $isLongName ? ($nameLength | 0x80000000) : $nameLength, $isLongValue ? ($valueLength | 0x80000000) : $valueLength, $nameData, $valueData ); } return $payload; }
[ "protected", "function", "packPayload", "(", ")", ":", "string", "{", "$", "payload", "=", "''", ";", "foreach", "(", "$", "this", "->", "values", "as", "$", "nameData", "=>", "$", "valueData", ")", "{", "$", "nameLength", "=", "strlen", "(", "$", "n...
{@inheritdoc}
[ "{" ]
train
https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/Record/Params.php#L86-L112
sinergi/php-browser-detector
src/LanguageDetector.php
LanguageDetector.detect
public static function detect(Language $language, AcceptLanguage $acceptLanguage) { $acceptLanguageString = $acceptLanguage->getAcceptLanguageString(); $languages = array(); $language->setLanguages($languages); if (!empty($acceptLanguageString)) { $httpLanguages = preg_split( '/q=([\d\.]*)/', $acceptLanguageString, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); $key = 0; foreach (array_reverse($httpLanguages) as $value) { $value = trim($value, ',; .'); if (is_numeric($value)) { $key = $value; } else { $languages[$key] = explode(',', $value); } } krsort($languages); foreach ($languages as $value) { $language->setLanguages(array_merge($language->getLanguages(), $value)); } } }
php
public static function detect(Language $language, AcceptLanguage $acceptLanguage) { $acceptLanguageString = $acceptLanguage->getAcceptLanguageString(); $languages = array(); $language->setLanguages($languages); if (!empty($acceptLanguageString)) { $httpLanguages = preg_split( '/q=([\d\.]*)/', $acceptLanguageString, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); $key = 0; foreach (array_reverse($httpLanguages) as $value) { $value = trim($value, ',; .'); if (is_numeric($value)) { $key = $value; } else { $languages[$key] = explode(',', $value); } } krsort($languages); foreach ($languages as $value) { $language->setLanguages(array_merge($language->getLanguages(), $value)); } } }
[ "public", "static", "function", "detect", "(", "Language", "$", "language", ",", "AcceptLanguage", "$", "acceptLanguage", ")", "{", "$", "acceptLanguageString", "=", "$", "acceptLanguage", "->", "getAcceptLanguageString", "(", ")", ";", "$", "languages", "=", "a...
Detect a user's languages and order them by priority. @param Language $language @param AcceptLanguage $acceptLanguage @return null
[ "Detect", "a", "user", "s", "languages", "and", "order", "them", "by", "priority", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/LanguageDetector.php#L15-L44
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.detect
public static function detect(Browser $browser, UserAgent $userAgent = null) { self::$browser = $browser; if (is_null($userAgent)) { $userAgent = self::$browser->getUserAgent(); } self::$userAgentString = $userAgent->getUserAgentString(); self::$browser->setName(Browser::UNKNOWN); self::$browser->setVersion(Browser::VERSION_UNKNOWN); self::checkChromeFrame(); self::checkFacebookWebView(); foreach (self::$browsersList as $browserName) { $funcName = self::FUNC_PREFIX . $browserName; if (self::$funcName()) { return true; } } return false; }
php
public static function detect(Browser $browser, UserAgent $userAgent = null) { self::$browser = $browser; if (is_null($userAgent)) { $userAgent = self::$browser->getUserAgent(); } self::$userAgentString = $userAgent->getUserAgentString(); self::$browser->setName(Browser::UNKNOWN); self::$browser->setVersion(Browser::VERSION_UNKNOWN); self::checkChromeFrame(); self::checkFacebookWebView(); foreach (self::$browsersList as $browserName) { $funcName = self::FUNC_PREFIX . $browserName; if (self::$funcName()) { return true; } } return false; }
[ "public", "static", "function", "detect", "(", "Browser", "$", "browser", ",", "UserAgent", "$", "userAgent", "=", "null", ")", "{", "self", "::", "$", "browser", "=", "$", "browser", ";", "if", "(", "is_null", "(", "$", "userAgent", ")", ")", "{", "...
Routine to determine the browser type. @param Browser $browser @param UserAgent $userAgent @return bool
[ "Routine", "to", "determine", "the", "browser", "type", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L82-L105
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkChromeFrame
public static function checkChromeFrame() { if (strpos(self::$userAgentString, 'chromeframe') !== false) { self::$browser->setIsChromeFrame(true); return true; } return false; }
php
public static function checkChromeFrame() { if (strpos(self::$userAgentString, 'chromeframe') !== false) { self::$browser->setIsChromeFrame(true); return true; } return false; }
[ "public", "static", "function", "checkChromeFrame", "(", ")", "{", "if", "(", "strpos", "(", "self", "::", "$", "userAgentString", ",", "'chromeframe'", ")", "!==", "false", ")", "{", "self", "::", "$", "browser", "->", "setIsChromeFrame", "(", "true", ")"...
Determine if the user is using Chrome Frame. @return bool
[ "Determine", "if", "the", "user", "is", "using", "Chrome", "Frame", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L112-L121
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkFacebookWebView
public static function checkFacebookWebView() { if (strpos(self::$userAgentString, 'FBAV') !== false) { self::$browser->setIsFacebookWebView(true); return true; } return false; }
php
public static function checkFacebookWebView() { if (strpos(self::$userAgentString, 'FBAV') !== false) { self::$browser->setIsFacebookWebView(true); return true; } return false; }
[ "public", "static", "function", "checkFacebookWebView", "(", ")", "{", "if", "(", "strpos", "(", "self", "::", "$", "userAgentString", ",", "'FBAV'", ")", "!==", "false", ")", "{", "self", "::", "$", "browser", "->", "setIsFacebookWebView", "(", "true", ")...
Determine if the user is using Facebook. @return bool
[ "Determine", "if", "the", "user", "is", "using", "Facebook", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L128-L137
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserBlackBerry
public static function checkBrowserBlackBerry() { if (stripos(self::$userAgentString, 'blackberry') !== false) { if (stripos(self::$userAgentString, 'Version/') !== false) { $aresult = explode('Version/', self::$userAgentString); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } } else { $aresult = explode('/', stristr(self::$userAgentString, 'BlackBerry')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } } self::$browser->setName(Browser::BLACKBERRY); return true; } elseif (stripos(self::$userAgentString, 'BB10') !== false) { $aresult = explode('Version/10.', self::$userAgentString); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion('10.' . $aversion[0]); } self::$browser->setName(Browser::BLACKBERRY); return true; } return false; }
php
public static function checkBrowserBlackBerry() { if (stripos(self::$userAgentString, 'blackberry') !== false) { if (stripos(self::$userAgentString, 'Version/') !== false) { $aresult = explode('Version/', self::$userAgentString); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } } else { $aresult = explode('/', stristr(self::$userAgentString, 'BlackBerry')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } } self::$browser->setName(Browser::BLACKBERRY); return true; } elseif (stripos(self::$userAgentString, 'BB10') !== false) { $aresult = explode('Version/10.', self::$userAgentString); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion('10.' . $aversion[0]); } self::$browser->setName(Browser::BLACKBERRY); return true; } return false; }
[ "public", "static", "function", "checkBrowserBlackBerry", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'blackberry'", ")", "!==", "false", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", "...
Determine if the user is using a BlackBerry. @return bool
[ "Determine", "if", "the", "user", "is", "using", "a", "BlackBerry", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L144-L174
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserRobot
public static function checkBrowserRobot() { if (stripos(self::$userAgentString, 'bot') !== false || stripos(self::$userAgentString, 'spider') !== false || stripos(self::$userAgentString, 'crawler') !== false ) { self::$browser->setIsRobot(true); return true; } return false; }
php
public static function checkBrowserRobot() { if (stripos(self::$userAgentString, 'bot') !== false || stripos(self::$userAgentString, 'spider') !== false || stripos(self::$userAgentString, 'crawler') !== false ) { self::$browser->setIsRobot(true); return true; } return false; }
[ "public", "static", "function", "checkBrowserRobot", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'bot'", ")", "!==", "false", "||", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'spider'", ")", "!==",...
Determine if the browser is a robot. @return bool
[ "Determine", "if", "the", "browser", "is", "a", "robot", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L181-L193
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserInternetExplorer
public static function checkBrowserInternetExplorer() { // Test for v1 - v1.5 IE if (stripos(self::$userAgentString, 'microsoft internet explorer') !== false) { self::$browser->setName(Browser::IE); self::$browser->setVersion('1.0'); $aresult = stristr(self::$userAgentString, '/'); if (preg_match('/308|425|426|474|0b1/i', $aresult)) { self::$browser->setVersion('1.5'); } return true; } // Test for versions > 1.5 and < 11 and some cases of 11 else { if (stripos(self::$userAgentString, 'msie') !== false && stripos(self::$userAgentString, 'opera') === false ) { // See if the browser is the odd MSN Explorer if (stripos(self::$userAgentString, 'msnb') !== false) { $aresult = explode(' ', stristr(str_replace(';', '; ', self::$userAgentString), 'MSN')); self::$browser->setName(Browser::MSN); if (isset($aresult[1])) { self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); } return true; } $aresult = explode(' ', stristr(str_replace(';', '; ', self::$userAgentString), 'msie')); self::$browser->setName(Browser::IE); if (isset($aresult[1])) { self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); } // See https://msdn.microsoft.com/en-us/library/ie/hh869301%28v=vs.85%29.aspx // Might be 11, anyway ! if (stripos(self::$userAgentString, 'trident') !== false) { preg_match('/rv:(\d+\.\d+)/', self::$userAgentString, $matches); if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } // At this poing in the method, we know the MSIE and Trident // strings are present in the $userAgentString. If we're in // compatibility mode, we need to determine the true version. // If the MSIE version is 7.0, we can look at the Trident // version to *approximate* the true IE version. If we don't // find a matching pair, ( e.g. MSIE 7.0 && Trident/7.0 ) // we're *not* in compatibility mode and the browser really // is version 7.0. if (stripos(self::$userAgentString, 'MSIE 7.0;')) { if (stripos(self::$userAgentString, 'Trident/7.0;')) { // IE11 in compatibility mode self::$browser->setVersion('11.0'); self::$browser->setIsCompatibilityMode(true); } elseif (stripos(self::$userAgentString, 'Trident/6.0;')) { // IE10 in compatibility mode self::$browser->setVersion('10.0'); self::$browser->setIsCompatibilityMode(true); } elseif (stripos(self::$userAgentString, 'Trident/5.0;')) { // IE9 in compatibility mode self::$browser->setVersion('9.0'); self::$browser->setIsCompatibilityMode(true); } elseif (stripos(self::$userAgentString, 'Trident/4.0;')) { // IE8 in compatibility mode self::$browser->setVersion('8.0'); self::$browser->setIsCompatibilityMode(true); } } } return true; } // Test for versions >= 11 else { if (stripos(self::$userAgentString, 'trident') !== false) { self::$browser->setName(Browser::IE); preg_match('/rv:(\d+\.\d+)/', self::$userAgentString, $matches); if (isset($matches[1])) { self::$browser->setVersion($matches[1]); return true; } else { return false; } } // Test for Pocket IE else { if (stripos(self::$userAgentString, 'mspie') !== false || stripos( self::$userAgentString, 'pocket' ) !== false ) { $aresult = explode(' ', stristr(self::$userAgentString, 'mspie')); self::$browser->setName(Browser::POCKET_IE); if (stripos(self::$userAgentString, 'mspie') !== false) { if (isset($aresult[1])) { self::$browser->setVersion($aresult[1]); } } else { $aversion = explode('/', self::$userAgentString); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } } return true; } } } } return false; }
php
public static function checkBrowserInternetExplorer() { // Test for v1 - v1.5 IE if (stripos(self::$userAgentString, 'microsoft internet explorer') !== false) { self::$browser->setName(Browser::IE); self::$browser->setVersion('1.0'); $aresult = stristr(self::$userAgentString, '/'); if (preg_match('/308|425|426|474|0b1/i', $aresult)) { self::$browser->setVersion('1.5'); } return true; } // Test for versions > 1.5 and < 11 and some cases of 11 else { if (stripos(self::$userAgentString, 'msie') !== false && stripos(self::$userAgentString, 'opera') === false ) { // See if the browser is the odd MSN Explorer if (stripos(self::$userAgentString, 'msnb') !== false) { $aresult = explode(' ', stristr(str_replace(';', '; ', self::$userAgentString), 'MSN')); self::$browser->setName(Browser::MSN); if (isset($aresult[1])) { self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); } return true; } $aresult = explode(' ', stristr(str_replace(';', '; ', self::$userAgentString), 'msie')); self::$browser->setName(Browser::IE); if (isset($aresult[1])) { self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); } // See https://msdn.microsoft.com/en-us/library/ie/hh869301%28v=vs.85%29.aspx // Might be 11, anyway ! if (stripos(self::$userAgentString, 'trident') !== false) { preg_match('/rv:(\d+\.\d+)/', self::$userAgentString, $matches); if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } // At this poing in the method, we know the MSIE and Trident // strings are present in the $userAgentString. If we're in // compatibility mode, we need to determine the true version. // If the MSIE version is 7.0, we can look at the Trident // version to *approximate* the true IE version. If we don't // find a matching pair, ( e.g. MSIE 7.0 && Trident/7.0 ) // we're *not* in compatibility mode and the browser really // is version 7.0. if (stripos(self::$userAgentString, 'MSIE 7.0;')) { if (stripos(self::$userAgentString, 'Trident/7.0;')) { // IE11 in compatibility mode self::$browser->setVersion('11.0'); self::$browser->setIsCompatibilityMode(true); } elseif (stripos(self::$userAgentString, 'Trident/6.0;')) { // IE10 in compatibility mode self::$browser->setVersion('10.0'); self::$browser->setIsCompatibilityMode(true); } elseif (stripos(self::$userAgentString, 'Trident/5.0;')) { // IE9 in compatibility mode self::$browser->setVersion('9.0'); self::$browser->setIsCompatibilityMode(true); } elseif (stripos(self::$userAgentString, 'Trident/4.0;')) { // IE8 in compatibility mode self::$browser->setVersion('8.0'); self::$browser->setIsCompatibilityMode(true); } } } return true; } // Test for versions >= 11 else { if (stripos(self::$userAgentString, 'trident') !== false) { self::$browser->setName(Browser::IE); preg_match('/rv:(\d+\.\d+)/', self::$userAgentString, $matches); if (isset($matches[1])) { self::$browser->setVersion($matches[1]); return true; } else { return false; } } // Test for Pocket IE else { if (stripos(self::$userAgentString, 'mspie') !== false || stripos( self::$userAgentString, 'pocket' ) !== false ) { $aresult = explode(' ', stristr(self::$userAgentString, 'mspie')); self::$browser->setName(Browser::POCKET_IE); if (stripos(self::$userAgentString, 'mspie') !== false) { if (isset($aresult[1])) { self::$browser->setVersion($aresult[1]); } } else { $aversion = explode('/', self::$userAgentString); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } } return true; } } } } return false; }
[ "public", "static", "function", "checkBrowserInternetExplorer", "(", ")", "{", "// Test for v1 - v1.5 IE", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'microsoft internet explorer'", ")", "!==", "false", ")", "{", "self", "::", "$", "bro...
Determine if the browser is Internet Explorer. @return bool
[ "Determine", "if", "the", "browser", "is", "Internet", "Explorer", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L200-L311
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserOpera
public static function checkBrowserOpera() { if (stripos(self::$userAgentString, 'opera mini') !== false) { $resultant = stristr(self::$userAgentString, 'opera mini'); if (preg_match('/\//', $resultant)) { $aresult = explode('/', $resultant); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } } else { $aversion = explode(' ', stristr($resultant, 'opera mini')); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } } self::$browser->setName(Browser::OPERA_MINI); return true; } elseif (stripos(self::$userAgentString, 'OPiOS') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'OPiOS')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::OPERA_MINI); return true; } elseif (stripos(self::$userAgentString, 'opera') !== false) { $resultant = stristr(self::$userAgentString, 'opera'); if (preg_match('/Version\/(1[0-2].*)$/', $resultant, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } } elseif (preg_match('/\//', $resultant)) { $aresult = explode('/', str_replace('(', ' ', $resultant)); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } } else { $aversion = explode(' ', stristr($resultant, 'opera')); self::$browser->setVersion(isset($aversion[1]) ? $aversion[1] : ''); } self::$browser->setName(Browser::OPERA); return true; } elseif (stripos(self::$userAgentString, ' OPR/') !== false) { self::$browser->setName(Browser::OPERA); if (preg_match('/OPR\/([\d\.]*)/', self::$userAgentString, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } } return true; } return false; }
php
public static function checkBrowserOpera() { if (stripos(self::$userAgentString, 'opera mini') !== false) { $resultant = stristr(self::$userAgentString, 'opera mini'); if (preg_match('/\//', $resultant)) { $aresult = explode('/', $resultant); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } } else { $aversion = explode(' ', stristr($resultant, 'opera mini')); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } } self::$browser->setName(Browser::OPERA_MINI); return true; } elseif (stripos(self::$userAgentString, 'OPiOS') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'OPiOS')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::OPERA_MINI); return true; } elseif (stripos(self::$userAgentString, 'opera') !== false) { $resultant = stristr(self::$userAgentString, 'opera'); if (preg_match('/Version\/(1[0-2].*)$/', $resultant, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } } elseif (preg_match('/\//', $resultant)) { $aresult = explode('/', str_replace('(', ' ', $resultant)); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } } else { $aversion = explode(' ', stristr($resultant, 'opera')); self::$browser->setVersion(isset($aversion[1]) ? $aversion[1] : ''); } self::$browser->setName(Browser::OPERA); return true; } elseif (stripos(self::$userAgentString, ' OPR/') !== false) { self::$browser->setName(Browser::OPERA); if (preg_match('/OPR\/([\d\.]*)/', self::$userAgentString, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } } return true; } return false; }
[ "public", "static", "function", "checkBrowserOpera", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'opera mini'", ")", "!==", "false", ")", "{", "$", "resultant", "=", "stristr", "(", "self", "::", "$", "userAgentStr...
Determine if the browser is Opera. @return bool
[ "Determine", "if", "the", "browser", "is", "Opera", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L318-L377
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserSamsung
public static function checkBrowserSamsung() { if (stripos(self::$userAgentString, 'SamsungBrowser') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'SamsungBrowser')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::SAMSUNG_BROWSER); return true; } return false; }
php
public static function checkBrowserSamsung() { if (stripos(self::$userAgentString, 'SamsungBrowser') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'SamsungBrowser')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::SAMSUNG_BROWSER); return true; } return false; }
[ "public", "static", "function", "checkBrowserSamsung", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'SamsungBrowser'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", ...
Determine if the browser is Samsung. @return bool
[ "Determine", "if", "the", "browser", "is", "Samsung", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L384-L398
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserChrome
public static function checkBrowserChrome() { if (stripos(self::$userAgentString, 'Chrome') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Chrome')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::CHROME); return true; } elseif (stripos(self::$userAgentString, 'CriOS') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'CriOS')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::CHROME); return true; } return false; }
php
public static function checkBrowserChrome() { if (stripos(self::$userAgentString, 'Chrome') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Chrome')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::CHROME); return true; } elseif (stripos(self::$userAgentString, 'CriOS') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'CriOS')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::CHROME); return true; } return false; }
[ "public", "static", "function", "checkBrowserChrome", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Chrome'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self",...
Determine if the browser is Chrome. @return bool
[ "Determine", "if", "the", "browser", "is", "Chrome", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L405-L428
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserVivaldi
public static function checkBrowserVivaldi() { if (stripos(self::$userAgentString, 'Vivaldi') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Vivaldi')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::VIVALDI); return true; } return false; }
php
public static function checkBrowserVivaldi() { if (stripos(self::$userAgentString, 'Vivaldi') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Vivaldi')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::VIVALDI); return true; } return false; }
[ "public", "static", "function", "checkBrowserVivaldi", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Vivaldi'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self...
Determine if the browser is Vivaldi. @return bool
[ "Determine", "if", "the", "browser", "is", "Vivaldi", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L435-L449
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserEdge
public static function checkBrowserEdge() { if (stripos(self::$userAgentString, 'Edge') !== false) { $version = explode('Edge/', self::$userAgentString); if (isset($version[1])) { self::$browser->setVersion((float)$version[1]); } self::$browser->setName(Browser::EDGE); return true; } return false; }
php
public static function checkBrowserEdge() { if (stripos(self::$userAgentString, 'Edge') !== false) { $version = explode('Edge/', self::$userAgentString); if (isset($version[1])) { self::$browser->setVersion((float)$version[1]); } self::$browser->setName(Browser::EDGE); return true; } return false; }
[ "public", "static", "function", "checkBrowserEdge", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Edge'", ")", "!==", "false", ")", "{", "$", "version", "=", "explode", "(", "'Edge/'", ",", "self", "::", "$", "u...
Determine if the browser is Microsoft Edge. @return bool
[ "Determine", "if", "the", "browser", "is", "Microsoft", "Edge", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L456-L469
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserGsa
public static function checkBrowserGsa() { if (stripos(self::$userAgentString, 'GSA') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'GSA')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::GSA); return true; } return false; }
php
public static function checkBrowserGsa() { if (stripos(self::$userAgentString, 'GSA') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'GSA')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::GSA); return true; } return false; }
[ "public", "static", "function", "checkBrowserGsa", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'GSA'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self", "::...
Determine if the browser is Google Search Appliance. @return bool
[ "Determine", "if", "the", "browser", "is", "Google", "Search", "Appliance", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L476-L490
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserWebTv
public static function checkBrowserWebTv() { if (stripos(self::$userAgentString, 'webtv') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'webtv')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::WEBTV); return true; } return false; }
php
public static function checkBrowserWebTv() { if (stripos(self::$userAgentString, 'webtv') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'webtv')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::WEBTV); return true; } return false; }
[ "public", "static", "function", "checkBrowserWebTv", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'webtv'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self", ...
Determine if the browser is WebTv. @return bool
[ "Determine", "if", "the", "browser", "is", "WebTv", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L497-L511
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserNetPositive
public static function checkBrowserNetPositive() { if (stripos(self::$userAgentString, 'NetPositive') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'NetPositive')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aversion[0])); } self::$browser->setName(Browser::NETPOSITIVE); return true; } return false; }
php
public static function checkBrowserNetPositive() { if (stripos(self::$userAgentString, 'NetPositive') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'NetPositive')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aversion[0])); } self::$browser->setName(Browser::NETPOSITIVE); return true; } return false; }
[ "public", "static", "function", "checkBrowserNetPositive", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'NetPositive'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(",...
Determine if the browser is NetPositive. @return bool
[ "Determine", "if", "the", "browser", "is", "NetPositive", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L518-L532
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserGaleon
public static function checkBrowserGaleon() { if (stripos(self::$userAgentString, 'galeon') !== false) { $aresult = explode(' ', stristr(self::$userAgentString, 'galeon')); $aversion = explode('/', $aresult[0]); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::GALEON); return true; } return false; }
php
public static function checkBrowserGaleon() { if (stripos(self::$userAgentString, 'galeon') !== false) { $aresult = explode(' ', stristr(self::$userAgentString, 'galeon')); $aversion = explode('/', $aresult[0]); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::GALEON); return true; } return false; }
[ "public", "static", "function", "checkBrowserGaleon", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'galeon'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "' '", ",", "stristr", "(", "self",...
Determine if the browser is Galeon. @return bool
[ "Determine", "if", "the", "browser", "is", "Galeon", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L539-L553
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserKonqueror
public static function checkBrowserKonqueror() { if (stripos(self::$userAgentString, 'Konqueror') !== false) { $aresult = explode(' ', stristr(self::$userAgentString, 'Konqueror')); $aversion = explode('/', $aresult[0]); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::KONQUEROR); return true; } return false; }
php
public static function checkBrowserKonqueror() { if (stripos(self::$userAgentString, 'Konqueror') !== false) { $aresult = explode(' ', stristr(self::$userAgentString, 'Konqueror')); $aversion = explode('/', $aresult[0]); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::KONQUEROR); return true; } return false; }
[ "public", "static", "function", "checkBrowserKonqueror", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Konqueror'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "' '", ",", "stristr", "(", "...
Determine if the browser is Konqueror. @return bool
[ "Determine", "if", "the", "browser", "is", "Konqueror", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L560-L574
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserIcab
public static function checkBrowserIcab() { if (stripos(self::$userAgentString, 'icab') !== false) { $aversion = explode(' ', stristr(str_replace('/', ' ', self::$userAgentString), 'icab')); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::ICAB); return true; } return false; }
php
public static function checkBrowserIcab() { if (stripos(self::$userAgentString, 'icab') !== false) { $aversion = explode(' ', stristr(str_replace('/', ' ', self::$userAgentString), 'icab')); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::ICAB); return true; } return false; }
[ "public", "static", "function", "checkBrowserIcab", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'icab'", ")", "!==", "false", ")", "{", "$", "aversion", "=", "explode", "(", "' '", ",", "stristr", "(", "str_repla...
Determine if the browser is iCab. @return bool
[ "Determine", "if", "the", "browser", "is", "iCab", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L581-L594
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserOmniWeb
public static function checkBrowserOmniWeb() { if (stripos(self::$userAgentString, 'omniweb') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'omniweb')); $aversion = explode(' ', isset($aresult[1]) ? $aresult[1] : ''); self::$browser->setVersion($aversion[0]); self::$browser->setName(Browser::OMNIWEB); return true; } return false; }
php
public static function checkBrowserOmniWeb() { if (stripos(self::$userAgentString, 'omniweb') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'omniweb')); $aversion = explode(' ', isset($aresult[1]) ? $aresult[1] : ''); self::$browser->setVersion($aversion[0]); self::$browser->setName(Browser::OMNIWEB); return true; } return false; }
[ "public", "static", "function", "checkBrowserOmniWeb", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'omniweb'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self...
Determine if the browser is OmniWeb. @return bool
[ "Determine", "if", "the", "browser", "is", "OmniWeb", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L601-L613
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserPhoenix
public static function checkBrowserPhoenix() { if (stripos(self::$userAgentString, 'Phoenix') !== false) { $aversion = explode('/', stristr(self::$userAgentString, 'Phoenix')); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::PHOENIX); return true; } return false; }
php
public static function checkBrowserPhoenix() { if (stripos(self::$userAgentString, 'Phoenix') !== false) { $aversion = explode('/', stristr(self::$userAgentString, 'Phoenix')); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::PHOENIX); return true; } return false; }
[ "public", "static", "function", "checkBrowserPhoenix", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Phoenix'", ")", "!==", "false", ")", "{", "$", "aversion", "=", "explode", "(", "'/'", ",", "stristr", "(", "sel...
Determine if the browser is Phoenix. @return bool
[ "Determine", "if", "the", "browser", "is", "Phoenix", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L620-L633
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserFirebird
public static function checkBrowserFirebird() { if (stripos(self::$userAgentString, 'Firebird') !== false) { $aversion = explode('/', stristr(self::$userAgentString, 'Firebird')); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::FIREBIRD); return true; } return false; }
php
public static function checkBrowserFirebird() { if (stripos(self::$userAgentString, 'Firebird') !== false) { $aversion = explode('/', stristr(self::$userAgentString, 'Firebird')); if (isset($aversion[1])) { self::$browser->setVersion($aversion[1]); } self::$browser->setName(Browser::FIREBIRD); return true; } return false; }
[ "public", "static", "function", "checkBrowserFirebird", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Firebird'", ")", "!==", "false", ")", "{", "$", "aversion", "=", "explode", "(", "'/'", ",", "stristr", "(", "s...
Determine if the browser is Firebird. @return bool
[ "Determine", "if", "the", "browser", "is", "Firebird", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L640-L653
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserNetscapeNavigator9Plus
public static function checkBrowserNetscapeNavigator9Plus() { if (stripos(self::$userAgentString, 'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i', self::$userAgentString, $matches) ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::NETSCAPE_NAVIGATOR); return true; } elseif (stripos(self::$userAgentString, 'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i', self::$userAgentString, $matches) ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::NETSCAPE_NAVIGATOR); return true; } return false; }
php
public static function checkBrowserNetscapeNavigator9Plus() { if (stripos(self::$userAgentString, 'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i', self::$userAgentString, $matches) ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::NETSCAPE_NAVIGATOR); return true; } elseif (stripos(self::$userAgentString, 'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i', self::$userAgentString, $matches) ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::NETSCAPE_NAVIGATOR); return true; } return false; }
[ "public", "static", "function", "checkBrowserNetscapeNavigator9Plus", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Firefox'", ")", "!==", "false", "&&", "preg_match", "(", "'/Navigator\\/([^ ]*)/i'", ",", "self", "::", "...
Determine if the browser is Netscape Navigator 9+. @return bool
[ "Determine", "if", "the", "browser", "is", "Netscape", "Navigator", "9", "+", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L660-L683
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserShiretoko
public static function checkBrowserShiretoko() { if (stripos(self::$userAgentString, 'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i', self::$userAgentString, $matches) ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::SHIRETOKO); return true; } return false; }
php
public static function checkBrowserShiretoko() { if (stripos(self::$userAgentString, 'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i', self::$userAgentString, $matches) ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::SHIRETOKO); return true; } return false; }
[ "public", "static", "function", "checkBrowserShiretoko", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Mozilla'", ")", "!==", "false", "&&", "preg_match", "(", "'/Shiretoko\\/([^ ]*)/i'", ",", "self", "::", "$", "userAg...
Determine if the browser is Shiretoko. @return bool
[ "Determine", "if", "the", "browser", "is", "Shiretoko", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L690-L704
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserIceCat
public static function checkBrowserIceCat() { if (stripos(self::$userAgentString, 'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i', self::$userAgentString, $matches) ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::ICECAT); return true; } return false; }
php
public static function checkBrowserIceCat() { if (stripos(self::$userAgentString, 'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i', self::$userAgentString, $matches) ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::ICECAT); return true; } return false; }
[ "public", "static", "function", "checkBrowserIceCat", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Mozilla'", ")", "!==", "false", "&&", "preg_match", "(", "'/IceCat\\/([^ ]*)/i'", ",", "self", "::", "$", "userAgentStr...
Determine if the browser is Ice Cat. @return bool
[ "Determine", "if", "the", "browser", "is", "Ice", "Cat", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L711-L725
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserNokia
public static function checkBrowserNokia() { if (preg_match("/Nokia([^\/]+)\/([^ SP]+)/i", self::$userAgentString, $matches)) { self::$browser->setVersion($matches[2]); if (stripos(self::$userAgentString, 'Series60') !== false || strpos(self::$userAgentString, 'S60') !== false ) { self::$browser->setName(Browser::NOKIA_S60); } else { self::$browser->setName(Browser::NOKIA); } return true; } return false; }
php
public static function checkBrowserNokia() { if (preg_match("/Nokia([^\/]+)\/([^ SP]+)/i", self::$userAgentString, $matches)) { self::$browser->setVersion($matches[2]); if (stripos(self::$userAgentString, 'Series60') !== false || strpos(self::$userAgentString, 'S60') !== false ) { self::$browser->setName(Browser::NOKIA_S60); } else { self::$browser->setName(Browser::NOKIA); } return true; } return false; }
[ "public", "static", "function", "checkBrowserNokia", "(", ")", "{", "if", "(", "preg_match", "(", "\"/Nokia([^\\/]+)\\/([^ SP]+)/i\"", ",", "self", "::", "$", "userAgentString", ",", "$", "matches", ")", ")", "{", "self", "::", "$", "browser", "->", "setVersio...
Determine if the browser is Nokia. @return bool
[ "Determine", "if", "the", "browser", "is", "Nokia", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L732-L748
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserFirefox
public static function checkBrowserFirefox() { if (stripos(self::$userAgentString, 'safari') === false) { if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", self::$userAgentString, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::FIREFOX); return true; } elseif (preg_match('/Firefox$/i', self::$userAgentString, $matches)) { self::$browser->setVersion(''); self::$browser->setName(Browser::FIREFOX); return true; } } return false; }
php
public static function checkBrowserFirefox() { if (stripos(self::$userAgentString, 'safari') === false) { if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", self::$userAgentString, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::FIREFOX); return true; } elseif (preg_match('/Firefox$/i', self::$userAgentString, $matches)) { self::$browser->setVersion(''); self::$browser->setName(Browser::FIREFOX); return true; } } return false; }
[ "public", "static", "function", "checkBrowserFirefox", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'safari'", ")", "===", "false", ")", "{", "if", "(", "preg_match", "(", "\"/Firefox[\\/ \\(]([^ ;\\)]+)/i\"", ",", "sel...
Determine if the browser is Firefox. @return bool
[ "Determine", "if", "the", "browser", "is", "Firefox", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L755-L774
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserSeaMonkey
public static function checkBrowserSeaMonkey() { if (stripos(self::$userAgentString, 'safari') === false) { if (preg_match("/SeaMonkey[\/ \(]([^ ;\)]+)/i", self::$userAgentString, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::SEAMONKEY); return true; } elseif (preg_match('/SeaMonkey$/i', self::$userAgentString, $matches)) { self::$browser->setVersion(''); self::$browser->setName(Browser::SEAMONKEY); return true; } } return false; }
php
public static function checkBrowserSeaMonkey() { if (stripos(self::$userAgentString, 'safari') === false) { if (preg_match("/SeaMonkey[\/ \(]([^ ;\)]+)/i", self::$userAgentString, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::SEAMONKEY); return true; } elseif (preg_match('/SeaMonkey$/i', self::$userAgentString, $matches)) { self::$browser->setVersion(''); self::$browser->setName(Browser::SEAMONKEY); return true; } } return false; }
[ "public", "static", "function", "checkBrowserSeaMonkey", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'safari'", ")", "===", "false", ")", "{", "if", "(", "preg_match", "(", "\"/SeaMonkey[\\/ \\(]([^ ;\\)]+)/i\"", ",", ...
Determine if the browser is SeaMonkey. @return bool
[ "Determine", "if", "the", "browser", "is", "SeaMonkey", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L781-L800
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserIceweasel
public static function checkBrowserIceweasel() { if (stripos(self::$userAgentString, 'Iceweasel') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Iceweasel')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::ICEWEASEL); return true; } return false; }
php
public static function checkBrowserIceweasel() { if (stripos(self::$userAgentString, 'Iceweasel') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Iceweasel')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::ICEWEASEL); return true; } return false; }
[ "public", "static", "function", "checkBrowserIceweasel", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Iceweasel'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "...
Determine if the browser is Iceweasel. @return bool
[ "Determine", "if", "the", "browser", "is", "Iceweasel", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L807-L821
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserMozilla
public static function checkBrowserMozilla() { if (stripos(self::$userAgentString, 'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i', self::$userAgentString) && stripos(self::$userAgentString, 'netscape') === false ) { $aversion = explode(' ', stristr(self::$userAgentString, 'rv:')); preg_match('/rv:[0-9].[0-9][a-b]?/i', self::$userAgentString, $aversion); self::$browser->setVersion(str_replace('rv:', '', $aversion[0])); self::$browser->setName(Browser::MOZILLA); return true; } elseif (stripos(self::$userAgentString, 'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i', self::$userAgentString) && stripos(self::$userAgentString, 'netscape') === false ) { $aversion = explode('', stristr(self::$userAgentString, 'rv:')); self::$browser->setVersion(str_replace('rv:', '', $aversion[0])); self::$browser->setName(Browser::MOZILLA); return true; } elseif (stripos(self::$userAgentString, 'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i', self::$userAgentString, $matches) && stripos(self::$userAgentString, 'netscape') === false ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::MOZILLA); return true; } return false; }
php
public static function checkBrowserMozilla() { if (stripos(self::$userAgentString, 'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i', self::$userAgentString) && stripos(self::$userAgentString, 'netscape') === false ) { $aversion = explode(' ', stristr(self::$userAgentString, 'rv:')); preg_match('/rv:[0-9].[0-9][a-b]?/i', self::$userAgentString, $aversion); self::$browser->setVersion(str_replace('rv:', '', $aversion[0])); self::$browser->setName(Browser::MOZILLA); return true; } elseif (stripos(self::$userAgentString, 'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i', self::$userAgentString) && stripos(self::$userAgentString, 'netscape') === false ) { $aversion = explode('', stristr(self::$userAgentString, 'rv:')); self::$browser->setVersion(str_replace('rv:', '', $aversion[0])); self::$browser->setName(Browser::MOZILLA); return true; } elseif (stripos(self::$userAgentString, 'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i', self::$userAgentString, $matches) && stripos(self::$userAgentString, 'netscape') === false ) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } self::$browser->setName(Browser::MOZILLA); return true; } return false; }
[ "public", "static", "function", "checkBrowserMozilla", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'mozilla'", ")", "!==", "false", "&&", "preg_match", "(", "'/rv:[0-9].[0-9][a-b]?/i'", ",", "self", "::", "$", "userAge...
Determine if the browser is Mozilla. @return bool
[ "Determine", "if", "the", "browser", "is", "Mozilla", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L828-L862
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserLynx
public static function checkBrowserLynx() { if (stripos(self::$userAgentString, 'lynx') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Lynx')); $aversion = explode(' ', (isset($aresult[1]) ? $aresult[1] : '')); self::$browser->setVersion($aversion[0]); self::$browser->setName(Browser::LYNX); return true; } return false; }
php
public static function checkBrowserLynx() { if (stripos(self::$userAgentString, 'lynx') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Lynx')); $aversion = explode(' ', (isset($aresult[1]) ? $aresult[1] : '')); self::$browser->setVersion($aversion[0]); self::$browser->setName(Browser::LYNX); return true; } return false; }
[ "public", "static", "function", "checkBrowserLynx", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'lynx'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self", "...
Determine if the browser is Lynx. @return bool
[ "Determine", "if", "the", "browser", "is", "Lynx", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L869-L881
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserAmaya
public static function checkBrowserAmaya() { if (stripos(self::$userAgentString, 'amaya') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Amaya')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::AMAYA); return true; } return false; }
php
public static function checkBrowserAmaya() { if (stripos(self::$userAgentString, 'amaya') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Amaya')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::AMAYA); return true; } return false; }
[ "public", "static", "function", "checkBrowserAmaya", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'amaya'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self", ...
Determine if the browser is Amaya. @return bool
[ "Determine", "if", "the", "browser", "is", "Amaya", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L888-L902
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserWkhtmltopdf
public static function checkBrowserWkhtmltopdf() { if (stripos(self::$userAgentString, 'wkhtmltopdf') !== false) { self::$browser->setName(Browser::WKHTMLTOPDF); return true; } return false; }
php
public static function checkBrowserWkhtmltopdf() { if (stripos(self::$userAgentString, 'wkhtmltopdf') !== false) { self::$browser->setName(Browser::WKHTMLTOPDF); return true; } return false; }
[ "public", "static", "function", "checkBrowserWkhtmltopdf", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'wkhtmltopdf'", ")", "!==", "false", ")", "{", "self", "::", "$", "browser", "->", "setName", "(", "Browser", "...
Determine if the browser is Safari. @return bool
[ "Determine", "if", "the", "browser", "is", "Safari", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L909-L917
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserSafari
public static function checkBrowserSafari() { if (stripos(self::$userAgentString, 'Safari') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Version')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } else { self::$browser->setVersion(Browser::VERSION_UNKNOWN); } self::$browser->setName(Browser::SAFARI); return true; } return false; }
php
public static function checkBrowserSafari() { if (stripos(self::$userAgentString, 'Safari') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Version')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } else { self::$browser->setVersion(Browser::VERSION_UNKNOWN); } self::$browser->setName(Browser::SAFARI); return true; } return false; }
[ "public", "static", "function", "checkBrowserSafari", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Safari'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self",...
Determine if the browser is Safari. @return bool
[ "Determine", "if", "the", "browser", "is", "Safari", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L923-L939
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserYandex
public static function checkBrowserYandex() { if (stripos(self::$userAgentString, 'YaBrowser') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'YaBrowser')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::YANDEX); return true; } return false; }
php
public static function checkBrowserYandex() { if (stripos(self::$userAgentString, 'YaBrowser') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'YaBrowser')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::YANDEX); return true; } return false; }
[ "public", "static", "function", "checkBrowserYandex", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'YaBrowser'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "sel...
Determine if the browser is Yandex. @return bool
[ "Determine", "if", "the", "browser", "is", "Yandex", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L946-L960
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserDragon
public static function checkBrowserDragon() { if (stripos(self::$userAgentString, 'Dragon') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Dragon')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::DRAGON); return true; } return false; }
php
public static function checkBrowserDragon() { if (stripos(self::$userAgentString, 'Dragon') !== false) { $aresult = explode('/', stristr(self::$userAgentString, 'Dragon')); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); self::$browser->setVersion($aversion[0]); } self::$browser->setName(Browser::DRAGON); return true; } return false; }
[ "public", "static", "function", "checkBrowserDragon", "(", ")", "{", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Dragon'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "self",...
Determine if the browser is Comodo Dragon / Ice Dragon / Chromodo. @return bool
[ "Determine", "if", "the", "browser", "is", "Comodo", "Dragon", "/", "Ice", "Dragon", "/", "Chromodo", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L967-L981
sinergi/php-browser-detector
src/BrowserDetector.php
BrowserDetector.checkBrowserAndroid
public static function checkBrowserAndroid() { // Navigator if (stripos(self::$userAgentString, 'Android') !== false) { if (preg_match('/Version\/([\d\.]*)/i', self::$userAgentString, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } } else { self::$browser->setVersion(Browser::VERSION_UNKNOWN); } self::$browser->setName(Browser::NAVIGATOR); return true; } return false; }
php
public static function checkBrowserAndroid() { // Navigator if (stripos(self::$userAgentString, 'Android') !== false) { if (preg_match('/Version\/([\d\.]*)/i', self::$userAgentString, $matches)) { if (isset($matches[1])) { self::$browser->setVersion($matches[1]); } } else { self::$browser->setVersion(Browser::VERSION_UNKNOWN); } self::$browser->setName(Browser::NAVIGATOR); return true; } return false; }
[ "public", "static", "function", "checkBrowserAndroid", "(", ")", "{", "// Navigator", "if", "(", "stripos", "(", "self", "::", "$", "userAgentString", ",", "'Android'", ")", "!==", "false", ")", "{", "if", "(", "preg_match", "(", "'/Version\\/([\\d\\.]*)/i'", ...
Determine if the browser is Android. @return bool
[ "Determine", "if", "the", "browser", "is", "Android", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/BrowserDetector.php#L988-L1005
sinergi/php-browser-detector
src/DeviceDetector.php
DeviceDetector.detect
public static function detect(Device $device, UserAgent $userAgent) { $device->setName($device::UNKNOWN); return ( self::checkIpad($device, $userAgent) || self::checkIphone($device, $userAgent) || self::checkWindowsPhone($device, $userAgent) || self::checkSamsungPhone($device, $userAgent) ); }
php
public static function detect(Device $device, UserAgent $userAgent) { $device->setName($device::UNKNOWN); return ( self::checkIpad($device, $userAgent) || self::checkIphone($device, $userAgent) || self::checkWindowsPhone($device, $userAgent) || self::checkSamsungPhone($device, $userAgent) ); }
[ "public", "static", "function", "detect", "(", "Device", "$", "device", ",", "UserAgent", "$", "userAgent", ")", "{", "$", "device", "->", "setName", "(", "$", "device", "::", "UNKNOWN", ")", ";", "return", "(", "self", "::", "checkIpad", "(", "$", "de...
Determine the user's device. @param Device $device @param UserAgent $userAgent @return bool
[ "Determine", "the", "user", "s", "device", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/DeviceDetector.php#L14-L24
sinergi/php-browser-detector
src/DeviceDetector.php
DeviceDetector.checkIpad
private static function checkIpad(Device $device, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'ipad') !== false) { $device->setName(Device::IPAD); return true; } return false; }
php
private static function checkIpad(Device $device, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'ipad') !== false) { $device->setName(Device::IPAD); return true; } return false; }
[ "private", "static", "function", "checkIpad", "(", "Device", "$", "device", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'ipad'", ")", "!==", "false", ")", "{", "$"...
Determine if the device is iPad. @param Device $device @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "device", "is", "iPad", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/DeviceDetector.php#L33-L41
sinergi/php-browser-detector
src/DeviceDetector.php
DeviceDetector.checkIphone
private static function checkIphone(Device $device, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'iphone;') !== false) { $device->setName(Device::IPHONE); return true; } return false; }
php
private static function checkIphone(Device $device, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'iphone;') !== false) { $device->setName(Device::IPHONE); return true; } return false; }
[ "private", "static", "function", "checkIphone", "(", "Device", "$", "device", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'iphone;'", ")", "!==", "false", ")", "{", ...
Determine if the device is iPhone. @param Device $device @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "device", "is", "iPhone", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/DeviceDetector.php#L50-L58
sinergi/php-browser-detector
src/DeviceDetector.php
DeviceDetector.checkWindowsPhone
private static function checkWindowsPhone(Device $device, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) { if (preg_match('/Microsoft; (Lumia [^)]*)\)/', $userAgent->getUserAgentString(), $matches)) { $device->setName($matches[1]); return true; } $device->setName($device::WINDOWS_PHONE); return true; } return false; }
php
private static function checkWindowsPhone(Device $device, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) { if (preg_match('/Microsoft; (Lumia [^)]*)\)/', $userAgent->getUserAgentString(), $matches)) { $device->setName($matches[1]); return true; } $device->setName($device::WINDOWS_PHONE); return true; } return false; }
[ "private", "static", "function", "checkWindowsPhone", "(", "Device", "$", "device", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'Windows Phone'", ")", "!==", "false", ...
Determine if the device is Windows Phone. @param Device $device @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "device", "is", "Windows", "Phone", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/DeviceDetector.php#L67-L79
sinergi/php-browser-detector
src/DeviceDetector.php
DeviceDetector.checkSamsungPhone
private static function checkSamsungPhone(Device $device, UserAgent $userAgent) { if (preg_match('/SAMSUNG SM-([^ ]*)/i', $userAgent->getUserAgentString(), $matches)) { $device->setName(str_ireplace('SAMSUNG', 'Samsung', $matches[0])); return true; } return false; }
php
private static function checkSamsungPhone(Device $device, UserAgent $userAgent) { if (preg_match('/SAMSUNG SM-([^ ]*)/i', $userAgent->getUserAgentString(), $matches)) { $device->setName(str_ireplace('SAMSUNG', 'Samsung', $matches[0])); return true; } return false; }
[ "private", "static", "function", "checkSamsungPhone", "(", "Device", "$", "device", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "preg_match", "(", "'/SAMSUNG SM-([^ ]*)/i'", ",", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "$", "m...
Determine if the device is Windows Phone. @param Device $device @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "device", "is", "Windows", "Phone", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/DeviceDetector.php#L88-L95
sinergi/php-browser-detector
src/Language.php
Language.getLanguages
public function getLanguages() { if (!is_array($this->languages)) { LanguageDetector::detect($this, $this->getAcceptLanguage()); } return $this->languages; }
php
public function getLanguages() { if (!is_array($this->languages)) { LanguageDetector::detect($this, $this->getAcceptLanguage()); } return $this->languages; }
[ "public", "function", "getLanguages", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "languages", ")", ")", "{", "LanguageDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getAcceptLanguage", "(", ")", ")", ";", ...
Get all user's languages. @return array
[ "Get", "all", "user", "s", "languages", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Language.php#L41-L48
sinergi/php-browser-detector
src/Language.php
Language.getLanguage
public function getLanguage() { if (!is_array($this->languages)) { LanguageDetector::detect($this, $this->getAcceptLanguage()); } return strtolower(substr(reset($this->languages), 0, 2)); }
php
public function getLanguage() { if (!is_array($this->languages)) { LanguageDetector::detect($this, $this->getAcceptLanguage()); } return strtolower(substr(reset($this->languages), 0, 2)); }
[ "public", "function", "getLanguage", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "languages", ")", ")", "{", "LanguageDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getAcceptLanguage", "(", ")", ")", ";", ...
Get a user's language. @return string
[ "Get", "a", "user", "s", "language", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Language.php#L69-L76
sinergi/php-browser-detector
src/Language.php
Language.getLanguageLocale
public function getLanguageLocale($separator = '-') { if (!is_array($this->languages)) { LanguageDetector::detect($this, $this->getAcceptLanguage()); } $userLanguage = $this->getLanguage(); foreach ($this->languages as $language) { if (strlen($language) === 5 && strpos($language, $userLanguage) === 0) { $locale = substr($language, -2); break; } } if (!empty($locale)) { return $userLanguage . $separator . strtoupper($locale); } else { return $userLanguage; } }
php
public function getLanguageLocale($separator = '-') { if (!is_array($this->languages)) { LanguageDetector::detect($this, $this->getAcceptLanguage()); } $userLanguage = $this->getLanguage(); foreach ($this->languages as $language) { if (strlen($language) === 5 && strpos($language, $userLanguage) === 0) { $locale = substr($language, -2); break; } } if (!empty($locale)) { return $userLanguage . $separator . strtoupper($locale); } else { return $userLanguage; } }
[ "public", "function", "getLanguageLocale", "(", "$", "separator", "=", "'-'", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "languages", ")", ")", "{", "LanguageDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getAc...
Get a user's language and locale. @param string $separator @return string
[ "Get", "a", "user", "s", "language", "and", "locale", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Language.php#L85-L104
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.detect
public static function detect(Os $os, UserAgent $userAgent) { $os->setName($os::UNKNOWN); $os->setVersion($os::VERSION_UNKNOWN); $os->setIsMobile(false); self::checkMobileBrowsers($os, $userAgent); return ( // Chrome OS before OS X self::checkChromeOs($os, $userAgent) || // iOS before OS X self::checkIOS($os, $userAgent) || self::checkOSX($os, $userAgent) || self::checkSymbOS($os, $userAgent) || self::checkWindows($os, $userAgent) || self::checkWindowsPhone($os, $userAgent) || self::checkFreeBSD($os, $userAgent) || self::checkOpenBSD($os, $userAgent) || self::checkNetBSD($os, $userAgent) || self::checkOpenSolaris($os, $userAgent) || self::checkSunOS($os, $userAgent) || self::checkOS2($os, $userAgent) || self::checkBeOS($os, $userAgent) || // Android before Linux self::checkAndroid($os, $userAgent) || self::checkLinux($os, $userAgent) || self::checkNokia($os, $userAgent) || self::checkBlackBerry($os, $userAgent) ); }
php
public static function detect(Os $os, UserAgent $userAgent) { $os->setName($os::UNKNOWN); $os->setVersion($os::VERSION_UNKNOWN); $os->setIsMobile(false); self::checkMobileBrowsers($os, $userAgent); return ( // Chrome OS before OS X self::checkChromeOs($os, $userAgent) || // iOS before OS X self::checkIOS($os, $userAgent) || self::checkOSX($os, $userAgent) || self::checkSymbOS($os, $userAgent) || self::checkWindows($os, $userAgent) || self::checkWindowsPhone($os, $userAgent) || self::checkFreeBSD($os, $userAgent) || self::checkOpenBSD($os, $userAgent) || self::checkNetBSD($os, $userAgent) || self::checkOpenSolaris($os, $userAgent) || self::checkSunOS($os, $userAgent) || self::checkOS2($os, $userAgent) || self::checkBeOS($os, $userAgent) || // Android before Linux self::checkAndroid($os, $userAgent) || self::checkLinux($os, $userAgent) || self::checkNokia($os, $userAgent) || self::checkBlackBerry($os, $userAgent) ); }
[ "public", "static", "function", "detect", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "$", "os", "->", "setName", "(", "$", "os", "::", "UNKNOWN", ")", ";", "$", "os", "->", "setVersion", "(", "$", "os", "::", "VERSION_UNKNOWN...
Determine the user's operating system. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "the", "user", "s", "operating", "system", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L15-L45
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkMobileBrowsers
public static function checkMobileBrowsers(Os $os, UserAgent $userAgent) { // Check for Opera Mini if (stripos($userAgent->getUserAgentString(), 'opera mini') !== false) { $os->setIsMobile(true); } // Set is mobile for Pocket IE elseif (stripos($userAgent->getUserAgentString(), 'mspie') !== false || stripos($userAgent->getUserAgentString(), 'pocket') !== false) { $os->setIsMobile(true); } }
php
public static function checkMobileBrowsers(Os $os, UserAgent $userAgent) { // Check for Opera Mini if (stripos($userAgent->getUserAgentString(), 'opera mini') !== false) { $os->setIsMobile(true); } // Set is mobile for Pocket IE elseif (stripos($userAgent->getUserAgentString(), 'mspie') !== false || stripos($userAgent->getUserAgentString(), 'pocket') !== false) { $os->setIsMobile(true); } }
[ "public", "static", "function", "checkMobileBrowsers", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "// Check for Opera Mini", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'opera mini'", ")", "...
Determine if the user's browser is on a mobile device. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "browser", "is", "on", "a", "mobile", "device", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L55-L65
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkIOS
private static function checkIOS(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'CPU OS') !== false || stripos($userAgent->getUserAgentString(), 'iPhone OS') !== false && stripos($userAgent->getUserAgentString(), 'OS X')) { $os->setName($os::IOS); if (preg_match('/CPU( iPhone)? OS ([\d_]*)/i', $userAgent->getUserAgentString(), $matches)) { $os->setVersion(str_replace('_', '.', $matches[2])); } $os->setIsMobile(true); return true; } return false; }
php
private static function checkIOS(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'CPU OS') !== false || stripos($userAgent->getUserAgentString(), 'iPhone OS') !== false && stripos($userAgent->getUserAgentString(), 'OS X')) { $os->setName($os::IOS); if (preg_match('/CPU( iPhone)? OS ([\d_]*)/i', $userAgent->getUserAgentString(), $matches)) { $os->setVersion(str_replace('_', '.', $matches[2])); } $os->setIsMobile(true); return true; } return false; }
[ "private", "static", "function", "checkIOS", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'CPU OS'", ")", "!==", "false", "||", "stripos", "("...
Determine if the user's operating system is iOS. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "iOS", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L75-L90
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkChromeOs
private static function checkChromeOs(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), ' CrOS') !== false || stripos($userAgent->getUserAgentString(), 'CrOS ') !== false ) { $os->setName($os::CHROME_OS); if (preg_match('/Chrome\/([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) { $os->setVersion($matches[1]); } return true; } return false; }
php
private static function checkChromeOs(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), ' CrOS') !== false || stripos($userAgent->getUserAgentString(), 'CrOS ') !== false ) { $os->setName($os::CHROME_OS); if (preg_match('/Chrome\/([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) { $os->setVersion($matches[1]); } return true; } return false; }
[ "private", "static", "function", "checkChromeOs", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "' CrOS'", ")", "!==", "false", "||", "stripos", ...
Determine if the user's operating system is Chrome OS. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "Chrome", "OS", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L100-L113
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkOSX
private static function checkOSX(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'OS X') !== false) { $os->setName($os::OSX); if (preg_match('/OS X ([\d\._]*)/i', $userAgent->getUserAgentString(), $matches)) { if (isset($matches[1])) { $os->setVersion(str_replace('_', '.', $matches[1])); } } return true; } return false; }
php
private static function checkOSX(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'OS X') !== false) { $os->setName($os::OSX); if (preg_match('/OS X ([\d\._]*)/i', $userAgent->getUserAgentString(), $matches)) { if (isset($matches[1])) { $os->setVersion(str_replace('_', '.', $matches[1])); } } return true; } return false; }
[ "private", "static", "function", "checkOSX", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'OS X'", ")", "!==", "false", ")", "{", "$", "os",...
Determine if the user's operating system is OS X. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "OS", "X", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L123-L137
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkWindows
private static function checkWindows(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Windows NT') !== false) { $os->setName($os::WINDOWS); // Windows version if (preg_match('/Windows NT ([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) { if (isset($matches[1])) { switch (str_replace('_', '.', $matches[1])) { case '6.3': $os->setVersion('8.1'); break; case '6.2': $os->setVersion('8'); break; case '6.1': $os->setVersion('7'); break; case '6.0': $os->setVersion('Vista'); break; case '5.2': case '5.1': $os->setVersion('XP'); break; case '5.01': case '5.0': $os->setVersion('2000'); break; case '4.0': $os->setVersion('NT 4.0'); break; default: if ((float)$matches[1] >= 10.0) { $os->setVersion($matches[1]); } break; } } } return true; } // Windows Me, Windows 98, Windows 95, Windows CE elseif (preg_match( '/(Windows 98; Win 9x 4\.90|Windows 98|Windows 95|Windows CE)/i', $userAgent->getUserAgentString(), $matches )) { $os->setName($os::WINDOWS); switch (strtolower($matches[0])) { case 'windows 98; win 9x 4.90': $os->setVersion('Me'); break; case 'windows 98': $os->setVersion('98'); break; case 'windows 95': $os->setVersion('95'); break; case 'windows ce': $os->setVersion('CE'); break; } return true; } return false; }
php
private static function checkWindows(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Windows NT') !== false) { $os->setName($os::WINDOWS); // Windows version if (preg_match('/Windows NT ([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) { if (isset($matches[1])) { switch (str_replace('_', '.', $matches[1])) { case '6.3': $os->setVersion('8.1'); break; case '6.2': $os->setVersion('8'); break; case '6.1': $os->setVersion('7'); break; case '6.0': $os->setVersion('Vista'); break; case '5.2': case '5.1': $os->setVersion('XP'); break; case '5.01': case '5.0': $os->setVersion('2000'); break; case '4.0': $os->setVersion('NT 4.0'); break; default: if ((float)$matches[1] >= 10.0) { $os->setVersion($matches[1]); } break; } } } return true; } // Windows Me, Windows 98, Windows 95, Windows CE elseif (preg_match( '/(Windows 98; Win 9x 4\.90|Windows 98|Windows 95|Windows CE)/i', $userAgent->getUserAgentString(), $matches )) { $os->setName($os::WINDOWS); switch (strtolower($matches[0])) { case 'windows 98; win 9x 4.90': $os->setVersion('Me'); break; case 'windows 98': $os->setVersion('98'); break; case 'windows 95': $os->setVersion('95'); break; case 'windows ce': $os->setVersion('CE'); break; } return true; } return false; }
[ "private", "static", "function", "checkWindows", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'Windows NT'", ")", "!==", "false", ")", "{", "$...
Determine if the user's operating system is Windows. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "Windows", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L147-L214
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkWindowsPhone
private static function checkWindowsPhone(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) { $os->setIsMobile(true); $os->setName($os::WINDOWS_PHONE); // Windows version if (preg_match('/Windows Phone ([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) { if (isset($matches[1])) { $os->setVersion((float)$matches[1]); } } return true; } return false; }
php
private static function checkWindowsPhone(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) { $os->setIsMobile(true); $os->setName($os::WINDOWS_PHONE); // Windows version if (preg_match('/Windows Phone ([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) { if (isset($matches[1])) { $os->setVersion((float)$matches[1]); } } return true; } return false; }
[ "private", "static", "function", "checkWindowsPhone", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'Windows Phone'", ")", "!==", "false", ")", "...
Determine if the user's operating system is Windows Phone. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "Windows", "Phone", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L224-L239
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkSymbOS
private static function checkSymbOS(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'SymbOS') !== false) { $os->setName($os::SYMBOS); return true; } return false; }
php
private static function checkSymbOS(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'SymbOS') !== false) { $os->setName($os::SYMBOS); return true; } return false; }
[ "private", "static", "function", "checkSymbOS", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'SymbOS'", ")", "!==", "false", ")", "{", "$", ...
Determine if the user's operating system is SymbOS. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "SymbOS", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L249-L258
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkLinux
private static function checkLinux(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Linux') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::LINUX); return true; } return false; }
php
private static function checkLinux(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Linux') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::LINUX); return true; } return false; }
[ "private", "static", "function", "checkLinux", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'Linux'", ")", "!==", "false", ")", "{", "$", "o...
Determine if the user's operating system is Linux. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "Linux", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L268-L278
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkNokia
private static function checkNokia(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Nokia') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::NOKIA); $os->setIsMobile(true); return true; } return false; }
php
private static function checkNokia(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Nokia') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::NOKIA); $os->setIsMobile(true); return true; } return false; }
[ "private", "static", "function", "checkNokia", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'Nokia'", ")", "!==", "false", ")", "{", "$", "o...
Determine if the user's operating system is Nokia. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "Nokia", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L288-L299
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkBlackBerry
private static function checkBlackBerry(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'BlackBerry') !== false) { if (stripos($userAgent->getUserAgentString(), 'Version/') !== false) { $aresult = explode('Version/', $userAgent->getUserAgentString()); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); $os->setVersion($aversion[0]); } } else { $os->setVersion($os::VERSION_UNKNOWN); } $os->setName($os::BLACKBERRY); $os->setIsMobile(true); return true; } elseif (stripos($userAgent->getUserAgentString(), 'BB10') !== false) { $aresult = explode('Version/10.', $userAgent->getUserAgentString()); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); $os->setVersion('10.' . $aversion[0]); } else { $os->setVersion('10'); } $os->setName($os::BLACKBERRY); $os->setIsMobile(true); return true; } return false; }
php
private static function checkBlackBerry(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'BlackBerry') !== false) { if (stripos($userAgent->getUserAgentString(), 'Version/') !== false) { $aresult = explode('Version/', $userAgent->getUserAgentString()); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); $os->setVersion($aversion[0]); } } else { $os->setVersion($os::VERSION_UNKNOWN); } $os->setName($os::BLACKBERRY); $os->setIsMobile(true); return true; } elseif (stripos($userAgent->getUserAgentString(), 'BB10') !== false) { $aresult = explode('Version/10.', $userAgent->getUserAgentString()); if (isset($aresult[1])) { $aversion = explode(' ', $aresult[1]); $os->setVersion('10.' . $aversion[0]); } else { $os->setVersion('10'); } $os->setName($os::BLACKBERRY); $os->setIsMobile(true); return true; } return false; }
[ "private", "static", "function", "checkBlackBerry", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'BlackBerry'", ")", "!==", "false", ")", "{", ...
Determine if the user's operating system is BlackBerry. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "BlackBerry", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L309-L340
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkAndroid
private static function checkAndroid(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Android') !== false) { if (preg_match('/Android ([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) { if (isset($matches[1])) { $os->setVersion($matches[1]); } } else { $os->setVersion($os::VERSION_UNKNOWN); } $os->setName($os::ANDROID); $os->setIsMobile(true); return true; } return false; }
php
private static function checkAndroid(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'Android') !== false) { if (preg_match('/Android ([\d\.]*)/i', $userAgent->getUserAgentString(), $matches)) { if (isset($matches[1])) { $os->setVersion($matches[1]); } } else { $os->setVersion($os::VERSION_UNKNOWN); } $os->setName($os::ANDROID); $os->setIsMobile(true); return true; } return false; }
[ "private", "static", "function", "checkAndroid", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'Android'", ")", "!==", "false", ")", "{", "if",...
Determine if the user's operating system is Android. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "Android", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L350-L367
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkFreeBSD
private static function checkFreeBSD(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'FreeBSD') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::FREEBSD); return true; } return false; }
php
private static function checkFreeBSD(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'FreeBSD') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::FREEBSD); return true; } return false; }
[ "private", "static", "function", "checkFreeBSD", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'FreeBSD'", ")", "!==", "false", ")", "{", "$", ...
Determine if the user's operating system is FreeBSD. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "FreeBSD", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L377-L387
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkOpenBSD
private static function checkOpenBSD(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'OpenBSD') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::OPENBSD); return true; } return false; }
php
private static function checkOpenBSD(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'OpenBSD') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::OPENBSD); return true; } return false; }
[ "private", "static", "function", "checkOpenBSD", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'OpenBSD'", ")", "!==", "false", ")", "{", "$", ...
Determine if the user's operating system is OpenBSD. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "OpenBSD", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L397-L407
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkSunOS
private static function checkSunOS(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'SunOS') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::SUNOS); return true; } return false; }
php
private static function checkSunOS(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'SunOS') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::SUNOS); return true; } return false; }
[ "private", "static", "function", "checkSunOS", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'SunOS'", ")", "!==", "false", ")", "{", "$", "o...
Determine if the user's operating system is SunOS. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "SunOS", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L417-L427
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkNetBSD
private static function checkNetBSD(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'NetBSD') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::NETBSD); return true; } return false; }
php
private static function checkNetBSD(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'NetBSD') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::NETBSD); return true; } return false; }
[ "private", "static", "function", "checkNetBSD", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'NetBSD'", ")", "!==", "false", ")", "{", "$", ...
Determine if the user's operating system is NetBSD. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "NetBSD", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L437-L447
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkOpenSolaris
private static function checkOpenSolaris(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'OpenSolaris') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::OPENSOLARIS); return true; } return false; }
php
private static function checkOpenSolaris(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'OpenSolaris') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::OPENSOLARIS); return true; } return false; }
[ "private", "static", "function", "checkOpenSolaris", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'OpenSolaris'", ")", "!==", "false", ")", "{",...
Determine if the user's operating system is OpenSolaris. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "OpenSolaris", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L457-L467
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkOS2
private static function checkOS2(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'OS\/2') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::OS2); return true; } return false; }
php
private static function checkOS2(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'OS\/2') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::OS2); return true; } return false; }
[ "private", "static", "function", "checkOS2", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'OS\\/2'", ")", "!==", "false", ")", "{", "$", "os...
Determine if the user's operating system is OS2. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "OS2", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L477-L487
sinergi/php-browser-detector
src/OsDetector.php
OsDetector.checkBeOS
private static function checkBeOS(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'BeOS') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::BEOS); return true; } return false; }
php
private static function checkBeOS(Os $os, UserAgent $userAgent) { if (stripos($userAgent->getUserAgentString(), 'BeOS') !== false) { $os->setVersion($os::VERSION_UNKNOWN); $os->setName($os::BEOS); return true; } return false; }
[ "private", "static", "function", "checkBeOS", "(", "Os", "$", "os", ",", "UserAgent", "$", "userAgent", ")", "{", "if", "(", "stripos", "(", "$", "userAgent", "->", "getUserAgentString", "(", ")", ",", "'BeOS'", ")", "!==", "false", ")", "{", "$", "os"...
Determine if the user's operating system is BeOS. @param Os $os @param UserAgent $userAgent @return bool
[ "Determine", "if", "the", "user", "s", "operating", "system", "is", "BeOS", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/OsDetector.php#L497-L507
sinergi/php-browser-detector
src/Os.php
Os.getName
public function getName() { if (!isset($this->name)) { OsDetector::detect($this, $this->getUserAgent()); } return $this->name; }
php
public function getName() { if (!isset($this->name)) { OsDetector::detect($this, $this->getUserAgent()); } return $this->name; }
[ "public", "function", "getName", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", ")", "{", "OsDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getUserAgent", "(", ")", ")", ";", "}", "return", "$"...
Return the name of the OS. @return string
[ "Return", "the", "name", "of", "the", "OS", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Os.php#L72-L79
sinergi/php-browser-detector
src/Os.php
Os.getVersion
public function getVersion() { if (isset($this->version)) { return (string)$this->version; } else { OsDetector::detect($this, $this->getUserAgent()); return (string)$this->version; } }
php
public function getVersion() { if (isset($this->version)) { return (string)$this->version; } else { OsDetector::detect($this, $this->getUserAgent()); return (string)$this->version; } }
[ "public", "function", "getVersion", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "version", ")", ")", "{", "return", "(", "string", ")", "$", "this", "->", "version", ";", "}", "else", "{", "OsDetector", "::", "detect", "(", "$", "thi...
Return the version of the OS. @return string
[ "Return", "the", "version", "of", "the", "OS", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Os.php#L100-L109
sinergi/php-browser-detector
src/Os.php
Os.getIsMobile
public function getIsMobile() { if (!isset($this->name)) { OsDetector::detect($this, $this->getUserAgent()); } return $this->isMobile; }
php
public function getIsMobile() { if (!isset($this->name)) { OsDetector::detect($this, $this->getUserAgent()); } return $this->isMobile; }
[ "public", "function", "getIsMobile", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", ")", "{", "OsDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getUserAgent", "(", ")", ")", ";", "}", "return", ...
Is the browser from a mobile device? @return bool
[ "Is", "the", "browser", "from", "a", "mobile", "device?" ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Os.php#L130-L137
sinergi/php-browser-detector
src/Browser.php
Browser.getName
public function getName() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return $this->name; }
php
public function getName() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return $this->name; }
[ "public", "function", "getName", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", ")", "{", "BrowserDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getUserAgent", "(", ")", ")", ";", "}", "return", ...
Return the name of the Browser. @return string
[ "Return", "the", "name", "of", "the", "Browser", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Browser.php#L122-L129
sinergi/php-browser-detector
src/Browser.php
Browser.getVersion
public function getVersion() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return (string) $this->version; }
php
public function getVersion() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return (string) $this->version; }
[ "public", "function", "getVersion", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", ")", "{", "BrowserDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getUserAgent", "(", ")", ")", ";", "}", "return...
The version of the browser. @return string
[ "The", "version", "of", "the", "browser", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Browser.php#L162-L169
sinergi/php-browser-detector
src/Browser.php
Browser.getIsRobot
public function getIsRobot() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return $this->isRobot; }
php
public function getIsRobot() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return $this->isRobot; }
[ "public", "function", "getIsRobot", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", ")", "{", "BrowserDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getUserAgent", "(", ")", ")", ";", "}", "return...
Is the browser from a robot (ex Slurp,GoogleBot)? @return bool
[ "Is", "the", "browser", "from", "a", "robot", "(", "ex", "Slurp", "GoogleBot", ")", "?" ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Browser.php#L190-L197
sinergi/php-browser-detector
src/Browser.php
Browser.getIsChromeFrame
public function getIsChromeFrame() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return $this->isChromeFrame; }
php
public function getIsChromeFrame() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return $this->isChromeFrame; }
[ "public", "function", "getIsChromeFrame", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", ")", "{", "BrowserDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getUserAgent", "(", ")", ")", ";", "}", "...
Used to determine if the browser is actually "chromeframe". @return bool
[ "Used", "to", "determine", "if", "the", "browser", "is", "actually", "chromeframe", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Browser.php#L224-L231
sinergi/php-browser-detector
src/Browser.php
Browser.getIsFacebookWebView
public function getIsFacebookWebView() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return $this->isFacebookWebView; }
php
public function getIsFacebookWebView() { if (!isset($this->name)) { BrowserDetector::detect($this, $this->getUserAgent()); } return $this->isFacebookWebView; }
[ "public", "function", "getIsFacebookWebView", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", ")", "{", "BrowserDetector", "::", "detect", "(", "$", "this", ",", "$", "this", "->", "getUserAgent", "(", ")", ")", ";", "}",...
Used to determine if the browser is actually "facebook". @return bool
[ "Used", "to", "determine", "if", "the", "browser", "is", "actually", "facebook", "." ]
train
https://github.com/sinergi/php-browser-detector/blob/5f18a4180a3e9afffc0c9fea9ded9ae115d0f072/src/Browser.php#L258-L265
floriansemm/SolrBundle
DependencyInjection/FSSolrExtension.php
FSSolrExtension.load
public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.xml'); $loader->load('event_listener.xml'); $loader->load('log_listener.xml'); $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $this->setupClients($config, $container); if (!$container->hasParameter('solr.auto_index')) { $container->setParameter('solr.auto_index', $config['auto_index']); } $this->setupDoctrineListener($config, $container); $this->setupDoctrineConfiguration($config, $container); }
php
public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.xml'); $loader->load('event_listener.xml'); $loader->load('log_listener.xml'); $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $this->setupClients($config, $container); if (!$container->hasParameter('solr.auto_index')) { $container->setParameter('solr.auto_index', $config['auto_index']); } $this->setupDoctrineListener($config, $container); $this->setupDoctrineConfiguration($config, $container); }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "loader", "=", "new", "Loader", "\\", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resource...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/DependencyInjection/FSSolrExtension.php#L17-L36
floriansemm/SolrBundle
DependencyInjection/FSSolrExtension.php
FSSolrExtension.setupDoctrineListener
private function setupDoctrineListener(array $config, ContainerBuilder $container) { $autoIndexing = $container->getParameter('solr.auto_index'); if ($autoIndexing == false) { return; } if ($this->isODMConfigured($container)) { $container->getDefinition('solr.document.odm.subscriber')->addTag('doctrine_mongodb.odm.event_subscriber'); } if ($this->isOrmConfigured($container)) { $container->getDefinition('solr.document.orm.subscriber')->addTag('doctrine.event_subscriber'); } }
php
private function setupDoctrineListener(array $config, ContainerBuilder $container) { $autoIndexing = $container->getParameter('solr.auto_index'); if ($autoIndexing == false) { return; } if ($this->isODMConfigured($container)) { $container->getDefinition('solr.document.odm.subscriber')->addTag('doctrine_mongodb.odm.event_subscriber'); } if ($this->isOrmConfigured($container)) { $container->getDefinition('solr.document.orm.subscriber')->addTag('doctrine.event_subscriber'); } }
[ "private", "function", "setupDoctrineListener", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "autoIndexing", "=", "$", "container", "->", "getParameter", "(", "'solr.auto_index'", ")", ";", "if", "(", "$", "autoIndexing"...
doctrine_orm and doctrine_mongoDB can't be used together. mongo_db wins when it is configured. listener-methods expecting different types of events @param array $config @param ContainerBuilder $container
[ "doctrine_orm", "and", "doctrine_mongoDB", "can", "t", "be", "used", "together", ".", "mongo_db", "wins", "when", "it", "is", "configured", "." ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/DependencyInjection/FSSolrExtension.php#L96-L111
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.where
public function where($field) { $solrField = $this->metaInformation->getField($field); if ($solrField === null) { throw new UnknownFieldException(sprintf('Field %s does not exists', $field)); } $fieldName = $solrField->getNameWithAlias(); $this->criteria = Criteria::where($fieldName); return $this; }
php
public function where($field) { $solrField = $this->metaInformation->getField($field); if ($solrField === null) { throw new UnknownFieldException(sprintf('Field %s does not exists', $field)); } $fieldName = $solrField->getNameWithAlias(); $this->criteria = Criteria::where($fieldName); return $this; }
[ "public", "function", "where", "(", "$", "field", ")", "{", "$", "solrField", "=", "$", "this", "->", "metaInformation", "->", "getField", "(", "$", "field", ")", ";", "if", "(", "$", "solrField", "===", "null", ")", "{", "throw", "new", "UnknownFieldE...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L41-L53
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.andWhere
public function andWhere($field) { if ($field instanceof QueryBuilder) { $this->criteria = $this->criteria->andWhere($field->getCriteria()); return $this; } $solrField = $this->metaInformation->getField($field); if ($solrField === null) { throw new UnknownFieldException(sprintf('Field %s does not exists', $field)); } $fieldName = $solrField->getNameWithAlias(); $this->criteria = $this->criteria->andWhere($fieldName); return $this; }
php
public function andWhere($field) { if ($field instanceof QueryBuilder) { $this->criteria = $this->criteria->andWhere($field->getCriteria()); return $this; } $solrField = $this->metaInformation->getField($field); if ($solrField === null) { throw new UnknownFieldException(sprintf('Field %s does not exists', $field)); } $fieldName = $solrField->getNameWithAlias(); $this->criteria = $this->criteria->andWhere($fieldName); return $this; }
[ "public", "function", "andWhere", "(", "$", "field", ")", "{", "if", "(", "$", "field", "instanceof", "QueryBuilder", ")", "{", "$", "this", "->", "criteria", "=", "$", "this", "->", "criteria", "->", "andWhere", "(", "$", "field", "->", "getCriteria", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L58-L76
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.between
public function between($lowerBound, $upperBound, $includeLowerBound = true, $includeUpperBound = true) { $this->criteria = $this->criteria->between($lowerBound, $upperBound, $includeLowerBound, $includeUpperBound); return $this; }
php
public function between($lowerBound, $upperBound, $includeLowerBound = true, $includeUpperBound = true) { $this->criteria = $this->criteria->between($lowerBound, $upperBound, $includeLowerBound, $includeUpperBound); return $this; }
[ "public", "function", "between", "(", "$", "lowerBound", ",", "$", "upperBound", ",", "$", "includeLowerBound", "=", "true", ",", "$", "includeUpperBound", "=", "true", ")", "{", "$", "this", "->", "criteria", "=", "$", "this", "->", "criteria", "->", "b...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L114-L119
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.withinCircle
public function withinCircle($latitude, $longitude, $distance) { $this->criteria = $this->criteria->withinCircle($latitude, $longitude, $distance); return $this; }
php
public function withinCircle($latitude, $longitude, $distance) { $this->criteria = $this->criteria->withinCircle($latitude, $longitude, $distance); return $this; }
[ "public", "function", "withinCircle", "(", "$", "latitude", ",", "$", "longitude", ",", "$", "distance", ")", "{", "$", "this", "->", "criteria", "=", "$", "this", "->", "criteria", "->", "withinCircle", "(", "$", "latitude", ",", "$", "longitude", ",", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L134-L139
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.withinBox
public function withinBox($startLatitude, $startLongitude, $endLatitude, $endLongitude) { $this->criteria = $this->criteria->withinBox($startLatitude, $startLongitude, $endLatitude, $endLongitude); return $this; }
php
public function withinBox($startLatitude, $startLongitude, $endLatitude, $endLongitude) { $this->criteria = $this->criteria->withinBox($startLatitude, $startLongitude, $endLatitude, $endLongitude); return $this; }
[ "public", "function", "withinBox", "(", "$", "startLatitude", ",", "$", "startLongitude", ",", "$", "endLatitude", ",", "$", "endLongitude", ")", "{", "$", "this", "->", "criteria", "=", "$", "this", "->", "criteria", "->", "withinBox", "(", "$", "startLat...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L144-L149
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.nearCircle
public function nearCircle($latitude, $longitude, $distance) { $this->criteria = $this->criteria->nearCircle($latitude, $longitude, $distance); return $this; }
php
public function nearCircle($latitude, $longitude, $distance) { $this->criteria = $this->criteria->nearCircle($latitude, $longitude, $distance); return $this; }
[ "public", "function", "nearCircle", "(", "$", "latitude", ",", "$", "longitude", ",", "$", "distance", ")", "{", "$", "this", "->", "criteria", "=", "$", "this", "->", "criteria", "->", "nearCircle", "(", "$", "latitude", ",", "$", "longitude", ",", "$...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L154-L159
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.fuzzy
public function fuzzy($value, $levenshteinDistance = null) { $this->criteria = $this->criteria->fuzzy($value, $levenshteinDistance); return $this; }
php
public function fuzzy($value, $levenshteinDistance = null) { $this->criteria = $this->criteria->fuzzy($value, $levenshteinDistance); return $this; }
[ "public", "function", "fuzzy", "(", "$", "value", ",", "$", "levenshteinDistance", "=", "null", ")", "{", "$", "this", "->", "criteria", "=", "$", "this", "->", "criteria", "->", "fuzzy", "(", "$", "value", ",", "$", "levenshteinDistance", ")", ";", "r...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L234-L239
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.sloppy
public function sloppy($phrase, $distance) { $this->criteria = $this->criteria->sloppy($phrase, $distance); return $this; }
php
public function sloppy($phrase, $distance) { $this->criteria = $this->criteria->sloppy($phrase, $distance); return $this; }
[ "public", "function", "sloppy", "(", "$", "phrase", ",", "$", "distance", ")", "{", "$", "this", "->", "criteria", "=", "$", "this", "->", "criteria", "->", "sloppy", "(", "$", "phrase", ",", "$", "distance", ")", ";", "return", "$", "this", ";", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L244-L249
floriansemm/SolrBundle
Query/QueryBuilder.php
QueryBuilder.getQuery
public function getQuery() { $query = new SolrQuery(); $query->setSolr($this->solr); $query->setRows(1000000); $query->setCustomQuery($this->criteria->getQuery()); $query->setIndex($this->metaInformation->getIndex()); $query->setEntity($this->metaInformation->getEntity()); $query->setMetaInformation($this->metaInformation); return $query; }
php
public function getQuery() { $query = new SolrQuery(); $query->setSolr($this->solr); $query->setRows(1000000); $query->setCustomQuery($this->criteria->getQuery()); $query->setIndex($this->metaInformation->getIndex()); $query->setEntity($this->metaInformation->getEntity()); $query->setMetaInformation($this->metaInformation); return $query; }
[ "public", "function", "getQuery", "(", ")", "{", "$", "query", "=", "new", "SolrQuery", "(", ")", ";", "$", "query", "->", "setSolr", "(", "$", "this", "->", "solr", ")", ";", "$", "query", "->", "setRows", "(", "1000000", ")", ";", "$", "query", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Query/QueryBuilder.php#L312-L323
floriansemm/SolrBundle
Doctrine/Hydration/DoctrineHydrator.php
DoctrineHydrator.hydrate
public function hydrate($document, MetaInformationInterface $metaInformation) { $entityId = $this->valueHydrator->removePrefixedKeyValues($document['id']); $doctrineEntity = null; if ($metaInformation->getDoctrineMapperType() == MetaInformationInterface::DOCTRINE_MAPPER_TYPE_RELATIONAL) { $doctrineEntity = $this->ormManager ->getManager() ->getRepository($metaInformation->getClassName()) ->find($entityId); } elseif ($metaInformation->getDoctrineMapperType() == MetaInformationInterface::DOCTRINE_MAPPER_TYPE_DOCUMENT) { $doctrineEntity = $this->odmManager ->getManager() ->getRepository($metaInformation->getClassName()) ->find($entityId); } if ($doctrineEntity !== null) { $metaInformation->setEntity($doctrineEntity); } return $this->valueHydrator->hydrate($document, $metaInformation); }
php
public function hydrate($document, MetaInformationInterface $metaInformation) { $entityId = $this->valueHydrator->removePrefixedKeyValues($document['id']); $doctrineEntity = null; if ($metaInformation->getDoctrineMapperType() == MetaInformationInterface::DOCTRINE_MAPPER_TYPE_RELATIONAL) { $doctrineEntity = $this->ormManager ->getManager() ->getRepository($metaInformation->getClassName()) ->find($entityId); } elseif ($metaInformation->getDoctrineMapperType() == MetaInformationInterface::DOCTRINE_MAPPER_TYPE_DOCUMENT) { $doctrineEntity = $this->odmManager ->getManager() ->getRepository($metaInformation->getClassName()) ->find($entityId); } if ($doctrineEntity !== null) { $metaInformation->setEntity($doctrineEntity); } return $this->valueHydrator->hydrate($document, $metaInformation); }
[ "public", "function", "hydrate", "(", "$", "document", ",", "MetaInformationInterface", "$", "metaInformation", ")", "{", "$", "entityId", "=", "$", "this", "->", "valueHydrator", "->", "removePrefixedKeyValues", "(", "$", "document", "[", "'id'", "]", ")", ";...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Hydration/DoctrineHydrator.php#L59-L81
floriansemm/SolrBundle
Logging/DebugLogger.php
DebugLogger.startRequest
public function startRequest(array $request) { $this->start = microtime(true); $this->queries[++$this->currentQuery] = [ 'request' => $request, 'executionMS' => 0 ]; }
php
public function startRequest(array $request) { $this->start = microtime(true); $this->queries[++$this->currentQuery] = [ 'request' => $request, 'executionMS' => 0 ]; }
[ "public", "function", "startRequest", "(", "array", "$", "request", ")", "{", "$", "this", "->", "start", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "queries", "[", "++", "$", "this", "->", "currentQuery", "]", "=", "[", "'request'", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Logging/DebugLogger.php#L36-L43
floriansemm/SolrBundle
Client/Solarium/SolariumMulticoreClient.php
SolariumMulticoreClient.clearCores
public function clearCores() { $delete = $this->solariumClient->createUpdate(); $delete->addDeleteQuery('*:*'); $delete->addCommit(); $this->applyOnAllCores($delete); }
php
public function clearCores() { $delete = $this->solariumClient->createUpdate(); $delete->addDeleteQuery('*:*'); $delete->addCommit(); $this->applyOnAllCores($delete); }
[ "public", "function", "clearCores", "(", ")", "{", "$", "delete", "=", "$", "this", "->", "solariumClient", "->", "createUpdate", "(", ")", ";", "$", "delete", "->", "addDeleteQuery", "(", "'*:*'", ")", ";", "$", "delete", "->", "addCommit", "(", ")", ...
Runs a *:* delete query on all cores
[ "Runs", "a", "*", ":", "*", "delete", "query", "on", "all", "cores" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Client/Solarium/SolariumMulticoreClient.php#L66-L73
floriansemm/SolrBundle
Doctrine/AbstractIndexingListener.php
AbstractIndexingListener.hasChanged
protected function hasChanged($doctrineChangeSet, $entity) { if (empty($doctrineChangeSet)) { return false; } $metaInformation = $this->metaInformationFactory->loadInformation($entity); $documentChangeSet = array(); /* Check all Solr fields on this entity and check if this field is in the change set */ foreach ($metaInformation->getFields() as $field) { if (array_key_exists($field->name, $doctrineChangeSet)) { $documentChangeSet[] = $field->name; } } return count($documentChangeSet) > 0; }
php
protected function hasChanged($doctrineChangeSet, $entity) { if (empty($doctrineChangeSet)) { return false; } $metaInformation = $this->metaInformationFactory->loadInformation($entity); $documentChangeSet = array(); /* Check all Solr fields on this entity and check if this field is in the change set */ foreach ($metaInformation->getFields() as $field) { if (array_key_exists($field->name, $doctrineChangeSet)) { $documentChangeSet[] = $field->name; } } return count($documentChangeSet) > 0; }
[ "protected", "function", "hasChanged", "(", "$", "doctrineChangeSet", ",", "$", "entity", ")", "{", "if", "(", "empty", "(", "$", "doctrineChangeSet", ")", ")", "{", "return", "false", ";", "}", "$", "metaInformation", "=", "$", "this", "->", "metaInformat...
@param array $doctrineChangeSet @param object $entity @return bool
[ "@param", "array", "$doctrineChangeSet", "@param", "object", "$entity" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/AbstractIndexingListener.php#L46-L64
floriansemm/SolrBundle
Doctrine/AbstractIndexingListener.php
AbstractIndexingListener.isAbleToIndex
protected function isAbleToIndex($entity) { try { $metaInformation = $this->metaInformationFactory->loadInformation($entity); } catch (SolrMappingException $e) { return false; } return true; }
php
protected function isAbleToIndex($entity) { try { $metaInformation = $this->metaInformationFactory->loadInformation($entity); } catch (SolrMappingException $e) { return false; } return true; }
[ "protected", "function", "isAbleToIndex", "(", "$", "entity", ")", "{", "try", "{", "$", "metaInformation", "=", "$", "this", "->", "metaInformationFactory", "->", "loadInformation", "(", "$", "entity", ")", ";", "}", "catch", "(", "SolrMappingException", "$",...
@param object $entity @return bool
[ "@param", "object", "$entity" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/AbstractIndexingListener.php#L83-L92
floriansemm/SolrBundle
Doctrine/Mapper/MetaInformationFactory.php
MetaInformationFactory.loadInformation
public function loadInformation($entity) { $className = $this->getClass($entity); if (!is_object($entity)) { $reflectionClass = new \ReflectionClass($className); if (!$reflectionClass->isInstantiable()) { throw new SolrMappingException(sprintf('Cannot instantiate entity %s', $className)); } $entity = $reflectionClass->newInstanceWithoutConstructor(); } if (!$this->annotationReader->hasDocumentDeclaration($entity)) { throw new SolrMappingException(sprintf('no declaration for document found in entity %s', $className)); } $fields = array_merge($this->annotationReader->getFields($entity), $this->annotationReader->getMethods($entity)); $metaInformation = new MetaInformation(); $metaInformation->setEntity($entity); $metaInformation->setClassName($className); $metaInformation->setDocumentName($this->getDocumentName($className)); $metaInformation->setFieldMapping($this->annotationReader->getFieldMapping($entity)); $metaInformation->setFields($fields); $metaInformation->setRepository($this->annotationReader->getRepository($entity)); $metaInformation->setIdentifier($this->annotationReader->getIdentifier($entity)); $metaInformation->setBoost($this->annotationReader->getEntityBoost($entity)); $metaInformation->setSynchronizationCallback($this->annotationReader->getSynchronizationCallback($entity)); $metaInformation->setIndex($this->annotationReader->getDocumentIndex($entity)); $metaInformation->setIsDoctrineEntity($this->isDoctrineEntity($entity)); $metaInformation->setDoctrineMapperType($this->getDoctrineMapperType($entity)); $metaInformation->setNested($this->annotationReader->isNested($entity)); $fields = $this->annotationReader->getFields($entity); foreach ($fields as $field) { if (!$field->nestedClass) { continue; } $nestedObjectMetainformation = $this->loadInformation($field->nestedClass); $subentityMapping = []; $nestedFieldName = $field->name; foreach ($nestedObjectMetainformation->getFieldMapping() as $documentName => $fieldName) { $subentityMapping[$nestedFieldName . '.' . $documentName] = $nestedFieldName . '.' . $fieldName; } $rootEntityMapping = $metaInformation->getFieldMapping(); $subentityMapping = array_merge($subentityMapping, $rootEntityMapping); unset($subentityMapping[$field->name]); $metaInformation->setFieldMapping($subentityMapping); } return $metaInformation; }
php
public function loadInformation($entity) { $className = $this->getClass($entity); if (!is_object($entity)) { $reflectionClass = new \ReflectionClass($className); if (!$reflectionClass->isInstantiable()) { throw new SolrMappingException(sprintf('Cannot instantiate entity %s', $className)); } $entity = $reflectionClass->newInstanceWithoutConstructor(); } if (!$this->annotationReader->hasDocumentDeclaration($entity)) { throw new SolrMappingException(sprintf('no declaration for document found in entity %s', $className)); } $fields = array_merge($this->annotationReader->getFields($entity), $this->annotationReader->getMethods($entity)); $metaInformation = new MetaInformation(); $metaInformation->setEntity($entity); $metaInformation->setClassName($className); $metaInformation->setDocumentName($this->getDocumentName($className)); $metaInformation->setFieldMapping($this->annotationReader->getFieldMapping($entity)); $metaInformation->setFields($fields); $metaInformation->setRepository($this->annotationReader->getRepository($entity)); $metaInformation->setIdentifier($this->annotationReader->getIdentifier($entity)); $metaInformation->setBoost($this->annotationReader->getEntityBoost($entity)); $metaInformation->setSynchronizationCallback($this->annotationReader->getSynchronizationCallback($entity)); $metaInformation->setIndex($this->annotationReader->getDocumentIndex($entity)); $metaInformation->setIsDoctrineEntity($this->isDoctrineEntity($entity)); $metaInformation->setDoctrineMapperType($this->getDoctrineMapperType($entity)); $metaInformation->setNested($this->annotationReader->isNested($entity)); $fields = $this->annotationReader->getFields($entity); foreach ($fields as $field) { if (!$field->nestedClass) { continue; } $nestedObjectMetainformation = $this->loadInformation($field->nestedClass); $subentityMapping = []; $nestedFieldName = $field->name; foreach ($nestedObjectMetainformation->getFieldMapping() as $documentName => $fieldName) { $subentityMapping[$nestedFieldName . '.' . $documentName] = $nestedFieldName . '.' . $fieldName; } $rootEntityMapping = $metaInformation->getFieldMapping(); $subentityMapping = array_merge($subentityMapping, $rootEntityMapping); unset($subentityMapping[$field->name]); $metaInformation->setFieldMapping($subentityMapping); } return $metaInformation; }
[ "public", "function", "loadInformation", "(", "$", "entity", ")", "{", "$", "className", "=", "$", "this", "->", "getClass", "(", "$", "entity", ")", ";", "if", "(", "!", "is_object", "(", "$", "entity", ")", ")", "{", "$", "reflectionClass", "=", "n...
@param object|string $entity entity, entity-alias or classname @return MetaInformation @throws SolrMappingException if no declaration for document found in $entity
[ "@param", "object|string", "$entity", "entity", "entity", "-", "alias", "or", "classname" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/MetaInformationFactory.php#L45-L99
floriansemm/SolrBundle
Doctrine/Mapper/MetaInformationFactory.php
MetaInformationFactory.isDoctrineEntity
private function isDoctrineEntity($entity) { if ($this->annotationReader->isOrm($entity) || $this->annotationReader->isOdm($entity)) { return true; } return false; }
php
private function isDoctrineEntity($entity) { if ($this->annotationReader->isOrm($entity) || $this->annotationReader->isOdm($entity)) { return true; } return false; }
[ "private", "function", "isDoctrineEntity", "(", "$", "entity", ")", "{", "if", "(", "$", "this", "->", "annotationReader", "->", "isOrm", "(", "$", "entity", ")", "||", "$", "this", "->", "annotationReader", "->", "isOdm", "(", "$", "entity", ")", ")", ...
@param object $entity @return bool
[ "@param", "object", "$entity" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/MetaInformationFactory.php#L106-L113
floriansemm/SolrBundle
Doctrine/Mapper/MetaInformationFactory.php
MetaInformationFactory.getDoctrineMapperType
private function getDoctrineMapperType($entity) { if ($this->isDoctrineEntity($entity) == false) { return ''; } if ($this->annotationReader->isOdm($entity)) { return MetaInformationInterface::DOCTRINE_MAPPER_TYPE_DOCUMENT; } if ($this->annotationReader->isOrm($entity)) { return MetaInformationInterface::DOCTRINE_MAPPER_TYPE_RELATIONAL; } }
php
private function getDoctrineMapperType($entity) { if ($this->isDoctrineEntity($entity) == false) { return ''; } if ($this->annotationReader->isOdm($entity)) { return MetaInformationInterface::DOCTRINE_MAPPER_TYPE_DOCUMENT; } if ($this->annotationReader->isOrm($entity)) { return MetaInformationInterface::DOCTRINE_MAPPER_TYPE_RELATIONAL; } }
[ "private", "function", "getDoctrineMapperType", "(", "$", "entity", ")", "{", "if", "(", "$", "this", "->", "isDoctrineEntity", "(", "$", "entity", ")", "==", "false", ")", "{", "return", "''", ";", "}", "if", "(", "$", "this", "->", "annotationReader", ...
@param object $entity @return string
[ "@param", "object", "$entity" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/MetaInformationFactory.php#L120-L133
floriansemm/SolrBundle
Doctrine/Mapper/MetaInformationFactory.php
MetaInformationFactory.getClass
private function getClass($entity) { if (is_object($entity)) { return get_class($entity); } if (class_exists($entity)) { return $entity; } $realClassName = $this->classnameResolver->resolveFullQualifiedClassname($entity); return $realClassName; }
php
private function getClass($entity) { if (is_object($entity)) { return get_class($entity); } if (class_exists($entity)) { return $entity; } $realClassName = $this->classnameResolver->resolveFullQualifiedClassname($entity); return $realClassName; }
[ "private", "function", "getClass", "(", "$", "entity", ")", "{", "if", "(", "is_object", "(", "$", "entity", ")", ")", "{", "return", "get_class", "(", "$", "entity", ")", ";", "}", "if", "(", "class_exists", "(", "$", "entity", ")", ")", "{", "ret...
@param object $entity @return string @throws \RuntimeException
[ "@param", "object", "$entity" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/MetaInformationFactory.php#L142-L155
floriansemm/SolrBundle
Doctrine/Mapper/EntityMapper.php
EntityMapper.toEntity
public function toEntity(\ArrayAccess $document, $sourceTargetEntity) { if (null === $sourceTargetEntity) { throw new SolrMappingException('$sourceTargetEntity should not be null'); } $metaInformation = $this->metaInformationFactory->loadInformation($sourceTargetEntity); if ($metaInformation->isDoctrineEntity() === false && $this->hydrationMode == HydrationModes::HYDRATE_DOCTRINE) { throw new SolrMappingException(sprintf('Please check your config. Given entity is not a Doctrine entity, but Doctrine hydration is enabled. Use setHydrationMode(HydrationModes::HYDRATE_DOCTRINE) to fix this.')); } if ($this->hydrationMode == HydrationModes::HYDRATE_INDEX) { return $this->indexHydrator->hydrate($document, $metaInformation); } if ($this->hydrationMode == HydrationModes::HYDRATE_DOCTRINE) { return $this->doctrineHydrator->hydrate($document, $metaInformation); } }
php
public function toEntity(\ArrayAccess $document, $sourceTargetEntity) { if (null === $sourceTargetEntity) { throw new SolrMappingException('$sourceTargetEntity should not be null'); } $metaInformation = $this->metaInformationFactory->loadInformation($sourceTargetEntity); if ($metaInformation->isDoctrineEntity() === false && $this->hydrationMode == HydrationModes::HYDRATE_DOCTRINE) { throw new SolrMappingException(sprintf('Please check your config. Given entity is not a Doctrine entity, but Doctrine hydration is enabled. Use setHydrationMode(HydrationModes::HYDRATE_DOCTRINE) to fix this.')); } if ($this->hydrationMode == HydrationModes::HYDRATE_INDEX) { return $this->indexHydrator->hydrate($document, $metaInformation); } if ($this->hydrationMode == HydrationModes::HYDRATE_DOCTRINE) { return $this->doctrineHydrator->hydrate($document, $metaInformation); } }
[ "public", "function", "toEntity", "(", "\\", "ArrayAccess", "$", "document", ",", "$", "sourceTargetEntity", ")", "{", "if", "(", "null", "===", "$", "sourceTargetEntity", ")", "{", "throw", "new", "SolrMappingException", "(", "'$sourceTargetEntity should not be nul...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Mapper/EntityMapper.php#L64-L83
floriansemm/SolrBundle
Doctrine/Hydration/ValueHydrator.php
ValueHydrator.hydrate
public function hydrate($document, MetaInformationInterface $metaInformation) { if (!isset($this->cache[$metaInformation->getDocumentName()])) { $this->cache[$metaInformation->getDocumentName()] = array(); } $targetEntity = $metaInformation->getEntity(); $reflectionClass = new \ReflectionClass($targetEntity); foreach ($document as $property => $value) { if ($property === MetaInformationInterface::DOCUMENT_KEY_FIELD_NAME) { $value = $this->removePrefixedKeyValues($value); } // skip field if value is array or "flat" object // hydrated object should contain a list of real entities / entity if ($this->mapValue($property, $value, $metaInformation) == false) { continue; } if (isset($this->cache[$metaInformation->getDocumentName()][$property])) { $this->cache[$metaInformation->getDocumentName()][$property]->setValue($targetEntity, $value); continue; } // find setter method $camelCasePropertyName = $this->toCamelCase($this->removeFieldSuffix($property)); $setterMethodName = 'set'.ucfirst($camelCasePropertyName); if (method_exists($targetEntity, $setterMethodName)) { $accessor = new MethodCallPropertyAccessor($setterMethodName); $accessor->setValue($targetEntity, $value); $this->cache[$metaInformation->getDocumentName()][$property] = $accessor; continue; } if ($reflectionClass->hasProperty($this->removeFieldSuffix($property))) { $classProperty = $reflectionClass->getProperty($this->removeFieldSuffix($property)); } else { // could no found document-field in underscore notation, transform them to camel-case notation $camelCasePropertyName = $this->toCamelCase($this->removeFieldSuffix($property)); if ($reflectionClass->hasProperty($camelCasePropertyName) == false) { continue; } $classProperty = $reflectionClass->getProperty($camelCasePropertyName); } $accessor = new PrivatePropertyAccessor($classProperty); $accessor->setValue($targetEntity, $value); $this->cache[$metaInformation->getDocumentName()][$property] = $accessor; } return $targetEntity; }
php
public function hydrate($document, MetaInformationInterface $metaInformation) { if (!isset($this->cache[$metaInformation->getDocumentName()])) { $this->cache[$metaInformation->getDocumentName()] = array(); } $targetEntity = $metaInformation->getEntity(); $reflectionClass = new \ReflectionClass($targetEntity); foreach ($document as $property => $value) { if ($property === MetaInformationInterface::DOCUMENT_KEY_FIELD_NAME) { $value = $this->removePrefixedKeyValues($value); } // skip field if value is array or "flat" object // hydrated object should contain a list of real entities / entity if ($this->mapValue($property, $value, $metaInformation) == false) { continue; } if (isset($this->cache[$metaInformation->getDocumentName()][$property])) { $this->cache[$metaInformation->getDocumentName()][$property]->setValue($targetEntity, $value); continue; } // find setter method $camelCasePropertyName = $this->toCamelCase($this->removeFieldSuffix($property)); $setterMethodName = 'set'.ucfirst($camelCasePropertyName); if (method_exists($targetEntity, $setterMethodName)) { $accessor = new MethodCallPropertyAccessor($setterMethodName); $accessor->setValue($targetEntity, $value); $this->cache[$metaInformation->getDocumentName()][$property] = $accessor; continue; } if ($reflectionClass->hasProperty($this->removeFieldSuffix($property))) { $classProperty = $reflectionClass->getProperty($this->removeFieldSuffix($property)); } else { // could no found document-field in underscore notation, transform them to camel-case notation $camelCasePropertyName = $this->toCamelCase($this->removeFieldSuffix($property)); if ($reflectionClass->hasProperty($camelCasePropertyName) == false) { continue; } $classProperty = $reflectionClass->getProperty($camelCasePropertyName); } $accessor = new PrivatePropertyAccessor($classProperty); $accessor->setValue($targetEntity, $value); $this->cache[$metaInformation->getDocumentName()][$property] = $accessor; } return $targetEntity; }
[ "public", "function", "hydrate", "(", "$", "document", ",", "MetaInformationInterface", "$", "metaInformation", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cache", "[", "$", "metaInformation", "->", "getDocumentName", "(", ")", "]", ")", ")...
{@inheritdoc}
[ "{" ]
train
https://github.com/floriansemm/SolrBundle/blob/fc28cee1eef2a3e85adeb4371599857980563b09/Doctrine/Hydration/ValueHydrator.php#L25-L83