idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
51,900 | private function getTotalNumberOfEntities ( $ entity , $ startOffset ) { $ objectManager = $ this -> getObjectManager ( $ entity ) ; $ repository = $ objectManager -> getRepository ( $ entity ) ; if ( $ repository instanceof DocumentRepository ) { $ totalSize = $ repository -> createQueryBuilder ( ) -> getQuery ( ) -> ... | Get the total number of entities in a repository |
51,901 | private function getPropertiesByType ( $ entity , $ type ) { $ properties = $ this -> readClassProperties ( $ entity ) ; $ fields = [ ] ; foreach ( $ properties as $ property ) { $ annotation = $ this -> reader -> getPropertyAnnotation ( $ property , $ type ) ; if ( null === $ annotation ) { continue ; } $ property -> ... | reads the entity and returns a set of annotations |
51,902 | public function getFieldMapping ( $ entity ) { $ fields = $ this -> getPropertiesByType ( $ entity , self :: FIELD_CLASS ) ; $ mapping = [ ] ; foreach ( $ fields as $ field ) { $ mapping [ $ field -> getNameWithAlias ( ) ] = $ field -> name ; } $ id = $ this -> getIdentifier ( $ entity ) ; $ mapping [ 'id' ] = $ id -> ... | returns all fields and field for idendification |
51,903 | private function querifyFieldValue ( $ fieldValue ) { if ( is_array ( $ fieldValue ) && count ( $ fieldValue ) > 1 ) { sort ( $ fieldValue ) ; $ quoted = array_map ( function ( $ value ) { return '"' . $ value . '"' ; } , $ fieldValue ) ; $ fieldValue = implode ( ' TO ' , $ quoted ) ; $ fieldValue = '[' . $ fieldValue ... | Transforms array to string representation and adds quotes |
51,904 | protected function setHtmlBody ( $ view , array $ data ) { $ this -> message -> builder ( ) -> setHtmlBody ( $ this -> renderView ( $ view , $ data ) ) ; } | Set rendered HTML body . |
51,905 | protected function setTextBody ( $ view , array $ data ) { $ this -> message -> builder ( ) -> setTextBody ( $ this -> renderView ( $ view , $ data ) ) ; } | Set rendered text body . |
51,906 | protected function setRawBody ( $ view ) { $ this -> message -> builder ( ) -> setHtmlBody ( $ view ) ; $ this -> message -> builder ( ) -> setTextBody ( strip_tags ( $ view , '<a>' ) ) ; } | Set the raw body |
51,907 | private function parseTime ( $ time ) { $ timezone = $ this -> config -> get ( 'app.timezone' , 'UTC' ) ; $ now = Carbon :: now ( $ timezone ) ; if ( is_object ( $ time ) ) { $ deliveryTime = Carbon :: instance ( $ time ) ; } else { if ( is_array ( $ time ) ) { reset ( $ time ) ; $ type = key ( $ time ) ; $ amount = $ ... | Parse given time and convert it to the required format |
51,908 | public function tag ( $ tags ) { $ tags = array_slice ( ( array ) $ tags , 0 , 3 ) ; foreach ( $ tags as $ tag ) { $ this -> messageBuilder -> addTag ( $ tag ) ; } return $ this ; } | Add Mailgun tags to the message . Tag limit is 3 . |
51,909 | public function trackClicks ( $ value ) { $ value = $ value === 'htmlonly' ? 'html' : $ value ; $ this -> messageBuilder -> setClickTracking ( $ value ) ; return $ this ; } | Toggles clicks tracking on a per - message basis . This setting has a higher priority than the domain - level setting . Pass true false or html or htmlonly . |
51,910 | protected function setConfigReplyTo ( ) { $ address = $ this -> config -> get ( 'mailgun.reply_to.address' ) ; $ name = $ this -> config -> get ( 'mailgun.reply_to.name' ) ; if ( $ address ) { $ name = $ name ? [ 'full_name' => $ name ] : null ; $ this -> messageBuilder -> setReplyToAddress ( $ address , $ name ) ; } } | Apply reply - to address from config . |
51,911 | public function searchIn ( $ index , $ type = null ) { $ this -> indices = [ ] ; $ this -> types = [ ] ; $ this -> searchInIndices ( ( array ) $ index ) ; if ( $ type !== null ) { $ this -> searchInTypes ( ( array ) $ type ) ; } } | Define on which indices and types the query should be run . |
51,912 | protected function buildQuery ( ) { $ this -> setup ( ) ; $ query = array ( ) ; $ query [ 'index' ] = empty ( $ this -> indices ) ? '_all' : implode ( ',' , array_values ( $ this -> indices ) ) ; if ( ! empty ( $ this -> types ) ) { $ query [ 'type' ] = implode ( ',' , array_values ( $ this -> types ) ) ; } $ query [ '... | Build the query by adding all chunks together . |
51,913 | public function run ( ) { $ query = $ this -> buildQuery ( ) ; $ rawResults = $ this -> searcher -> getClient ( ) -> search ( $ query ) ; $ resultParser = $ this -> getResultParser ( ) ; $ resultParser -> setRawResults ( $ rawResults ) ; return $ resultParser ; } | Build and execute the query . |
51,914 | public function createClient ( ) { $ client = ClientBuilder :: fromConfig ( $ this -> environment -> all ( ) ) ; $ this -> setClient ( $ client ) ; } | Create a client instance from the ElasticSearch SDK . |
51,915 | public function getRegistered ( $ indexName ) { if ( ! $ this -> isRegistered ( $ indexName ) ) { throw new Exception ( 'Index [' . $ indexName . '] could not be found in the register of the indices manager.' ) ; } return $ this -> indices [ $ indexName ] ; } | Get a registered index . When not found it will throw an exception . If you do not want the exception being thrown use getRegistered first . |
51,916 | public function update ( $ indexName ) { $ index = $ this -> getRegistered ( $ indexName ) ; foreach ( $ index -> getTypes ( ) as $ type => $ typeBody ) { $ params = [ 'index' => $ index -> getInternalName ( ) , 'type' => $ type , 'body' => [ $ type => $ typeBody ] ] ; $ this -> elasticSearcher -> getClient ( ) -> indi... | Update the index and all its types . This should be used when wanting to reflect changes in the Index object with the elasticsearch server . |
51,917 | public function set ( $ key , $ value ) { Arr :: set ( $ this -> body , $ key , $ value ) ; return $ this ; } | Set a value in the body using the dotted notation . |
51,918 | public function index ( $ indexName , $ type , array $ data ) { $ index = $ this -> elasticSearcher -> indicesManager ( ) -> getRegistered ( $ indexName ) ; $ params = [ 'index' => $ index -> getInternalName ( ) , 'type' => $ type , 'body' => $ data ] ; if ( array_key_exists ( 'id' , $ data ) ) { $ params [ 'id' ] = $ ... | Create a document . |
51,919 | public function bulkIndex ( $ indexName , $ type , array $ data ) { $ params = [ 'body' => [ ] ] ; foreach ( $ data as $ item ) { $ header = [ '_index' => $ indexName , '_type' => $ type , ] ; if ( array_key_exists ( 'id' , $ item ) ) { $ header [ '_id' ] = $ item [ 'id' ] ; } $ params [ 'body' ] [ ] = [ 'index' => $ h... | Index a set of documents . |
51,920 | public function update ( $ indexName , $ type , $ id , array $ data ) { $ index = $ this -> elasticSearcher -> indicesManager ( ) -> getRegistered ( $ indexName ) ; $ params = [ 'index' => $ index -> getInternalName ( ) , 'type' => $ type , 'id' => $ id , 'body' => [ 'doc' => $ data ] ] ; return $ this -> elasticSearch... | Partial updating of an existing document . |
51,921 | public function updateOrIndex ( $ indexName , $ type , $ id , array $ data ) { if ( $ this -> exists ( $ indexName , $ type , $ id ) ) { return $ this -> update ( $ indexName , $ type , $ id , $ data ) ; } else { return $ this -> index ( $ indexName , $ type , $ data ) ; } } | Update a document . Create it if it doesn t exist . |
51,922 | public function work ( $ id = 1 ) { if ( ! method_exists ( $ this , 'handleWork' ) ) throw new Exception ( "You need to declare `handleWork()` method in your worker controller." , 500 ) ; if ( $ this -> debug ) { error_reporting ( - 1 ) ; ini_set ( 'display_errors' , 1 ) ; } set_time_limit ( 0 ) ; $ startTime = microti... | Action for creating a worker |
51,923 | public function launch ( $ action = 'listen' ) { if ( ! $ this -> _isLinux ( ) ) { die ( "Error environment: Queue Launcher requires Linux OS, you could use `work` or `single` instead." ) ; } if ( ! in_array ( $ action , [ 'listen' , 'work' ] ) ) { die ( "Action: `{$action}` is invalid for Launcher." ) ; } $ logPath = ... | Launcher for guaranteeing unique process |
51,924 | public function single ( $ force = false ) { if ( ! method_exists ( $ this , 'handleSingle' ) ) throw new Exception ( "You need to declare `handleSingle()` method in your worker controller." , 500 ) ; $ lockFile = sys_get_temp_dir ( ) . "/yidas-codeiginiter-queue-worker_" . str_replace ( '/' , '_' , $ this -> router ->... | Action for activating a single listened worker |
51,925 | public function _singleUpdateLock ( $ lockFile ) { $ lockData = [ 'pid' => getmypid ( ) , 'expires_at' => time ( ) + $ this -> singleSleep + $ this -> singleLockTimeout , ] ; return file_put_contents ( $ lockFile , json_encode ( $ lockData ) ) ; } | Single process creates or extends lock file |
51,926 | protected function _workerCmd ( $ workerCmd , $ workerCount ) { $ cmd = "{$workerCmd}/{$workerCount}" ; $ cmd = ( $ this -> logPath ) ? "{$cmd} >> {$this->logPath}" : $ cmd ; $ process = proc_open ( "{$cmd} &" , self :: $ _procDescriptorspec , $ pipe ) ; $ status = proc_get_status ( $ process ) ; $ pid = $ status [ 'pi... | Command for creating a worker |
51,927 | protected function _log ( $ textLine , $ logPath = null ) { $ this -> _print ( $ textLine ) ; $ logPath = ( $ logPath ) ? $ logPath : $ this -> logPath ; if ( $ logPath ) return file_put_contents ( $ logPath , $ this -> _formatTextLine ( $ textLine ) , FILE_APPEND ) ; else return false ; } | Log to file |
51,928 | public function popJob ( ) { $ taskJSON = $ this -> redisClient -> lpop ( self :: QUEUE_KEY ) ; return json_decode ( $ taskJSON , true ) ; } | Pop up a job from Redis queue |
51,929 | public function setTempDir ( $ dir ) { $ dir = $ this -> addTrailingSlash ( $ dir ) ; if ( ! is_dir ( $ dir ) ) { $ this -> log -> addDebug ( sprintf ( 'Creating new temporary directory "%s"' , $ dir ) ) ; if ( ! mkdir ( $ dir , 0755 , true ) ) { $ this -> log -> addCritical ( sprintf ( 'Could not create temporary dire... | Set the temporary download directory . |
51,930 | public function setInstallDir ( $ dir ) { $ dir = $ this -> addTrailingSlash ( $ dir ) ; if ( ! is_dir ( $ dir ) ) { $ this -> log -> addDebug ( sprintf ( 'Creating new install directory "%s"' , $ dir ) ) ; if ( ! mkdir ( $ dir , 0755 , true ) ) { $ this -> log -> addCritical ( sprintf ( 'Could not create install direc... | Set the install directory . |
51,931 | public function setCache ( $ adapter , $ ttl = 3600 ) { $ adapter -> setOption ( 'ttl' , $ ttl ) ; $ this -> cache = new Cache ( $ adapter ) ; return $ this ; } | Set the cache component . |
51,932 | public function setBasicAuth ( $ username , $ password ) { $ this -> username = $ username ; $ this -> password = $ password ; return $ this ; } | Set username and password for basic authentication . |
51,933 | public function addLogHandler ( \ Monolog \ Handler \ HandlerInterface $ handler ) { $ this -> log -> pushHandler ( $ handler ) ; return $ this ; } | Add a new logging handler . |
51,934 | protected function _downloadCurl ( $ url ) { $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_URL , $ url ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , 1 ) ; if ( $ this -> sslVerifyHost ) { curl_setopt ( $ curl , CURLOPT_SSL_VERIFYHOST , 2 ) ; } else { curl_setopt ( $ curl , CURLOPT_SSL_VERIFYHOST , 0 ) ;... | Download file via curl . |
51,935 | protected function _downloadUpdate ( $ updateUrl , $ updateFile ) { $ this -> log -> addInfo ( sprintf ( 'Downloading update "%s" to "%s"' , $ updateUrl , $ updateFile ) ) ; if ( function_exists ( 'curl_version' ) && $ this -> _isValidUrl ( $ updateUrl ) ) { $ update = $ this -> _downloadCurl ( $ updateUrl ) ; if ( $ u... | Download the update |
51,936 | public function addCustomBrowserDetection ( $ browserName , $ uaNameToLookFor = '' , $ isMobile = false , $ isRobot = false , $ separator = '/' , $ uaNameFindWords = true ) { if ( $ browserName == '' ) { return false ; } if ( array_key_exists ( $ browserName , $ this -> _customBrowserDetection ) ) { unset ( $ this -> _... | Dynamically add support for a new Web browser . |
51,937 | public function addCustomPlatformDetection ( $ platformName , $ platformNameToLookFor = '' , $ isMobile = false ) { if ( $ platformName == '' ) { return false ; } if ( array_key_exists ( $ platformName , $ this -> _customPlatformDetection ) ) { unset ( $ this -> _customPlatformDetection [ $ platformName ] ) ; } if ( $ ... | Dynamically add support for a new platform . |
51,938 | public function compareVersions ( $ sourceVer , $ compareVer ) { $ sourceVer = explode ( '.' , $ sourceVer ) ; foreach ( $ sourceVer as $ k => $ v ) { $ sourceVer [ $ k ] = $ this -> parseInt ( $ v ) ; } $ compareVer = explode ( '.' , $ compareVer ) ; foreach ( $ compareVer as $ k => $ v ) { $ compareVer [ $ k ] = $ th... | Compare two version number strings . |
51,939 | public function getPlatformVersion ( $ returnVersionNumbers = false , $ returnServerFlavor = false ) { if ( $ this -> _platformVersion == self :: PLATFORM_VERSION_UNKNOWN || $ this -> _platformVersion == '' ) { return self :: PLATFORM_VERSION_UNKNOWN ; } if ( $ returnVersionNumbers ) { return $ this -> _platformVersion... | Get the platform version on which the browser is run on . It can be returned as a string number like NT 6 . 3 or as a name like Windows 8 . 1 . When returning version string numbers for Windows NT OS families the number is prefixed by NT to differentiate from older Windows 3 . x & 9x release . At the moment only the Wi... |
51,940 | public function removeCustomBrowserDetection ( $ browserName ) { if ( array_key_exists ( $ browserName , $ this -> _customBrowserDetection ) ) { unset ( $ this -> _customBrowserDetection [ $ browserName ] ) ; return true ; } return false ; } | Remove support for a previously added Web browser . |
51,941 | public function removeCustomPlatformDetection ( $ platformName ) { if ( array_key_exists ( $ platformName , $ this -> _customPlatformDetection ) ) { unset ( $ this -> _customPlatformDetection [ $ platformName ] ) ; return true ; } return false ; } | Remove support for a previously added platform . |
51,942 | public function setUserAgent ( $ agentString = '' ) { if ( ! is_string ( $ agentString ) || trim ( $ agentString ) == '' ) { if ( filter_has_var ( INPUT_SERVER , 'HTTP_USER_AGENT' ) ) { $ agentString = filter_input ( INPUT_SERVER , 'HTTP_USER_AGENT' , FILTER_SANITIZE_STRING , FILTER_FLAG_STRIP_LOW ) ; } else if ( array... | Set the user agent to use with the class . |
51,943 | protected function androidVerToStr ( $ androidVer ) { if ( $ this -> compareVersions ( $ androidVer , '10' ) >= 0 && $ this -> compareVersions ( $ androidVer , '11' ) < 0 ) { return 'Android Q' ; } else if ( $ this -> compareVersions ( $ androidVer , '9' ) >= 0 && $ this -> compareVersions ( $ androidVer , '10' ) < 0 )... | Convert the Android version numbers to the operating system name . For instance 1 . 6 returns Donut . |
51,944 | protected function checkBrowserBlackBerry ( ) { $ found = false ; if ( $ this -> checkSimpleBrowserUA ( 'RIM Tablet OS' , $ this -> _agent , self :: BROWSER_TABLET_OS , true ) ) { return true ; } if ( $ this -> checkBrowserUAWithVersion ( array ( 'BlackBerry' , 'BB10' ) , $ this -> _agent , self :: BROWSER_BLACKBERRY ,... | Determine if the browser is the BlackBerry browser or not . |
51,945 | protected function checkBrowserCustom ( ) { foreach ( $ this -> _customBrowserDetection as $ browserName => $ customBrowser ) { $ uaNameToLookFor = $ customBrowser [ 'uaNameToLookFor' ] ; $ isMobile = $ customBrowser [ 'isMobile' ] ; $ isRobot = $ customBrowser [ 'isRobot' ] ; $ separator = $ customBrowser [ 'separator... | Determine if the browser is among the custom browser rules or not . Rules are checked in the order they were added . |
51,946 | protected function checkBrowserFirefox ( ) { if ( preg_match ( '/.*Firefox[ (\/]*([a-z0-9.-]*)/i' , $ this -> _agent , $ matches ) && ! $ this -> containString ( $ this -> _agent , 'Safari' ) ) { $ this -> setBrowser ( self :: BROWSER_FIREFOX ) ; $ this -> setVersion ( $ matches [ 1 ] ) ; $ this -> setMobile ( false ) ... | Determine if the browser is Firefox or not . |
51,947 | protected function checkBrowserGooglebot ( ) { if ( $ this -> checkSimpleBrowserUA ( 'Googlebot' , $ this -> _agent , self :: BROWSER_GOOGLEBOT , false , true ) ) { if ( $ this -> containString ( $ this -> _agent , 'googlebot-mobile' ) ) { $ this -> setMobile ( true ) ; } return true ; } return false ; } | Determine if the browser is the Googlebot crawler or not . |
51,948 | protected function checkBrowserNetscape ( ) { if ( $ this -> containString ( $ this -> _agent , array ( 'BlackBerry' , 'Nokia' ) , true , false ) ) { return false ; } if ( $ this -> checkSimpleBrowserUA ( array ( 'Netscape' , 'Navigator' , 'Netscape6' ) , $ this -> _agent , self :: BROWSER_NETSCAPE ) ) { return true ; ... | Determine if the browser is Netscape or not . Official support for this browser ended on March 1st 2008 . |
51,949 | protected function checkBrowserNokia ( ) { if ( $ this -> containString ( $ this -> _agent , array ( 'Nokia5800' , 'Nokia5530' , 'Nokia5230' ) , true , false ) ) { $ this -> setBrowser ( self :: BROWSER_NOKIA ) ; $ this -> setVersion ( '7.0' ) ; $ this -> setMobile ( true ) ; $ this -> setRobot ( false ) ; return true ... | Determine if the browser is a Nokia browser or not . |
51,950 | protected function checkBrowserOpera ( ) { if ( $ this -> checkBrowserUAWithVersion ( 'Opera Mobi' , $ this -> _agent , self :: BROWSER_OPERA_MOBILE , true ) ) { return true ; } if ( $ this -> checkSimpleBrowserUA ( 'Opera Mini' , $ this -> _agent , self :: BROWSER_OPERA_MINI , true ) ) { return true ; } $ version = ''... | Determine if the browser is Opera or not . |
51,951 | protected function checkBrowsers ( ) { return $ this -> checkBrowserCustom ( ) || $ this -> checkBrowserMsnTv ( ) || $ this -> checkBrowserInternetExplorer ( ) || $ this -> checkBrowserOpera ( ) || $ this -> checkBrowserEdge ( ) || $ this -> checkBrowserSamsung ( ) || $ this -> checkBrowserUC ( ) || $ this -> checkBrow... | Determine what is the browser used by the user . |
51,952 | protected function checkBrowserSafari ( ) { $ version = '' ; $ found = $ this -> checkBrowserUAWithVersion ( array ( 'Safari' , 'AppleWebKit' ) , $ this -> _agent , self :: BROWSER_SAFARI ) ; if ( $ found && $ this -> getVersion ( ) != self :: VERSION_UNKNOWN ) { $ version = $ this -> getVersion ( ) ; } if ( ! $ found ... | Determine if the browser is Safari or not . |
51,953 | protected function checkBrowserW3CValidator ( ) { if ( $ this -> checkSimpleBrowserUA ( 'W3C-checklink' , $ this -> _agent , self :: BROWSER_W3CVALIDATOR , false , true ) ) { if ( $ this -> getVersion ( ) != self :: VERSION_UNKNOWN ) { $ this -> setVersion ( 'Link-' . $ this -> getVersion ( ) ) ; } return true ; } if (... | Determine if the browser is the W3C Validator or not . |
51,954 | protected function checkPlatformCustom ( ) { foreach ( $ this -> _customPlatformDetection as $ platformName => $ customPlatform ) { $ platformNameToLookFor = $ customPlatform [ 'platformNameToLookFor' ] ; $ isMobile = $ customPlatform [ 'isMobile' ] ; if ( $ this -> containString ( $ this -> _agent , $ platformNameToLo... | Determine if the platform is among the custom platform rules or not . Rules are checked in the order they were added . |
51,955 | protected function checkPlatformVersion ( ) { $ result = '' ; switch ( $ this -> getPlatform ( ) ) { case self :: PLATFORM_WINDOWS : if ( preg_match ( '/Windows NT\s*(\d+(?:\.\d+)*)/i' , $ this -> _agent , $ foundVersion ) ) { $ result = 'NT ' . $ foundVersion [ 1 ] ; } else { if ( $ this -> containString ( $ this -> _... | Determine the user s platform version . |
51,956 | protected function containString ( $ haystack , $ needle , $ insensitive = true , $ findWords = true ) { if ( ! is_array ( $ needle ) ) { $ needle = array ( $ needle ) ; } foreach ( $ needle as $ currNeedle ) { if ( $ findWords ) { $ found = $ this -> wordPos ( $ haystack , $ currNeedle , $ insensitive ) !== false ; } ... | Find if one or more substring is contained in a string . |
51,957 | protected function cleanVersion ( $ version ) { $ cleanVer = preg_replace ( '/\([^)]+\)?/' , '' , $ version ) ; $ cleanVer = preg_replace ( '/[^0-9.a-zA-Z_ -]/' , ' ' , $ cleanVer ) ; $ cleanVer = trim ( $ cleanVer ) ; while ( in_array ( substr ( $ cleanVer , - 1 ) , array ( '.' , '-' , '_' ) ) ) { $ cleanVer = substr ... | Clean a version string from unwanted characters . |
51,958 | protected function reset ( ) { $ this -> _agent = '' ; $ this -> _browserName = self :: BROWSER_UNKNOWN ; $ this -> _compatibilityViewName = '' ; $ this -> _compatibilityViewVer = '' ; $ this -> _is64bit = false ; $ this -> _isMobile = false ; $ this -> _isRobot = false ; $ this -> _platform = self :: PLATFORM_UNKNOWN ... | Reset all the properties of the class . |
51,959 | protected function safariBuildToSafariVer ( $ version ) { $ verParts = explode ( '.' , $ version ) ; while ( count ( $ verParts ) < 3 ) { $ verParts [ ] = 0 ; } foreach ( $ verParts as $ i => $ currPart ) { $ verParts [ $ i ] = $ this -> parseInt ( $ currPart ) ; } switch ( $ verParts [ 0 ] ) { case 419 : $ result = '2... | Convert a Safari build number to a Safari version number . |
51,960 | protected function setVersion ( $ version ) { $ cleanVer = $ this -> cleanVersion ( $ version ) ; if ( $ cleanVer == '' ) { $ this -> _version = self :: VERSION_UNKNOWN ; } else { $ this -> _version = $ cleanVer ; } } | Set the version of the browser . |
51,961 | protected function webKitBuildToSafariVer ( $ version ) { $ verParts = explode ( '.' , $ version ) ; while ( count ( $ verParts ) < 3 ) { $ verParts [ ] = 0 ; } foreach ( $ verParts as $ i => $ currPart ) { $ verParts [ $ i ] = $ this -> parseInt ( $ currPart ) ; } switch ( $ verParts [ 0 ] ) { case 419 : $ result = '2... | Convert a WebKit build number to a Safari version number . |
51,962 | protected function windowsNTVerToStr ( $ winVer , $ returnServerFlavor = false ) { $ cleanWinVer = explode ( '.' , $ winVer ) ; while ( count ( $ cleanWinVer ) > 2 ) { array_pop ( $ cleanWinVer ) ; } $ cleanWinVer = implode ( '.' , $ cleanWinVer ) ; if ( $ this -> compareVersions ( $ cleanWinVer , '11' ) >= 0 ) { retur... | Convert the Windows NT family version numbers to the operating system name . For instance 5 . 1 returns Windows XP . |
51,963 | protected function windowsVerToStr ( $ winVer ) { if ( $ this -> compareVersions ( $ winVer , '4.90' ) >= 0 && $ this -> compareVersions ( $ winVer , '4.91' ) < 0 ) { return self :: PLATFORM_WINDOWS . ' Me' ; } else if ( $ this -> compareVersions ( $ winVer , '4.10' ) >= 0 && $ this -> compareVersions ( $ winVer , '4.1... | Convert the Windows 3 . x & 9x family version numbers to the operating system name . For instance 4 . 10 . 1998 returns Windows 98 . |
51,964 | protected function wordPos ( $ haystack , $ needle , $ insensitive = true , $ offset = 0 , & $ foundString = NULL ) { if ( $ offset != 0 ) { $ haystack = substr ( $ haystack , $ offset ) ; } $ parts = explode ( ' ' , $ needle ) ; foreach ( $ parts as $ i => $ currPart ) { $ parts [ $ i ] = preg_quote ( $ currPart , '/'... | Find the position of the first occurrence of a word in a string . |
51,965 | public function insertToken ( string $ lockTo = '' , bool $ echo = true ) : string { $ token_array = $ this -> getTokenArray ( $ lockTo ) ; $ ret = \ implode ( \ array_map ( function ( string $ key , string $ value ) : string { return "<!--\n . "<input type=\"hidden\"" . " name=\"" . $ key . "\"" . " value=\"" . self :... | Insert a CSRF token to a form |
51,966 | public function getTokenArray ( string $ lockTo = '' ) : array { if ( $ this -> useNativeSession ) { if ( ! isset ( $ _SESSION [ $ this -> sessionIndex ] ) ) { $ _SESSION [ $ this -> sessionIndex ] = [ ] ; } } elseif ( ! isset ( $ this -> session [ $ this -> sessionIndex ] ) ) { $ this -> session [ $ this -> sessionInd... | Retrieve a token array for unit testing endpoints |
51,967 | protected function generateToken ( string $ lockTo ) : array { $ index = Base64UrlSafe :: encode ( \ random_bytes ( 18 ) ) ; $ token = Base64UrlSafe :: encode ( \ random_bytes ( 33 ) ) ; $ new = $ this -> buildBasicToken ( [ 'created' => \ intval ( \ date ( 'YmdHis' ) ) , 'uri' => isset ( $ this -> server [ 'REQUEST_UR... | Generate store and return the index and token |
51,968 | protected function recycleTokens ( ) { if ( ! $ this -> expire_old ) { return $ this ; } if ( $ this -> useNativeSession ) { $ sess = & $ _SESSION [ $ this -> sessionIndex ] ; } else { $ sess = & $ this -> session [ $ this -> sessionIndex ] ; } \ uasort ( $ sess , function ( array $ a , array $ b ) : int { return ( int... | Enforce an upper limit on the number of tokens stored in session state by removing the oldest tokens first . |
51,969 | public function validateIpAddress ( string $ ipAddress ) : bool { if ( $ ipAddress === '' ) { return false ; } return ( bool ) filter_var ( $ ipAddress , FILTER_VALIDATE_IP , FILTER_FLAG_NO_PRIV_RANGE ) ; } | Checks whether the given string is a valid public IPv4 or IPv6 address |
51,970 | public function validateVatNumberFormat ( string $ vatNumber ) : bool { if ( $ vatNumber === '' ) { return false ; } $ vatNumber = strtoupper ( $ vatNumber ) ; $ country = substr ( $ vatNumber , 0 , 2 ) ; $ number = substr ( $ vatNumber , 2 ) ; if ( ! isset ( $ this -> patterns [ $ country ] ) ) { return false ; } $ ma... | Validate a VAT number format . This does not check whether the VAT number was really issued . |
51,971 | public function validateVatNumber ( string $ vatNumber ) : bool { return $ this -> validateVatNumberFormat ( $ vatNumber ) && $ this -> validateVatNumberExistence ( $ vatNumber ) ; } | Validates a VAT number using format + existence check . |
51,972 | public function fetch ( $ url , array $ params = array ( ) ) { $ params = array_merge ( array ( 'curl' => array ( ) , 'fopen' => array ( ) , ) , $ params ) ; if ( function_exists ( 'curl_init' ) && $ this -> config [ 'prefer_curl' ] ) { return $ this -> curl ( $ url , $ params [ 'curl' ] ) ; } return $ this -> fileGetC... | Executes http requests |
51,973 | protected function curl ( $ url , array $ params = array ( ) ) { $ options = $ params + $ this -> config [ 'curl' ] + array ( CURLOPT_USERAGENT => $ this -> userAgent , CURLOPT_ENCODING => '' , CURLOPT_FOLLOWLOCATION => true , ) ; $ options [ CURLOPT_URL ] = $ url ; $ options [ CURLOPT_HEADER ] = true ; $ options [ CUR... | Uses Curl to fetch data from an url |
51,974 | protected function fileGetContents ( $ url , array $ params = array ( ) ) { if ( ! ini_get ( 'allow_url_fopen' ) ) { throw new \ Exception ( 'Could not execute lookup, allow_url_fopen is disabled' ) ; } if ( ! filter_var ( $ url , FILTER_VALIDATE_URL ) ) { throw new \ Exception ( 'Invalid url ' . $ url ) ; } $ defaultO... | Uses file_get_contents to fetch data from an url |
51,975 | protected function getProviders ( $ body = '' ) { $ regex = ( $ this -> config [ 'use_embed_prefix' ] === true ? $ this -> urlEmbedRegex : $ this -> urlRegex ) ; if ( is_array ( $ body ) ) { $ body = array_filter ( $ body , function ( $ arr ) use ( $ regex ) { return preg_match ( $ regex , $ arr ) ; } ) ; $ services = ... | Finds all the valid urls inside the given text compares which are allowed and returns an array with the detected providers |
51,976 | protected function clean ( array $ services = array ( ) ) { if ( empty ( $ services ) ) { return array ( ) ; } if ( ! empty ( $ this -> config [ 'allow' ] ) ) { $ allow = array_map ( 'strtolower' , ( array ) $ this -> config [ 'allow' ] ) ; $ services = array_filter ( $ services , function ( $ arr ) use ( $ allow ) { $... | Strips invalid providers from the list |
51,977 | public function getResourceInfo ( $ behaviour , $ apiUrl , $ url , array $ params = array ( ) ) { if ( $ behaviour === false ) { return array ( ) ; } return $ this -> lookup ( $ this -> constructUrl ( $ apiUrl , array_merge ( $ params , array ( 'url' => $ url ) ) ) ) ; } | Gets information about a resource |
51,978 | protected function lookup ( $ url ) { $ response = $ this -> http -> fetch ( $ url ) ; $ json = json_decode ( $ response , true ) ; if ( $ json ) { return array_merge ( array ( 'embera_using_fake' => 0 ) , $ json ) ; } return array ( ) ; } | Executes a http request to the given url and returns an associative array with the fetched data . |
51,979 | protected function constructUrl ( $ apiUrl , array $ params = array ( ) ) { return $ apiUrl . ( ( strpos ( $ apiUrl , '?' ) === false ) ? '?' : '&' ) . http_build_query ( array_filter ( $ params ) ) ; } | Builds a valid Oembed query string based on the given parameters Since this method uses the http_build_query function there is no need to pass urlencoded parameters http_build_query already does this for us . |
51,980 | public function addProvider ( $ host , $ class , array $ params = array ( ) ) { $ host = preg_replace ( '~^(?:www)\.~i' , '' , strtolower ( $ host ) ) ; $ this -> services [ $ host ] = $ class ; $ this -> customParams [ $ host ] = $ params ; } | Adds a new Provider into the service map |
51,981 | protected function extractCustomParams ( array $ params = array ( ) ) { foreach ( $ params as $ name => $ values ) { foreach ( $ this -> services as $ host => $ service ) { if ( preg_match ( '~' . preg_quote ( $ name , '~' ) . '~i' , $ service ) ) { $ this -> customParams [ $ host ] = ( array ) $ values ; } } } } | Extracts custom parameters for a Provider |
51,982 | public function getAll ( $ urls ) { $ this -> wildCardHosts = array_filter ( array_keys ( $ this -> services ) , function ( $ key ) { return ( strpos ( $ key , '*' ) !== false ) ; } ) ; return $ this -> findServices ( ( array ) $ urls ) ; } | Returns an array with all valid services found . |
51,983 | public function setTemplate ( $ template , $ body = null ) { $ this -> template = $ template ; if ( ! is_null ( $ body ) ) { return $ this -> transform ( $ body ) ; } return '' ; } | Sets a template with placeholders that should be replaced by the data from an oembed response . |
51,984 | public function transform ( $ body = null ) { $ providers = array ( ) ; if ( $ urls = $ this -> embera -> getUrlInfo ( $ body ) ) { foreach ( $ urls as $ url => $ data ) { if ( ! $ this -> allowOffline && ( int ) $ data [ 'embera_using_fake' ] === 1 ) { $ this -> errors [ ] = 'Using fake oembed response on ' . $ url ; ... | This method transforms an array or a string with urls into another string using a specified template . |
51,985 | public function process ( $ content ) { foreach ( $ this -> tags as $ t ) { $ content = $ this -> reserveTag ( $ content , $ t ) ; } $ content = strtr ( $ content , $ this -> replacementTable ) ; return $ this -> restoreHolders ( $ content ) ; } | Process the content and does the replacements |
51,986 | protected function reserveTag ( $ content , $ tag ) { if ( stripos ( $ content , '<' . $ tag ) !== false ) { if ( in_array ( strtolower ( $ tag ) , array ( 'img' ) ) ) { $ pattern = '~(<' . preg_quote ( $ tag , '~' ) . '[^>]+\>)~i' ; } else { $ pattern = '~(<' . preg_quote ( $ tag , '~' ) . '\\b[^>]*?>[\\s\\S]*?<\\/' .... | Reserves a tag which in this case all it does is replace the html tag with a placeholder . |
51,987 | protected function placeHolder ( array $ matches ) { $ placeholder = '%{{' . md5 ( time ( ) . count ( $ this -> holder ) . mt_rand ( 0 , 500 ) ) . '}}%' ; $ this -> holder [ $ placeholder ] = $ matches [ '1' ] ; return $ placeholder ; } | Assigns a placeholder to the matched content . Its used by preg_replace_callback |
51,988 | protected function restoreHolders ( $ content ) { if ( ! empty ( $ this -> holder ) ) { $ count = count ( $ this -> tags ) + 1 ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ content = str_replace ( array_keys ( $ this -> holder ) , array_values ( $ this -> holder ) , $ content ) ; if ( strpos ( $ content , '%{{' ) === ... | Restores all the dummy placeholders with the original content |
51,989 | public function getValue ( ) { $ sql = '(' . $ this -> query -> toSql ( ) . ')' ; if ( $ this -> alias ) { $ alias = $ this -> query -> getGrammar ( ) -> wrapTable ( $ this -> alias ) ; $ sql .= ' as ' . $ alias ; } return $ sql ; } | Evaluate query as string . |
51,990 | public function getWeights ( ) { $ weights = [ ] ; foreach ( $ this -> columns as $ column ) { $ weights [ $ column -> getMapping ( ) ] = $ column -> getWeight ( ) ; } return $ weights ; } | Get array of columns mappings and weights . |
51,991 | protected function addMissingWeights ( array $ columns ) { $ parsed = [ ] ; foreach ( $ columns as $ column => $ weight ) { if ( is_numeric ( $ column ) ) { list ( $ column , $ weight ) = [ $ weight , $ this -> weight ] ; } $ parsed [ $ column ] = $ weight ; } return $ parsed ; } | Add search weight to the columns if missing . |
51,992 | public function parseQuery ( $ query , $ fulltext = true ) { $ words = $ this -> splitString ( $ query ) ; if ( $ fulltext ) { $ words = $ this -> addWildcards ( $ words ) ; } return $ words ; } | Parse query string into separate words with wildcards if applicable . |
51,993 | protected function addWildcards ( array $ words ) { $ token = $ this -> wildcard ; return array_map ( function ( $ word ) use ( $ token ) { return preg_replace ( '/\*+/' , '*' , "{$token}{$word}{$token}" ) ; } , $ words ) ; } | Add wildcard tokens to the words . |
51,994 | protected function cleanAttributes ( CleansAttributes $ model ) { $ dirty = array_keys ( $ model -> getDirty ( ) ) ; $ invalidColumns = array_diff ( $ dirty , $ model -> getColumnListing ( ) ) ; foreach ( $ invalidColumns as $ column ) { unset ( $ model -> { $ column } ) ; } } | Get rid of attributes that are not correct columns on this model s table . |
51,995 | public function search ( $ query , $ columns = null , $ fulltext = true , $ threshold = null ) { if ( is_bool ( $ columns ) ) { list ( $ fulltext , $ columns ) = [ $ columns , [ ] ] ; } $ parser = static :: $ parser -> make ( ) ; $ words = is_array ( $ query ) ? $ query : $ parser -> parseQuery ( $ query , $ fulltext )... | Search through any columns on current table or any defined relations and return results ordered by search relevance . |
51,996 | protected function buildSubquery ( array $ words , array $ mappings , $ threshold ) { $ subquery = new SearchableSubquery ( $ this -> query -> newQuery ( ) , $ this -> model -> getTable ( ) ) ; $ columns = $ this -> joinForSearch ( $ mappings , $ subquery ) ; $ threshold = ( is_null ( $ threshold ) ) ? array_sum ( $ co... | Build the search subquery . |
51,997 | protected function addSearchClauses ( SearchableSubquery $ subquery , ColumnCollection $ columns , array $ words , $ threshold ) { $ whereBindings = $ this -> searchSelect ( $ subquery , $ columns , $ words , $ threshold ) ; $ joinBindings = collect ( $ subquery -> getQuery ( ) -> joins ) -> flatMap ( function ( $ join... | Add select and where clauses on the subquery . |
51,998 | protected function searchSelect ( SearchableSubquery $ subquery , ColumnCollection $ columns , array $ words ) { $ cases = $ bindings = [ ] ; foreach ( $ columns as $ column ) { list ( $ cases [ ] , $ binding ) = $ this -> buildCase ( $ column , $ words ) ; $ bindings = array_merge_recursive ( $ bindings , $ binding ) ... | Apply relevance select on the subquery . |
51,999 | protected function searchWhere ( SearchableSubquery $ subquery , ColumnCollection $ columns , array $ words , array $ bindings ) { $ operator = $ this -> getLikeOperator ( ) ; $ wheres = [ ] ; foreach ( $ columns as $ column ) { $ wheres [ ] = implode ( ' or ' , array_fill ( 0 , count ( $ words ) , sprintf ( '%s %s ?' ... | Apply where clauses on the subquery . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.