idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
11,600 | public function getTokenRange ( $ start , $ finish ) { $ tokens = array_slice ( $ this -> tokens , ( integer ) $ start , ( integer ) $ finish - ( integer ) $ start ) ; return new Tokenizer ( $ tokens ) ; } | Returns a new tokenizer that consists of a subset of the tokens specified by the provided range . |
11,601 | public function prependTokens ( Tokenizer $ new_tokens ) { $ this -> tokens = array_merge ( $ new_tokens -> asArray ( ) , $ this -> tokens ) ; $ this -> rewind ( ) ; return $ this ; } | Prepends a tokenizer to the beginning of this tokenizer . |
11,602 | public function appendTokens ( Tokenizer $ new_tokens ) { $ this -> tokens = array_merge ( $ this -> tokens , $ new_tokens -> asArray ( ) ) ; $ this -> rewind ( ) ; return $ this ; } | Appends a tokenizer to the beginning of this tokenizer . |
11,603 | public function offsetSet ( $ offset , $ value ) { if ( ! ( is_integer ( $ offset ) && $ offset >= 0 && $ offset <= $ this -> count ( ) ) ) { throw new \ InvalidArgumentException ( 'The offset must be a valid, positive integer.' ) ; } if ( ! $ value instanceof Token ) { throw new \ InvalidArgumentException ( 'The value... | Sets the token at the specified offset . |
11,604 | public function offsetUnset ( $ offset ) { if ( $ this -> offsetExists ( $ offset ) ) { unset ( $ this -> tokens [ $ offset ] ) ; $ this -> tokens = array_values ( $ this -> tokens ) ; if ( ! $ this -> valid ( ) ) { $ this -> rewind ( ) ; } } } | Unsets the token at the specified offset . |
11,605 | public function unserialize ( $ serialized ) { $ unserialized = unserialize ( $ serialized ) ; $ this -> __construct ( $ unserialized [ 'tokens' ] ) ; $ this -> seek ( $ unserialized [ 'index' ] ) ; } | Unserialize the tokenizer . |
11,606 | public function htmlizeTag ( $ arrayInfo , $ sizeRange ) { if ( isset ( $ this -> _htmlizeTagFunction ) ) { $ htmlizer = $ this -> _htmlizeTagFunction ; return $ htmlizer ( $ arrayInfo , $ sizeRange ) ; } else { return "<span class='tag size{$sizeRange}'> {$arrayInfo['tag']} </span>" ; } } | Convert a tag into an html - snippet |
11,607 | public function render ( ? string $ url = null ) : void { $ el = $ this -> getElementPrototype ( ) ; $ el -> size = $ this -> size ; $ el -> annotation = $ this -> annotation ; if ( $ url !== null ) { Validators :: assert ( $ url , 'string|url' ) ; $ el -> href = $ url ; } else { $ el -> href = $ this -> url ; } if ( $... | Render google + 1 button |
11,608 | public function renderJs ( ) : void { if ( $ this -> mode === self :: MODE_DEFAULT ) { $ el = Html :: el ( 'script type="text/javascript" async defer' ) ; $ el -> src = self :: GOOGLE_PLATFORM_URL ; $ el -> addText ( "{lang: '" . $ this -> lang . "'}" ) ; echo $ el ; } elseif ( $ this -> mode === self :: MODE_EXPLICIT ... | Render google javascript |
11,609 | public function setShareButton ( $ text = null ) : void { $ this -> element -> addClass ( 'twitter-share-button' ) ; $ this -> href = self :: TWITTER_SHARE_URL ; if ( $ text ) { $ this -> elementText = 'Tweet ' . $ text ; } } | Configure share button |
11,610 | public function setMentionButton ( $ mention = null ) : void { $ this -> element -> addClass ( 'twitter-mention-button' ) ; $ url = new Url ( self :: TWITTER_TWEET_URL ) ; $ url -> setQueryParameter ( 'screen_name' , $ mention ) ; $ this -> href = ( string ) $ url ; if ( $ mention ) { $ this -> elementText = 'Tweet to ... | Configure mention button |
11,611 | public function setHashtagButton ( $ hashtag = null ) : void { $ this -> element -> addClass ( 'twitter-hashtag-button' ) ; $ url = new Url ( self :: TWITTER_TWEET_URL ) ; $ url -> setQueryParameter ( 'button_hashtag' , $ hashtag ) ; $ this -> href = ( string ) $ url ; if ( $ hashtag ) { $ this -> elementText = 'Tweet ... | Configure hashtag button |
11,612 | public function render ( ? string $ url = null ) : void { $ el = $ this -> getElementPrototype ( ) ; $ el -> addText ( $ this -> getElementText ( ) ) ; $ el -> href ( $ this -> getHref ( ) ) ; if ( $ url !== null ) { Validators :: assert ( $ url , 'string|url' ) ; $ el -> { 'data-url' } = $ url ; } elseif ( $ this -> u... | Render twitter tweet button |
11,613 | public function renderJs ( ) : void { $ el = Html :: el ( 'script type="text/javascript"' ) ; $ el -> addText ( 'window.twttr=(function(d,s,id){var t,js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id)){return}js=d.createElement(s);js.id=id;js.src="' . self :: TWITTER_PLATFORM_URL . '";fjs.parentNode.insertBefo... | Render twitter javascript |
11,614 | public function setConnectionManager ( ManagerInterface $ manager ) { $ this -> connectionManager = $ manager ; foreach ( $ this -> servers as $ server ) { $ this -> connectionManager -> addServer ( $ server ) ; } } | Set a connection manager |
11,615 | public function registerCommand ( CommandInterface $ commandHandler ) { $ command = strtoupper ( $ commandHandler -> getCommand ( ) ) ; $ this -> commandHandlers [ $ command ] = $ commandHandler ; } | Register a command handler |
11,616 | public function queue ( $ name ) { if ( ! isset ( $ this -> queues [ $ name ] ) ) { $ this -> queues [ $ name ] = new Queue ( $ this , $ name ) ; } return $ this -> queues [ $ name ] ; } | Get a queue |
11,617 | public function schedule ( JobInterface $ job , DateTime $ when , array $ options = [ ] ) { if ( ! isset ( $ this -> timeZone ) ) { $ this -> timeZone = new DateTimeZone ( self :: DEFAULT_JOB_TIMEZONE ) ; } $ date = clone ( $ when ) ; $ date -> setTimeZone ( $ this -> timeZone ) ; $ now = new DateTime ( 'now' , $ this ... | Pushes a job into the queue setting it to be up for processing only at the specific date & time . |
11,618 | public function push ( JobInterface $ job , array $ options = [ ] ) { $ this -> checkConnected ( ) ; $ id = $ this -> client -> addJob ( $ this -> name , $ this -> marshaler -> marshal ( $ job ) , $ options ) ; $ job -> setId ( $ id ) ; return $ job ; } | Pushes a job into the queue |
11,619 | public function processing ( JobInterface $ job ) { $ this -> checkConnected ( ) ; return $ this -> client -> working ( $ job -> getId ( ) ) ; } | Marks that a Job is still being processed |
11,620 | public function processed ( JobInterface $ job ) { $ this -> checkConnected ( ) ; $ this -> client -> ackJob ( $ job -> getId ( ) ) ; } | Acknowledges a Job as properly handled |
11,621 | public function failed ( JobInterface $ job ) { $ this -> checkConnected ( ) ; $ this -> client -> nack ( $ job -> getId ( ) ) ; } | Marks the job as failed and returns it to the queue |
11,622 | public function getAssetPath ( string $ path ) { if ( ! $ this -> urlHelper -> isFullUrl ( $ path ) ) { $ path = $ this -> pathHelper -> prefix ( $ path ) ; } return $ this -> urlHelper -> getUrl ( self :: BASE_URL . $ path ) ; } | Get asset path for hot module replacement mode |
11,623 | public function isEnabled ( ) { $ path = $ this -> directory . '/' . self :: FLAG_FILENAME ; return ( bool ) $ this -> pathHelper -> getPublicPath ( $ path ) ; } | Check if hot module replacement mode is enabled |
11,624 | protected function deriveKeys ( $ salt ) { $ key = hash_pbkdf2 ( 'sha256' , $ this -> password , $ salt , $ this -> pbkdf2Iterations , $ this -> keyLength * 2 , true ) ; return str_split ( $ key , $ this -> keyLength ) ; } | Derive the keys for encryption and authentication using the given salt and the password |
11,625 | public static function fetch ( $ ldap , $ dn = null ) { if ( ! $ ldap instanceof Net_LDAP2 ) { return PEAR :: raiseError ( "Unable to fetch Schema: Parameter \$ldap must be a Net_LDAP2 object!" ) ; } $ schema_o = new Net_LDAP2_Schema ( ) ; if ( is_null ( $ dn ) ) { $ dse = $ ldap -> rootDSE ( array ( 'subschemaSubentry... | Fetch the Schema from an LDAP connection |
11,626 | public function & getAll ( $ type ) { $ map = array ( 'objectclasses' => & $ this -> _objectClasses , 'attributes' => & $ this -> _attributeTypes , 'ditcontentrules' => & $ this -> _dITContentRules , 'ditstructurerules' => & $ this -> _dITStructureRules , 'matchingrules' => & $ this -> _matchingRules , 'matchingruleuse... | Return a hash of entries for the given type |
11,627 | public function & get ( $ type , $ name ) { if ( $ this -> _initialized ) { $ type = strtolower ( $ type ) ; if ( false == key_exists ( $ type , $ this -> types ) ) { return PEAR :: raiseError ( "No such type $type" ) ; } $ name = strtolower ( $ name ) ; $ type_var = & $ this -> { '_' . $ this -> types [ $ type ] } ; i... | Return a specific entry |
11,628 | protected function _getAttr ( $ oc , $ attr ) { $ oc = strtolower ( $ oc ) ; if ( key_exists ( $ oc , $ this -> _objectClasses ) && key_exists ( $ attr , $ this -> _objectClasses [ $ oc ] ) ) { return $ this -> _objectClasses [ $ oc ] [ $ attr ] ; } elseif ( key_exists ( $ oc , $ this -> _oids ) && $ this -> _oids [ $ ... | Fetches the given attribute from the given objectclass |
11,629 | public function parse ( & $ entry ) { foreach ( $ this -> types as $ type => $ attr ) { $ type_var = '_' . $ attr ; $ this -> { $ type_var } = array ( ) ; if ( $ entry -> exists ( $ attr ) ) { $ values = $ entry -> getValue ( $ attr ) ; if ( is_array ( $ values ) ) { foreach ( $ values as $ value ) { unset ( $ schema_e... | Parses the schema of the given Subschema entry |
11,630 | protected function & _parse_entry ( $ value ) { $ noValue = array ( 'single-value' , 'obsolete' , 'collective' , 'no-user-modification' , 'abstract' , 'structural' , 'auxiliary' ) ; $ multiValue = array ( 'must' , 'may' , 'sup' ) ; $ schema_entry = array ( 'aliases' => array ( ) ) ; $ tokens = $ this -> _tokenize ( $ v... | Parses an attribute value into a schema entry |
11,631 | protected function _tokenize ( $ value ) { $ tokens = array ( ) ; $ matches = array ( ) ; $ pattern = "/\s* (?:([()]) | ([^'\s()]+) | '((?:[^']+|'[^\s)])*)') \s*/x" ; preg_match_all ( $ pattern , $ value , $ matches ) ; for ( $ i = 0 ; $ i < count ( $ matches [ 0 ] ) ; $ i ++ ) { for ( $ j = 1 ; $ j < 4 ; $ j ++ ) { if... | Tokenizes the given value into an array of tokens |
11,632 | public function isBinary ( $ attribute ) { $ return = false ; $ syntax_binary = array ( NET_LDAP2_SYNTAX_OCTET_STRING , NET_LDAP2_SYNTAX_JPEG ) ; $ attr_s = $ this -> get ( 'attribute' , $ attribute ) ; if ( Net_LDAP2 :: isError ( $ attr_s ) ) { $ return = false ; } elseif ( isset ( $ attr_s [ 'syntax' ] ) && in_array ... | Returns wether a attribute syntax is binary or not |
11,633 | public function exists ( $ type , $ name ) { $ entry = $ this -> get ( $ type , $ name ) ; if ( $ entry instanceof Net_LDAP2_ERROR ) { return false ; } else { return true ; } } | See if an schema element exists |
11,634 | public function getAssignedOCLs ( $ attribute ) { $ may = array ( ) ; $ must = array ( ) ; $ attr_entry = $ this -> get ( 'attribute' , $ attribute ) ; if ( $ attr_entry instanceof Net_LDAP2_ERROR ) { return PEAR :: raiseError ( "Attribute $attribute not defined in schema: " . $ attr_entry -> getMessage ( ) ) ; } else ... | See to which ObjectClasses an attribute is assigned |
11,635 | public function checkAttribute ( $ attribute , $ ocls ) { foreach ( $ ocls as $ ocl ) { $ ocl_entry = $ this -> get ( 'objectclass' , $ ocl ) ; $ ocl_may_attrs = $ this -> may ( $ ocl ) ; $ ocl_must_attrs = $ this -> must ( $ ocl ) ; if ( is_array ( $ ocl_may_attrs ) && in_array ( $ attribute , $ ocl_may_attrs ) ) { re... | See if an attribute is available in a set of objectClasses |
11,636 | public function link ( $ fileId ) { $ links = session ( static :: SESSION_KEY , [ ] ) ; $ links [ $ fileId ] = true ; session ( ) -> put ( static :: SESSION_KEY , $ links ) ; return $ this ; } | Links a given ID to this session . |
11,637 | public function unlink ( $ fileId ) { if ( ! $ this -> isIdLinked ( $ fileId ) ) { return $ this ; } $ links = session ( static :: SESSION_KEY , [ ] ) ; unset ( $ links [ $ fileId ] ) ; session ( ) -> put ( static :: SESSION_KEY , $ links ) ; return $ this ; } | Unlinks a given ID from this session . |
11,638 | public function getAssetPath ( string $ path , $ manifestDirectory = '' ) { $ this -> setManifestDirectory ( $ manifestDirectory ) ; if ( $ this -> isHotModuleReplacementEnabled ( ) ) { return $ this -> getHotModuleReplacementAssetPath ( $ path ) ; } return $ this -> getManifestAssetPath ( $ path ) ; } | Get the resolved asset path |
11,639 | protected function setManifestDirectory ( string $ manifestDirectory ) { $ this -> manifest -> directory = $ manifestDirectory ; $ this -> hotModuleReplacement -> directory = $ manifestDirectory ; } | Set the manifest directory for model dependencies |
11,640 | public static function fromArray ( array $ arr ) : self { $ prop = $ arr + ( new self ( $ arr [ 'text' ] ?? '' ) ) -> toArray ( ) ; foreach ( $ prop [ 'attachments' ] as & $ attachment ) { if ( ! $ attachment instanceof AttachmentInterface ) { $ attachment = Attachment :: fromArray ( $ attachment ) ; } } unset ( $ atta... | Returns a new instance from an array |
11,641 | public function setText ( string $ text ) : self { $ text = trim ( $ text ) ; if ( '' === $ text ) { throw new Exception ( 'The text can not be empty' ) ; } $ this -> text = $ text ; return $ this ; } | Returns an instance with the specified message text . |
11,642 | public function setAttachments ( $ attachments ) : self { if ( ! is_iterable ( $ attachments ) ) { throw new Exception ( sprintf ( '%s() expects argument passed to be iterable, %s given' , __METHOD__ , gettype ( $ attachments ) ) ) ; } $ this -> attachments = [ ] ; foreach ( $ attachments as $ attachment ) { $ this -> ... | Override all attachements object with a iterable structure |
11,643 | public function indexAction ( ) { $ id = ( int ) $ this -> params ( ) -> fromRoute ( 'id' , 0 ) ; if ( ! $ id ) return $ this -> redirect ( ) -> toRoute ( 'csn-cms/default' , array ( 'controller' => 'article' , 'action' => 'index' ) ) ; $ entityManager = $ this -> getServiceLocator ( ) -> get ( 'doctrine.entitymanager.... | R - retriev |
11,644 | public static function create ( $ attr_name , $ match , $ value = '' , $ escape = true ) { $ leaf_filter = new Net_LDAP2_Filter ( ) ; if ( $ escape ) { $ array = Net_LDAP2_Util :: escape_filter_value ( array ( $ value ) ) ; $ value = $ array [ 0 ] ; } $ match = strtolower ( $ match ) ; $ neg_matches = array ( ) ; $ neg... | Constructor of a new part of a LDAP filter . |
11,645 | public static function & combine ( $ log_op , $ filters ) { if ( PEAR :: isError ( $ filters ) ) { return $ filters ; } if ( $ log_op == 'and' ) $ log_op = '&' ; if ( $ log_op == 'or' ) $ log_op = '|' ; if ( $ log_op == 'not' ) $ log_op = '!' ; if ( $ log_op == '!' ) { if ( $ filters instanceof Net_LDAP2_Filter ) { $ f... | Combine two or more filter objects using a logical operator |
11,646 | public function asString ( ) { if ( $ this -> isLeaf ( ) ) { $ return = $ this -> _filter ; } else { $ return = '' ; foreach ( $ this -> _subfilters as $ filter ) { $ return = $ return . $ filter -> asString ( ) ; } $ return = '(' . $ this -> _match . $ return . ')' ; } return $ return ; } | Get the string representation of this filter |
11,647 | public function printMe ( $ FH = false ) { if ( ! is_resource ( $ FH ) ) { if ( PEAR :: isError ( $ FH ) ) { return $ FH ; } $ filter_str = $ this -> asString ( ) ; if ( PEAR :: isError ( $ filter_str ) ) { return $ filter_str ; } else { print ( $ filter_str ) ; } } else { $ filter_str = $ this -> asString ( ) ; if ( P... | Print the text representation of the filter to FH or the currently selected output handle if FH is not given |
11,648 | function matches ( & $ entries , & $ results = array ( ) ) { $ numOfMatches = 0 ; if ( ! is_array ( $ entries ) ) { $ all_entries = array ( & $ entries ) ; } else { $ all_entries = & $ entries ; } foreach ( $ all_entries as $ entry ) { $ entry_matched = false ; if ( ! $ this -> isLeaf ( ) ) { $ partial_results = array ... | Filter entries using this filter or see if a filter matches |
11,649 | function getComponents ( ) { if ( $ this -> isLeaf ( ) ) { $ raw_filter = preg_replace ( '/^\(|\)$/' , '' , $ this -> _filter ) ; $ parts = Net_LDAP2_Util :: split_attribute_string ( $ raw_filter , true , true ) ; if ( count ( $ parts ) != 3 ) { return PEAR :: raiseError ( "Net_LDAP2_Filter getComponents() error: inval... | Retrieve this leaf - filters attribute match and value component . |
11,650 | protected function toArguments ( array $ options ) { if ( empty ( $ options ) ) { return [ ] ; } elseif ( ! empty ( array_diff_key ( $ options , $ this -> availableArguments ) ) ) { throw new InvalidOptionException ( $ this , $ options ) ; } $ options += $ this -> options ; $ arguments = [ ] ; foreach ( $ this -> avail... | Build command arguments out of options |
11,651 | public function send ( $ url , Message $ message , array $ options = [ ] ) : ResponseInterface { try { unset ( $ options [ 'body' ] ) ; $ options [ 'json' ] = $ message ; $ options [ 'Content-Type' ] = 'application/json' ; return $ this -> client -> request ( 'POST' , $ url , $ options ) ; } catch ( Throwable $ e ) { t... | Send a message to a Mattermost Webhook |
11,652 | public function addChildren ( Collection $ children ) { foreach ( $ children as $ child ) { $ this -> addChild ( $ child ) ; } return $ this ; } | Add Child - translation |
11,653 | public function onIsVisibleElement ( Model $ element , $ isVisible ) : bool { $ isVisible = ( bool ) $ isVisible ; if ( $ element instanceof ContentModel && $ element -> type == 'module' ) { $ element = ModuleModel :: findByPK ( $ element -> module ) ; } if ( ! $ element instanceof ModuleModel ) { return $ isVisible ; ... | Check if a module is loaded which make use the bs_nav_class value . |
11,654 | public function onParseTemplate ( Template $ template ) : void { if ( substr ( $ template -> getName ( ) , 0 , 4 ) !== 'nav_' ) { return ; } $ template -> navClass = ( string ) $ this -> navClass ; } | Set the nav class in the nav template . |
11,655 | protected function checkOptionsInt ( array $ options , array $ keys ) { foreach ( $ keys as $ intOption ) { if ( isset ( $ options [ $ intOption ] ) && ! is_int ( $ options [ $ intOption ] ) ) { throw new InvalidOptionException ( $ this , $ options ) ; } } } | Checks an array so that their keys are ints |
11,656 | protected function checkOptionsString ( array $ options , array $ keys ) { foreach ( $ keys as $ intOption ) { if ( isset ( $ options [ $ intOption ] ) && ! is_string ( $ options [ $ intOption ] ) ) { throw new InvalidOptionException ( $ this , $ options ) ; } } } | Checks an array so that their keys are strings |
11,657 | protected function checkOptionsArray ( array $ options , array $ keys ) { foreach ( $ keys as $ intOption ) { if ( isset ( $ options [ $ intOption ] ) && ! is_array ( $ options [ $ intOption ] ) ) { throw new InvalidOptionException ( $ this , $ options ) ; } } } | Checks an array so that their keys are arrays |
11,658 | function LoadDriver ( $ driver ) { $ driver = strtolower ( $ driver ) ; if ( $ driver == $ this -> _activeDriver ) return TRUE ; if ( ! file_exists ( $ file = dirname ( __FILE__ ) . "/drivers/$driver.php" ) ) return ; require_once ( $ file ) ; $ driverName = "RefLib_" . ucfirst ( $ driver ) ; $ this -> driver = new $ d... | Load a specific driver |
11,659 | function IdentifyDriver ( ) { $ types = func_get_args ( ) ; foreach ( $ types as $ type ) { switch ( $ type ) { case 'xml' : case 'text/xml' : return 'endnotexml' ; case 'ris' : return 'ris' ; case 'csv' : case 'text/csv' : return 'csv' ; case 'medline' : case 'nbib' : return 'medline' ; default : if ( is_file ( $ type... | Tries to identify the correct driver to use based on an array of data |
11,660 | function DownloadContents ( $ filename = null , $ driver = null ) { if ( $ filename && $ driver ) { $ this -> LoadDriver ( $ driver ) ; } elseif ( $ filename ) { if ( ! $ driver = $ this -> IdentifyDriver ( $ filename ) ) { trigger_error ( "Unknown reference driver to use with filename '$filename'" ) ; } else { $ this ... | Generate an XML file and output it to the browser This will force the user to save the file somewhere to be opened later by EndNote |
11,661 | function ToEpoc ( $ date , $ ref = null ) { if ( preg_match ( '!^[0-9]{10,}$!' , $ date ) ) { return $ date ; } else if ( preg_match ( '!^[0-9]{4}$!' , $ date ) ) { return strtotime ( "$date-01-01" ) ; } else if ( preg_match ( '!^[0-9]{4}-[0-9]{2}$!' , $ date ) ) { return strtotime ( "$date-01" ) ; } elseif ( $ month =... | Converts an incomming string to an epoc value suitable for use later on |
11,662 | public function send ( $ data ) { $ this -> shouldBeConnected ( ) ; do { $ length = strlen ( $ data ) ; $ bytes = fwrite ( $ this -> socket , $ data ) ; if ( empty ( $ bytes ) ) { throw new ConnectionException ( "Could not write {$length} bytes to client" ) ; } elseif ( $ bytes === $ length ) { break ; } $ data = subst... | Execute a command on the connection |
11,663 | public function receive ( $ keepWaiting = false ) { $ this -> shouldBeConnected ( ) ; $ type = $ this -> getType ( $ keepWaiting ) ; if ( ! array_key_exists ( $ type , $ this -> responseHandlers ) ) { throw new ResponseException ( "Don't know how to handle a response of type {$type}" ) ; } $ responseHandlerClass = $ th... | Read data from connection |
11,664 | protected function getSocket ( $ host , $ port , $ timeout ) { return stream_socket_client ( "tcp://{$host}:{$port}" , $ error , $ message , $ timeout , STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT ) ; } | Build actual socket |
11,665 | private function getType ( $ keepWaiting = false ) { $ type = null ; while ( ! feof ( $ this -> socket ) ) { $ type = fgetc ( $ this -> socket ) ; if ( $ type !== false && $ type !== '' ) { break ; } $ info = stream_get_meta_data ( $ this -> socket ) ; if ( ! $ keepWaiting || ! $ info [ 'timed_out' ] ) { break ; } } if... | Get the first byte from Disque which contains the data type |
11,666 | private function getData ( ) { $ data = fgets ( $ this -> socket ) ; if ( $ data === false || $ data === '' ) { throw new ConnectionException ( 'Nothing received while reading from client' ) ; } return $ data ; } | Get a line of data |
11,667 | protected function getCustomValidator ( UploadedFile $ file , $ rules ) { if ( null === $ rules ) { return null ; } if ( ! is_array ( $ rules ) ) { $ rules = explode ( '|' , $ rules ) ; } return Validator :: make ( [ 'file' => $ file ] , [ 'file' => $ rules ] ) ; } | Gets a validator for the uploaded file with custom request - specified rules . |
11,668 | protected function performGarbageCollection ( ) { if ( ! config ( 'cms-upload-module.gc.enabled' , true ) ) { return ; } list ( $ probability , $ total ) = config ( 'cms-upload-module.gc.lottery' , [ 0 , 0 ] ) ; if ( $ probability < 1 || $ total < 1 || rand ( 0 , $ total ) > $ probability ) { return ; } $ this -> fileR... | Performs garbage collection based on lottery . |
11,669 | public function isBlocking ( ) { $ arguments = $ this -> getArguments ( ) ; $ options = end ( $ arguments ) ; if ( is_array ( $ options ) && ! empty ( $ options [ 'nohang' ] ) ) { return false ; } return true ; } | Tells if this command blocks while waiting for a response to avoid being affected by connection timeouts . |
11,670 | protected function findAvailableConnection ( ) { $ servers = $ this -> credentials ; shuffle ( $ servers ) ; $ previous = null ; foreach ( $ servers as $ server ) { try { $ node = $ this -> getNodeConnection ( $ server ) ; } catch ( ConnectionException $ e ) { $ previous = $ e ; continue ; } if ( $ node -> isConnected ... | Get a functional connection to any known node |
11,671 | protected function getNodeConnection ( Credentials $ server ) { $ node = $ this -> createNode ( $ server ) ; $ node -> connect ( ) ; return $ node ; } | Connect to the node given in the credentials |
11,672 | protected function postprocessExecution ( CommandInterface $ command , $ response ) { if ( $ command instanceof GetJob ) { $ this -> updateNodeStats ( $ command -> parse ( $ response ) ) ; $ this -> switchNodeIfNeeded ( ) ; } return $ response ; } | Postprocess the command execution eg . update node stats |
11,673 | protected function updateNodeStats ( array $ jobs ) { foreach ( $ jobs as $ job ) { $ jobId = $ job [ JobsResponse :: KEY_ID ] ; $ nodeId = $ this -> getNodeIdFromJobId ( $ jobId ) ; if ( ! isset ( $ nodeId ) || ! isset ( $ this -> nodes [ $ nodeId ] ) ) { continue ; } $ node = $ this -> nodes [ $ nodeId ] ; $ node -> ... | Update node counters indicating how many jobs the node has produced |
11,674 | private function switchNodeIfNeeded ( ) { $ sortedNodes = $ this -> priorityStrategy -> sort ( $ this -> nodes , $ this -> nodeId ) ; $ previous = null ; foreach ( $ sortedNodes as $ nodeCandidate ) { if ( $ nodeCandidate -> getId ( ) === $ this -> nodeId && $ nodeCandidate -> isConnected ( ) ) { return ; } try { if ( ... | Decide if we should switch to a better node |
11,675 | private function getNodeIdFromJobId ( $ jobId ) { $ nodePrefix = $ this -> getNodePrefixFromJobId ( $ jobId ) ; if ( isset ( $ this -> nodePrefixes [ $ nodePrefix ] ) && array_key_exists ( $ this -> nodePrefixes [ $ nodePrefix ] , $ this -> nodes ) ) { return $ this -> nodePrefixes [ $ nodePrefix ] ; } return null ; } | Get a node ID based off a Job ID |
11,676 | private function getNodePrefixFromJobId ( $ jobId ) { $ nodePrefix = substr ( $ jobId , JobsResponse :: ID_NODE_PREFIX_START , Node :: PREFIX_LENGTH ) ; return $ nodePrefix ; } | Get the node prefix from the job ID |
11,677 | protected function shouldBeConnected ( ) { if ( ! $ this -> isConnected ( ) ) { try { $ this -> switchNodeIfNeeded ( ) ; } catch ( ConnectionException $ e ) { throw new ConnectionException ( 'Not connected. ' . $ e -> getMessage ( ) , 0 , $ e ) ; } } } | We should be connected |
11,678 | private function createNode ( Credentials $ credentials ) { $ host = $ credentials -> getHost ( ) ; $ port = $ credentials -> getPort ( ) ; $ connection = $ this -> connectionFactory -> create ( $ host , $ port ) ; return new Node ( $ credentials , $ connection ) ; } | Create a new Node object |
11,679 | private function switchToNode ( Node $ node ) { $ nodeId = $ node -> getId ( ) ; if ( ( $ this -> nodeId === $ nodeId ) ) { if ( $ this -> getCurrentNode ( ) -> isConnected ( ) ) { return ; } $ this -> copyNodeStats ( $ this -> getCurrentNode ( ) , $ node ) ; } $ this -> resetNodeCounters ( ) ; $ this -> nodeId = $ nod... | Switch to the given node and map the cluster from its HELLO |
11,680 | private function revealClusterFromHello ( Node $ node ) { $ hello = $ node -> getHello ( ) ; $ revealedNodes = [ ] ; foreach ( $ hello [ HelloResponse :: NODES ] as $ node ) { $ id = $ node [ HelloResponse :: NODE_ID ] ; $ revealedNode = $ this -> revealNodeFromHello ( $ id , $ node ) ; $ priority = $ node [ HelloRespo... | Reveal the whole Disque cluster from a node HELLO response |
11,681 | private function revealNodeFromHello ( $ nodeId , array $ node ) { $ prefix = substr ( $ nodeId , Node :: PREFIX_START , Node :: PREFIX_LENGTH ) ; $ this -> nodePrefixes [ $ prefix ] = $ nodeId ; if ( isset ( $ this -> nodes [ $ nodeId ] ) ) { return $ this -> nodes [ $ nodeId ] ; } $ host = $ node [ HelloResponse :: N... | Reveal a single node from a HELLO response or use an existing node |
11,682 | private function copyNodeStats ( Node $ oldNode , Node $ newNode ) { $ oldNodeJobCount = $ oldNode -> getTotalJobCount ( ) ; $ newNode -> addJobCount ( $ oldNodeJobCount ) ; } | Copy node stats from the old to the new node |
11,683 | final public function send ( $ message ) { $ response = $ this -> client ( ) -> { $ this -> config -> getRequestMethod ( ) } ( $ this -> config -> getMessageUri ( ) , array_merge ( $ this -> config -> getProviderConfig ( ) , [ 'command' => 'send' , 'to' => $ this -> recipient , 'message' => $ message , ] ) ) ; return $... | Final send function |
11,684 | public static function fromCallable ( $ callable ) { if ( ! is_callable ( $ callable ) ) { throw new \ InvalidArgumentException ( 'You must provide a vaild PHP callable.' ) ; } elseif ( is_string ( $ callable ) && strpos ( $ callable , '::' ) > 0 ) { $ callable = explode ( '::' , $ callable ) ; } if ( is_array ( $ call... | A factory method that creates a FunctionParser from any PHP callable . |
11,685 | public function getName ( ) { $ name = $ this -> reflection -> getName ( ) ; if ( strpos ( $ name , '{closure}' ) !== false ) { return null ; } return $ name ; } | Returns the name of the function if there is one . |
11,686 | protected function fetchTokenizer ( ) { $ file = new \ SplFileObject ( $ this -> reflection -> getFileName ( ) ) ; $ first_line = $ this -> reflection -> getStartLine ( ) ; $ last_line = $ this -> reflection -> getEndLine ( ) ; $ code = '' ; $ file -> seek ( $ first_line - 1 ) ; while ( $ file -> key ( ) < $ last_line ... | Creates a tokenizer representing the code that is the best candidate for representing the function . It uses reflection to find the file and lines of the code and then puts that code into the tokenizer . |
11,687 | protected function parseCode ( ) { $ brace_level = 0 ; $ parsed_code = '' ; $ parsing_complete = false ; foreach ( $ this -> tokenizer as $ token ) { if ( $ parsing_complete ) { if ( $ token -> is ( T_FUNCTION ) ) { throw new \ RuntimeException ( 'Cannot parse the function; multiple, non-nested functions were defined' ... | Parses the code using the tokenizer and keeping track of matching braces . |
11,688 | protected function parseBody ( ) { $ start = strpos ( $ this -> code , '{' ) ; $ finish = strrpos ( $ this -> code , '}' ) ; $ body = ltrim ( rtrim ( substr ( $ this -> code , $ start + 1 , $ finish - $ start - 1 ) ) , "\n" ) ; return $ body ; } | Removes the function signature and braces to expose only the procedural body of the function . |
11,689 | public function check ( ) { $ this -> state = self :: STATE_UNCHECKED ; foreach ( $ this -> processorDeclarationList -> getKeys ( ) as $ processorName ) { $ processor = $ this -> getProcessor ( $ processorName ) ; if ( $ processor -> isPassed ( ) ) { $ processor -> afterCheckPassed ( ) ; $ this -> trigger ( self :: STA... | Check if request is not fraud |
11,690 | public function declareProcessor ( $ name , $ callable = null , $ priority = 0 ) { $ this -> processorDeclarationList -> set ( $ name , $ callable , $ priority ) ; return $ this ; } | Add processor identified by its name . If processor already added it will be replaced by new instance . |
11,691 | private function getProcessorClassName ( $ name ) { $ className = ucfirst ( $ name ) . 'Processor' ; foreach ( $ this -> processorNamespaces as $ namespace ) { $ fullyQualifiedClassName = $ namespace . '\\' . $ className ; if ( class_exists ( $ fullyQualifiedClassName ) ) { return $ fullyQualifiedClassName ; } } throw ... | Factory method to create new check condition |
11,692 | public static function bitStringToOctetString ( BitString $ bs ) : OctetString { $ str = $ bs -> string ( ) ; if ( $ bs -> unusedBits ( ) ) { throw new \ RuntimeException ( "Unaligned bitstrings to supported" ) ; } return new OctetString ( $ str ) ; } | Perform Bit - String - to - Octet - String Conversion . |
11,693 | public static function integerToOctetString ( Integer $ num , $ mlen = null ) : OctetString { $ gmp = gmp_init ( $ num -> number ( ) , 10 ) ; $ str = gmp_export ( $ gmp , 1 , GMP_MSW_FIRST | GMP_BIG_ENDIAN ) ; if ( null !== $ mlen ) { $ len = strlen ( $ str ) ; if ( $ len > $ mlen ) { throw new \ RangeException ( "Numb... | Perform Integer - to - Octet - String Conversion . |
11,694 | public static function octetStringToInteger ( OctetString $ os ) : Integer { $ num = gmp_import ( $ os -> string ( ) , 1 , GMP_MSW_FIRST | GMP_BIG_ENDIAN ) ; return new Integer ( gmp_strval ( $ num , 10 ) ) ; } | Perform Octet - String - to - Integer Conversion . |
11,695 | public static function numberToOctets ( $ num , $ mlen = null ) : string { return self :: integerToOctetString ( new Integer ( $ num ) , $ mlen ) -> string ( ) ; } | Convert a base - 10 number to octets . |
11,696 | public function _resolve ( $ value ) { if ( $ this -> state === self :: PENDING ) { $ this -> value = $ value ; for ( $ i = 0 ; $ i < count ( $ this -> success_pending ) ; $ i ++ ) { $ callback = $ this -> success_pending [ $ i ] ; $ callback ( $ value ) ; } $ this -> state = self :: RESOLVED ; } } | Dispatch queued callbacks . Also sets state to RESOLVED . |
11,697 | public function _reject ( $ value ) { if ( $ this -> state === self :: PENDING ) { $ this -> value = $ value ; for ( $ i = 0 ; $ i < count ( $ this -> failure_pending ) ; $ i ++ ) { $ callback = $ this -> failure_pending [ $ i ] ; $ callback ( $ value ) ; } $ this -> state = self :: REJECTED ; } } | Dispatch queued callbacks . Also sets state to REJECTED . |
11,698 | private function _catch ( $ callback ) { if ( $ this -> state === self :: REJECTED ) { $ this -> value = $ callback ( $ this -> value ) ; } return $ this ; } | Execute a callback if the promise has been rejected . |
11,699 | private function _finally ( $ callback ) { if ( $ this -> state !== self :: PENDING ) { $ callback ( $ this -> value ) ; } return $ this ; } | Execute a callback without changing value of promise . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.