idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
46,500 | public function read ( $ waitTime = 0 , $ waitMicroTime = 200000 , $ getFrame = false ) { if ( ! \ is_resource ( $ this -> socket ) || \ feof ( $ this -> socket ) ) { return null ; } $ read = [ $ this -> socket ] ; $ write = null ; $ expect = null ; if ( 0 === \ stream_select ( $ read , $ write , $ expect , $ waitTime ... | Block until it receive a frame from websocket or return null if no more connexion . |
46,501 | public function getContext ( ) { $ directory = \ sys_get_temp_dir ( ) . '/ctb-' . \ microtime ( ) ; $ this -> fs -> mkdir ( $ directory ) ; $ this -> write ( $ directory ) ; $ result = new Context ( $ directory , $ this -> format , $ this -> fs ) ; $ result -> setCleanup ( true ) ; return $ result ; } | Create context given the state of builder . |
46,502 | private function write ( $ directory ) : void { $ dockerfile = [ ] ; if ( empty ( $ this -> commands ) || $ this -> commands [ 0 ] [ 'type' ] !== 'FROM' ) { $ dockerfile [ ] = 'FROM base' ; } foreach ( $ this -> commands as $ command ) { switch ( $ command [ 'type' ] ) { case 'FROM' : $ dockerfile [ ] = 'FROM ' . $ com... | Write docker file and associated files in a directory . |
46,503 | private function getFile ( $ directory , $ content ) { $ hash = \ md5 ( $ content ) ; if ( ! \ array_key_exists ( $ hash , $ this -> files ) ) { $ file = \ tempnam ( $ directory , '' ) ; $ this -> fs -> dumpFile ( $ file , $ content ) ; $ this -> files [ $ hash ] = \ basename ( $ file ) ; } return $ this -> files [ $ h... | Generate a file in a directory . |
46,504 | private function getFileFromStream ( $ directory , $ stream ) { $ file = \ tempnam ( $ directory , '' ) ; $ target = \ fopen ( $ file , 'w' ) ; if ( 0 === \ stream_copy_to_stream ( $ stream , $ target ) ) { throw new \ RuntimeException ( 'Failed to write stream to file' ) ; } \ fclose ( $ target ) ; return \ basename (... | Generated a file in a directory from a stream . |
46,505 | private function getFileFromDisk ( $ directory , $ source ) { $ hash = 'DISK-' . \ md5 ( \ realpath ( $ source ) ) ; if ( ! \ array_key_exists ( $ hash , $ this -> files ) ) { if ( \ is_dir ( $ source ) ) { $ this -> fs -> mirror ( $ source , $ directory . '/' . $ hash , null , [ 'copy_on_windows' => true ] ) ; } else ... | Generated a file in a directory from an existing file . |
46,506 | public static function sendLink ( $ link , $ message = '' ) { self :: initialize ( ) ; $ data = compact ( 'link' , 'message' ) ; try { $ response = self :: $ fb -> post ( '/me/feed' , $ data , self :: $ page_access_token ) ; } catch ( Facebook \ Exceptions \ FacebookResponseException $ e ) { throw new \ Exception ( 'Gr... | Send link and text message |
46,507 | public static function sendPhoto ( $ photo , $ message = '' ) { self :: initialize ( ) ; $ data = [ 'message' => $ message , 'source' => self :: $ fb -> fileToUpload ( $ photo ) ] ; try { $ response = self :: $ fb -> post ( '/me/photos' , $ data , self :: $ page_access_token ) ; } catch ( Facebook \ Exceptions \ Facebo... | Send photo and text message |
46,508 | public static function sendMessage ( $ message , $ media = [ ] , $ options = [ ] ) { self :: initialize ( ) ; $ mediaIds = [ ] ; foreach ( $ media as $ item ) { $ res = self :: request ( 'https://upload.twitter.com/1.1/media/upload.json' , 'POST' , null , [ 'media' => $ item ] ) ; $ mediaIds [ ] = $ res -> media_id_str... | Sends message to the Twitter . |
46,509 | public static function sendMessage ( $ chat_id = null , $ text , $ inline_keyboard = '' , $ reply_keyboard = '' , $ parse_mode = 'HTML' , $ disable_web_page_preview = false , $ disable_notification = false , $ reply_to_message_id = '' ) { self :: initialize ( ) ; $ chat_id = $ chat_id ? $ chat_id : self :: $ channel_us... | Send text messages |
46,510 | public static function sendMediaGroup ( $ chat_id = null , $ media , $ disable_notification = false , $ reply_to_message_id = '' ) { self :: initialize ( ) ; $ chat_id = $ chat_id ? $ chat_id : self :: $ channel_username ; $ params = compact ( 'chat_id' , 'media' , 'disable_notification' , 'reply_to_message_id' ) ; $ r... | Send media group |
46,511 | public static function sendRequest ( $ method = 'sendMessage' , $ params ) { $ curl = curl_init ( self :: $ api_url . self :: $ api_token . '/' . $ method ) ; curl_setopt ( $ curl , CURLOPT_HEADER , false ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ curl , CURLOPT_POST , 1 ) ; curl_setopt (... | Send Request to Telegram api |
46,512 | public static function Facebook ( $ type , $ data ) { switch ( $ type ) { case 'link' : $ message = isset ( $ data [ 'message' ] ) ? $ data [ 'message' ] : '' ; $ result = FacebookApi :: sendLink ( $ data [ 'link' ] , $ data [ 'message' ] ) ; break ; case 'photo' : $ message = isset ( $ data [ 'message' ] ) ? $ data [ ... | Send message to Facebook page |
46,513 | public static function assignSignature ( $ text , $ type ) { $ signature = "\n" . Config :: get ( 'larasap.telegram.channel_signature' ) ; $ signature_length = strlen ( $ signature ) ; $ text_length = strlen ( $ text ) ; $ max_length = ( $ type == 'text' ) ? TelegramApi :: TEXT_LENGTH : TelegramApi :: CAPTION_LENGTH ; ... | Assign channel signature in the footer of message |
46,514 | public function getAvailableDirective ( Request $ request ) { if ( null === $ this -> uaParser ) { return $ this -> getChromeDirectives ( ) ; } switch ( $ this -> uaParser -> getBrowser ( $ request -> headers -> get ( 'user-agent' ) ) ) { case UserAgentParserInterface :: BROWSER_CHROME : case UserAgentParserInterface :... | Returns the list of supported directives for the current Request |
46,515 | public function startSpan ( $ operationName , $ options = [ ] ) { if ( is_array ( $ options ) ) { $ options = SpanOptions :: create ( $ options ) ; } else { throw new \ Exception ( "options is not array" ) ; } $ references = $ options -> getReferences ( ) ; $ hasParent = false ; $ parentSpan = null ; foreach ( $ refere... | init span info |
46,516 | public function log ( array $ fields = [ ] , $ timestamp = null ) { $ log [ 'timestamp' ] = $ timestamp ? $ timestamp : $ this -> microtimeToInt ( ) ; $ log [ 'fields' ] = $ fields ; $ this -> logs [ ] = $ log ; } | Adds a log record to the span |
46,517 | public function initTrace ( $ serverName , $ agentHostPort = '' ) { if ( self :: $ disabled ) { return NoopTracer :: create ( ) ; } if ( $ serverName == '' ) { throw new \ Exception ( "serverName require" ) ; } if ( isset ( self :: $ tracer [ $ serverName ] ) && ! empty ( self :: $ tracer [ $ serverName ] ) ) { return ... | init jaeger and set GlobalTracer return can use flush buffers |
46,518 | public function transformRecords ( $ records ) { if ( method_exists ( $ this -> class , 'laratablesModifyCollection' ) ) { $ records = $ this -> class :: laratablesModifyCollection ( $ records ) -> values ( ) ; } return $ records -> map ( function ( $ item ) { return $ this -> transformRecord ( $ item ) ; } ) ; } | Transforms each record for Datatables display . |
46,519 | protected function transformRecord ( $ record ) { $ columnNames = $ this -> columnManager -> getRequestedColumnNames ( ) ; $ columnNames -> transform ( function ( $ item ) use ( $ record ) { return $ this -> getColumnValue ( $ item , $ record ) ; } ) ; $ datatableParameters = $ this -> getDatatableParameters ( $ record... | Transform the record data for Datatables display . |
46,520 | protected function getColumnValue ( $ columnName , $ record ) { if ( $ methodName = $ this -> columnManager -> isCustomColumn ( $ columnName ) ) { return $ this -> class :: $ methodName ( $ record ) ; } if ( $ methodName = $ this -> customisesColumnValue ( $ columnName ) ) { return $ record -> $ methodName ( ) ; } if (... | Retuns column value to be displayed in datatables . |
46,521 | protected function customisesColumnValue ( $ columnName ) { $ methodName = camel_case ( 'laratables_' . $ columnName ) ; if ( method_exists ( $ this -> class , $ methodName ) ) { return $ methodName ; } return false ; } | Decides whether there is a custom method on the class for the specified column . Returns method name if yes . |
46,522 | protected function getRelationColumnValue ( $ columnName , $ record ) { list ( $ relationName , $ relationColumnName ) = getRelationDetails ( $ columnName ) ; if ( $ methodName = $ this -> customisesColumnValue ( $ relationName . '_' . $ relationColumnName ) ) { return $ record -> $ methodName ( ) ; } if ( $ record -> ... | Returns the value of relation table column . |
46,523 | protected function isCarbonInstance ( $ columnValue ) { return is_object ( $ columnValue ) && ( $ columnValue instanceof \ Carbon \ Carbon || $ columnValue instanceof \ Illuminate \ Support \ Carbon ) ; } | Decides whether provided column value is a carbon date instance . |
46,524 | public function getDatatableParameters ( $ record ) { $ datatableParameters = [ 'DT_RowId' => config ( 'laratables.row_id_prefix' ) . $ record -> { $ record -> getKeyName ( ) } , ] ; if ( method_exists ( $ this -> class , 'laratablesRowClass' ) ) { $ datatableParameters [ 'DT_RowClass' ] = $ record -> laratablesRowClas... | Returns the datatable specific parameters for the record . |
46,525 | public static function recordsOf ( $ model , $ classOrCallable = null ) { $ instance = new static ( ... self :: prepareProperties ( $ model , $ classOrCallable ) ) ; $ instance -> applyFiltersTo ( ) ; $ records = $ instance -> fetchRecords ( ) ; $ records = $ instance -> recordsTransformer -> transformRecords ( $ recor... | Accepts datatables ajax request and returns table data . |
46,526 | private static function prepareProperties ( $ model , $ classOrCallable ) { $ callable = null ; $ class = $ model ; if ( is_object ( $ classOrCallable ) && $ classOrCallable instanceof \ Closure ) { $ callable = $ classOrCallable ; } elseif ( is_string ( $ classOrCallable ) ) { $ class = $ classOrCallable ; } return [ ... | Prepares the model class and callable for the instance . |
46,527 | protected function applyFiltersTo ( ) { $ searchValue = request ( 'search' ) [ 'value' ] ; if ( $ searchValue ) { $ this -> queryHandler -> applyFilters ( $ this -> columnManager -> getSearchColumns ( ) , $ searchValue ) ; } } | Applies conditions to the query if search is performed in datatables . |
46,528 | protected function fetchRecords ( ) { $ query = $ this -> queryHandler -> getQuery ( ) ; $ orderByValue = $ this -> columnManager -> getOrderBy ( ) ; $ orderByStatement = is_array ( $ orderByValue ) ? 'orderBy' : 'orderByRaw' ; $ orderByValue = Arr :: wrap ( $ orderByValue ) ; return $ query -> with ( $ this -> columnM... | Fetches records from the database . |
46,529 | protected function tableData ( $ records ) { return [ 'draw' => request ( 'draw' ) + 1 , 'recordsTotal' => $ this -> queryHandler -> getRecordsCount ( ) , 'recordsFiltered' => $ this -> queryHandler -> getFilteredCount ( ) , 'data' => $ records -> toArray ( ) , ] ; } | Prepares and returns data for the datatables . |
46,530 | public function addRelation ( $ columnName ) { $ relationName = getRelationName ( $ columnName ) ; if ( ! array_key_exists ( $ relationName , $ this -> relations ) && ! in_array ( $ relationName , $ this -> relations ) ) { $ methodName = camel_case ( 'laratables_' . $ relationName . 'relation_query' ) ; if ( method_exi... | Adds the relation to be loaded with the query . |
46,531 | protected function decideRelationColumns ( $ relationName ) { $ relationType = ( new \ ReflectionClass ( $ this -> modelObject -> $ relationName ( ) ) ) -> getShortName ( ) ; $ selectColumns = [ ] ; switch ( $ relationType ) { case 'BelongsTo' : $ methodName = method_exists ( $ this -> modelObject -> $ relationName ( )... | Decides the columns to be used based on the relationship . |
46,532 | protected static function applyFilter ( $ query , $ column , $ searchValue ) { if ( $ methodName = self :: hasCustomSearch ( $ column ) ) { return self :: $ class :: $ methodName ( $ query , $ searchValue ) ; } if ( isRelationColumn ( $ column ) ) { return self :: applyRelationFilter ( $ query , $ column , $ searchValu... | Applies filter condition for the table column . |
46,533 | protected static function hasCustomSearch ( $ columnName ) { $ methodName = camel_case ( 'laratables_search_' . $ columnName ) ; if ( method_exists ( self :: $ class , $ methodName ) ) { return $ methodName ; } return false ; } | Decides whether column has custom search method defined in the model and returns method name if yes . |
46,534 | protected static function applyRelationFilter ( $ query , $ column , $ searchValue ) { if ( $ methodName = self :: hasCustomSearch ( str_replace ( '.' , '_' , $ column ) ) ) { return self :: $ class :: $ methodName ( $ query , $ searchValue ) ; } list ( $ relationName , $ relationColumnName ) = getRelationDetails ( $ c... | Applies filter condition for the relation column . |
46,535 | protected function initializeProperties ( $ model , $ class ) { $ this -> class = $ class ; $ this -> modelObject = new $ model ( ) ; $ this -> primaryColumn = $ this -> modelObject -> getKeyName ( ) ; $ requestData = collect ( request ( ) -> all ( ) ) ; $ this -> requestedColumns = collect ( $ requestData -> get ( 'co... | Initializes class properties . |
46,536 | protected function setColumnProperties ( ) { if ( ! $ this -> requestedColumns -> contains ( 'name' , $ this -> primaryColumn ) ) { $ this -> selectColumns [ ] = $ this -> primaryColumn ; } $ this -> requestedColumns -> each ( function ( $ column ) { $ this -> setColumnPropertiesFor ( $ column ) ; } ) ; } | Set column properties from the request data . |
46,537 | protected function setColumnPropertiesFor ( $ column ) { $ columnName = $ column [ 'name' ] ; if ( $ column [ 'searchable' ] == 'true' && ! in_array ( $ columnName , config ( 'laratables.non_searchable_columns' ) ) ) { $ this -> searchColumns [ ] = $ columnName ; } if ( $ this -> isCustomColumn ( $ columnName ) && ! is... | Set column properties from the specified column data . |
46,538 | public function isCustomColumn ( $ columnName ) { $ columnName = str_replace ( '.' , '_' , $ columnName ) ; $ methodName = camel_case ( 'laratables_custom_' . $ columnName ) ; if ( method_exists ( $ this -> class , $ methodName ) ) { return $ methodName ; } return false ; } | Decides wether specified column name is custom column . Returns method name if yes . |
46,539 | public function getOrderBy ( ) { $ orderColumn = $ this -> getOrderColumn ( ) ; if ( is_array ( $ orderColumn ) ) { return $ orderColumn [ 0 ] ; } $ selectedColumnNames = $ this -> getSelectColumns ( ) ; if ( ! in_array ( $ orderColumn , $ selectedColumnNames ) ) { throw IncorrectOrderColumn :: name ( $ orderColumn ) ;... | Returns the values for order by clause of the query . |
46,540 | public function getOrderColumn ( ) { $ requestedColumnNames = $ this -> getRequestedColumnNames ( ) -> toArray ( ) ; $ order = request ( 'order' ) ; $ orderColumn = $ requestedColumnNames [ $ order [ 0 ] [ 'column' ] ] ; if ( $ methodName = $ this -> hasCustomOrdering ( $ orderColumn ) ) { $ orderColumn = $ this -> cla... | Returns the name of the column for ordering . |
46,541 | public function hasCustomOrdering ( $ orderColumn ) { $ methodName = camel_case ( 'laratables_order_' . $ orderColumn ) ; if ( method_exists ( $ this -> class , $ methodName ) ) { return $ methodName ; } return false ; } | Decides weather there is a custom ordering for the specified column name . Returns method name if yes . |
46,542 | public function hasCustomRawOrdering ( $ orderColumn ) { $ methodName = camel_case ( 'laratables_order_raw_' . $ orderColumn ) ; if ( method_exists ( $ this -> class , $ methodName ) ) { return $ methodName ; } return false ; } | Decides weather there is a custom raw ordering for the specified column name . Returns method name if yes . |
46,543 | protected function setQuery ( $ model , $ class ) { $ this -> query = new $ model ( ) ; if ( method_exists ( $ class , 'laratablesQueryConditions' ) ) { $ this -> query = $ class :: laratablesQueryConditions ( $ this -> query ) ; } } | Initialises Query object . |
46,544 | public function loadSettings ( ) { $ extra = $ this -> composer -> getPackage ( ) -> getExtra ( ) ; $ config = array_merge ( array ( 'include' => array ( ) , 'require' => array ( ) , 'recurse' => true , 'replace' => false , 'ignore-duplicates' => false , 'merge-dev' => true , 'merge-extra' => false , 'merge-extra-deep'... | Load plugin settings |
46,545 | public function onInstallUpdateOrDump ( ScriptEvent $ event ) { $ this -> state -> loadSettings ( ) ; $ this -> state -> setDevMode ( $ event -> isDevMode ( ) ) ; $ this -> mergeFiles ( $ this -> state -> getIncludes ( ) , false ) ; $ this -> mergeFiles ( $ this -> state -> getRequires ( ) , true ) ; if ( $ event -> ge... | Handle an event callback for an install update or dump command by checking for merge - plugin in the extra data and merging package contents if found . |
46,546 | protected function mergeFiles ( array $ patterns , $ required = false ) { $ root = $ this -> composer -> getPackage ( ) ; $ files = array_map ( function ( $ files , $ pattern ) use ( $ required ) { if ( $ required && ! $ files ) { throw new MissingFileException ( "merge-plugin: No files matched required '{$pattern}'" )... | Find configuration files matching the configured glob patterns and merge their contents with the master package . |
46,547 | protected function mergeFile ( RootPackageInterface $ root , $ path ) { if ( isset ( $ this -> loaded [ $ path ] ) || ( isset ( $ this -> loadedNoDev [ $ path ] ) && ! $ this -> state -> isDevMode ( ) ) ) { $ this -> logger -> debug ( "Already merged <comment>$path</comment> completely" ) ; return ; } $ package = new E... | Read a JSON file and merge its contents |
46,548 | public function onPostPackageInstall ( PackageEvent $ event ) { $ op = $ event -> getOperation ( ) ; if ( $ op instanceof InstallOperation ) { $ package = $ op -> getPackage ( ) -> getName ( ) ; if ( $ package === self :: PACKAGE_NAME ) { $ this -> logger -> info ( 'composer-merge-plugin installed' ) ; $ this -> state ... | Handle an event callback following installation of a new package by checking to see if the package that was installed was our plugin . |
46,549 | protected function readPackageJson ( $ path ) { $ file = new JsonFile ( $ path ) ; $ json = $ file -> read ( ) ; if ( ! isset ( $ json [ 'name' ] ) ) { $ json [ 'name' ] = 'merge-plugin/' . strtr ( $ path , DIRECTORY_SEPARATOR , '-' ) ; } if ( ! isset ( $ json [ 'version' ] ) ) { $ json [ 'version' ] = '1.0.0' ; } retu... | Read the contents of a composer . json style file into an array . |
46,550 | public function mergeInto ( RootPackageInterface $ root , PluginState $ state ) { $ this -> prependRepositories ( $ root ) ; $ this -> mergeRequires ( 'require' , $ root , $ state ) ; $ this -> mergePackageLinks ( 'conflict' , $ root ) ; $ this -> mergePackageLinks ( 'replace' , $ root ) ; $ this -> mergePackageLinks (... | Merge this package into a RootPackageInterface |
46,551 | public function mergeDevInto ( RootPackageInterface $ root , PluginState $ state ) { $ this -> mergeRequires ( 'require-dev' , $ root , $ state ) ; $ this -> mergeAutoload ( 'devAutoload' , $ root ) ; $ this -> mergeReferences ( $ root ) ; } | Merge just the dev portion into a RootPackageInterface |
46,552 | protected function mergeRequires ( $ type , RootPackageInterface $ root , PluginState $ state ) { $ linkType = BasePackage :: $ supportedLinkTypes [ $ type ] ; $ getter = 'get' . ucfirst ( $ linkType [ 'method' ] ) ; $ setter = 'set' . ucfirst ( $ linkType [ 'method' ] ) ; $ requires = $ this -> package -> { $ getter }... | Merge require or require - dev into a RootPackageInterface |
46,553 | protected function mergeAutoload ( $ type , RootPackageInterface $ root ) { $ getter = 'get' . ucfirst ( $ type ) ; $ setter = 'set' . ucfirst ( $ type ) ; $ autoload = $ this -> package -> { $ getter } ( ) ; if ( empty ( $ autoload ) ) { return ; } $ unwrapped = self :: unwrapIfNeeded ( $ root , $ setter ) ; $ unwrapp... | Merge autoload or autoload - dev into a RootPackageInterface |
46,554 | protected function fixRelativePaths ( array $ paths ) { $ base = dirname ( $ this -> path ) ; $ base = ( $ base === '.' ) ? '' : "{$base}/" ; array_walk_recursive ( $ paths , function ( & $ path ) use ( $ base ) { $ path = "{$base}{$path}" ; } ) ; return $ paths ; } | Fix a collection of paths that are relative to this package to be relative to the base package . |
46,555 | protected function mergeStabilityFlags ( RootPackageInterface $ root , array $ requires ) { $ flags = $ root -> getStabilityFlags ( ) ; $ sf = new StabilityFlags ( $ flags , $ root -> getMinimumStability ( ) ) ; $ unwrapped = self :: unwrapIfNeeded ( $ root , 'setStabilityFlags' ) ; $ unwrapped -> setStabilityFlags ( a... | Extract and merge stability flags from the given collection of requires and merge them into a RootPackageInterface |
46,556 | protected function mergeSuggests ( RootPackageInterface $ root ) { $ suggests = $ this -> package -> getSuggests ( ) ; if ( ! empty ( $ suggests ) ) { $ unwrapped = self :: unwrapIfNeeded ( $ root , 'setSuggests' ) ; $ unwrapped -> setSuggests ( array_merge ( $ root -> getSuggests ( ) , $ suggests ) ) ; } } | Merge suggested packages into a RootPackageInterface |
46,557 | public function mergeExtra ( RootPackageInterface $ root , PluginState $ state ) { $ extra = $ this -> package -> getExtra ( ) ; unset ( $ extra [ 'merge-plugin' ] ) ; if ( ! $ state -> shouldMergeExtra ( ) || empty ( $ extra ) ) { return ; } $ rootExtra = $ root -> getExtra ( ) ; $ unwrapped = self :: unwrapIfNeeded (... | Merge extra config into a RootPackageInterface |
46,558 | public function mergeScripts ( RootPackageInterface $ root , PluginState $ state ) { $ scripts = $ this -> package -> getScripts ( ) ; if ( ! $ state -> shouldMergeScripts ( ) || empty ( $ scripts ) ) { return ; } $ rootScripts = $ root -> getScripts ( ) ; $ unwrapped = self :: unwrapIfNeeded ( $ root , 'setScripts' ) ... | Merge scripts config into a RootPackageInterface |
46,559 | public static function mergeExtraArray ( $ mergeDeep , $ array1 , $ array2 ) { if ( $ mergeDeep ) { return NestedArray :: mergeDeep ( $ array1 , $ array2 ) ; } return array_merge ( $ array1 , $ array2 ) ; } | Merges two arrays either via arrayMergeDeep or via array_merge . |
46,560 | protected function replaceSelfVersionDependencies ( $ type , array $ links , RootPackageInterface $ root ) { $ linkType = BasePackage :: $ supportedLinkTypes [ $ type ] ; $ version = $ root -> getVersion ( ) ; $ prettyVersion = $ root -> getPrettyVersion ( ) ; $ vp = $ this -> versionParser ; $ method = 'get' . ucfirst... | Update Links with a self . version constraint with the root package s version . |
46,561 | public static function unwrapIfNeeded ( RootPackageInterface $ root , $ method = 'setExtra' ) { if ( $ root instanceof RootAliasPackage && ! method_exists ( $ root , $ method ) ) { $ root = $ root -> getAliasOf ( ) ; } return $ root ; } | Get a full featured Package from a RootPackageInterface . |
46,562 | protected function mergeReferences ( RootPackageInterface $ root ) { $ references = array ( ) ; $ unwrapped = $ this -> unwrapIfNeeded ( $ root , 'setReferences' ) ; foreach ( array ( 'require' , 'require-dev' ) as $ linkType ) { $ linkInfo = BasePackage :: $ supportedLinkTypes [ $ linkType ] ; $ method = 'get' . ucfir... | Update the root packages reference information . |
46,563 | public function extractAll ( array $ requires ) { $ flags = array ( ) ; foreach ( $ requires as $ name => $ link ) { $ name = strtolower ( $ name ) ; $ version = $ link -> getPrettyConstraint ( ) ; $ stability = $ this -> getExplicitStability ( $ version ) ; if ( $ stability === null ) { $ stability = $ this -> getPars... | Extract and merge stability flags from the given collection of requires with another collection of stability flags . |
46,564 | protected function getCurrentStability ( $ name ) { return isset ( $ this -> stabilityFlags [ $ name ] ) ? $ this -> stabilityFlags [ $ name ] : null ; } | Get the current stability of a given package . |
46,565 | public function serialize ( $ payload ) { $ serialized = '' ; foreach ( $ payload as $ line ) { $ serialized .= '"' . implode ( '","' , $ line ) . '"' . "\n" ; } return $ serialized ; } | Takes a two dimensional array and turns it into a serialized string to include as the body of a request |
46,566 | public static function registerHandlers ( ) { if ( self :: $ registered === true ) { return ; } $ handlers = array ( \ Httpful \ Mime :: JSON => new \ Httpful \ Handlers \ JsonHandler ( ) , \ Httpful \ Mime :: XML => new \ Httpful \ Handlers \ XmlHandler ( ) , \ Httpful \ Mime :: FORM => new \ Httpful \ Handlers \ Form... | Register default mime handlers . Is idempotent . |
46,567 | public function followRedirects ( $ follow = true ) { $ this -> max_redirects = $ follow === true ? self :: MAX_REDIRECTS_DEFAULT : max ( 0 , $ follow ) ; $ this -> follow_redirects = ( bool ) $ follow ; return $ this ; } | If the response is a 301 or 302 redirect automatically send off another request to that location |
46,568 | public function digestAuth ( $ username , $ password ) { $ this -> addOnCurlOption ( CURLOPT_HTTPAUTH , CURLAUTH_DIGEST ) ; return $ this -> basicAuth ( $ username , $ password ) ; } | User Digest Auth . |
46,569 | public function clientSideCert ( $ cert , $ key , $ passphrase = null , $ encoding = 'PEM' ) { $ this -> client_cert = $ cert ; $ this -> client_key = $ key ; $ this -> client_passphrase = $ passphrase ; $ this -> client_encoding = $ encoding ; return $ this ; } | Use Client Side Cert Authentication |
46,570 | public function mime ( $ mime ) { if ( empty ( $ mime ) ) return $ this ; $ this -> content_type = $ this -> expected_type = Mime :: getFullMime ( $ mime ) ; if ( $ this -> isUpload ( ) ) { $ this -> neverSerializePayload ( ) ; } return $ this ; } | Helper function to set the Content type and Expected as same in one swoop |
46,571 | public function useProxy ( $ proxy_host , $ proxy_port = 80 , $ auth_type = null , $ auth_username = null , $ auth_password = null , $ proxy_type = Proxy :: HTTP ) { $ this -> addOnCurlOption ( CURLOPT_PROXY , "{$proxy_host}:{$proxy_port}" ) ; $ this -> addOnCurlOption ( CURLOPT_PROXYTYPE , $ proxy_type ) ; if ( in_arr... | Use proxy configuration |
46,572 | public function useSocks4Proxy ( $ proxy_host , $ proxy_port = 80 , $ auth_type = null , $ auth_username = null , $ auth_password = null ) { return $ this -> useProxy ( $ proxy_host , $ proxy_port , $ auth_type , $ auth_username , $ auth_password , Proxy :: SOCKS4 ) ; } | Shortcut for useProxy to configure SOCKS 4 proxy |
46,573 | public function useSocks5Proxy ( $ proxy_host , $ proxy_port = 80 , $ auth_type = null , $ auth_username = null , $ auth_password = null ) { return $ this -> useProxy ( $ proxy_host , $ proxy_port , $ auth_type , $ auth_username , $ auth_password , Proxy :: SOCKS5 ) ; } | Shortcut for useProxy to configure SOCKS 5 proxy |
46,574 | private function _setDefaults ( ) { if ( ! isset ( self :: $ _template ) ) self :: _initializeDefaults ( ) ; foreach ( self :: $ _template as $ k => $ v ) { if ( $ k [ 0 ] != '_' ) $ this -> $ k = $ v ; } return $ this ; } | Set the defaults on a newly instantiated object Doesn t copy variables prefixed with _ |
46,575 | public function buildResponse ( $ result ) { if ( $ result === false ) { if ( $ curlErrorNumber = curl_errno ( $ this -> _ch ) ) { $ curlErrorString = curl_error ( $ this -> _ch ) ; $ this -> _error ( $ curlErrorString ) ; $ exception = new ConnectionErrorException ( 'Unable to connect to "' . $ this -> uri . '": ' . $... | Takes a curl result and generates a Response from it |
46,576 | private function _serializePayload ( $ payload ) { if ( empty ( $ payload ) || $ this -> serialize_payload_method === self :: SERIALIZE_PAYLOAD_NEVER ) return $ payload ; if ( $ this -> serialize_payload_method === self :: SERIALIZE_PAYLOAD_SMART && is_scalar ( $ payload ) ) return $ payload ; if ( isset ( $ this -> pa... | Turn payload from structured data into a string based on the current Mime type . This uses the auto_serialize option to determine it s course of action . See serialize method for more . Renamed from _detectPayload to _serializePayload as of 2012 - 02 - 15 . |
46,577 | public static function get ( $ uri , $ mime = null ) { return self :: init ( Http :: GET ) -> uri ( $ uri ) -> mime ( $ mime ) ; } | HTTP Method Get |
46,578 | public static function post ( $ uri , $ payload = null , $ mime = null ) { return self :: init ( Http :: POST ) -> uri ( $ uri ) -> body ( $ payload , $ mime ) ; } | HTTP Method Post |
46,579 | public static function put ( $ uri , $ payload = null , $ mime = null ) { return self :: init ( Http :: PUT ) -> uri ( $ uri ) -> body ( $ payload , $ mime ) ; } | HTTP Method Put |
46,580 | public static function patch ( $ uri , $ payload = null , $ mime = null ) { return self :: init ( Http :: PATCH ) -> uri ( $ uri ) -> body ( $ payload , $ mime ) ; } | HTTP Method Patch |
46,581 | public static function delete ( $ uri , $ mime = null ) { return self :: init ( Http :: DELETE ) -> uri ( $ uri ) -> mime ( $ mime ) ; } | HTTP Method Delete |
46,582 | public function _interpretHeaders ( ) { $ content_type = isset ( $ this -> headers [ 'Content-Type' ] ) ? $ this -> headers [ 'Content-Type' ] : '' ; $ content_type = explode ( ';' , $ content_type ) ; $ this -> content_type = $ content_type [ 0 ] ; if ( count ( $ content_type ) == 2 && strpos ( $ content_type [ 1 ] , ... | After we ve parse the headers let s clean things up a bit and treat some headers specially |
46,583 | public static function getFullMime ( $ short_name ) { return array_key_exists ( $ short_name , self :: $ mimes ) ? self :: $ mimes [ $ short_name ] : $ short_name ; } | Get the full Mime Type name from a short name . Returns the short if no mapping was found . |
46,584 | public function fetchRequestToken ( array $ params = [ ] ) { $ this -> setAccessToken ( null ) ; $ defaultParams = [ 'oauth_consumer_key' => $ this -> consumerKey , 'oauth_callback' => $ this -> getReturnUrl ( ) , ] ; if ( ! empty ( $ this -> scope ) ) { $ defaultParams [ 'scope' ] = $ this -> scope ; } $ request = $ t... | Fetches the OAuth request token . |
46,585 | public function fetchAccessToken ( $ oauthToken = null , OAuthToken $ requestToken = null , $ oauthVerifier = null , array $ params = [ ] ) { $ incomingRequest = Yii :: $ app -> getRequest ( ) ; if ( $ oauthToken === null ) { $ oauthToken = $ incomingRequest -> get ( 'oauth_token' , $ incomingRequest -> post ( 'oauth_t... | Fetches OAuth access token . |
46,586 | protected function composeSignatureKey ( $ token = null ) { $ signatureKeyParts = [ $ this -> consumerSecret ] ; if ( $ token === null ) { $ token = $ this -> getAccessToken ( ) ; } if ( is_object ( $ token ) ) { $ signatureKeyParts [ ] = $ token -> getTokenSecret ( ) ; } else { $ signatureKeyParts [ ] = '' ; } $ signa... | Composes request signature key . |
46,587 | protected function composeAuthorizationHeader ( array $ params , $ realm = '' ) { $ header = 'OAuth' ; $ headerParams = [ ] ; if ( ! empty ( $ realm ) ) { $ headerParams [ ] = 'realm="' . rawurlencode ( $ realm ) . '"' ; } foreach ( $ params as $ key => $ value ) { if ( substr_compare ( $ key , 'oauth' , 0 , 5 ) ) { co... | Composes authorization header . |
46,588 | public function getHttpClient ( ) { if ( ! is_object ( $ this -> _httpClient ) ) { $ this -> _httpClient = $ this -> createHttpClient ( $ this -> _httpClient ) ; } return $ this -> _httpClient ; } | Returns HTTP client . |
46,589 | public function createRequest ( ) { return $ this -> getHttpClient ( ) -> createRequest ( ) -> addOptions ( $ this -> defaultRequestOptions ( ) ) -> addOptions ( $ this -> getRequestOptions ( ) ) ; } | Creates HTTP request instance . |
46,590 | public function setAccessToken ( $ token ) { if ( ! is_object ( $ token ) && $ token !== null ) { $ token = $ this -> createToken ( $ token ) ; } $ this -> _accessToken = $ token ; $ this -> saveAccessToken ( $ token ) ; } | Sets access token to be used . |
46,591 | public function setSignatureMethod ( $ signatureMethod ) { if ( ! is_object ( $ signatureMethod ) && ! is_array ( $ signatureMethod ) ) { throw new InvalidParamException ( '"' . get_class ( $ this ) . '::signatureMethod" should be instance of "\yii\autclient\signature\BaseMethod" or its array configuration. "' . gettyp... | Set signature method to be used . |
46,592 | protected function createSignatureMethod ( array $ signatureMethodConfig ) { if ( ! array_key_exists ( 'class' , $ signatureMethodConfig ) ) { $ signatureMethodConfig [ 'class' ] = signature \ HmacSha1 :: className ( ) ; } return Yii :: createObject ( $ signatureMethodConfig ) ; } | Creates signature method instance from its configuration . |
46,593 | protected function createToken ( array $ tokenConfig = [ ] ) { if ( ! array_key_exists ( 'class' , $ tokenConfig ) ) { $ tokenConfig [ 'class' ] = OAuthToken :: className ( ) ; } return Yii :: createObject ( $ tokenConfig ) ; } | Creates token from its configuration . |
46,594 | protected function sendRequest ( $ request ) { $ response = $ request -> send ( ) ; if ( ! $ response -> getIsOk ( ) ) { throw new InvalidResponseException ( $ response , 'Request failed with code: ' . $ response -> getStatusCode ( ) . ', message: ' . $ response -> getContent ( ) ) ; } return $ response -> getData ( ) ... | Sends the given HTTP request returning response data . |
46,595 | protected function restoreAccessToken ( ) { $ token = $ this -> getState ( 'token' ) ; if ( is_object ( $ token ) ) { if ( $ token -> getIsExpired ( ) && $ this -> autoRefreshAccessToken ) { $ token = $ this -> refreshAccessToken ( $ token ) ; } } return $ token ; } | Restores access token . |
46,596 | public function verify ( $ signature , $ baseString , $ key ) { $ expectedSignature = $ this -> generateSignature ( $ baseString , $ key ) ; if ( empty ( $ signature ) || empty ( $ expectedSignature ) ) { return false ; } return ( strcmp ( $ expectedSignature , $ signature ) === 0 ) ; } | Verifies given OAuth request . |
46,597 | protected function defaultExpireDurationParamKey ( ) { $ expireDurationParamKey = 'expires_in' ; foreach ( $ this -> getParams ( ) as $ name => $ value ) { if ( strpos ( $ name , 'expir' ) !== false ) { $ expireDurationParamKey = $ name ; break ; } } return $ expireDurationParamKey ; } | Fetches default expire duration param key . |
46,598 | public function getIsExpired ( ) { $ expirationDuration = $ this -> getExpireDuration ( ) ; if ( empty ( $ expirationDuration ) ) { return false ; } return ( time ( ) >= ( $ this -> createTimestamp + $ expirationDuration ) ) ; } | Checks if token has expired . |
46,599 | protected function discoverConfig ( ) { $ request = $ this -> createRequest ( ) ; $ configUrl = rtrim ( $ this -> issuerUrl , '/' ) . '/.well-known/openid-configuration' ; $ request -> setMethod ( 'GET' ) -> setUrl ( $ configUrl ) ; $ response = $ this -> sendRequest ( $ request ) ; return $ response ; } | Discovers OpenID Provider configuration parameters . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.