idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
6,300 | public function getSequencePrefix ( AbstractPlatform $ platform ) { $ tableName = $ this -> getTableName ( ) ; $ sequencePrefix = $ tableName ; if ( $ schemaName = $ this -> getSchemaName ( ) ) { $ sequencePrefix = $ schemaName . '.' . $ tableName ; if ( ! $ platform -> supportsSchemas ( ) && $ platform -> canEmulateSc... | Gets the sequence name prefix based on class metadata . |
6,301 | public function getBets ( ) { $ query = \ Drupal :: entityQuery ( 'bet' ) ; $ query -> condition ( 'game' , $ this -> id ( ) ) ; $ games_ids = $ query -> execute ( ) ; return Bet :: loadMultiple ( $ games_ids ) ; } | Return all bets for the current game |
6,302 | public static function getGameWithoutMarks ( $ only_past = true ) { $ game_storage = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'game' ) ; $ query = \ Drupal :: entityQuery ( 'game' ) ; if ( $ only_past ) { $ now = new \ DateTime ( null , new \ DateTimeZone ( "UTC" ) ) ; $ query -> condition ( 'game_date' , $ no... | Return array of games that has no marks setted |
6,303 | public static function getGamesToBet ( Day $ day ) { $ game_storage = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'game' ) ; $ query = \ Drupal :: entityQuery ( 'game' ) ; $ now = new \ DateTime ( null , new \ DateTimeZone ( "UTC" ) ) ; $ query -> condition ( 'day' , $ day -> id ( ) ) ; $ query -> condition ( 'ga... | Return all games available to bet on a given day |
6,304 | private function fromArrayToString ( array $ fromArray ) : string { if ( count ( $ fromArray ) > 0 ) { reset ( $ fromArray ) ; $ fromString = key ( $ fromArray ) ; return $ fromString ; } throw new \ InvalidArgumentException ( 'Set at least one \'from\' address when using ' . self :: class ) ; } | The Gmail API can only take one address at a time let s get the very first one . |
6,305 | private function fromArrayToFailedRecipients ( array $ fromArray ) : array { if ( count ( $ fromArray ) > 0 ) { reset ( $ fromArray ) ; $ keyOfFirstElement = key ( $ fromArray ) ; unset ( $ fromArray [ $ keyOfFirstElement ] ) ; return $ fromArray ; } return [ ] ; } | The Gmail API can only take one address at a time the others are failed recipients . |
6,306 | private function getMappedEntities ( EntityManagerInterface $ entityManager ) { $ entityClassNames = $ entityManager -> getConfiguration ( ) -> getMetadataDriverImpl ( ) -> getAllClassNames ( ) ; if ( ! $ entityClassNames ) { throw new \ InvalidArgumentException ( 'You do not have any mapped Doctrine ORM entities accor... | Return all mapped entity class names |
6,307 | private function formatMappings ( array $ propertyMappings ) { $ output = array ( ) ; foreach ( $ propertyMappings as $ propertyName => $ mapping ) { $ output [ ] = $ this -> formatField ( sprintf ( ' %s' , $ propertyName ) , '' ) ; foreach ( $ mapping as $ field => $ value ) { $ output [ ] = $ this -> formatField ( s... | Format the association mappings |
6,308 | public function addInverseJoinColumn ( $ columnName , $ referencedColumnName , $ nullable = true , $ unique = false , $ onDelete = null , $ columnDef = null ) { $ this -> inverseJoinColumns [ ] = array ( 'name' => $ columnName , 'referencedColumnName' => $ referencedColumnName , 'nullable' => $ nullable , 'unique' => $... | Adds Inverse Join Columns . |
6,309 | private function createInitializer ( ClassMetadata $ classMetadata , EntityPersister $ entityPersister ) { if ( $ classMetadata -> getReflectionClass ( ) -> hasMethod ( '__wakeup' ) ) { return function ( BaseProxy $ proxy ) use ( $ entityPersister , $ classMetadata ) { $ initializer = $ proxy -> __getInitializer ( ) ; ... | Creates a closure capable of initializing a proxy |
6,310 | private function createCloner ( ClassMetadata $ classMetadata , EntityPersister $ entityPersister ) { return function ( BaseProxy $ proxy ) use ( $ entityPersister , $ classMetadata ) { if ( $ proxy -> __isInitialized ( ) ) { return ; } $ proxy -> __setInitialized ( true ) ; $ proxy -> __setInitializer ( null ) ; $ cla... | Creates a closure capable of finalizing state a cloned proxy |
6,311 | public function getExporter ( $ type , $ dest = null ) { if ( ! isset ( self :: $ _exporterDrivers [ $ type ] ) ) { throw ExportException :: invalidExporterDriverType ( $ type ) ; } $ class = self :: $ _exporterDrivers [ $ type ] ; return new $ class ( $ dest ) ; } | Gets an exporter driver instance . |
6,312 | protected function isValidEntityState ( $ entity ) { $ entityState = $ this -> uow -> getEntityState ( $ entity , UnitOfWork :: STATE_NEW ) ; if ( $ entityState === UnitOfWork :: STATE_NEW ) { return false ; } if ( $ entityState === UnitOfWork :: STATE_MANAGED && $ this -> uow -> isScheduledForInsert ( $ entity ) ) { r... | Check if entity is in a valid state for operations . |
6,313 | protected function findRedirectLinkInHeader ( & $ http_header ) { PHPCrawlerBenchmark :: start ( "checking_for_redirect_link" ) ; $ redirect_link = PHPCrawlerUtils :: getRedirectURLFromHeader ( $ http_header ) ; if ( $ redirect_link != null ) { $ this -> addLinkToCache ( $ redirect_link , "" , "" , true ) ; } PHPCrawle... | Checks for a redirect - URL in the given http - header and adds it to the internal link - cache . |
6,314 | protected function prepareHTMLChunk ( & $ html_source ) { if ( $ this -> ignore_document_sections & PHPCrawlerLinkSearchDocumentSections :: SCRIPT_SECTIONS ) { $ html_source = preg_replace ( "#<script(?:(?!src).)*>.*(?:<\/script>|$)# Uis" , "" , $ html_source ) ; $ html_source = preg_replace ( "#^(?:(?!<script).)*<\/sc... | Prepares a chunk of HTML before links get searched in it |
6,315 | public function domId ( $ record , $ prefix = null , $ fallbackPrefix = 'create' ) { if ( $ recordId = $ this -> recordKeyForDomId ( $ record ) ) { return $ this -> domClass ( $ record , $ prefix ) . '_' . $ recordId ; } else { $ prefix = $ prefix ? : $ fallbackPrefix ; return $ this -> domClass ( $ record , $ prefix )... | The DOM id convention is to use the singular form of an object or class with the id following an underscore . If no id is found prefix with create_ instead . |
6,316 | public function formId ( $ record , $ fallbackPrefix = 'create' ) { if ( $ recordId = $ this -> recordKeyForDomId ( $ record ) ) { return $ this -> domClass ( $ record , 'edit' ) . '_' . $ recordId ; } return $ this -> domClass ( $ record , $ fallbackPrefix ) ; } | The Form id convention is to use the singular form of an object or class with the id following an underscore . If id is found prefix with edit_ . If no id is found prefix with create_ instead . |
6,317 | public function domClass ( $ recordOrClass , $ prefix = null ) { $ singular = snake_case ( camel_case ( preg_replace ( '/\\\\/' , ' ' , $ this -> modelNameFromRecordOrClassname ( $ recordOrClass ) ) ) ) ; return $ prefix ? $ prefix . '_' . $ singular : $ singular ; } | The DOM class convention is to use the singular form of an object or class . |
6,318 | protected function removeRootNamespace ( $ classname ) { $ namespaces = $ this -> splitNamespaces ( $ classname ) ; if ( count ( $ namespaces ) > 1 ) { $ classname = implode ( '\\' , array_slice ( $ namespaces , 1 ) ) ; } return $ classname ; } | Remove Root namespace . E . G App \ Message - > Message |
6,319 | public static function isUTF8String ( $ string ) { $ sample = @ iconv ( 'utf-8' , 'utf-8' , $ string ) ; if ( md5 ( $ sample ) == md5 ( $ string ) ) return true ; else return false ; } | Checks wether the given string is an UTF8 - encoded string . |
6,320 | public static function decodeHtmlEntities ( $ string ) { $ entities = array ( "'&(quot|#34);'i" , "'&(amp|#38);'i" , "'&(lt|#60);'i" , "'&(gt|#62);'i" , "'&(nbsp|#160);'i" , "'&(iexcl|#161);'i" , "'&(cent|#162);'i" , "'&(pound|#163);'i" , "'&(copy|#169);'i" ) ; $ entitie_replacements = array ( "\"" , "&" , "<" , ">" , ... | Decodes all HTML - entities in the given string including numeric and hexadecimal character references |
6,321 | public function getMetadata ( ) { $ schema = array ( ) ; foreach ( $ this -> from as $ path ) { if ( is_dir ( $ path ) ) { $ files = glob ( $ path . '/*.yml' ) ; foreach ( $ files as $ file ) { $ schema = array_merge ( $ schema , ( array ) Yaml :: parse ( file_get_contents ( $ file ) ) ) ; } } else { $ schema = array_m... | Gets an array of ClassMetadataInfo instances from the passed Doctrine 1 schema . |
6,322 | protected function setup_item ( $ post = false , $ max = 10 ) { if ( empty ( $ post ) ) { return ; } $ time = $ this -> item_start ; $ type = 'items' ; $ max_int = absint ( $ max ) ; for ( $ i = 0 , $ j = $ this -> item_days ; $ i < $ j ; ++ $ i ) { $ day = ( int ) date_i18n ( 'j' , $ time ) ; $ month = ( int ) date_i1... | Add a post to the item array keyed by day |
6,323 | protected function display_mode ( ) { $ timestamp = mktime ( 0 , 0 , 0 , $ this -> month , 1 , $ this -> year ) ; $ max_day = date_i18n ( 't' , $ timestamp ) ; $ this_month = getdate ( $ timestamp ) ; $ start_day = $ this_month [ 'wday' ] ; for ( $ i = 0 ; $ i < ( $ max_day + $ start_day ) ; $ i ++ ) { if ( ( $ i % 7 )... | Display a calendar by month and year |
6,324 | private function rebuildOrderByClauseForOuterScope ( OrderByClause $ orderByClause ) { $ dqlAliasToSqlTableAliasMap = $ searchPatterns = $ replacements = $ dqlAliasToClassMap = $ selectListAdditions = $ orderByItems = [ ] ; foreach ( array_keys ( $ this -> rsm -> aliasMap ) as $ dqlAlias ) { $ dqlAliasToClassMap [ $ dq... | Generates a new order by clause that works in the scope of a select query wrapping the original |
6,325 | public function parseRobotsTxt ( PHPCrawlerURLDescriptor $ BaseUrl , $ user_agent_string , $ robots_txt_uri = null ) { PHPCrawlerBenchmark :: start ( "processing_robotstxt" ) ; if ( $ robots_txt_uri === null ) $ robots_txt_uri = self :: getRobotsTxtURL ( $ BaseUrl -> url_rebuild ) ; $ robots_txt_content = PHPCrawlerUti... | Parses a robots . txt - file and returns regular - expression - rules corresponding to the containing disallow - rules that are adressed to the given user - agent . |
6,326 | protected function getUserAgentLines ( & $ robots_txt_content , $ user_agent_string ) { $ robotstxt_lines = explode ( "\n" , $ robots_txt_content ) ; $ user_agent_lines = array ( ) ; $ current_user_agent = null ; $ cnt = count ( $ robotstxt_lines ) ; for ( $ x = 0 ; $ x < $ cnt ; $ x ++ ) { $ line = trim ( $ robotstxt_... | Gets all raw lines from the given robots . txt - content that apply to the given useragent - string . |
6,327 | public static function getRobotsTxtURL ( $ url ) { $ url_parts = PHPCrawlerUtils :: splitURL ( $ url ) ; $ robots_txt_url = $ url_parts [ "protocol" ] . $ url_parts [ "host" ] . ":" . $ url_parts [ "port" ] . "/robots.txt" ; return $ robots_txt_url ; } | Returns the default Robots . txt - URL related to the given URL |
6,328 | private function getColumnAlias ( $ columnName , $ mode , array $ customRenameColumns ) { switch ( $ mode ) { case self :: COLUMN_RENAMING_INCREMENT : return $ columnName . $ this -> sqlCounter ++ ; case self :: COLUMN_RENAMING_CUSTOM : return isset ( $ customRenameColumns [ $ columnName ] ) ? $ customRenameColumns [ $... | Gets column alias for a given column . |
6,329 | private function getColumnAliasMap ( $ className , $ mode , array $ customRenameColumns ) { if ( $ customRenameColumns ) { $ mode = self :: COLUMN_RENAMING_CUSTOM ; } $ columnAlias = array ( ) ; $ class = $ this -> em -> getClassMetadata ( $ className ) ; foreach ( $ class -> getColumnNames ( ) as $ columnName ) { $ co... | Retrieves a class columns and join columns aliases that are used in the SELECT clause . |
6,330 | public function addNamedNativeQueryMapping ( ClassMetadataInfo $ class , array $ queryMapping ) { if ( isset ( $ queryMapping [ 'resultClass' ] ) ) { return $ this -> addNamedNativeQueryResultClassMapping ( $ class , $ queryMapping [ 'resultClass' ] ) ; } return $ this -> addNamedNativeQueryResultSetMapping ( $ class ,... | Adds the mappings of the results of native SQL queries to the result set . |
6,331 | public function addNamedNativeQueryResultClassMapping ( ClassMetadataInfo $ class , $ resultClassName ) { $ classMetadata = $ this -> em -> getClassMetadata ( $ resultClassName ) ; $ shortName = $ classMetadata -> reflClass -> getShortName ( ) ; $ alias = strtolower ( $ shortName [ 0 ] ) . '0' ; $ this -> addEntityResu... | Adds the class mapping of the results of native SQL queries to the result set . |
6,332 | public function addNamedNativeQueryResultSetMapping ( ClassMetadataInfo $ class , $ resultSetMappingName ) { $ counter = 0 ; $ resultMapping = $ class -> getSqlResultSetMapping ( $ resultSetMappingName ) ; $ rooShortName = $ class -> reflClass -> getShortName ( ) ; $ rootAlias = strtolower ( $ rooShortName [ 0 ] ) . $ ... | Adds the result set mapping of the results of native SQL queries to the result set . |
6,333 | public function addNamedNativeQueryEntityResultMapping ( ClassMetadataInfo $ classMetadata , array $ entityMapping , $ alias ) { if ( isset ( $ entityMapping [ 'discriminatorColumn' ] ) && $ entityMapping [ 'discriminatorColumn' ] ) { $ discriminatorColumn = $ entityMapping [ 'discriminatorColumn' ] ; $ this -> setDisc... | Adds the entity result mapping of the results of native SQL queries to the result set . |
6,334 | public static function getRankingForBetter ( \ Drupal \ user \ Entity \ User $ better , $ entity = null , $ entity_name = null , $ storage_name = null ) { return parent :: getRankingForBetter ( $ better , null , null , 'ranking_general' ) ; } | Get General ranking for user |
6,335 | private function handleRedirect ( ResponseInterface $ response ) : ResponseInterface { if ( $ this -> debugbar -> isDataPersisted ( ) || session_status ( ) === PHP_SESSION_ACTIVE ) { $ this -> debugbar -> stackData ( ) ; } return $ response ; } | Handle redirection responses |
6,336 | private function handleHtml ( ResponseInterface $ response , bool $ isAjax ) : ResponseInterface { $ html = ( string ) $ response -> getBody ( ) ; $ renderer = $ this -> debugbar -> getJavascriptRenderer ( ) ; if ( ! $ isAjax ) { if ( $ this -> inline ) { ob_start ( ) ; echo "<style>\n" ; $ renderer -> dumpCssAssets ( ... | Handle html responses |
6,337 | protected function registerManaged ( ClassMetadata $ class , $ entity , array $ data ) { if ( $ class -> isIdentifierComposite ) { $ id = array ( ) ; foreach ( $ class -> identifier as $ fieldName ) { $ id [ $ fieldName ] = isset ( $ class -> associationMappings [ $ fieldName ] ) ? $ data [ $ class -> associationMappin... | Register entity as managed in UnitOfWork . |
6,338 | public function getNbGame ( ) : int { $ query = \ Drupal :: entityQuery ( 'game' ) -> condition ( 'day' , $ this -> id ( ) ) ; $ ids = $ query -> execute ( ) ; return count ( $ ids ) ; } | Return the number of games of the day |
6,339 | public function getGamesId ( $ onlyFuture = FALSE ) { $ query = \ Drupal :: entityQuery ( 'game' ) ; $ query -> condition ( 'day' , $ this -> id ( ) ) ; if ( $ onlyFuture ) { $ now = new \ DateTime ( NULL , new \ DateTimeZone ( 'UTC' ) ) ; $ query -> condition ( 'game_date' , $ now -> format ( 'Y-m-d\TH:i:s' ) , '>' ) ... | Return all games id for day |
6,340 | public function getNbGameWIthScore ( ) { $ query = \ Drupal :: entityQuery ( 'game' ) -> condition ( 'day' , $ this -> id ( ) ) -> condition ( 'score_team_1' , NULL , 'IS NOT' ) -> condition ( 'score_team_2' , NULL , 'IS NOT' ) ; $ ids = $ query -> execute ( ) ; return \ count ( $ ids ) ; } | Return the number of games of the day with score setted |
6,341 | public function registerAsanaService ( ) { $ this -> app -> singleton ( 'torann.asana' , function ( $ app ) { $ config = $ app -> config -> get ( 'asana' , [ ] ) ; return new Asana ( $ config ) ; } ) ; } | Register the Asana service . |
6,342 | private function expandToManyParameters ( $ criteria ) { $ params = array ( ) ; $ types = array ( ) ; foreach ( $ criteria as $ criterion ) { if ( $ criterion [ 'value' ] === null ) { continue ; } $ types = array_merge ( $ types , $ this -> getTypes ( $ criterion [ 'field' ] , $ criterion [ 'value' ] , $ criterion [ 'c... | Expands the parameters from the given criteria and use the correct binding types if found specialized for OneToMany or ManyToMany associations . |
6,343 | public function get ( string $ userId , string $ emailId , array $ options = [ ] ) : ? \ Google_Service_Gmail_Message { try { return $ this -> googleServices -> getGoogleServiceGmailForUserId ( $ userId ) -> users_messages -> get ( $ userId , $ emailId , $ options ) ; } catch ( \ Google_Service_Exception $ exception ) ... | Get email information given its ID . |
6,344 | public function trash ( string $ userId , string $ emailId ) : ? \ Google_Service_Gmail_Message { if ( $ this -> get ( $ userId , $ emailId ) ) { return null ; } return $ this -> googleServices -> getGoogleServiceGmailForUserId ( $ userId ) -> users_messages -> trash ( $ userId , $ emailId ) ; } | Delete an email given its ID . |
6,345 | public function getLabels ( string $ userId ) : \ Google_Service_Gmail_ListLabelsResponse { return $ this -> googleServices -> getGoogleServiceGmailForUserId ( $ userId ) -> users_labels -> listUsersLabels ( $ userId ) ; } | Get user s labels . |
6,346 | function verifyIPN ( ) { if ( ! count ( $ _POST ) ) { throw new Exception ( "Missing POST Data" ) ; } $ raw_post_data = file_get_contents ( 'php://input' ) ; $ raw_post_array = explode ( '&' , $ raw_post_data ) ; $ myPost = [ ] ; foreach ( $ raw_post_array as $ keyval ) { $ keyval = explode ( '=' , $ keyval ) ; if ( co... | Verification Function Sends the incoming post data back to PayPal using the cURL library . |
6,347 | public function setHeaders ( array $ values ) { foreach ( $ values as $ key => $ value ) { $ this -> setHeader ( $ key , $ value ) ; } } | Add multiple headers to request . |
6,348 | private function request ( $ method , $ url , array $ parameters = [ ] , array $ headers = [ ] ) { $ this -> errors = null ; $ this -> setHeader ( 'Content-Type' , 'application/json' ) ; $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , [ CURLOPT_URL => "{$this->endpoint}{$url}" , CURLOPT_CONNECTTIMEOUT => 10 , CUR... | This function communicates with Asana REST API . You don t need to call this function directly . It s only for inner class working . |
6,349 | protected function buildArrayForCurl ( $ params ) { if ( isset ( $ params [ 'file' ] ) ) { $ this -> setHeader ( 'Content-Type' , null ) ; return $ this -> http_build_query_for_curl ( $ params ) ; } return json_encode ( $ params ) ; } | Build http query that will be cUrl compliant . |
6,350 | protected function http_build_query_for_curl ( $ var , $ prefix = null ) { $ return = [ ] ; foreach ( $ var as $ key => $ value ) { $ name = $ prefix ? $ prefix . '[' . $ key . ']' : $ key ; if ( is_array ( $ value ) ) { $ return = array_merge ( $ return , $ this -> http_build_query_for_curl ( $ value , $ name ) ) ; } ... | Handle nested arrays when posting |
6,351 | public function addPostFile ( $ filename ) { if ( $ filename instanceof UploadedFile ) { $ name = $ filename -> getClientOriginalName ( ) ; $ file = $ filename -> move ( sys_get_temp_dir ( ) . '/' . uniqid ( ) , $ name ) ; $ filename = $ file -> getRealPath ( ) ; } if ( ! is_readable ( $ filename ) ) { throw new Invali... | POST file upload |
6,352 | public static function load ( $ color , $ resource ) { if ( $ color === 'transparent' ) { return imagecolorallocatealpha ( $ resource , 0 , 0 , 0 , 127 ) ; } $ gdpixel = new GDPixel ( $ color ) ; return imagecolorallocate ( $ resource , $ gdpixel -> channelR , $ gdpixel -> channelG , $ gdpixel -> channelB ) ; } | Returns a color representation for GD based on a color string . |
6,353 | public function validateNumber ( $ creditCardNumber ) { if ( ! $ this -> checkType ( ) ) { throw new Exception ( Yii :: t ( 'ECCValidator' , 'The "format" property must be specified with a supported Credit Card format.' ) ) ; } $ creditCardNumber = preg_replace ( '/[ -]+/' , '' , $ creditCardNumber ) ; return $ this ->... | Validates a Credit Card number |
6,354 | public function validateDate ( $ creditCardExpiredMonth , $ creditCardExpiredYear ) { $ currentYear = intval ( date ( 'Y' ) ) ; $ currentMonth = intval ( date ( 'm' ) ) ; if ( is_scalar ( $ creditCardExpiredMonth ) ) { $ creditCardExpiredMonth = intval ( $ creditCardExpiredMonth ) ; } if ( is_scalar ( $ creditCardExpir... | Validates a Credit Card date |
6,355 | public function validateAll ( $ creditCardHolder , $ creditCardNumber , $ creditCardExpiredMonth , $ creditCardExpiredYear ) { return $ this -> validateName ( $ creditCardHolder ) && $ this -> validateNumber ( $ creditCardNumber ) && $ this -> validateDate ( $ creditCardExpiredMonth , $ creditCardExpiredYear ) ; } | Validates holder number and dates of Credit Card numbers |
6,356 | protected function checkFormat ( $ cardNumber ) { return preg_match ( '/^[0-9]+$/' , $ cardNumber ) && preg_match ( $ this -> patterns [ $ this -> format ] , $ cardNumber ) ; } | Checks Credit Card Prefixes |
6,357 | protected function mod10 ( $ cardNumber ) { $ cardNumber = strrev ( $ cardNumber ) ; $ numSum = 0 ; for ( $ i = 0 ; $ i < strlen ( $ cardNumber ) ; $ i ++ ) { $ currentNum = substr ( $ cardNumber , $ i , 1 ) ; if ( $ i % 2 == 1 ) { $ currentNum *= 2 ; } if ( $ currentNum > 9 ) { $ firstNum = $ currentNum % 10 ; $ secon... | Check credit card number by Mod 10 algorithm |
6,358 | public static function track ( $ jquery = false ) { $ link = new Link ( Request :: url ( ) ) ; return $ link -> ajax ( $ jquery ) ; } | Create a new link from the current page url . |
6,359 | private static function luhn ( $ str ) { $ v = 0 ; $ sum = 0 ; for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { $ v = intval ( $ str [ $ i ] ) ; $ v *= 2 - ( $ i % 2 ) ; if ( $ v > 9 ) { $ v -= 9 ; } $ sum += $ v ; } return intval ( ceil ( $ sum / 10 ) * 10 - $ sum ) ; } | The Luhn algorithm . |
6,360 | protected static function getParts ( $ str ) { $ reg = '/^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([\+\-\s]?)(\d{3})(\d)$/' ; preg_match ( $ reg , $ str , $ match ) ; if ( ! isset ( $ match ) || count ( $ match ) !== 8 ) { return array ( ) ; } $ century = $ match [ 1 ] ; $ year = $ match [ 2 ] ; $ month = $ match [ 3 ] ; $ da... | Parse Swedish social security numbers and get the parts |
6,361 | public static function valid ( $ str ) { if ( ! is_numeric ( $ str ) && ! is_string ( $ str ) ) { return false ; } $ str = strval ( $ str ) ; $ parts = array_pad ( self :: getParts ( $ str ) , 7 , '' ) ; if ( in_array ( '' , $ parts , true ) ) { return false ; } list ( $ century , $ year , $ month , $ day , $ sep , $ n... | Validate Swedish social security numbers . |
6,362 | public static function format ( $ str , $ longFormat = false ) { if ( ! self :: valid ( $ str ) ) { return '' ; } $ parts = self :: getParts ( $ str ) ; if ( $ longFormat ) { $ format = '%1$s%2$s%3$s%4$s%6$s%7$s' ; } else { $ format = '%2$s%3$s%4$s%5$s%6$s%7$s' ; } $ return = sprintf ( $ format , $ parts [ 'century' ] ... | Format Swedish social security numbers to official format |
6,363 | public function addNextState ( $ name , $ type , Node $ target ) { $ this -> nextStates [ $ name ] = new NextState ( $ name , $ type , $ target ) ; } | Add a next state . |
6,364 | public function addNextStateOr ( $ name , $ type , array $ targets ) { $ this -> nextStates [ $ name ] = new NextStateOr ( $ name , $ type , $ targets ) ; } | Add a next state OR |
6,365 | protected function search ( $ filter , $ baseDn = null , $ scope = Ldap :: SEARCH_SCOPE_SUB , $ attributes = [ ] , $ sort = '' ) { $ records = $ this -> ldap -> search ( $ filter , $ baseDn , $ scope , $ attributes , $ sort ) ; return $ this -> processSearchResults ( $ records ) ; } | Query the LDAP directory with the given filter . |
6,366 | public function getUserByDN ( $ dn , $ baseDn = null , $ scope = Ldap :: SEARCH_SCOPE_SUB , $ attributes = [ ] ) { return $ this -> search ( sprintf ( '(&(objectClass=user)(distinguishedname=%s))' , $ dn ) , $ baseDn , $ scope , $ attributes ) ; } | Return a particular LDAP user by DN value . |
6,367 | public function getUserByEmail ( $ email , $ baseDn = null , $ scope = Ldap :: SEARCH_SCOPE_SUB , $ attributes = [ ] ) { return $ this -> search ( sprintf ( '(&(objectClass=user)(mail=%s))' , AbstractFilter :: escapeValue ( $ email ) ) , $ baseDn , $ scope , $ attributes ) ; } | Return a particular LDAP user by mail value . |
6,368 | public function getUserByUsername ( $ username , $ baseDn = null , $ scope = Ldap :: SEARCH_SCOPE_SUB , $ attributes = [ ] ) { $ options = $ this -> config ( ) -> options ; $ option = isset ( $ options [ 'accountCanonicalForm' ] ) ? $ options [ 'accountCanonicalForm' ] : null ; $ username = $ this -> ldap -> getCanonic... | Get a specific user s data from LDAP |
6,369 | public function getCanonicalUsername ( $ data ) { $ options = $ this -> config ( ) -> options ; $ option = isset ( $ options [ 'accountCanonicalForm' ] ) ? $ options [ 'accountCanonicalForm' ] : null ; switch ( $ option ) { case Ldap :: ACCTNAME_FORM_USERNAME : if ( empty ( $ data [ 'samaccountname' ] ) ) { throw new \... | Get a canonical username from the record based on the connection settings . |
6,370 | public function setHashAlgorithm ( $ hashAlgorithm ) { $ this -> hashAlgorithm = ( string ) $ hashAlgorithm ; WirecardCEE_Stdlib_Fingerprint :: setHashAlgorithm ( $ hashAlgorithm ) ; return $ this ; } | Hash algorithm setter |
6,371 | public function addMandatoryField ( $ mandatoryField ) { if ( ! in_array ( ( string ) $ mandatoryField , $ this -> _mandatoryFields ) ) { $ this -> _mandatoryFields [ ] = ( string ) $ mandatoryField ; } return $ this ; } | Add madatory field |
6,372 | public function isValid ( $ value , $ context = null ) { $ context = array_change_key_case ( $ context , CASE_LOWER ) ; switch ( $ this -> hashAlgorithm ) { case WirecardCEE_Stdlib_Fingerprint :: HASH_ALGORITHM_HMAC_SHA512 : case WirecardCEE_Stdlib_Fingerprint :: HASH_ALGORITHM_SHA512 : $ stringLength = 128 ; break ; c... | Is validator check valid? |
6,373 | public static function parseFile ( $ path ) { if ( ! is_file ( $ path ) ) { throw new Exception ( 'Invalid file path' ) ; } $ toml = file_get_contents ( $ path ) ; $ toml = preg_replace ( '/^' . pack ( 'H*' , 'EFBBBF' ) . '/' , '' , $ toml ) ; return self :: parse ( $ toml ) ; } | Reads string from specified file path and parses it as TOML . |
6,374 | private static function parseTableName ( $ name ) { $ buffer = '' ; $ strOpen = false ; $ names = array ( ) ; $ strLen = strlen ( $ name ) ; for ( $ i = 0 ; $ i < $ strLen ; $ i ++ ) { if ( $ name [ $ i ] == '"' ) { if ( ! $ strOpen || ( $ strOpen && $ name [ $ i - 1 ] != "\\" ) ) { $ strOpen = ! $ strOpen ; } } elseif... | Parses TOML table names and returns the hierarchy array of table names . |
6,375 | private static function parseValue ( $ val ) { $ parsedVal = null ; $ val = trim ( $ val ) ; if ( $ val === '' ) { throw new Exception ( 'Empty value not allowed' ) ; } if ( $ val == 'true' || $ val == 'false' ) { $ parsedVal = ( $ val == 'true' ) ; } elseif ( substr ( $ val , 0 , 3 ) == "'''" && substr ( $ val , - 3 )... | Parses TOML value and returns it to be assigned on the hashed array |
6,376 | private static function parseInlineTable ( $ val ) { if ( $ val [ 0 ] == '{' && substr ( $ val , - 1 ) == '}' ) { $ val = substr ( $ val , 1 , - 1 ) ; } else { throw new Exception ( 'Invalid inline table definition: ' . $ val ) ; } $ result = new stdClass ( ) ; $ openString = false ; $ openLString = false ; $ buffer = ... | Parse inline tables into common table array |
6,377 | private static function parseKeyValue ( $ key , $ val , & $ pointer ) { $ openQuote = false ; $ openDoubleQuote = false ; $ buff = '' ; for ( $ i = 0 ; $ i < strlen ( $ key ) ; $ i ++ ) { if ( $ key [ $ i ] == '"' ) { if ( ! $ openQuote ) { if ( $ openDoubleQuote ) { $ openDoubleQuote = false ; } else { $ openDoubleQuo... | Function that takes a key expression and the current pointer to position in the right hierarchy . Then it sets the corresponding value on that position . |
6,378 | private static function checkDataType ( $ array ) { if ( count ( $ array ) <= 1 ) { return true ; } $ last = count ( $ array ) - 1 ; $ type = self :: getCustomDataType ( $ array [ $ last ] ) ; if ( $ type != self :: getCustomDataType ( $ array [ 0 ] ) ) { return false ; } else { return true ; } } | Function that checks the data type of the first and last elements of an array and returns false if they don t match |
6,379 | public static function isISODate ( $ val ) { if ( ! is_string ( $ val ) ) { return false ; } try { $ date = new DateTime ( $ val ) ; } catch ( Exception $ e ) { return false ; } return true ; } | Return whether the given value is a valid ISODate |
6,380 | protected function makeBuilder ( $ resourceClass , $ data , TransformerAbstract $ transformer = null , $ resourceKey = null ) { $ fractal = $ this -> makeFractal ( ) ; $ builder = new FractalBuilder ( $ fractal , $ resourceClass , $ data ) ; if ( $ transformer !== null ) { $ builder -> setTransformer ( $ transformer ) ... | Creates a builder for serializing data . |
6,381 | public function getAutoloaderConfig ( ) { $ autoloaderArray = array ( ) ; $ classmapPath = $ this -> getDir ( ) . '/' . $ this -> relativeModuleDir . 'autoload_classmap.php' ; if ( file_exists ( $ classmapPath ) ) { $ autoloaderArray [ 'Zend\Loader\ClassMapAutoloader' ] = array ( $ classmapPath ) ; } $ autoloaderArray ... | Return an array to configure a default autoloader instance . |
6,382 | public function run ( $ request ) { $ email = $ request -> getVar ( 'email' ) ; if ( ! $ email ) { echo 'You must supply an email parameter to this method.' , PHP_EOL ; exit ; } $ user = $ this -> ldapService -> getUserByEmail ( $ email ) ; if ( ! $ user ) { echo sprintf ( 'No user found in LDAP for email %s' , $ email... | Syncs a single user based on the email address passed in the URL |
6,383 | protected function getProcessStep ( $ stepName ) { $ step = $ this -> process -> getStep ( $ stepName ) ; if ( ! ( $ step instanceof Step ) ) { throw new WorkflowException ( sprintf ( 'Can\'t find step named "%s" in process "%s".' , $ stepName , $ this -> process -> getName ( ) ) ) ; } return $ step ; } | Returns a step by its name . |
6,384 | protected function checkCredentials ( ModelInterface $ model , Step $ step ) { $ roles = $ step -> getRoles ( ) ; if ( ! empty ( $ roles ) && ! $ this -> authorizationChecker -> isGranted ( $ roles , $ model -> getWorkflowObject ( ) ) ) { throw new AccessDeniedException ( $ step -> getName ( ) ) ; } } | Check if the user is allowed to reach the step . |
6,385 | protected static function _getSuccessInstance ( $ return , $ secret ) { if ( ! array_key_exists ( 'paymentType' , $ return ) ) { throw new WirecardCEE_QPay_Exception_InvalidResponseException ( 'Invalid response from QPAY. Paymenttype is missing.' ) ; } switch ( strtoupper ( $ return [ 'paymentType' ] ) ) { case Wirecar... | getter for the correct qpay success return instance |
6,386 | public function getStepLabel ( ModelState $ state ) { $ step = $ this -> aggregator -> getProcess ( $ state -> getProcessName ( ) ) -> getStep ( $ state -> getStepName ( ) ) ; return $ step instanceof Step ? $ step -> getLabel ( ) : '' ; } | Return the state s step label . |
6,387 | public function getStateMessage ( ModelState $ state ) { $ message = '' ; if ( $ state -> getSuccessful ( ) ) { $ data = $ state -> getData ( ) ; $ message = isset ( $ data [ 'success_message' ] ) ? $ data [ 'success_message' ] : '' ; } else { $ message = implode ( "\n" , $ state -> getErrors ( ) ) ; } return $ message... | Returns the state message . |
6,388 | public function getOrderDetails ( $ iOrderNumber ) { $ this -> _requestData [ self :: COMMAND ] = self :: $ COMMAND_GET_ORDER_DETAILS ; $ this -> _setField ( self :: ORDER_NUMBER , $ iOrderNumber ) ; $ this -> _fingerprintOrder -> setOrder ( Array ( self :: CUSTOMER_ID , self :: SHOP_ID , self :: TOOLKIT_PASSWORD , sel... | Returns order details |
6,389 | protected function execute ( ) { $ authMethod = '?access_token=' . $ this -> params [ 'access_token' ] ; $ endpoint = Constants :: API_VERSION . $ this -> path . ( ( 'GET' === $ this -> method ) ? '?' . http_build_query ( $ this -> params ) : $ authMethod ) ; $ endpoint .= ( strstr ( $ endpoint , '?' ) ? '&' : '?' ) . ... | Execute the Instagram Request |
6,390 | public static function generateSignature ( InstagramApp $ app , $ endpoint , $ params ) { $ signature = $ endpoint ; ksort ( $ params ) ; foreach ( $ params as $ key => $ value ) { $ signature .= "|$key=$value" ; } return hash_hmac ( 'sha256' , $ signature , $ app -> getSecret ( ) , false ) ; } | Secure API Request by using endpoint paramters and API secret |
6,391 | public static function generateConfirmResponseString ( $ messages = null , $ inCommentTag = false ) { $ template = '<QPAY-CONFIRMATION-RESPONSE result="%status%" %message%/>' ; if ( empty ( $ messages ) ) { $ returnValue = str_replace ( '%status%' , 'OK' , $ template ) ; $ returnValue = str_replace ( '%message%' , '' ,... | generator for qpay confirm response strings . the response - string must be returned to QPAY in confirmation process . |
6,392 | public function getErrors ( ) { if ( empty ( $ this -> _errors ) ) { $ errorList = Array ( ) ; foreach ( $ this -> __get ( self :: $ ERROR ) as $ error ) { $ errorCode = $ error [ self :: $ ERROR_ERROR_CODE ] ; $ message = $ error [ self :: $ ERROR_MESSAGE ] ; $ consumerMessage = $ error [ self :: $ ERROR_CONSUMER_MESS... | Returns all the errors return Array |
6,393 | public function supportsClass ( $ class ) { if ( $ class ) { $ classNameArray = explode ( '\\' , $ class ) ; $ className = $ classNameArray [ count ( $ classNameArray ) - 1 ] ; if ( in_array ( $ className , array ( 'User' , 'AdminVoter' ) ) ) { return true ; } } return false ; } | Checks if the voter supports the given class . |
6,394 | public function writeWithoutSync ( ) { $ this -> owner -> LDAPMemberExtension_NoSync = true ; try { $ this -> owner -> write ( ) ; } finally { $ this -> owner -> LDAPMemberExtension_NoSync = false ; } } | Write DataObject without triggering this extension s hooks . |
6,395 | public function sync ( ) { $ service = Injector :: inst ( ) -> get ( LDAPService :: class ) ; if ( ! $ service -> enabled ( ) || ! $ this -> owner -> GUID ) { return ; } $ service -> updateLDAPFromMember ( $ this -> owner ) ; $ service -> updateLDAPGroupsForMember ( $ this -> owner ) ; } | Update the local data with LDAP and ensure local membership is also set in LDAP too . This writes into LDAP provided that feature is enabled . |
6,396 | public function onBeforeChangePassword ( $ newPassword , $ validation ) { if ( ! $ validation -> isValid ( ) ) { return ; } Injector :: inst ( ) -> get ( LDAPService :: class ) -> setPassword ( $ this -> owner , $ newPassword ) ; } | Synchronise password changes to AD when they happen in SilverStripe |
6,397 | public function trace ( ) { foreach ( $ this -> files as $ file ) { ( $ this -> debug === true ) ? $ this -> addTrace ( $ file ) : $ this -> removeTrace ( $ file ) ; } } | Start the tracer . |
6,398 | public function addTrace ( $ file ) { if ( strpos ( File :: get ( $ file ) , $ this -> realPath ) === false && $ this -> debug == true ) { File :: prepend ( $ file , $ this -> realPath ) ; File :: append ( $ file , '</span>' ) ; } } | Add the trace to the view . |
6,399 | public function removeTrace ( $ file ) { if ( strpos ( File :: get ( $ file ) , $ this -> realPath ) !== false ) { $ content = str_replace ( $ this -> realPath , '' , File :: get ( $ file ) ) ; File :: put ( $ file , $ content ) ; } } | Remove the trace from the view . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.