idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
34,500
public function subtract ( MoneyContainer $ money ) : MoneyBag { foreach ( $ money -> getAmounts ( ) as $ currencyCode => $ amount ) { $ this -> amounts [ $ currencyCode ] = $ this -> getAmount ( $ currencyCode ) -> minus ( $ amount ) ; } return $ this ; }
Subtracts money from this bag .
34,501
final public function to ( Context $ context , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { return Money :: create ( $ this -> getAmount ( ) , $ this -> getCurrency ( ) , $ context , $ roundingMode ) ; }
Converts this money to a Money in the given Context .
34,502
final protected function getAmountOf ( $ that ) { if ( $ that instanceof AbstractMoney ) { if ( ! $ that -> getCurrency ( ) -> is ( $ this -> getCurrency ( ) ) ) { throw MoneyMismatchException :: currencyMismatch ( $ this -> getCurrency ( ) , $ that -> getCurrency ( ) ) ; } return $ that -> getAmount ( ) ; } return $ t...
Returns the amount of the given parameter .
34,503
public static function getInstance ( ) : ISOCurrencyProvider { if ( self :: $ instance === null ) { self :: $ instance = new ISOCurrencyProvider ( ) ; } return self :: $ instance ; }
Returns the singleton instance of ISOCurrencyProvider .
34,504
public function getCurrency ( $ currencyCode ) : Currency { if ( isset ( $ this -> currencies [ $ currencyCode ] ) ) { return $ this -> currencies [ $ currencyCode ] ; } if ( ! isset ( $ this -> currencyData [ $ currencyCode ] ) ) { if ( $ this -> numericToCurrency === null ) { $ this -> numericToCurrency = require __D...
Returns the currency matching the given currency code .
34,505
public function getAvailableCurrencies ( ) : array { if ( $ this -> isPartial ) { foreach ( $ this -> currencyData as $ currencyCode => $ data ) { if ( ! isset ( $ this -> currencies [ $ currencyCode ] ) ) { $ this -> currencies [ $ currencyCode ] = new Currency ( ... $ data ) ; } } ksort ( $ this -> currencies ) ; $ t...
Returns all the available currencies .
34,506
public function getCurrencyForCountry ( string $ countryCode ) : Currency { $ currencies = $ this -> getCurrenciesForCountry ( $ countryCode ) ; $ count = count ( $ currencies ) ; if ( $ count === 1 ) { return $ currencies [ 0 ] ; } if ( $ count === 0 ) { throw UnknownCurrencyException :: noCurrencyForCountry ( $ count...
Returns the currency for the given ISO country code .
34,507
public function getCurrenciesForCountry ( string $ countryCode ) : array { if ( $ this -> countryToCurrency === null ) { $ this -> countryToCurrency = require __DIR__ . '/../data/country-to-currency.php' ; } $ result = [ ] ; if ( isset ( $ this -> countryToCurrency [ $ countryCode ] ) ) { foreach ( $ this -> countryToC...
Returns the currencies for the given ISO country code .
34,508
public function is ( $ currency ) : bool { if ( $ currency instanceof Currency ) { return $ this -> currencyCode === $ currency -> currencyCode ; } return $ this -> currencyCode === ( string ) $ currency || ( $ this -> numericCode !== 0 && $ this -> numericCode === ( int ) $ currency ) ; }
Returns whether this currency is equal to the given currency .
34,509
public static function of ( $ amount , $ currency ) : RationalMoney { $ amount = BigRational :: of ( $ amount ) ; if ( ! $ currency instanceof Currency ) { $ currency = Currency :: of ( $ currency ) ; } return new RationalMoney ( $ amount , $ currency ) ; }
Convenience factory method .
34,510
public function plus ( $ that ) : RationalMoney { $ that = $ this -> getAmountOf ( $ that ) ; $ amount = $ this -> amount -> plus ( $ that ) ; return new self ( $ amount , $ this -> currency ) ; }
Returns the sum of this RationalMoney and the given amount .
34,511
public function minus ( $ that ) : RationalMoney { $ that = $ this -> getAmountOf ( $ that ) ; $ amount = $ this -> amount -> minus ( $ that ) ; return new self ( $ amount , $ this -> currency ) ; }
Returns the difference of this RationalMoney and the given amount .
34,512
public function multipliedBy ( $ that ) : RationalMoney { $ amount = $ this -> amount -> multipliedBy ( $ that ) ; return new self ( $ amount , $ this -> currency ) ; }
Returns the product of this RationalMoney and the given number .
34,513
public function dividedBy ( $ that ) : RationalMoney { $ amount = $ this -> amount -> dividedBy ( $ that ) ; return new self ( $ amount , $ this -> currency ) ; }
Returns the result of the division of this RationalMoney by the given number .
34,514
public static function min ( Money $ money , Money ... $ monies ) : Money { $ min = $ money ; foreach ( $ monies as $ money ) { if ( $ money -> isLessThan ( $ min ) ) { $ min = $ money ; } } return $ min ; }
Returns the minimum of the given monies .
34,515
public static function max ( Money $ money , Money ... $ monies ) : Money { $ max = $ money ; foreach ( $ monies as $ money ) { if ( $ money -> isGreaterThan ( $ max ) ) { $ max = $ money ; } } return $ max ; }
Returns the maximum of the given monies .
34,516
public static function total ( Money $ money , Money ... $ monies ) : Money { $ total = $ money ; foreach ( $ monies as $ money ) { $ total = $ total -> plus ( $ money ) ; } return $ total ; }
Returns the total of the given monies .
34,517
public static function create ( BigNumber $ amount , Currency $ currency , Context $ context , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { $ amount = $ context -> applyTo ( $ amount , $ currency , $ roundingMode ) ; return new Money ( $ amount , $ currency , $ context ) ; }
Creates a Money from a rational amount a currency and a context .
34,518
public static function of ( $ amount , $ currency , Context $ context = null , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { if ( ! $ currency instanceof Currency ) { $ currency = Currency :: of ( $ currency ) ; } if ( $ context === null ) { $ context = new DefaultContext ( ) ; } $ amount = BigNumber :: ...
Returns a Money of the given amount and currency .
34,519
public static function ofMinor ( $ minorAmount , $ currency , Context $ context = null , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { if ( ! $ currency instanceof Currency ) { $ currency = Currency :: of ( $ currency ) ; } if ( $ context === null ) { $ context = new DefaultContext ( ) ; } $ amount = Big...
Returns a Money from a number of minor units .
34,520
public static function zero ( $ currency , Context $ context = null ) : Money { if ( ! $ currency instanceof Currency ) { $ currency = Currency :: of ( $ currency ) ; } if ( $ context === null ) { $ context = new DefaultContext ( ) ; } $ amount = BigDecimal :: zero ( ) ; return self :: create ( $ amount , $ currency , ...
Returns a Money with zero value in the given currency .
34,521
public function plus ( $ that , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { $ amount = $ this -> getAmountOf ( $ that ) ; if ( $ that instanceof Money ) { $ this -> checkContext ( $ that -> getContext ( ) , __FUNCTION__ ) ; if ( $ this -> context -> isFixedScale ( ) ) { return new Money ( $ this -> amo...
Returns the sum of this Money and the given amount .
34,522
public function multipliedBy ( $ that , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { $ amount = $ this -> amount -> toBigRational ( ) -> multipliedBy ( $ that ) ; return self :: create ( $ amount , $ this -> currency , $ this -> context , $ roundingMode ) ; }
Returns the product of this Money and the given number .
34,523
public function quotient ( $ that ) : Money { $ that = BigInteger :: of ( $ that ) ; $ step = $ this -> context -> getStep ( ) ; $ scale = $ this -> amount -> getScale ( ) ; $ amount = $ this -> amount -> withPointMovedRight ( $ scale ) -> dividedBy ( $ step ) ; $ q = $ amount -> quotient ( $ that ) ; $ q = $ q -> mult...
Returns the quotient of the division of this Money by the given number .
34,524
public function allocate ( int ... $ ratios ) : array { if ( ! $ ratios ) { throw new \ InvalidArgumentException ( 'Cannot allocate() an empty list of ratios.' ) ; } foreach ( $ ratios as $ ratio ) { if ( $ ratio < 0 ) { throw new \ InvalidArgumentException ( 'Cannot allocate() negative ratios.' ) ; } } $ total = array...
Allocates this Money according to a list of ratios .
34,525
public function abs ( ) : Money { return new Money ( $ this -> amount -> abs ( ) , $ this -> currency , $ this -> context ) ; }
Returns a Money whose value is the absolute value of this Money .
34,526
public function negated ( ) : Money { return new Money ( $ this -> amount -> negated ( ) , $ this -> currency , $ this -> context ) ; }
Returns a Money whose value is the negated value of this Money .
34,527
public function convertedTo ( $ currency , $ exchangeRate , Context $ context = null , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { if ( ! $ currency instanceof Currency ) { $ currency = Currency :: of ( $ currency ) ; } if ( $ context === null ) { $ context = $ this -> context ; } $ amount = $ this -> ...
Converts this Money to another currency using an exchange rate .
34,528
public function formatWith ( \ NumberFormatter $ formatter ) : string { return $ formatter -> formatCurrency ( $ this -> amount -> toFloat ( ) , $ this -> currency -> getCurrencyCode ( ) ) ; }
Formats this Money with the given NumberFormatter .
34,529
public function formatTo ( string $ locale , bool $ allowWholeNumber = false ) : string { $ scale = $ this -> amount -> getScale ( ) ; $ formatter = new \ NumberFormatter ( $ locale , \ NumberFormatter :: CURRENCY ) ; if ( $ allowWholeNumber && ! $ this -> amount -> hasNonZeroFractionalPart ( ) ) { $ scale = 0 ; } $ fo...
Formats this Money to the given locale .
34,530
public static function factory ( RequestInterface $ request , Response $ response ) { if ( $ response -> isClientError ( ) ) { $ label = 'Client error response' ; $ class = __NAMESPACE__ . '\\ClientErrorResponseException' ; } elseif ( $ response -> isServerError ( ) ) { $ label = 'Server error response' ; $ class = __N...
Factory method to create a new response exception based on the response code .
34,531
public function setData ( $ nameOrData , $ data = null ) { if ( is_array ( $ nameOrData ) ) { $ this -> data = $ nameOrData ; } else { $ this -> data [ $ nameOrData ] = $ data ; } return $ this ; }
Set the extra data properties of the parameter or set a specific extra property
34,532
public function getProperty ( $ name ) { if ( ! isset ( $ this -> properties [ $ name ] ) ) { return null ; } if ( ! ( $ this -> properties [ $ name ] instanceof self ) ) { $ this -> properties [ $ name ] [ 'name' ] = $ name ; $ this -> properties [ $ name ] = new static ( $ this -> properties [ $ name ] , $ this -> se...
Get a specific property from the parameter
34,533
public function addProperty ( Parameter $ property ) { $ this -> properties [ $ property -> getName ( ) ] = $ property ; $ property -> setParent ( $ this ) ; $ this -> propertiesCache = null ; return $ this ; }
Add a property to the parameter
34,534
public function setItems ( Parameter $ items = null ) { if ( $ this -> items = $ items ) { $ this -> items -> setParent ( $ this ) ; } return $ this ; }
Set the items data of the parameter
34,535
public function getItems ( ) { if ( is_array ( $ this -> items ) ) { $ this -> items = new static ( $ this -> items , $ this -> serviceDescription ) ; $ this -> items -> setParent ( $ this ) ; } return $ this -> items ; }
Get the item data of the parameter
34,536
public static function getDefaultChain ( ClientInterface $ client ) { $ factories = array ( ) ; if ( $ description = $ client -> getDescription ( ) ) { $ factories [ ] = new ServiceDescriptionFactory ( $ description ) ; } $ factories [ ] = new ConcreteClassFactory ( $ client ) ; return new static ( $ factories ) ; }
Get the default chain to use with clients
34,537
public function add ( FactoryInterface $ factory , $ before = null ) { $ pos = null ; if ( $ before ) { foreach ( $ this -> factories as $ i => $ f ) { if ( $ before instanceof FactoryInterface ) { if ( $ f === $ before ) { $ pos = $ i ; break ; } } elseif ( is_string ( $ before ) ) { if ( $ f instanceof $ before ) { $...
Add a command factory to the chain
34,538
public function remove ( $ factory = null ) { if ( ! ( $ factory instanceof FactoryInterface ) ) { $ factory = $ this -> find ( $ factory ) ; } $ this -> factories = array_values ( array_filter ( $ this -> factories , function ( $ f ) use ( $ factory ) { return $ f !== $ factory ; } ) ) ; return $ this ; }
Remove a specific command factory from the chain
34,539
public function find ( $ factory ) { foreach ( $ this -> factories as $ f ) { if ( $ factory === $ f || ( is_string ( $ factory ) && $ f instanceof $ factory ) ) { return $ f ; } } }
Get a command factory by class name
34,540
public function factory ( $ name , array $ args = array ( ) ) { foreach ( $ this -> factories as $ factory ) { $ command = $ factory -> factory ( $ name , $ args ) ; if ( $ command ) { return $ command ; } } }
Create a command using the associated command factories
34,541
protected function getCacheKey ( RequestInterface $ request ) { if ( $ filter = $ request -> getParams ( ) -> get ( 'cache.key_filter' ) ) { $ url = $ request -> getUrl ( true ) ; foreach ( explode ( ',' , $ filter ) as $ remove ) { $ url -> getQuery ( ) -> remove ( trim ( $ remove ) ) ; } } else { $ url = $ request ->...
Hash a request URL into a string that returns cache metadata
34,542
protected function getBodyKey ( $ url , EntityBodyInterface $ body ) { return $ this -> keyPrefix . md5 ( $ url ) . $ body -> getContentMd5 ( ) ; }
Create a cache key for a response s body
34,543
private function requestsMatch ( $ vary , $ r1 , $ r2 ) { if ( $ vary ) { foreach ( explode ( ',' , $ vary ) as $ header ) { $ key = trim ( strtolower ( $ header ) ) ; $ v1 = isset ( $ r1 [ $ key ] ) ? $ r1 [ $ key ] : null ; $ v2 = isset ( $ r2 [ $ key ] ) ? $ r2 [ $ key ] : null ; if ( $ v1 !== $ v2 ) { return false ...
Determines whether two Request HTTP header sets are non - varying
34,544
private function persistHeaders ( MessageInterface $ message ) { static $ noCache = array ( 'age' => true , 'connection' => true , 'keep-alive' => true , 'proxy-authenticate' => true , 'proxy-authorization' => true , 'te' => true , 'trailers' => true , 'transfer-encoding' => true , 'upgrade' => true , 'set-cookie' => t...
Creates an array of cacheable and normalized message headers
34,545
public function addParam ( Parameter $ param ) { $ this -> parameters [ $ param -> getName ( ) ] = $ param ; $ param -> setParent ( $ this ) ; return $ this ; }
Add a parameter to the command
34,546
public function setResponseType ( $ responseType ) { static $ types = array ( self :: TYPE_PRIMITIVE => true , self :: TYPE_CLASS => true , self :: TYPE_MODEL => true , self :: TYPE_DOCUMENTATION => true ) ; if ( ! isset ( $ types [ $ responseType ] ) ) { throw new InvalidArgumentException ( 'responseType must be one o...
Set qualifying information about the responseClass . One of primitive class model or documentation
34,547
public function setAdditionalParameters ( $ parameter ) { if ( $ this -> additionalParameters = $ parameter ) { $ this -> additionalParameters -> setParent ( $ this ) ; } return $ this ; }
Set the additionalParameters of the operation
34,548
protected function inferResponseType ( ) { static $ primitives = array ( 'array' => 1 , 'boolean' => 1 , 'string' => 1 , 'integer' => 1 , '' => 1 ) ; if ( isset ( $ primitives [ $ this -> responseClass ] ) ) { $ this -> responseType = self :: TYPE_PRIMITIVE ; } elseif ( $ this -> description && $ this -> description ->...
Infer the response type from the responseClass value
34,549
public function add ( HeaderInterface $ header ) { $ this -> headers [ strtolower ( $ header -> getName ( ) ) ] = $ header ; return $ this ; }
Set a header on the collection
34,550
public function progress ( $ downloadSize , $ downloaded , $ uploadSize , $ uploaded , $ handle = null ) { $ this -> request -> dispatch ( 'curl.callback.progress' , array ( 'request' => $ this -> request , 'handle' => $ handle , 'download_size' => $ downloadSize , 'downloaded' => $ downloaded , 'upload_size' => $ uplo...
Received a progress notification
34,551
protected function getUrlPartsFromMessage ( $ requestUrl , array $ parts ) { $ urlParts = array ( 'path' => $ requestUrl , 'scheme' => 'http' ) ; if ( isset ( $ parts [ 'headers' ] [ 'Host' ] ) ) { $ urlParts [ 'host' ] = $ parts [ 'headers' ] [ 'Host' ] ; } elseif ( isset ( $ parts [ 'headers' ] [ 'host' ] ) ) { $ url...
Create URL parts from HTTP message parts
34,552
protected function pruneCache ( $ cache ) { if ( count ( $ this -> cache [ $ cache ] ) == $ this -> maxCacheSize ) { $ this -> cache [ $ cache ] = array_slice ( $ this -> cache [ $ cache ] , $ this -> maxCacheSize * 0.2 ) ; } }
Prune one of the named caches by removing 20% of the cache if it is full
34,553
protected function createBatches ( ) { if ( count ( $ this -> queue ) ) { if ( $ batches = $ this -> divisionStrategy -> createBatches ( $ this -> queue ) ) { if ( is_array ( $ batches ) ) { $ batches = new \ ArrayIterator ( $ batches ) ; } $ this -> dividedBatches [ ] = $ batches ; } } }
Create batches for any queued items
34,554
public function setExceptions ( array $ exceptions ) { $ this -> exceptions = array ( ) ; foreach ( $ exceptions as $ exception ) { $ this -> add ( $ exception ) ; } return $ this ; }
Set all of the exceptions
34,555
protected function cleanupHandles ( ) { if ( $ diff = max ( 0 , count ( $ this -> handles ) - $ this -> maxHandles ) ) { for ( $ i = count ( $ this -> handles ) - 1 ; $ i > 0 && $ diff > 0 ; $ i -- ) { if ( ! count ( $ this -> handles [ $ i ] ) ) { unset ( $ this -> handles [ $ i ] ) ; $ diff -- ; } } $ this -> handles...
Trims down unused CurlMulti handles to limit the number of open connections
34,556
public static function onRequestError ( Event $ event ) { $ e = BadResponseException :: factory ( $ event [ 'request' ] , $ event [ 'response' ] ) ; $ event [ 'request' ] -> setState ( self :: STATE_ERROR , array ( 'exception' => $ e ) + $ event -> toArray ( ) ) ; throw $ e ; }
Default method that will throw exceptions if an unsuccessful response is received .
34,557
protected function processResponse ( array $ context = array ( ) ) { if ( ! $ this -> response ) { $ e = new RequestException ( 'Error completing request' ) ; $ e -> setRequest ( $ this ) ; throw $ e ; } $ this -> state = self :: STATE_COMPLETE ; $ this -> dispatch ( 'request.sent' , $ this -> getEventArray ( ) + $ con...
Process a received response
34,558
public function setError ( $ error , $ number ) { $ this -> curlError = $ error ; $ this -> curlErrorNo = $ number ; return $ this ; }
Set the cURL error message
34,559
protected function mergeIncludes ( & $ config , $ basePath = null ) { if ( ! empty ( $ config [ 'includes' ] ) ) { foreach ( $ config [ 'includes' ] as & $ path ) { if ( $ path [ 0 ] != DIRECTORY_SEPARATOR && ! isset ( $ this -> aliases [ $ path ] ) && $ basePath ) { $ path = "{$basePath}/{$path}" ; } if ( ! isset ( $ ...
Merges in all include files
34,560
public function serialize ( ) { return json_encode ( array_map ( function ( Cookie $ cookie ) { return $ cookie -> toArray ( ) ; } , $ this -> all ( null , null , null , true , true ) ) ) ; }
Serializes the cookie cookieJar
34,561
public function unserialize ( $ data ) { $ data = json_decode ( $ data , true ) ; if ( empty ( $ data ) ) { $ this -> cookies = array ( ) ; } else { $ this -> cookies = array_map ( function ( array $ cookie ) { return new Cookie ( $ cookie ) ; } , $ data ) ; } }
Unserializes the cookie cookieJar
34,562
public function setDefaultOption ( $ keyOrPath , $ value ) { $ keyOrPath = self :: REQUEST_OPTIONS . '/' . $ keyOrPath ; $ this -> config -> setPath ( $ keyOrPath , $ value ) ; return $ this ; }
Set a default request option on the client that will be used as a default for each request
34,563
public function getDefaultOption ( $ keyOrPath ) { $ keyOrPath = self :: REQUEST_OPTIONS . '/' . $ keyOrPath ; return $ this -> config -> getPath ( $ keyOrPath ) ; }
Retrieve a default request option from the client
34,564
protected function expandTemplate ( $ template , array $ variables = null ) { $ expansionVars = $ this -> getConfig ( ) -> toArray ( ) ; if ( $ variables ) { $ expansionVars = $ variables + $ expansionVars ; } return $ this -> getUriTemplate ( ) -> expand ( $ template , $ expansionVars ) ; }
Expand a URI template while merging client config settings into the template variables
34,565
protected function getUriTemplate ( ) { if ( ! $ this -> uriTemplate ) { $ this -> uriTemplate = ParserRegistry :: getInstance ( ) -> getParser ( 'uri_template' ) ; } return $ this -> uriTemplate ; }
Get the URI template expander used by the client
34,566
protected function sendMultiple ( array $ requests ) { $ curlMulti = $ this -> getCurlMulti ( ) ; foreach ( $ requests as $ request ) { $ curlMulti -> add ( $ request ) ; } $ curlMulti -> send ( ) ; $ result = array ( ) ; foreach ( $ requests as $ request ) { $ result [ ] = $ request -> getResponse ( ) ; } return $ res...
Send multiple requests in parallel
34,567
protected function prepareRequest ( RequestInterface $ request , array $ options = array ( ) ) { $ request -> setClient ( $ this ) -> setEventDispatcher ( clone $ this -> getEventDispatcher ( ) ) ; if ( $ curl = $ this -> config [ self :: CURL_OPTIONS ] ) { $ request -> getCurlOptions ( ) -> overwriteWith ( CurlHandle ...
Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request .
34,568
public static function extractPharCacert ( $ pharCacertPath ) { $ certFile = sys_get_temp_dir ( ) . '/guzzle-cacert.pem' ; if ( ! file_exists ( $ pharCacertPath ) ) { throw new \ RuntimeException ( "Could not find $pharCacertPath" ) ; } if ( ! file_exists ( $ certFile ) || filesize ( $ certFile ) != filesize ( $ pharCa...
Copies the phar cacert from a phar into the temp directory .
34,569
public static function getExponentialBackoff ( $ maxRetries = 3 , array $ httpCodes = null , array $ curlCodes = null ) { return new self ( new TruncatedBackoffStrategy ( $ maxRetries , new HttpBackoffStrategy ( $ httpCodes , new CurlBackoffStrategy ( $ curlCodes , new ExponentialBackoffStrategy ( ) ) ) ) ) ; }
Retrieve a basic truncated exponential backoff plugin that will retry HTTP errors and cURL errors
34,570
public function onRequestPoll ( Event $ event ) { $ request = $ event [ 'request' ] ; $ delay = $ request -> getParams ( ) -> get ( self :: DELAY_PARAM ) ; if ( null !== $ delay && microtime ( true ) >= $ delay ) { $ request -> getParams ( ) -> remove ( self :: DELAY_PARAM ) ; if ( $ request instanceof EntityEnclosingR...
Called when a request is polling in the curl multi object
34,571
public function addVisitor ( $ location , ResponseVisitorInterface $ visitor ) { $ this -> factory -> addResponseVisitor ( $ location , $ visitor ) ; return $ this ; }
Add a location visitor to the command
34,572
protected function parseClass ( CommandInterface $ command ) { $ event = new CreateResponseClassEvent ( array ( 'command' => $ command ) ) ; $ command -> getClient ( ) -> getEventDispatcher ( ) -> dispatch ( 'command.parse_response' , $ event ) ; if ( $ result = $ event -> getResult ( ) ) { return $ result ; } $ classN...
Parse a class object
34,573
protected function visitResult ( Parameter $ model , CommandInterface $ command , Response $ response ) { $ foundVisitors = $ result = $ knownProps = array ( ) ; $ props = $ model -> getProperties ( ) ; foreach ( $ props as $ schema ) { if ( $ location = $ schema -> getLocation ( ) ) { if ( ! isset ( $ foundVisitors [ ...
Perform transformations on the result array
34,574
protected function processArray ( Parameter $ param , & $ value ) { if ( ! isset ( $ value [ 0 ] ) ) { if ( $ param -> getItems ( ) && isset ( $ value [ $ param -> getItems ( ) -> getWireName ( ) ] ) ) { $ value = $ value [ $ param -> getItems ( ) -> getWireName ( ) ] ; if ( ! isset ( $ value [ 0 ] ) || ! is_array ( $ ...
Process an array
34,575
protected function processXmlAttribute ( Parameter $ property , array & $ value ) { $ sentAs = $ property -> getWireName ( ) ; if ( isset ( $ value [ '@attributes' ] [ $ sentAs ] ) ) { $ value [ $ property -> getName ( ) ] = $ value [ '@attributes' ] [ $ sentAs ] ; unset ( $ value [ '@attributes' ] [ $ sentAs ] ) ; if ...
Process an XML attribute property
34,576
public function getParser ( $ name ) { if ( ! isset ( $ this -> instances [ $ name ] ) ) { if ( ! isset ( $ this -> mapping [ $ name ] ) ) { return null ; } $ class = $ this -> mapping [ $ name ] ; $ this -> instances [ $ name ] = new $ class ( ) ; } return $ this -> instances [ $ name ] ; }
Get a parser by name from an instance
34,577
public static function fromConfig ( array $ config = array ( ) , array $ defaults = array ( ) , array $ required = array ( ) ) { $ data = $ config + $ defaults ; if ( $ missing = array_diff ( $ required , array_keys ( $ data ) ) ) { throw new InvalidArgumentException ( 'Config is missing the following keys: ' . implode...
Create a new collection from an array validate the keys and add default values where missing
34,578
public function getAll ( array $ keys = null ) { return $ keys ? array_intersect_key ( $ this -> data , array_flip ( $ keys ) ) : $ this -> data ; }
Get all or a subset of matching key value pairs
34,579
public function keySearch ( $ key ) { foreach ( array_keys ( $ this -> data ) as $ k ) { if ( ! strcasecmp ( $ k , $ key ) ) { return $ k ; } } return false ; }
Case insensitive search the keys in the collection
34,580
public function overwriteWith ( $ data ) { if ( is_array ( $ data ) ) { $ this -> data = $ data + $ this -> data ; } elseif ( $ data instanceof Collection ) { $ this -> data = $ data -> toArray ( ) + $ this -> data ; } else { foreach ( $ data as $ key => $ value ) { $ this -> data [ $ key ] = $ value ; } } return $ thi...
Over write key value pairs in this collection with all of the data from an array or collection .
34,581
public function inject ( $ input ) { Version :: warn ( __METHOD__ . ' is deprecated' ) ; $ replace = array ( ) ; foreach ( $ this -> data as $ key => $ val ) { $ replace [ '{' . $ key . '}' ] = $ val ; } return strtr ( $ input , $ replace ) ; }
Inject configuration settings into an input string
34,582
public function subsplitUpdate ( ) { $ repo = $ this -> getRepository ( ) ; $ this -> log ( 'git-subsplit update...' ) ; $ cmd = $ this -> client -> getCommand ( 'subsplit' ) ; $ cmd -> addArgument ( 'update' ) ; try { $ cmd -> execute ( ) ; } catch ( Exception $ e ) { throw new BuildException ( 'git subsplit update fa...
Runs git subsplit update
34,583
public function subsplitInit ( ) { $ remote = $ this -> getRemote ( ) ; $ cmd = $ this -> client -> getCommand ( 'subsplit' ) ; $ this -> log ( 'running git-subsplit init ' . $ remote ) ; $ cmd -> setArguments ( array ( 'init' , $ remote ) ) ; try { $ output = $ cmd -> execute ( ) ; } catch ( Exception $ e ) { throw ne...
Runs git subsplit init based on the remote repository .
34,584
public function onRequestBeforeSend ( Event $ event ) { $ request = $ event [ 'request' ] ; if ( ! $ request -> getParams ( ) -> get ( 'cookies.disable' ) ) { $ request -> removeHeader ( 'Cookie' ) ; foreach ( $ this -> cookieJar -> getMatchingCookies ( $ request ) as $ cookie ) { $ request -> addCookie ( $ cookie -> g...
Add cookies before a request is sent
34,585
protected static function getInvalidCharacters ( ) { if ( ! self :: $ invalidCharString ) { self :: $ invalidCharString = implode ( '' , array_map ( 'chr' , array_merge ( range ( 0 , 32 ) , array ( 34 , 40 , 41 , 44 , 47 ) , array ( 58 , 59 , 60 , 61 , 62 , 63 , 64 , 91 , 92 , 93 , 123 , 125 , 127 ) ) ) ) ; } return se...
Gets an array of invalid cookie characters
34,586
public function getAttribute ( $ name ) { return array_key_exists ( $ name , $ this -> data [ 'data' ] ) ? $ this -> data [ 'data' ] [ $ name ] : null ; }
Get a specific data point from the extra cookie data
34,587
public function matchesPath ( $ path ) { if ( $ path == $ this -> getPath ( ) ) { return true ; } $ pos = stripos ( $ path , $ this -> getPath ( ) ) ; if ( $ pos === 0 ) { if ( substr ( $ this -> getPath ( ) , - 1 , 1 ) === "/" ) { return true ; } if ( substr ( $ path , strlen ( $ this -> getPath ( ) ) , 1 ) === "/" ) ...
Check if the cookie matches a path value
34,588
public function getDirective ( $ param ) { $ directives = $ this -> getDirectives ( ) ; return isset ( $ directives [ $ param ] ) ? $ directives [ $ param ] : null ; }
Get a specific cache control directive
34,589
public function addDirective ( $ param , $ value ) { $ directives = $ this -> getDirectives ( ) ; $ directives [ $ param ] = $ value ; $ this -> updateFromDirectives ( $ directives ) ; return $ this ; }
Add a cache control directive
34,590
public function removeDirective ( $ param ) { $ directives = $ this -> getDirectives ( ) ; unset ( $ directives [ $ param ] ) ; $ this -> updateFromDirectives ( $ directives ) ; return $ this ; }
Remove a cache control directive by name
34,591
public function getDirectives ( ) { if ( $ this -> directives === null ) { $ this -> directives = array ( ) ; foreach ( $ this -> parseParams ( ) as $ collection ) { foreach ( $ collection as $ key => $ value ) { $ this -> directives [ $ key ] = $ value === '' ? true : $ value ; } } } return $ this -> directives ; }
Get an associative array of cache control directives
34,592
protected function updateFromDirectives ( array $ directives ) { $ this -> directives = $ directives ; $ this -> values = array ( ) ; foreach ( $ directives as $ key => $ value ) { $ this -> values [ ] = $ value === true ? $ key : "{$key}={$value}" ; } }
Updates the header value based on the parsed directives
34,593
protected function rebuildCache ( ) { $ this -> cache = stream_get_meta_data ( $ this -> stream ) ; $ this -> cache [ self :: IS_LOCAL ] = stream_is_local ( $ this -> stream ) ; $ this -> cache [ self :: IS_READABLE ] = isset ( self :: $ readWriteHash [ 'read' ] [ $ this -> cache [ 'mode' ] ] ) ; $ this -> cache [ self...
Reprocess stream metadata
34,594
public static function fromMultiTransferException ( MultiTransferException $ e ) { $ ce = new self ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; $ ce -> setSuccessfulRequests ( $ e -> getSuccessfulRequests ( ) ) ; $ alreadyAddedExceptions = array ( ) ; foreach ( $ e -> getFailedRequests ( ) ...
Creates a new CommandTransferException from a MultiTransferException
34,595
public function onRequestCreate ( Event $ event ) { $ event [ 'request' ] -> setAuth ( $ this -> username , $ this -> password , $ this -> scheme ) ; }
Add basic auth
34,596
protected function addPrefixedHeaders ( RequestInterface $ request , Parameter $ param , $ value ) { if ( ! is_array ( $ value ) ) { throw new InvalidArgumentException ( 'An array of mapped headers expected, but received a single value' ) ; } $ prefix = $ param -> getSentAs ( ) ; foreach ( $ value as $ headerName => $ ...
Add a prefixed array of headers to the request
34,597
protected function persist ( ) { if ( false === file_put_contents ( $ this -> filename , $ this -> serialize ( ) ) ) { throw new RuntimeException ( 'Unable to open file ' . $ this -> filename ) ; } }
Save the contents of the data array to the file
34,598
protected function load ( ) { $ json = file_get_contents ( $ this -> filename ) ; if ( false === $ json ) { throw new RuntimeException ( 'Unable to open file ' . $ this -> filename ) ; } $ this -> unserialize ( $ json ) ; $ this -> cookies = $ this -> cookies ? : array ( ) ; }
Load the contents of the json formatted file into the data array and discard any unsaved state
34,599
protected function findComposer ( ) { $ basedir = $ this -> project -> getBasedir ( ) ; $ php = $ this -> project -> getProperty ( 'php.interpreter' ) ; if ( file_exists ( $ basedir . '/composer.phar' ) ) { $ this -> composer = "$php $basedir/composer.phar" ; } else { $ out = array ( ) ; exec ( 'which composer' , $ out...
Find composer installation