idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
228,000 | public function deleteItem ( $ key ) { if ( ! is_string ( $ key ) ) throw new InvalidArgumentException ( "Invalid key: " . WF :: str ( $ key ) ) ; unset ( $ this -> cache [ $ key ] ) ; return true ; } | Remove an item from the pool |
228,001 | public function save ( CacheItemInterface $ item ) { $ this -> cache -> set ( $ item -> getKey ( ) , $ item ) ; return $ this -> commit ( ) ; } | Save item to the pool |
228,002 | public function saveDeferred ( CacheItemInterface $ item ) { $ this -> cache -> set ( $ item -> getKey ( ) , $ item ) ; return true ; } | Store but do not save yet |
228,003 | public function write ( $ content ) { $ this -> openForWrite ( ) ; $ writtenBytes = $ this -> file -> fwrite ( $ content ) ; return $ writtenBytes ; } | Write a text |
228,004 | protected final function AttachError ( $ message ) { $ this -> result -> message = $ message ; $ this -> result -> success = false ; } | Attaches the exception by setting message to the result and the success flag to false |
228,005 | protected final function GatherOutput ( ) { \ header ( 'Content-Type: application/json' ) ; try { $ this -> output = json_encode ( $ this -> result ) ; } catch ( \ Exception $ ex ) { $ this -> AttachException ( $ ex ) ; } } | Gathers the output by encoding the result to json |
228,006 | public function delete ( Post $ post ) { $ response = $ this -> api -> process ( new DeletePost ( $ post ) ) ; if ( $ response -> getStatusCode ( ) == 200 ) { return true ; } else { return false ; } } | Delete a Post |
228,007 | public function set_xor ( Bitmask $ Binary ) { if ( ! ( $ Binary instanceof Bitmask ) ) return ; $ data = $ Binary -> get_raw ( ) ; foreach ( $ data as $ Pos => $ Byte ) $ this -> data [ $ Pos ] = @ $ this -> data [ $ Pos ] ^ $ Byte ; } | Perform xor operation with another Binary object |
228,008 | public function to_bin ( ) { $ out = "" ; for ( $ i = 0 ; $ i < $ this -> dataLength ( $ this -> data ) ; $ i ++ ) $ out = sprintf ( "%08b" , $ this -> data [ $ i ] ) . $ out ; return $ out ; } | return value as binary string |
228,009 | protected function data2hex ( $ temp ) { $ data = "" ; for ( $ i = 0 ; $ i < $ this -> dataLength ( $ temp ) ; $ i ++ ) $ data .= sprintf ( "%02X" , $ temp [ $ i ] ) ; return $ data ; } | convert array of two byte integers to high endian hexadecimal string |
228,010 | protected function hex2data ( $ temp ) { $ data = array ( ) ; $ len = strlen ( $ temp ) ; for ( $ i = 0 ; $ i < $ len ; $ i += 2 ) $ data [ ( int ) ( $ i / 2 ) ] = hexdec ( substr ( $ temp , $ i , 2 ) ) ; return $ data ; } | convert high endian hexadecimal string to array of two byte integers |
228,011 | public static function language ( string $ template ) : string { list ( $ component , $ file ) = static :: separate ( $ template ) ; $ elements = [ ENGINE_APP_ROOT , 'src' , $ component , 'Resources' , 'Language' , $ file ] ; return implode ( DIRECTORY_SEPARATOR , $ elements ) ; } | creates the fully qualified include string for a language resource file |
228,012 | private function getBuses ( ContainerBuilder $ container ) { $ buses = [ ] ; $ busDefinitions = $ container -> findTaggedServiceIds ( 'sokil.command_bus' ) ; foreach ( $ busDefinitions as $ busServiceId => $ busTags ) { foreach ( $ busTags as $ busTagParams ) { $ buses [ $ busServiceId ] = $ container -> findDefinition... | Get command buses |
228,013 | private function registerHandlersInBuses ( ContainerBuilder $ container ) { $ buses = $ this -> getBuses ( $ container ) ; $ commandHandlerDefinitions = $ container -> findTaggedServiceIds ( 'sokil.command_bus_handler' ) ; foreach ( $ commandHandlerDefinitions as $ commandHandlerServiceId => $ commandBusHandlerTags ) {... | Add handlers to command buses |
228,014 | public function post_async ( $ url , $ data = array ( ) ) { if ( filter_var ( $ url , FILTER_VALIDATE_URL ) === false ) { throw new \ Exception ( 'Invalid URL received by http\HttpClient' , 400 ) ; } $ paramstr = '' ; if ( ! empty ( $ data ) ) { if ( is_array ( $ data ) ) { $ paramstr = $ this -> urlencode_array ( $ da... | Make an asynchronous POST request . |
228,015 | public static function get_remote_filesize ( $ url , $ maxredirs = 2 ) { $ parts = parse_url ( $ url ) ; if ( empty ( $ parts [ 'host' ] ) ) { return false ; } if ( $ parts [ 'scheme' ] === 'https' ) { $ host = 'ssl://' . $ parts [ 'host' ] ; $ port = ( isset ( $ parts [ 'port' ] ) ) ? $ parts [ 'port' ] : 443 ; } else... | Gets the reported filesize of a remote object . |
228,016 | public function urlencode_array ( array $ ar ) { $ datastring = '' ; foreach ( $ ar as $ key => $ val ) { if ( ! empty ( $ datastring ) ) { $ datastring .= '&' ; } $ datastring .= urlencode ( $ key ) . '=' . urlencode ( $ val ) ; } return $ datastring ; } | Transforms an array of parameters into a urlencoded request string . |
228,017 | public function set_basic_auth ( $ username , $ password ) { $ value = 'Basic ' . base64_encode ( $ username . ':' . $ password ) ; $ this -> set_header ( 'Authorization' , $ value ) ; return true ; } | Set a basic auth header . |
228,018 | protected function execute_curl ( $ options ) { $ ch = curl_init ( ) ; curl_setopt_array ( $ ch , $ options ) ; $ returned = curl_exec ( $ ch ) ; $ response = HttpClientResponse :: instance_from_curl ( $ ch , $ returned ) ; curl_close ( $ ch ) ; return $ response ; } | Execute a curl call with the given options . |
228,019 | public static function fromNative ( ) { $ urlString = \ func_get_arg ( 0 ) ; $ user = \ parse_url ( $ urlString , PHP_URL_USER ) ; $ pass = \ parse_url ( $ urlString , PHP_URL_PASS ) ; $ host = \ parse_url ( $ urlString , PHP_URL_HOST ) ; $ queryString = \ parse_url ( $ urlString , PHP_URL_QUERY ) ; $ fragmentId = \ pa... | Returns a new Url object from a native url string |
228,020 | public function sameValueAs ( ValueObjectInterface $ url ) { if ( false === Util :: classEquals ( $ this , $ url ) ) { return false ; } return $ this -> getScheme ( ) -> sameValueAs ( $ url -> getScheme ( ) ) && $ this -> getUser ( ) -> sameValueAs ( $ url -> getUser ( ) ) && $ this -> getPassword ( ) -> sameValueAs ( ... | Tells whether two Url are sameValueAs by comparing their components |
228,021 | public function clear ( bool $ current = false ) : void { if ( $ current ) { $ this -> curr -> clear ( ) ; } $ this -> next -> clear ( ) ; } | Removes any flash values for the _next_ request optionally also in the _current_ . |
228,022 | public function getCurrent ( string $ name , $ alt = null ) { return $ this -> curr -> get ( $ name , $ alt ) ; } | Gets the flash value for a key in the _current_ request . |
228,023 | public function set ( string $ name , $ value , bool $ current = false ) : void { if ( $ current ) { $ this -> curr -> offsetSet ( $ name , $ value ) ; } $ this -> next -> offsetSet ( $ name , $ value ) ; } | Sets a flash value for the _next_ request optionally also in the _current_ request . |
228,024 | protected function cycle ( ) { if ( ! $ this -> moved ) { $ this -> curr -> clear ( ) ; $ this -> curr -> merge ( $ this -> next ) ; $ this -> next -> clear ( ) ; $ this -> moved = true ; } } | Transitions the values from next to current . |
228,025 | protected function getMessagesFromContainer ( ) { $ container = $ this -> getContainer ( ) ; $ namespaces = array ( ) ; foreach ( $ container as $ namespace => $ messages ) { if ( isset ( $ this -> messages [ $ namespace ] ) ) { $ this -> messages [ $ namespace ] = array_merge ( $ this -> messages [ $ namespace ] , $ m... | Pull messages from the session container and merge them with current messages |
228,026 | public function cmdGetField ( ) { $ result = $ this -> getListField ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableField ( $ result ) ; $ this -> output ( ) ; } | Callback for field - get command |
228,027 | public function cmdUpdateField ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ this ->... | Callback for field - update command |
228,028 | protected function submitAddField ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'field' ) ; $ this -> addField ( ) ; } | Add a new field at once |
228,029 | protected function wizardAddField ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Name' ) , 'field' ) ; $ this -> validateMenu ( 'type' , $ this -> text ( 'Type' ) , 'field' , $ this -> field -> getTypes ( ) ) ; $ this -> validateMenu ( 'widget' , $ this -> text ( 'Widget' ) , 'field' , $ this -> field -> ... | Add a new field step by step |
228,030 | public function GetXX ( $ number_str , $ modifer ) { $ number_int = intval ( $ number_str ) ; if ( $ number_int >= 0 && $ number_int < 100 ) { if ( array_key_exists ( $ number_int , $ this -> words -> xx ) ) { return $ this -> words -> xx [ $ number_int ] ; } else { throw new Exception ( 'xx: Array index (' . $ number_... | Pass in a number that is inclusively between 0 and 99 and it will return the corresponding words . |
228,031 | public function send ( $ output , OutputStrategyInterface $ outputStrategy = null ) { if ( ! ( $ outputStrategy instanceof OutputStrategyInterface ) ) { $ outputStrategy = $ this -> defaultOutputStrategy ; } $ contentType = new Header ( Header :: CONTENT_TYPE , $ outputStrategy -> getMime ( ) ) ; $ this -> header ( $ c... | Send the given output using the given or default output strategy . |
228,032 | public function sendFile ( $ src ) { $ pointer = fopen ( $ src , 'r' ) ; if ( ! is_resource ( $ pointer ) ) { throw new RuntimeException ( "Unable to load '$src' for sending." ) ; } $ result = fpassthru ( $ pointer ) ; fclose ( $ pointer ) ; return $ result ; } | Directly output results from a file . This bypasses the output strategy altogether . |
228,033 | public function divide ( $ number ) { if ( Number :: isZero ( $ number ) ) { throw new DivisionByZeroException ; } $ this -> number = $ this -> number / $ number ; return $ this ; } | Divide a value |
228,034 | public function round ( $ precision = 0 , $ mode = PHP_ROUND_HALF_UP ) { $ this -> number = round ( $ this -> number , $ precision , $ mode ) ; return $ this ; } | Round the value |
228,035 | public function toTheN ( $ number ) { for ( $ i = 1 ; $ i <= $ number ; $ i ++ ) { $ this -> multiply ( $ this -> number ) ; } return $ this ; } | To the n expression |
228,036 | public function transform ( $ dateTime ) : ? int { if ( null === $ dateTime ) { return null ; } if ( ! $ dateTime instanceof \ DateTimeInterface ) { throw new TransformationFailedException ( 'Expected a \DateTimeInterface.' ) ; } return $ dateTime -> getTimestamp ( ) ; } | Transforms a DateTime object into a timestamp in the configured timezone . |
228,037 | public function getData ( ) { if ( $ this -> cacheProvider !== null && $ this -> cacheProvider -> contains ( 'routerCache' ) ) { return $ this -> cacheProvider -> fetch ( 'routerCache' ) ; } return parent :: getData ( ) ; } | Returns the collected route data as provided by the data generator . |
228,038 | public static function checkUpdate ( $ request , $ object ) { $ repo = new Tenant_Views_SpaRepository ( ) ; $ spa = $ repo -> get ( new Pluf_HTTP_Request ( '/' ) , array ( 'modelId' => $ object -> name ) ) ; $ object -> last_version = $ spa -> version ; $ object -> update ( ) ; return $ object ; } | Check update of an spa |
228,039 | public static function update ( $ request , $ object ) { $ backend = Pluf :: f ( 'marketplace.backend' , 'http://marketplace.webpich.com' ) ; $ path = '/api/v2/marketplace/spas/' . $ object -> name . '/file' ; $ file = Pluf :: f ( 'temp_folder' , '/tmp' ) . '/spa-' . rand ( ) ; $ client = new GuzzleHttp \ Client ( ) ; ... | Update an spa |
228,040 | private function storeValueInCache ( $ key , $ value , $ expiration = null ) { $ this -> cache [ $ key ] = new MemcacheObject ( $ key , serialize ( $ value ) , $ this -> normalizeExpirationTime ( $ expiration ) ) ; } | Dumb setter no checks by design . |
228,041 | public static function initialize ( Dimension $ dimension , Number $ value ) : self { $ rows = [ ] ; $ count = $ dimension -> rows ( ) -> value ( ) ; for ( $ i = 0 ; $ i < $ count ; ++ $ i ) { $ rows [ ] = new RowVector ( ... array_fill ( 0 , $ dimension -> columns ( ) -> value ( ) , $ value ) ) ; } return new self ( .... | Initialize a matrix to the wished dimension filled with the specified value |
228,042 | public static function identifier ( string $ name , string $ separator = '_' ) : string { $ slugify = new Slugify ( [ 'separator' => $ separator ] ) ; $ identifier = $ slugify -> slugify ( $ name ) ; return $ identifier ; } | Gets an identifier from a name . |
228,043 | public static function getIdentifier ( string $ name , string $ separator = '_' ) : string { return self :: identifier ( $ name , $ separator ) ; } | Alias for the identifier function . |
228,044 | private function handle ( $ request ) { $ found = $ this -> fileMap -> render ( $ request -> getPathToMatch ( ) ) ; if ( empty ( $ found ) ) { return null ; } if ( is_resource ( $ found [ 0 ] ) ) { return $ request -> respond ( ) -> asFileContents ( $ found [ 0 ] , $ found [ 1 ] ) ; } if ( is_string ( $ found [ 0 ] ) )... | do the quick extension check . |
228,045 | public function options ( array $ options ) { if ( array_key_exists ( 'enable_raw' , $ options ) ) { $ this -> fileMap -> enable_raw = ( bool ) $ options [ 'enable_raw' ] ; } if ( array_key_exists ( 'before' , $ options ) ) { $ this -> setBeforeFilter ( $ options [ 'before' ] ) ; } if ( array_key_exists ( 'after' , $ o... | set up optional behavior . |
228,046 | final public function socketRecv ( & $ buff , $ len , $ flags ) { return socket_recv ( $ this -> socket , $ buff , $ len , $ flags ) ; } | Receives data from a connected socket |
228,047 | final public function socketRecvfrom ( & $ buff , $ len , $ flags , & $ name , & $ port = null ) { return socket_recvfrom ( $ this -> socket , $ buff , $ len , $ flags , $ name , $ port ) ; } | Receives data from a socket whether or not it is connection - oriented |
228,048 | final public function socketStrerror ( $ errno = null ) { if ( ! is_int ( $ errno ) ) { $ errno = $ this -> socketLastError ( ) ; } return socket_strerror ( $ errno ) ; } | Return a string describing a socket error |
228,049 | public function setSource ( ChildSource $ v = null ) { if ( $ v === null ) { $ this -> setSourceId ( NULL ) ; } else { $ this -> setSourceId ( $ v -> getId ( ) ) ; } $ this -> aSource = $ v ; if ( $ v !== null ) { $ v -> addPage ( $ this ) ; } return $ this ; } | Declares an association between this object and a ChildSource object . |
228,050 | public function getSource ( ConnectionInterface $ con = null ) { if ( $ this -> aSource === null && ( $ this -> source_id != 0 ) ) { $ this -> aSource = ChildSourceQuery :: create ( ) -> findPk ( $ this -> source_id , $ con ) ; } return $ this -> aSource ; } | Get the associated ChildSource object |
228,051 | public function initC2Ps ( $ overrideExisting = true ) { if ( null !== $ this -> collC2Ps && ! $ overrideExisting ) { return ; } $ collectionClassName = C2PTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collC2Ps = new $ collectionClassName ; $ this -> collC2Ps -> setModel ( '\Attogram\SharedMedia... | Initializes the collC2Ps collection . |
228,052 | public function getC2Ps ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collC2PsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collC2Ps || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collC2Ps ) { $ this -> initC2Ps ( ) ; } els... | Gets an array of ChildC2P objects which contain a foreign key that references this object . |
228,053 | public function addC2P ( ChildC2P $ l ) { if ( $ this -> collC2Ps === null ) { $ this -> initC2Ps ( ) ; $ this -> collC2PsPartial = true ; } if ( ! $ this -> collC2Ps -> contains ( $ l ) ) { $ this -> doAddC2P ( $ l ) ; if ( $ this -> c2PsScheduledForDeletion and $ this -> c2PsScheduledForDeletion -> contains ( $ l ) )... | Method called to associate a ChildC2P object to this object through the ChildC2P foreign key attribute . |
228,054 | public function initM2Ps ( $ overrideExisting = true ) { if ( null !== $ this -> collM2Ps && ! $ overrideExisting ) { return ; } $ collectionClassName = M2PTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collM2Ps = new $ collectionClassName ; $ this -> collM2Ps -> setModel ( '\Attogram\SharedMedia... | Initializes the collM2Ps collection . |
228,055 | public function getM2Ps ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collM2PsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collM2Ps || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collM2Ps ) { $ this -> initM2Ps ( ) ; } els... | Gets an array of ChildM2P objects which contain a foreign key that references this object . |
228,056 | public function addM2P ( ChildM2P $ l ) { if ( $ this -> collM2Ps === null ) { $ this -> initM2Ps ( ) ; $ this -> collM2PsPartial = true ; } if ( ! $ this -> collM2Ps -> contains ( $ l ) ) { $ this -> doAddM2P ( $ l ) ; if ( $ this -> m2PsScheduledForDeletion and $ this -> m2PsScheduledForDeletion -> contains ( $ l ) )... | Method called to associate a ChildM2P object to this object through the ChildM2P foreign key attribute . |
228,057 | public function setHashedPassword ( $ hashedPassword ) { if ( $ hashedPassword !== $ this -> hashedPassword ) { $ this -> authenticated = FALSE ; $ this -> hashedPassword = $ hashedPassword ; } return $ this ; } | set password hash ; if password hash differs from previously set hash any previous authentication result is reset |
228,058 | public function authenticate ( $ plaintextPassword ) { $ encrypter = new PasswordEncrypter ( ) ; $ this -> authenticated = $ encrypter -> isPasswordValid ( $ plaintextPassword , $ this -> hashedPassword ) ; return $ this ; } | compare passed plain text password with stored hashed password and store result |
228,059 | public function setRoles ( array $ roles ) { $ this -> roles = [ ] ; foreach ( $ roles as $ role ) { if ( ! $ role instanceof Role ) { throw new \ InvalidArgumentException ( 'Role is not a role instance.' ) ; } if ( array_key_exists ( $ role -> getRoleName ( ) , $ this -> roles ) ) { throw new \ InvalidArgumentExceptio... | set all roles of user |
228,060 | public function getRolesAndSubRoles ( RoleHierarchy $ roleHierarchy ) { $ possibleRoles = [ ] ; foreach ( $ this -> roles as $ role ) { $ possibleRoles [ ] = $ role ; $ possibleRoles = array_merge ( $ possibleRoles , $ roleHierarchy -> getSubRoles ( $ role ) ) ; return $ possibleRoles ; } } | return all possible roles and subroles - defined by a role hierarchy - the user can take |
228,061 | protected static function p2mSettings ( ) { if ( isset ( self :: $ _p2mSettings ) ) { return self :: $ _p2mSettings ; } return self :: getSettingsItem ( self :: $ _p2mSettings , Yii :: $ app -> params , 'p2m' ) ; } | Get p2m settings |
228,062 | protected static function getSettingsBlock ( $ name ) { return self :: getSettingsItem ( self :: $ _settingsBlock , self :: p2mSettings ( ) , $ name , false ) ; } | Get settings block |
228,063 | protected static function getSettingsItem ( & $ target , $ source , $ name = '' , $ default = false ) { if ( isset ( $ target ) ) { return $ target ; } $ useSource = true ; if ( $ source === false || ! isset ( $ source [ $ name ] ) ) { $ useSource = false ; } $ target = ( $ useSource ? $ source [ $ name ] : $ default )... | Get settings item |
228,064 | public function getTotalFiles ( ) { if ( ! $ this -> _files ) { $ this -> scan ; } $ i = 0 ; foreach ( $ this -> _files as $ file ) { if ( $ file -> isFile ) { $ i ++ ; } } return $ i ; } | count total files |
228,065 | public function addLayout ( $ id , $ content , array $ attributes = [ ] ) { $ key = $ this -> getLayoutNameWithNamespace ( $ id ) ; $ this -> layouts [ $ key ] = [ $ id , $ content , $ attributes ] ; } | Add a new layout . |
228,066 | public function executeActionsFromFile ( $ fileName ) { $ actions = array ( ) ; if ( file_exists ( $ fileName ) ) { $ actionsClasses = $ this -> decode ( $ fileName ) ; foreach ( $ actionsClasses as $ bundleName => $ actionsClass ) { $ this -> actionManagerGenerator -> generate ( $ actionsClass ) ; $ actions [ $ bundle... | Execute the actions from a json file |
228,067 | public function addField ( $ name , $ transformer = null , $ pos = null ) { if ( $ pos === null ) $ pos = sizeof ( $ this -> fields ) ; $ this -> fields [ $ pos ] = $ name ; if ( is_callable ( $ transformer ) ) $ this -> transformers [ $ pos ] = $ transformer ; else if ( $ transformer !== null ) throw new InvalidArgume... | Adds a named field to a CSV row . |
228,068 | public function addFields ( array $ fields ) { foreach ( $ fields as $ k => $ v ) if ( is_string ( $ k ) ) $ this -> addField ( $ k , $ v ) ; else $ this -> addField ( $ v ) ; return $ this ; } | Adds multiple fields with an optional transformer to a CSV row . |
228,069 | public function run ( ) { if ( empty ( $ this -> queues ) ) { die ( 'Set queues var containing the list of queues to work.' . PHP_EOL ) ; } Resque :: setBackend ( $ this -> redisBackend , $ this -> database , $ this -> password ) ; if ( $ this -> count > 1 ) { for ( $ i = 0 ; $ i < $ this -> count ; ++ $ i ) { $ pid = ... | Run to start workers |
228,070 | protected function _startWorker ( ) { $ worker = new Worker ( $ this -> queues ) ; $ worker -> logLevel = $ this -> logLevel ; fwrite ( STDOUT , '*** Starting worker ' . $ worker . PHP_EOL ) ; $ worker -> work ( $ this -> interval ) ; } | Start a worker |
228,071 | public function getKey ( ) : string { if ( $ this -> key === null ) { $ this -> key = md5 ( $ this -> getContent ( ) ) ; } return $ this -> key ; } | Get the entity key 304 response needs a proper key value |
228,072 | public function next ( ) { $ this -> key ++ ; if ( \ PDO :: FETCH_COLUMN !== $ this -> fetchMode ) { $ this -> current = $ this -> queryResult -> fetch ( $ this -> fetchMode , $ this -> driverOptions ) ; } else { $ this -> current = $ this -> queryResult -> fetchOne ( $ this -> driverOptions [ 'columnIndex' ] ?? 0 ) ; ... | iterates to next result element |
228,073 | public static function SplitIntoSegments ( $ number ) { $ number_str = $ number -> GetStringValue ( ) ; $ segments = [ ] ; $ NumberSegments = [ ] ; while ( strlen ( $ number_str ) > 0 ) { if ( strlen ( $ number_str ) < 3 ) { $ segments [ ] = $ number_str ; break ; } $ segment = substr ( $ number_str , - 3 ) ; $ number_... | This will split the number into chunks and then turn them each into NumberSegments . |
228,074 | public static function MakeNumberSegments ( $ segments ) { $ NumberSegments = [ ] ; foreach ( $ segments as $ segment ) { $ NumberSegments [ ] = new NumberSegment ( $ segment ) ; } return $ NumberSegments ; } | This is the actual factory method that converts regular string segments into the number segment types we need to work with . |
228,075 | public static function setEncoding ( $ encoding ) { if ( false === is_string ( $ encoding ) || 0 === strlen ( $ encoding ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ encoding ) ) , E_USER_ERROR ) ; } $ encoding = strtolower ( $ enco... | Set a new encoding |
228,076 | private static function cssMatcher ( $ matches ) { $ chr = $ matches [ 0 ] ; if ( 1 === strlen ( $ chr ) ) { $ ord = ord ( $ chr ) ; } else { $ chr = static :: convert ( $ chr , 'UTF-8' , 'UTF-32BE' ) ; $ ord = hexdec ( bin2hex ( $ chr ) ) ; } return sprintf ( '\\%X ' , $ ord ) ; } | Callback function for preg_replace_callback that applies CSS escaping to all matches . |
228,077 | private static function convert ( $ string , $ from , $ to ) { if ( true === function_exists ( 'iconv' ) ) { $ result = iconv ( $ from , $ to , $ string ) ; } elseif ( true === function_exists ( 'mb_convert_encoding' ) ) { $ result = mb_convert_encoding ( $ string , $ to , $ from ) ; } else { return trigger_error ( spr... | Converts string from encoding to another encoding |
228,078 | private static function toUtf8 ( $ string ) { if ( static :: getEncoding ( ) === 'utf-8' ) { $ result = $ string ; } else { $ result = static :: convert ( $ string , static :: getEncoding ( ) , 'UTF-8' ) ; } if ( false === static :: isUtf8 ( $ result ) ) { return trigger_error ( sprintf ( 'String to be escaped was not ... | Converts a string from UTF - 8 to the base encoding |
228,079 | public function clear ( ) { $ this -> bold = false ; $ this -> underscore = false ; $ this -> textColor = new Color ( ) ; $ this -> fillColor = new Color ( ) ; } | Set the state to clear no styling |
228,080 | public function findChanges ( TerminalStateInterface $ desired ) { $ ret = new self ( ) ; if ( ! $ this -> isBold ( ) && $ desired -> isBold ( ) ) { $ ret -> setBold ( true ) ; } else if ( $ this -> isBold ( ) && ! $ desired -> isBold ( ) ) { return null ; } if ( ! $ this -> isUnderscore ( ) && $ desired -> isUnderscor... | Compare the desired state and capture any things that are going from off to on if something is going from on to off then a clear needs to be sent along with all the desired state in this case this function returns null |
228,081 | public static function toArray ( $ object ) { if ( is_array ( $ object ) ) return $ object ; elseif ( ! is_object ( $ object ) ) return ( array ) $ object ; elseif ( $ object instanceof IlluminateCollection ) return $ object -> all ( ) ; elseif ( $ object instanceof IlluminateArrayable ) return $ object -> toArray ( ) ... | Cast the given object to an array |
228,082 | public function getLocaled ( string $ attribute ) { if ( Any :: isArray ( $ this -> { $ attribute } ) ) { return $ this -> { $ attribute } [ App :: $ Request -> getLanguage ( ) ] ; } if ( ! Any :: isStr ( $ attribute ) || Str :: likeEmpty ( $ this -> { $ attribute } ) ) { return null ; } return Serialize :: getDecodeLo... | Special function for locale stored attributes under serialization . |
228,083 | public function setAttribute ( $ key , $ value ) { if ( $ value !== null && $ this -> isSerializeCastable ( $ key ) ) { $ value = $ this -> asSerialize ( $ value ) ; } return parent :: setAttribute ( $ key , $ value ) ; } | Set model attribute . Extend laravel attribute casting mutators by serialized array |
228,084 | protected function castAttribute ( $ key , $ value ) { if ( $ value === null ) { return $ value ; } if ( $ this -> getCastType ( $ key ) === 'serialize' ) { return $ this -> fromSerialize ( $ value ) ; } return parent :: castAttribute ( $ key , $ value ) ; } | Cast model attribute . Extend laravel attribute casting mutators by serialized array |
228,085 | public static function fromSimpleXml ( $ xml , $ userId = null ) { $ torrent = new NyaaTorrent ( ) ; $ torrent -> title = ( string ) $ xml -> title ; $ torrent -> setInfoFromDescription ( ( string ) $ xml -> description ) ; $ torrent -> meta = NyaaMeta :: createFromTitle ( $ torrent -> title ) ; $ torrent -> torrentUrl... | Creates a new NyaaTorrent instance from a simple xml element |
228,086 | public function setInfoFromDescription ( $ description ) { if ( ! preg_match ( '~([0-9]+) seeder\(s\), ([0-9]+) leecher\(s\), ([0-9]+) download\(s\)(?: - ([0-9]+(\.[0-9]+)))?~i' , $ description , $ match ) ) { return ; } $ this -> seeds = intval ( $ match [ 1 ] ) ; $ this -> leechers = intval ( $ match [ 2 ] ) ; $ this... | Sets the torrent info from the description string |
228,087 | public function getUserId ( ) { if ( $ this -> userId === null ) { $ this -> userId = $ this -> fetchUserId ( ) ; } return $ this -> userId ; } | Gets the user id for this torrent |
228,088 | public function getTorrentId ( ) { if ( $ this -> torrentId === null ) { $ this -> torrentId = false ; if ( preg_match ( '~tid=([0-9]+)~' , $ this -> torrentUrl , $ match ) ) { $ this -> torrentId = intval ( $ match [ 1 ] ) ; } } return $ this -> torrentId ; } | Get the id of this torrent |
228,089 | private function fetchUserId ( ) { $ pool = Registry :: getStash ( ) ; $ cache = $ pool -> getItem ( 'nyaa/user/' . $ this -> getTorrentId ( ) ) ; if ( $ cache -> isMiss ( ) ) { $ userId = false ; $ html = file_get_contents ( $ this -> siteUrl ) ; if ( preg_match ( '~\/\?user\=([0-9]+)~i' , $ html , $ match ) ) { $ use... | Gets the user id by getting the overview of the torrent page and looking for the user id there |
228,090 | public function getMeta ( $ meta = null ) { if ( $ meta === null ) { return $ this -> meta ; } return $ this -> meta -> get ( $ meta ) ; } | Gets the NyaaMeta object or a meta value from the meta object if an argument is given |
228,091 | public function has ( $ id ) { if ( strpos ( $ id , '.' ) !== false ) { $ k = '$this->data' . "['" . str_replace ( '.' , "']['" , $ id ) . "']" ; eval ( '$has = isset(' . $ k . ');' ) ; return $ has ; } else { return ( is_string ( $ id ) ) ? array_key_exists ( $ id , $ this -> data ) : false ; } } | Returns true if the collection can return an entry for the given identifier returns false otherwise . |
228,092 | public function get ( $ id , $ default = null ) { if ( strpos ( $ id , '.' ) !== false ) { $ k = '$this->data' . "['" . str_replace ( '.' , "']['" , $ id ) . "']" ; eval ( '$has = isset(' . $ k . ');' ) ; if ( $ has ) { eval ( '$value = ' . $ k . ';' ) ; return $ value ; } else { return $ default ; } } else { return $ ... | Finds an entry of the collection by its identifier and returns it . |
228,093 | public function remove ( $ id ) { if ( $ this -> locked ) { return false ; } if ( strpos ( $ id , '.' ) !== false ) { $ k = '$this->data' . "['" . str_replace ( '.' , "']['" , $ id ) . "']" ; eval ( '$has = isset(' . $ k . ');' ) ; if ( $ has ) { eval ( 'unset(' . $ k . ');' ) ; return true ; } else { return false ; } ... | Removes the value from identified by an identifier from the colection |
228,094 | public function clearIdentity ( ) { $ this -> getStorage ( ) -> clear ( ) ; $ ids = $ this -> getContainer ( ) -> getIdentities ( ) ; $ sessionIds = array ( ) ; foreach ( $ ids as $ id ) { $ sessionIds [ ] = $ id -> getSessionId ( ) ; } $ this -> getSessionProvider ( ) -> clear ( $ sessionIds ) ; $ this -> getEventMana... | Clears the identity from persistent storage |
228,095 | public function addAspect ( Aspect $ aspect ) { if ( $ this -> container !== null ) { $ this -> container -> registerAspect ( $ aspect ) ; } return $ this ; } | Registers an aspect to the aspects kernel |
228,096 | public function dispatchResponse ( $ response ) { $ parts = explode ( "\r\n\r\n" , $ response , 2 ) ; if ( count ( $ parts ) < 2 ) { $ this -> throwException ( ) ; } list ( $ headersAsString , $ body ) = $ parts ; $ headers = explode ( "\r\n" , $ headersAsString ) ; list ( $ code , $ status ) = $ this -> dispatchHttpSt... | Get response code headers status body |
228,097 | protected function dispatchHttpStatus ( $ header ) { $ statuses = array ( ) ; $ result = preg_match ( '/^http\/[1|2]\.\d (\d{3}) (.*)$/i' , $ header , $ statuses ) ; if ( $ result < 1 ) { $ this -> throwException ( ) ; } return array ( ( int ) $ statuses [ 1 ] , $ statuses [ 2 ] ) ; } | Get HTTP status and code from first header |
228,098 | protected function dispatchHeaders ( $ headersAsString ) { $ headers = array ( ) ; foreach ( $ headersAsString as $ header ) { $ headerData = $ this -> dispatchHeaderValue ( $ header ) ; if ( is_null ( $ headerData ) ) { continue ; } $ headers [ $ headerData [ 'name' ] ] = $ headerData [ 'value' ] ; } return $ headers ... | Get headers an values |
228,099 | protected function dispatchHeaderValue ( $ header ) { $ header = explode ( ':' , $ header , 2 ) ; if ( count ( $ header ) < 2 ) { return null ; } return array ( 'name' => trim ( $ header [ 0 ] ) , 'value' => trim ( $ header [ 1 ] ) , ) ; } | Get key - value array |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.