idx int64 0 241k | question stringlengths 92 3.54k | target stringlengths 5 803 | len_question int64 27 891 | len_target int64 3 240 |
|---|---|---|---|---|
0 | public function onChannelPreDelete ( ResourceControllerEvent $ event ) : void { $ channel = $ event -> getSubject ( ) ; if ( ! $ channel instanceof ChannelInterface ) { throw new UnexpectedTypeException ( $ channel , ChannelInterface :: class ) ; } $ results = $ this -> channelRepository -> findBy ( [ 'enabled' => true... | Prevent channel deletion if no more channels enabled . | 123 | 10 |
1 | public function getTaxTotal ( ) : int { $ taxTotal = 0 ; foreach ( $ this -> getAdjustments ( AdjustmentInterface :: TAX_ADJUSTMENT ) as $ taxAdjustment ) { $ taxTotal += $ taxAdjustment -> getAmount ( ) ; } foreach ( $ this -> units as $ unit ) { $ taxTotal += $ unit -> getTaxTotal ( ) ; } return $ taxTotal ; } | Returns sum of neutral and non neutral tax adjustments on order item and total tax of units . | 91 | 18 |
2 | private function isLastEnabledEntity ( $ result , $ entity ) : bool { return ! $ result || 0 === count ( $ result ) || ( 1 === count ( $ result ) && $ entity === ( $ result instanceof \ Iterator ? $ result -> current ( ) : current ( $ result ) ) ) ; } | If no entity matched the query criteria or a single entity matched which is the same as the entity being validated the entity is the last enabled entity available . | 66 | 30 |
3 | protected function recalculateTotal ( ) : void { $ this -> total = $ this -> itemsTotal + $ this -> adjustmentsTotal ; if ( $ this -> total < 0 ) { $ this -> total = 0 ; } } | Items total + Adjustments total . | 47 | 7 |
4 | public function loginAction ( Request $ request ) : Response { $ authenticationUtils = $ this -> get ( 'security.authentication_utils' ) ; $ error = $ authenticationUtils -> getLastAuthenticationError ( ) ; $ lastUsername = $ authenticationUtils -> getLastUsername ( ) ; $ options = $ request -> attributes -> get ( '_sy... | Login form action . | 202 | 4 |
5 | public function getTaxTotal ( ) : int { $ taxTotal = 0 ; foreach ( $ this -> getAdjustments ( AdjustmentInterface :: TAX_ADJUSTMENT ) as $ taxAdjustment ) { $ taxTotal += $ taxAdjustment -> getAmount ( ) ; } foreach ( $ this -> items as $ item ) { $ taxTotal += $ item -> getTaxTotal ( ) ; } return $ taxTotal ; } | Returns sum of neutral and non neutral tax adjustments on order and total tax of order items . | 91 | 18 |
6 | public function getShippingTotal ( ) : int { $ shippingTotal = $ this -> getAdjustmentsTotal ( AdjustmentInterface :: SHIPPING_ADJUSTMENT ) ; $ shippingTotal += $ this -> getAdjustmentsTotal ( AdjustmentInterface :: ORDER_SHIPPING_PROMOTION_ADJUSTMENT ) ; $ shippingTotal += $ this -> getAdjustmentsTotal ( AdjustmentInt... | Returns shipping fee together with taxes decreased by shipping discount . | 97 | 11 |
7 | public function getOrderPromotionTotal ( ) : int { $ orderPromotionTotal = 0 ; foreach ( $ this -> items as $ item ) { $ orderPromotionTotal += $ item -> getAdjustmentsTotalRecursively ( AdjustmentInterface :: ORDER_PROMOTION_ADJUSTMENT ) ; } return $ orderPromotionTotal ; } | Returns amount of order discount . Does not include order item and shipping discounts . | 74 | 15 |
8 | protected function recalculateTotal ( ) : void { $ this -> total = $ this -> unitsTotal + $ this -> adjustmentsTotal ; if ( $ this -> total < 0 ) { $ this -> total = 0 ; } if ( null !== $ this -> order ) { $ this -> order -> recalculateItemsTotal ( ) ; } } | Recalculates total after units total or adjustments total change . | 72 | 13 |
9 | private function updateUserByOAuthUserResponse ( UserInterface $ user , UserResponseInterface $ response ) : SyliusUserInterface { /** @var SyliusUserInterface $user */ Assert :: isInstanceOf ( $ user , SyliusUserInterface :: class ) ; /** @var UserOAuthInterface $oauth */ $ oauth = $ this -> oauthFactory -> createNew ... | Attach OAuth sign - in provider account to existing user . | 200 | 12 |
10 | public function serialize ( ) : string { return serialize ( [ $ this -> password , $ this -> salt , $ this -> usernameCanonical , $ this -> username , $ this -> locked , $ this -> enabled , $ this -> id , $ this -> encoderName , ] ) ; } | The serialized data have to contain the fields used by the equals method and the username . | 63 | 18 |
11 | public static function wrap ( callable $ credentialProvider , $ options , $ region , $ service ) { return function ( callable $ handler ) use ( $ credentialProvider , $ options , $ region , $ service ) { return new static ( $ handler , $ credentialProvider , $ options , $ region , $ service ) ; } ; } | Standard middleware wrapper function with CSM options passed in . | 69 | 12 |
12 | public function getOperationDocs ( $ operation ) { return isset ( $ this -> docs [ 'operations' ] [ $ operation ] ) ? $ this -> docs [ 'operations' ] [ $ operation ] : null ; } | Retrieves documentation about an operation . | 49 | 8 |
13 | public function getErrorDocs ( $ error ) { return isset ( $ this -> docs [ 'shapes' ] [ $ error ] [ 'base' ] ) ? $ this -> docs [ 'shapes' ] [ $ error ] [ 'base' ] : null ; } | Retrieves documentation about an error . | 59 | 8 |
14 | public function getShapeDocs ( $ shapeName , $ parentName , $ ref ) { if ( ! isset ( $ this -> docs [ 'shapes' ] [ $ shapeName ] ) ) { return '' ; } $ result = '' ; $ d = $ this -> docs [ 'shapes' ] [ $ shapeName ] ; if ( isset ( $ d [ 'refs' ] [ "{$parentName}\$${ref}" ] ) ) { $ result = $ d [ 'refs' ] [ "{$parentName... | Retrieves documentation about a shape specific to the context . | 189 | 12 |
15 | public function createToken ( $ endpoint , $ region , $ username ) { $ uri = new Uri ( $ endpoint ) ; $ uri = $ uri -> withPath ( '/' ) ; $ uri = $ uri -> withQuery ( 'Action=connect&DBUser=' . $ username ) ; $ request = new Request ( 'GET' , $ uri ) ; $ signer = new SignatureV4 ( 'rds-db' , $ region ) ; $ provider = $... | Create the token for database login | 168 | 6 |
16 | public static function resolve ( callable $ provider , array $ args = [ ] ) { $ result = $ provider ( $ args ) ; if ( is_array ( $ result ) ) { return $ result ; } throw new UnresolvedEndpointException ( 'Unable to resolve an endpoint using the provider arguments: ' . json_encode ( $ args ) . '. Note: you can provide a... | Resolves and endpoint provider and ensures a non - null return value . | 109 | 14 |
17 | public static function wrap ( $ region , array $ options ) { return function ( callable $ handler ) use ( $ region , $ options ) { return new self ( $ handler , $ region , $ options ) ; } ; } | Create a middleware wrapper function | 47 | 6 |
18 | public function save ( MetadataEnvelope $ envelope , array $ args ) { $ this -> client -> putObject ( [ 'Bucket' => $ args [ 'Bucket' ] , 'Key' => $ args [ 'Key' ] . $ this -> suffix , 'Body' => json_encode ( $ envelope ) ] ) ; return $ args ; } | Places the information in the MetadataEnvelope to a location on S3 . | 77 | 18 |
19 | public function load ( array $ args ) { $ result = $ this -> client -> getObject ( [ 'Bucket' => $ args [ 'Bucket' ] , 'Key' => $ args [ 'Key' ] . $ this -> suffix ] ) ; $ metadataHeaders = json_decode ( $ result [ 'Body' ] , true ) ; $ envelope = new MetadataEnvelope ( ) ; $ constantValues = MetadataEnvelope :: getCon... | Uses the strategy s client to retrieve the instruction file from S3 and generates a MetadataEnvelope from its contents . | 154 | 26 |
20 | public static function createSerializer ( Service $ api , $ endpoint ) { static $ mapping = [ 'json' => 'Aws\Api\Serializer\JsonRpcSerializer' , 'query' => 'Aws\Api\Serializer\QuerySerializer' , 'rest-json' => 'Aws\Api\Serializer\RestJsonSerializer' , 'rest-xml' => 'Aws\Api\Serializer\RestXmlSerializer' ] ; $ proto = $... | Creates a request serializer for the provided API object . | 209 | 12 |
21 | public function getOperation ( $ name ) { if ( ! isset ( $ this -> operations [ $ name ] ) ) { if ( ! isset ( $ this -> definition [ 'operations' ] [ $ name ] ) ) { throw new \ InvalidArgumentException ( "Unknown operation: $name" ) ; } $ this -> operations [ $ name ] = new Operation ( $ this -> definition [ 'operation... | Get an operation by name . | 113 | 6 |
22 | public function getOperations ( ) { $ result = [ ] ; foreach ( $ this -> definition [ 'operations' ] as $ name => $ definition ) { $ result [ $ name ] = $ this -> getOperation ( $ name ) ; } return $ result ; } | Get all of the operations of the description . | 58 | 9 |
23 | public function getMetadata ( $ key = null ) { if ( ! $ key ) { return $ this [ 'metadata' ] ; } if ( isset ( $ this -> definition [ 'metadata' ] [ $ key ] ) ) { return $ this -> definition [ 'metadata' ] [ $ key ] ; } return null ; } | Get all of the service metadata or a specific metadata key value . | 70 | 13 |
24 | public function getPaginators ( ) { if ( ! isset ( $ this -> paginators ) ) { $ res = call_user_func ( $ this -> apiProvider , 'paginator' , $ this -> serviceName , $ this -> apiVersion ) ; $ this -> paginators = isset ( $ res [ 'pagination' ] ) ? $ res [ 'pagination' ] : [ ] ; } return $ this -> paginators ; } | Gets an associative array of available paginator configurations where the key is the name of the paginator and the value is the paginator configuration . | 102 | 30 |
25 | public function getPaginatorConfig ( $ name ) { static $ defaults = [ 'input_token' => null , 'output_token' => null , 'limit_key' => null , 'result_key' => null , 'more_results' => null , ] ; if ( $ this -> hasPaginator ( $ name ) ) { return $ this -> paginators [ $ name ] + $ defaults ; } throw new \ UnexpectedValueE... | Retrieve a paginator by name . | 127 | 8 |
26 | public function getWaiters ( ) { if ( ! isset ( $ this -> waiters ) ) { $ res = call_user_func ( $ this -> apiProvider , 'waiter' , $ this -> serviceName , $ this -> apiVersion ) ; $ this -> waiters = isset ( $ res [ 'waiters' ] ) ? $ res [ 'waiters' ] : [ ] ; } return $ this -> waiters ; } | Gets an associative array of available waiter configurations where the key is the name of the waiter and the value is the waiter configuration . | 95 | 27 |
27 | public function addChecksum ( $ checksum , $ inBinaryForm = false ) { // Error if hash is already calculated if ( $ this -> hash ) { throw new \ LogicException ( 'You may not add more checksums to a ' . 'complete tree hash.' ) ; } // Convert the checksum to binary form if necessary $ this -> checksums [ ] = $ inBinaryF... | Add a checksum to the tree hash directly | 103 | 9 |
28 | private function getChecksumsMiddleware ( ) { return function ( callable $ handler ) { return function ( CommandInterface $ command , RequestInterface $ request = null ) use ( $ handler ) { // Accept "ContentSHA256" with a lowercase "c" to match other Glacier params. if ( ! $ command [ 'ContentSHA256' ] && $ command [ ... | Creates a middleware that updates a command with the content and tree hash headers for upload operations . | 521 | 20 |
29 | private function getApiVersionMiddleware ( ) { return function ( callable $ handler ) { return function ( CommandInterface $ command , RequestInterface $ request = null ) use ( $ handler ) { return $ handler ( $ command , $ request -> withHeader ( 'x-amz-glacier-version' , $ this -> getApi ( ) -> getMetadata ( 'apiVers... | Creates a middleware that adds the API version header for all requests . | 93 | 15 |
30 | public function getDefaultCurlOptionsMiddleware ( ) { return Middleware :: mapCommand ( function ( CommandInterface $ cmd ) { $ defaultCurlOptions = [ CURLOPT_TCP_KEEPALIVE => 1 , ] ; if ( ! isset ( $ cmd [ '@http' ] [ 'curl' ] ) ) { $ cmd [ '@http' ] [ 'curl' ] = $ defaultCurlOptions ; } else { $ cmd [ '@http' ] [ 'cu... | Provides a middleware that sets default Curl options for the command | 128 | 14 |
31 | public static function chain ( ) { $ links = func_get_args ( ) ; if ( empty ( $ links ) ) { throw new \ InvalidArgumentException ( 'No providers in chain' ) ; } return function ( ) use ( $ links ) { /** @var callable $parent */ $ parent = array_shift ( $ links ) ; $ promise = $ parent ( ) ; while ( $ next = array_shift... | Creates an aggregate credentials provider that invokes the provided variadic providers one after the other until a provider returns credentials . | 115 | 24 |
32 | public static function env ( ) { return function ( ) { // Use credentials from environment variables, if available $ enabled = getenv ( self :: ENV_ENABLED ) ; if ( $ enabled !== false ) { return Promise \ promise_for ( new Configuration ( $ enabled , getenv ( self :: ENV_PORT ) ? : self :: DEFAULT_PORT , getenv ( self... | Provider that creates CSM config from environment variables . | 162 | 10 |
33 | public static function fallback ( ) { return function ( ) { return Promise \ promise_for ( new Configuration ( self :: DEFAULT_ENABLED , self :: DEFAULT_PORT , self :: DEFAULT_CLIENT_ID ) ) ; } ; } | Fallback config options when other sources are not set . | 54 | 11 |
34 | public static function memoize ( callable $ provider ) { return function ( ) use ( $ provider ) { static $ result ; static $ isConstant ; // Constant config will be returned constantly. if ( $ isConstant ) { return $ result ; } // Create the initial promise that will be used as the cached value // until it expires. if ... | Wraps a CSM config provider and caches previously provided configuration . | 138 | 13 |
35 | public function getSignedCookie ( array $ options ) { foreach ( [ 'key_pair_id' , 'private_key' ] as $ required ) { if ( ! isset ( $ options [ $ required ] ) ) { throw new \ InvalidArgumentException ( "$required is required" ) ; } } $ cookieSigner = new CookieSigner ( $ options [ 'key_pair_id' ] , $ options [ 'private_... | Create a signed Amazon CloudFront cookie . | 183 | 8 |
36 | public function url_stat ( $ path , $ flags ) { $ this -> initProtocol ( $ path ) ; // Some paths come through as S3:// for some reason. $ split = explode ( '://' , $ path ) ; $ path = strtolower ( $ split [ 0 ] ) . '://' . $ split [ 1 ] ; // Check if this path is in the url_stat cache if ( $ value = $ this -> getCache... | Provides information for is_dir is_file filesize etc . Works on buckets keys and prefixes . | 164 | 22 |
37 | private function validate ( $ path , $ mode ) { $ errors = [ ] ; if ( ! $ this -> getOption ( 'Key' ) ) { $ errors [ ] = 'Cannot open a bucket. You must specify a path in the ' . 'form of s3://bucket/key' ; } if ( ! in_array ( $ mode , [ 'r' , 'w' , 'a' , 'x' ] ) ) { $ errors [ ] = "Mode not supported: {$mode}. " . "Us... | Validates the provided stream arguments for fopen and returns an array of errors . | 226 | 16 |
38 | private function getOptions ( $ removeContextData = false ) { // Context is not set when doing things like stat if ( $ this -> context === null ) { $ options = [ ] ; } else { $ options = stream_context_get_options ( $ this -> context ) ; $ options = isset ( $ options [ $ this -> protocol ] ) ? $ options [ $ this -> pro... | Get the stream context options available to the current stream | 195 | 10 |
39 | private function triggerError ( $ errors , $ flags = null ) { // This is triggered with things like file_exists() if ( $ flags & STREAM_URL_STAT_QUIET ) { return $ flags & STREAM_URL_STAT_LINK // This is triggered for things like is_link() ? $ this -> formatUrlStat ( false ) : false ; } // This is triggered when doing ... | Trigger one or more errors | 123 | 5 |
40 | private function formatUrlStat ( $ result = null ) { $ stat = $ this -> getStatTemplate ( ) ; switch ( gettype ( $ result ) ) { case 'NULL' : case 'string' : // Directory with 0777 access - see "man 2 stat". $ stat [ 'mode' ] = $ stat [ 2 ] = 0040777 ; break ; case 'array' : // Regular file with 0777 access - see "man ... | Prepare a url_stat result array | 281 | 8 |
41 | private function createBucket ( $ path , array $ params ) { if ( $ this -> getClient ( ) -> doesBucketExist ( $ params [ 'Bucket' ] ) ) { return $ this -> triggerError ( "Bucket already exists: {$path}" ) ; } return $ this -> boolCall ( function ( ) use ( $ params , $ path ) { $ this -> getClient ( ) -> createBucket ( ... | Creates a bucket for the given parameters . | 114 | 9 |
42 | private function deleteSubfolder ( $ path , $ params ) { // Use a key that adds a trailing slash if needed. $ prefix = rtrim ( $ params [ 'Key' ] , '/' ) . '/' ; $ result = $ this -> getClient ( ) -> listObjects ( [ 'Bucket' => $ params [ 'Bucket' ] , 'Prefix' => $ prefix , 'MaxKeys' => 1 ] ) ; // Check if the bucket c... | Deletes a nested subfolder if it is empty . | 211 | 11 |
43 | private function boolCall ( callable $ fn , $ flags = null ) { try { return $ fn ( ) ; } catch ( \ Exception $ e ) { return $ this -> triggerError ( $ e -> getMessage ( ) , $ flags ) ; } } | Invokes a callable and triggers an error if an exception occurs while calling the function . | 54 | 18 |
44 | private function getSize ( ) { $ size = $ this -> body -> getSize ( ) ; return $ size !== null ? $ size : $ this -> size ; } | Returns the size of the opened object body . | 36 | 9 |
45 | public function getInput ( ) { if ( ! $ this -> input ) { if ( $ input = $ this [ 'input' ] ) { $ this -> input = $ this -> shapeFor ( $ input ) ; } else { $ this -> input = new StructureShape ( [ ] , $ this -> shapeMap ) ; } } return $ this -> input ; } | Get the input shape of the operation . | 76 | 8 |
46 | public function getOutput ( ) { if ( ! $ this -> output ) { if ( $ output = $ this [ 'output' ] ) { $ this -> output = $ this -> shapeFor ( $ output ) ; } else { $ this -> output = new StructureShape ( [ ] , $ this -> shapeMap ) ; } } return $ this -> output ; } | Get the output shape of the operation . | 76 | 8 |
47 | public function getErrors ( ) { if ( $ this -> errors === null ) { if ( $ errors = $ this [ 'errors' ] ) { foreach ( $ errors as $ key => $ error ) { $ errors [ $ key ] = $ this -> shapeFor ( $ error ) ; } $ this -> errors = $ errors ; } else { $ this -> errors = [ ] ; } } return $ this -> errors ; } | Get an array of operation error shapes . | 91 | 8 |
48 | public function start ( CommandInterface $ cmd , RequestInterface $ req ) { $ ticket = uniqid ( ) ; $ this -> entries [ $ ticket ] = [ 'command' => $ cmd , 'request' => $ req , 'result' => null , 'exception' => null , ] ; return $ ticket ; } | Initiate an entry being added to the history . | 68 | 11 |
49 | public function registerSessionHandler ( array $ config = [ ] ) { $ handler = SessionHandler :: fromClient ( $ this , $ config ) ; $ handler -> register ( ) ; return $ handler ; } | Convenience method for instantiating and registering the DynamoDB Session handler with this DynamoDB client object . | 42 | 21 |
50 | public function createCredentials ( Result $ result ) { if ( ! $ result -> hasKey ( 'Credentials' ) ) { throw new \ InvalidArgumentException ( 'Result contains no credentials' ) ; } $ c = $ result [ 'Credentials' ] ; return new Credentials ( $ c [ 'AccessKeyId' ] , $ c [ 'SecretAccessKey' ] , isset ( $ c [ 'SessionToke... | Creates credentials from the result of an STS operations | 160 | 11 |
51 | private function extractHeader ( $ name , Shape $ shape , ResponseInterface $ response , & $ result ) { $ value = $ response -> getHeaderLine ( $ shape [ 'locationName' ] ? : $ name ) ; switch ( $ shape -> getType ( ) ) { case 'float' : case 'double' : $ value = ( float ) $ value ; break ; case 'long' : $ value = ( int... | Extract a single header from the response into the result . | 305 | 12 |
52 | private function extractHeaders ( $ name , Shape $ shape , ResponseInterface $ response , & $ result ) { // Check if the headers are prefixed by a location name $ result [ $ name ] = [ ] ; $ prefix = $ shape [ 'locationName' ] ; $ prefixLen = strlen ( $ prefix ) ; foreach ( $ response -> getHeaders ( ) as $ k => $ valu... | Extract a map of headers with an optional prefix from the response . | 164 | 14 |
53 | private function extractStatus ( $ name , ResponseInterface $ response , array & $ result ) { $ result [ $ name ] = ( int ) $ response -> getStatusCode ( ) ; } | Places the status code of the response into the result array . | 39 | 13 |
54 | private function getHeaderBlacklist ( ) { return [ 'cache-control' => true , 'content-type' => true , 'content-length' => true , 'expect' => true , 'max-forwards' => true , 'pragma' => true , 'range' => true , 'te' => true , 'if-match' => true , 'if-none-match' => true , 'if-modified-since' => true , 'if-unmodified-sin... | The following headers are not signed because signing these headers would potentially cause a signature mismatch when sending a request through a proxy or if modified at the HTTP client level . | 203 | 32 |
55 | private function getPresignHeaders ( array $ headers ) { $ presignHeaders = [ ] ; $ blacklist = $ this -> getHeaderBlacklist ( ) ; foreach ( $ headers as $ name => $ value ) { $ lName = strtolower ( $ name ) ; if ( ! isset ( $ blacklist [ $ lName ] ) && $ name !== self :: AMZ_CONTENT_SHA256_HEADER ) { $ presignHeaders ... | Get the headers that were used to pre - sign the request . Used for the X - Amz - SignedHeaders header . | 117 | 26 |
56 | public static function convertPostToGet ( RequestInterface $ request ) { if ( $ request -> getMethod ( ) !== 'POST' ) { throw new \ InvalidArgumentException ( 'Expected a POST request but ' . 'received a ' . $ request -> getMethod ( ) . ' request.' ) ; } $ sr = $ request -> withMethod ( 'GET' ) -> withBody ( Psr7 \ str... | Converts a POST request to a GET request by moving POST fields into the query string . | 204 | 18 |
57 | public static function env ( $ cacheLimit = self :: DEFAULT_CACHE_LIMIT ) { return function ( ) use ( $ cacheLimit ) { // Use config from environment variables, if available $ enabled = getenv ( self :: ENV_ENABLED ) ; if ( $ enabled === false || $ enabled === '' ) { $ enabled = getenv ( self :: ENV_ENABLED_ALT ) ; } i... | Provider that creates config from environment variables . | 157 | 8 |
58 | public static function ini ( $ profile = null , $ filename = null , $ cacheLimit = self :: DEFAULT_CACHE_LIMIT ) { $ filename = $ filename ? : ( self :: getHomeDir ( ) . '/.aws/config' ) ; $ profile = $ profile ? : ( getenv ( self :: ENV_PROFILE ) ? : 'default' ) ; return function ( ) use ( $ profile , $ filename , $ c... | Config provider that creates config using an ini file stored in the current user s home directory . | 300 | 19 |
59 | public function appendException ( ) { foreach ( func_get_args ( ) as $ value ) { if ( $ value instanceof \ Exception || $ value instanceof \ Throwable ) { $ this -> queue [ ] = $ value ; } else { throw new \ InvalidArgumentException ( 'Expected an \Exception or \Throwable.' ) ; } } } | Adds one or more \ Exception or \ Throwable to the queue | 77 | 13 |
60 | public function read ( $ s3BucketName , $ logFileKey ) { // Create a command for getting the log file object $ command = $ this -> s3Client -> getCommand ( 'GetObject' , [ 'Bucket' => ( string ) $ s3BucketName , 'Key' => ( string ) $ logFileKey , 'ResponseContentEncoding' => 'x-gzip' ] ) ; // Make sure gzip encoding he... | Downloads unzips and reads a CloudTrail log file from Amazon S3 | 213 | 17 |
61 | private function parseError ( array $ err , RequestInterface $ request , CommandInterface $ command , array $ stats ) { if ( ! isset ( $ err [ 'exception' ] ) ) { throw new \ RuntimeException ( 'The HTTP handler was rejected without an "exception" key value pair.' ) ; } $ serviceError = "AWS HTTP error: " . $ err [ 'ex... | Parses a rejection into an AWS error . | 384 | 10 |
62 | private function buildListObjectsIterator ( array $ options ) { // Extract and normalize the date values from the options $ startDate = isset ( $ options [ self :: START_DATE ] ) ? $ this -> normalizeDateValue ( $ options [ self :: START_DATE ] ) : null ; $ endDate = isset ( $ options [ self :: END_DATE ] ) ? $ this ->... | Constructs an S3 ListObjects iterator optionally decorated with FilterIterators based on the provided options . | 522 | 21 |
63 | private function normalizeDateValue ( $ date ) { if ( is_string ( $ date ) ) { $ date = strtotime ( $ date ) ; } elseif ( $ date instanceof \ DateTime ) { $ date = $ date -> format ( 'U' ) ; } elseif ( ! is_int ( $ date ) ) { throw new \ InvalidArgumentException ( 'Date values must be a ' . 'string, an int, or a DateTi... | Normalizes a date value to a unix timestamp | 110 | 10 |
64 | private function determineDateForPrefix ( $ startDate , $ endDate ) { // The default date value should look like "*/*/*" after joining $ dateParts = array_fill_keys ( [ 'Y' , 'm' , 'd' ] , self :: PREFIX_WILDCARD ) ; // Narrow down the date by replacing the WILDCARDs with values if they // are the same for the start an... | Uses the provided date values to determine the date portion of the prefix | 180 | 14 |
65 | private function applyRegexFilter ( $ objectsIterator , $ logKeyPrefix , $ candidatePrefix ) { // If the prefix and candidate prefix are not the same, then there were // WILDCARDs. if ( $ logKeyPrefix !== $ candidatePrefix ) { // Turn the candidate prefix into a regex by trimming and // converting WILDCARDs to regex no... | Applies a regex iterator filter that limits the ListObjects result set based on the provided options . | 262 | 20 |
66 | private function applyDateFilter ( $ objectsIterator , $ startDate , $ endDate ) { // If either a start or end date was provided, filter out dates that // don't match the date range. if ( $ startDate || $ endDate ) { $ fn = function ( $ object ) use ( $ startDate , $ endDate ) { if ( ! preg_match ( '/[0-9]{8}T[0-9]{4}Z... | Applies an iterator filter to restrict the ListObjects result set to the specified date range . | 191 | 19 |
67 | public function getVersions ( $ service ) { if ( ! isset ( $ this -> manifest ) ) { $ this -> buildVersionsList ( $ service ) ; } if ( ! isset ( $ this -> manifest [ $ service ] [ 'versions' ] ) ) { return [ ] ; } return array_values ( array_unique ( $ this -> manifest [ $ service ] [ 'versions' ] ) ) ; } | Retrieves a list of valid versions for the specified service . | 87 | 13 |
68 | private function buildVersionsList ( $ service ) { $ dir = "{$this->modelsDir}/{$service}/" ; if ( ! is_dir ( $ dir ) ) { return ; } // Get versions, remove . and .., and sort in descending order. $ results = array_diff ( scandir ( $ dir , SCANDIR_SORT_DESCENDING ) , [ '..' , '.' ] ) ; if ( ! $ results ) { $ this -> ma... | Build the versions list for the specified service by globbing the dir . | 177 | 14 |
69 | private static function calculateMessageAttributesMd5 ( $ message ) { if ( empty ( $ message [ 'MessageAttributes' ] ) || ! is_array ( $ message [ 'MessageAttributes' ] ) ) { return null ; } ksort ( $ message [ 'MessageAttributes' ] ) ; $ attributeValues = "" ; foreach ( $ message [ 'MessageAttributes' ] as $ name => $... | Calculates the expected md5 hash of message attributes according to the encoding scheme detailed in SQS documentation . | 249 | 22 |
70 | private function validateMd5 ( ) { return static function ( callable $ handler ) { return function ( CommandInterface $ c , RequestInterface $ r = null ) use ( $ handler ) { if ( $ c -> getName ( ) !== 'ReceiveMessage' ) { return $ handler ( $ c , $ r ) ; } return $ handler ( $ c , $ r ) -> then ( function ( $ result )... | Validates ReceiveMessage body and message attribute MD5s . | 483 | 13 |
71 | protected function decrypt ( $ cipherText , MaterialsProvider $ provider , MetadataEnvelope $ envelope , array $ cipherOptions = [ ] ) { $ cipherOptions [ 'Iv' ] = base64_decode ( $ envelope [ MetadataEnvelope :: IV_HEADER ] ) ; $ cipherOptions [ 'TagLength' ] = $ envelope [ MetadataEnvelope :: CRYPTO_TAG_LENGTH_HEADER... | Builds an AesStreamInterface using cipher options loaded from the MetadataEnvelope and MaterialsProvider . | 273 | 22 |
72 | public function marshalJson ( $ json ) { $ data = json_decode ( $ json ) ; if ( ! ( $ data instanceof \ stdClass ) ) { throw new \ InvalidArgumentException ( 'The JSON document must be valid and be an object at its root.' ) ; } return current ( $ this -> marshalValue ( $ data ) ) ; } | Marshal a JSON document from a string to a DynamoDB item . | 79 | 14 |
73 | public function marshalValue ( $ value ) { $ type = gettype ( $ value ) ; // Handle string values. if ( $ type === 'string' ) { if ( $ value === '' ) { return $ this -> handleInvalid ( 'empty strings are invalid' ) ; } return [ 'S' => $ value ] ; } // Handle number values. if ( $ type === 'integer' || $ type === 'doubl... | Marshal a native PHP value into a DynamoDB attribute value . | 587 | 13 |
74 | public static function fromListObjects ( AwsClientInterface $ client , array $ listObjectsParams , array $ options = [ ] ) { $ iter = $ client -> getPaginator ( 'ListObjects' , $ listObjectsParams ) ; $ bucket = $ listObjectsParams [ 'Bucket' ] ; $ fn = function ( BatchDelete $ that ) use ( $ iter ) { return $ iter -> ... | Creates a BatchDelete object from all of the paginated results of a ListObjects operation . Each result that is returned by the ListObjects operation will be deleted . | 207 | 36 |
75 | private function createPromise ( ) { // Create the promise $ promise = call_user_func ( $ this -> promiseCreator , $ this ) ; $ this -> promiseCreator = null ; // Cleans up the promise state and references. $ cleanup = function ( ) { $ this -> before = $ this -> client = $ this -> queue = null ; } ; // When done, ensur... | Returns a promise that will clean up any references when it completes . | 160 | 13 |
76 | public function getSignedCookie ( $ url = null , $ expires = null , $ policy = null ) { if ( $ url ) { $ this -> validateUrl ( $ url ) ; } $ cookieParameters = [ ] ; $ signature = $ this -> signer -> getSignature ( $ url , $ expires , $ policy ) ; foreach ( $ signature as $ key => $ value ) { $ cookieParameters [ "Clou... | Create a signed Amazon CloudFront Cookie . | 106 | 8 |
77 | private function getExpired ( ) { if ( count ( $ this -> expired ) < 1 ) { return null ; } $ expired = key ( $ this -> expired ) ; $ this -> increment ( $ this -> expired ) ; return $ expired ; } | Get an expired endpoint . Returns null if none found . | 52 | 11 |
78 | public function put ( array $ item , $ table = null ) { $ this -> queue [ ] = [ 'table' => $ this -> determineTable ( $ table ) , 'data' => [ 'PutRequest' => [ 'Item' => $ item ] ] , ] ; $ this -> autoFlush ( ) ; return $ this ; } | Adds a put item request to the batch . | 72 | 9 |
79 | public function delete ( array $ key , $ table = null ) { $ this -> queue [ ] = [ 'table' => $ this -> determineTable ( $ table ) , 'data' => [ 'DeleteRequest' => [ 'Key' => $ key ] ] , ] ; $ this -> autoFlush ( ) ; return $ this ; } | Adds a delete item request to the batch . | 72 | 9 |
80 | public function flush ( $ untilEmpty = true ) { // Send BatchWriteItem requests until the queue is empty $ keepFlushing = true ; while ( $ this -> queue && $ keepFlushing ) { $ commands = $ this -> prepareCommands ( ) ; $ pool = new CommandPool ( $ this -> client , $ commands , [ 'before' => $ this -> config [ 'before'... | Flushes the batch by combining all the queued put and delete requests into BatchWriteItem commands and executing them . Unprocessed items are automatically re - queued . | 313 | 35 |
81 | private function autoFlush ( ) { if ( $ this -> config [ 'autoflush' ] && count ( $ this -> queue ) >= $ this -> config [ 'threshold' ] ) { // Flush only once. Unprocessed items are handled in a later flush. $ this -> flush ( false ) ; } } | If autoflush is enabled and the threshold is met flush the batch | 70 | 15 |
82 | public function save ( MetadataEnvelope $ envelope , array $ args ) { foreach ( $ envelope as $ header => $ value ) { $ args [ 'Metadata' ] [ $ header ] = $ value ; } return $ args ; } | Places the information in the MetadataEnvelope in to the Meatadata for the PutObject request of the encrypted object . | 52 | 26 |
83 | public function load ( array $ args ) { $ envelope = new MetadataEnvelope ( ) ; $ constantValues = MetadataEnvelope :: getConstantValues ( ) ; foreach ( $ constantValues as $ constant ) { if ( ! empty ( $ args [ 'Metadata' ] [ $ constant ] ) ) { $ envelope [ $ constant ] = $ args [ 'Metadata' ] [ $ constant ] ; } } ret... | Generates a MetadataEnvelope according to the Metadata headers from the GetObject result . | 96 | 20 |
84 | public function build ( Shape $ shape , array $ args ) { $ xml = new XMLWriter ( ) ; $ xml -> openMemory ( ) ; $ xml -> startDocument ( '1.0' , 'UTF-8' ) ; $ this -> format ( $ shape , $ shape [ 'locationName' ] ? : $ shape [ 'name' ] , $ args , $ xml ) ; $ xml -> endDocument ( ) ; return $ xml -> outputMemory ( ) ; } | Builds the XML body based on an array of arguments . | 100 | 12 |
85 | public static function fromClient ( DynamoDbClient $ client , array $ config = [ ] ) { $ config += [ 'locking' => false ] ; if ( $ config [ 'locking' ] ) { $ connection = new LockingSessionConnection ( $ client , $ config ) ; } else { $ connection = new StandardSessionConnection ( $ client , $ config ) ; } return new s... | Creates a new DynamoDB Session Handler . | 86 | 9 |
86 | public function close ( ) { $ id = session_id ( ) ; // Make sure the session is unlocked and the expiration time is updated, // even if the write did not occur if ( $ this -> openSessionId !== $ id || ! $ this -> sessionWritten ) { $ result = $ this -> connection -> write ( $ this -> formatId ( $ id ) , '' , false ) ; ... | Close a session from writing . | 104 | 6 |
87 | public function read ( $ id ) { $ this -> openSessionId = $ id ; // PHP expects an empty string to be returned from this method if no // data is retrieved $ this -> dataRead = '' ; // Get session data using the selected locking strategy $ item = $ this -> connection -> read ( $ this -> formatId ( $ id ) ) ; // Return t... | Read a session stored in DynamoDB . | 176 | 8 |
88 | public function write ( $ id , $ data ) { $ changed = $ id !== $ this -> openSessionId || $ data !== $ this -> dataRead ; $ this -> openSessionId = $ id ; // Write the session data using the selected locking strategy $ this -> sessionWritten = $ this -> connection -> write ( $ this -> formatId ( $ id ) , $ data , $ cha... | Write a session to DynamoDB . | 93 | 7 |
89 | public function destroy ( $ id ) { $ this -> openSessionId = $ id ; // Delete the session data using the selected locking strategy $ this -> sessionWritten = $ this -> connection -> delete ( $ this -> formatId ( $ id ) ) ; return $ this -> sessionWritten ; } | Delete a session stored in DynamoDB . | 60 | 8 |
90 | private function isEof ( $ seekable ) { return $ seekable ? $ this -> source -> tell ( ) < $ this -> source -> getSize ( ) : ! $ this -> source -> eof ( ) ; } | Checks if the source is at EOF . | 47 | 10 |
91 | private function determineSource ( $ source ) { // Use the contents of a file as the data source. if ( is_string ( $ source ) ) { $ source = Psr7 \ try_fopen ( $ source , 'r' ) ; } // Create a source stream. $ stream = Psr7 \ stream_for ( $ source ) ; if ( ! $ stream -> isReadable ( ) ) { throw new IAE ( 'Source stream... | Turns the provided source into a stream and stores it . | 107 | 12 |
92 | public function createSynthesizeSpeechPreSignedUrl ( array $ args ) { $ uri = new Uri ( $ this -> getEndpoint ( ) ) ; $ uri = $ uri -> withPath ( '/v1/speech' ) ; // Formatting parameters follows rest-json protocol $ this -> formatter = $ this -> formatter ? : new JsonBody ( $ this -> getApi ( ) ) ; $ queryArray = json... | Create a pre - signed URL for Polly operation SynthesizeSpeech | 291 | 14 |
93 | public function update ( ) { // copy the code into memory $ backup = file ( $ this -> reflection -> getFileName ( ) ) ; list ( $ preamble , $ class ) = $ this -> splitClassFile ( $ backup ) ; $ preamble = $ this -> stripOutExistingDocBlock ( $ preamble ) ; $ preamble .= $ this -> buildUpdatedDocBlock ( ) ; if ( $ this ... | Performs update on class file and lints the output . If the output fails linting the change is reverted . | 163 | 24 |
94 | public static function format ( $ value , $ format ) { if ( $ value instanceof \ DateTime ) { $ value = $ value -> getTimestamp ( ) ; } elseif ( is_string ( $ value ) ) { $ value = strtotime ( $ value ) ; } elseif ( ! is_int ( $ value ) ) { throw new \ InvalidArgumentException ( 'Unable to handle the provided' . ' time... | Formats a timestamp value for a service . | 215 | 9 |
95 | public static function resolve ( callable $ provider , $ version , $ service , $ region ) { $ result = $ provider ( $ version , $ service , $ region ) ; if ( $ result instanceof SignatureInterface ) { return $ result ; } throw new UnresolvedSignatureException ( "Unable to resolve a signature for $version/$service/$regi... | Resolves and signature provider and ensures a non - null return value . | 92 | 14 |
96 | public static function memoize ( callable $ provider ) { $ cache = [ ] ; return function ( $ version , $ service , $ region ) use ( & $ cache , $ provider ) { $ key = "($version)($service)($region)" ; if ( ! isset ( $ cache [ $ key ] ) ) { $ cache [ $ key ] = $ provider ( $ version , $ service , $ region ) ; } return $... | Creates a signature provider that caches previously created signature objects . The computed cache key is the concatenation of the version service and region . | 101 | 28 |
97 | public static function generateSmtpPassword ( CredentialsInterface $ creds ) { static $ version = "\x02" ; static $ algo = 'sha256' ; static $ message = 'SendRawEmail' ; $ signature = hash_hmac ( $ algo , $ message , $ creds -> getSecretKey ( ) , true ) ; return base64_encode ( $ version . $ signature ) ; } | Create an SMTP password for a given IAM user s credentials . | 89 | 14 |
98 | public static function batch ( AwsClientInterface $ client , $ commands , array $ config = [ ] ) { $ results = [ ] ; self :: cmpCallback ( $ config , 'fulfilled' , $ results ) ; self :: cmpCallback ( $ config , 'rejected' , $ results ) ; return ( new self ( $ client , $ commands , $ config ) ) -> promise ( ) -> then ( ... | Executes a pool synchronously and aggregates the results of the pool into an indexed array in the same order as the passed in array . | 117 | 28 |
99 | private static function cmpCallback ( array & $ config , $ name , array & $ results ) { if ( ! isset ( $ config [ $ name ] ) ) { $ config [ $ name ] = function ( $ v , $ k ) use ( & $ results ) { $ results [ $ k ] = $ v ; } ; } else { $ currentFn = $ config [ $ name ] ; $ config [ $ name ] = function ( $ v , $ k ) use ... | Adds an onFulfilled or onRejected callback that aggregates results into an array . If a callback is already present it is replaced with the composed function . | 138 | 33 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.