repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
paquettg/php-html-parser
src/PHPHtmlParser/Dom/AbstractNode.php
AbstractNode.removeAttribute
public function removeAttribute(string $key): void { $this->tag->removeAttribute($key); //clear any cache $this->clear(); }
php
public function removeAttribute(string $key): void { $this->tag->removeAttribute($key); //clear any cache $this->clear(); }
[ "public", "function", "removeAttribute", "(", "string", "$", "key", ")", ":", "void", "{", "$", "this", "->", "tag", "->", "removeAttribute", "(", "$", "key", ")", ";", "//clear any cache", "$", "this", "->", "clear", "(", ")", ";", "}" ]
A wrapper method that simply calls the removeAttribute method on the tag of this node. @param string $key @return void
[ "A", "wrapper", "method", "that", "simply", "calls", "the", "removeAttribute", "method", "on", "the", "tag", "of", "this", "node", "." ]
77e4a44b0916690b4300fe9abf98fd05bbba48f0
https://github.com/paquettg/php-html-parser/blob/77e4a44b0916690b4300fe9abf98fd05bbba48f0/src/PHPHtmlParser/Dom/AbstractNode.php#L383-L389
train
braintree/braintree_php
lib/Braintree/UsBankAccountVerificationGateway.php
UsBankAccountVerificationGateway.confirmMicroTransferAmounts
public function confirmMicroTransferAmounts($token, $amounts) { try { $path = $this->_config->merchantPath() . '/us_bank_account_verifications/' . $token . '/confirm_micro_transfer_amounts'; $response = $this->_http->put($path, [ "us_bank_account_verification" => ["deposit_amounts" => $amounts] ]); return $this->_verifyGatewayResponse($response); } catch (Exception\Unexpected $e) { throw new Exception\Unexpected( 'Unexpected exception.' ); } }
php
public function confirmMicroTransferAmounts($token, $amounts) { try { $path = $this->_config->merchantPath() . '/us_bank_account_verifications/' . $token . '/confirm_micro_transfer_amounts'; $response = $this->_http->put($path, [ "us_bank_account_verification" => ["deposit_amounts" => $amounts] ]); return $this->_verifyGatewayResponse($response); } catch (Exception\Unexpected $e) { throw new Exception\Unexpected( 'Unexpected exception.' ); } }
[ "public", "function", "confirmMicroTransferAmounts", "(", "$", "token", ",", "$", "amounts", ")", "{", "try", "{", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/us_bank_account_verifications/'", ".", "$", "token", ".", "'/confirm_micro_transfer_amounts'", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "put", "(", "$", "path", ",", "[", "\"us_bank_account_verification\"", "=>", "[", "\"deposit_amounts\"", "=>", "$", "amounts", "]", "]", ")", ";", "return", "$", "this", "->", "_verifyGatewayResponse", "(", "$", "response", ")", ";", "}", "catch", "(", "Exception", "\\", "Unexpected", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "Unexpected", "(", "'Unexpected exception.'", ")", ";", "}", "}" ]
complete micro transfer verification by confirming the transfer amounts @access public @param string $token unique id @param array $amounts amounts deposited in micro transfer @return UsBankAccountVerification @throws Exception\Unexpected
[ "complete", "micro", "transfer", "verification", "by", "confirming", "the", "transfer", "amounts" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/UsBankAccountVerificationGateway.php#L84-L97
train
braintree/braintree_php
lib/Braintree/PaymentMethodGateway.php
PaymentMethodGateway.find
public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token; $response = $this->_http->get($path); return PaymentMethodParser::parsePaymentMethod($response); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'payment method with token ' . $token . ' not found' ); } }
php
public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token; $response = $this->_http->get($path); return PaymentMethodParser::parsePaymentMethod($response); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'payment method with token ' . $token . ' not found' ); } }
[ "public", "function", "find", "(", "$", "token", ")", "{", "$", "this", "->", "_validateId", "(", "$", "token", ")", ";", "try", "{", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/payment_methods/any/'", ".", "$", "token", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "get", "(", "$", "path", ")", ";", "return", "PaymentMethodParser", "::", "parsePaymentMethod", "(", "$", "response", ")", ";", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'payment method with token '", ".", "$", "token", ".", "' not found'", ")", ";", "}", "}" ]
find a PaymentMethod by token @param string $token payment method unique id @return CreditCard|PayPalAccount @throws Exception\NotFound
[ "find", "a", "PaymentMethod", "by", "token" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/PaymentMethodGateway.php#L50-L62
train
braintree/braintree_php
lib/Braintree/PaymentMethodGateway.php
PaymentMethodGateway._doDelete
public function _doDelete($subPath) { $fullPath = $this->_config->merchantPath() . $subPath; $this->_http->delete($fullPath); return new Result\Successful(); }
php
public function _doDelete($subPath) { $fullPath = $this->_config->merchantPath() . $subPath; $this->_http->delete($fullPath); return new Result\Successful(); }
[ "public", "function", "_doDelete", "(", "$", "subPath", ")", "{", "$", "fullPath", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "$", "subPath", ";", "$", "this", "->", "_http", "->", "delete", "(", "$", "fullPath", ")", ";", "return", "new", "Result", "\\", "Successful", "(", ")", ";", "}" ]
sends the delete request to the gateway @ignore @param string $subPath @return mixed
[ "sends", "the", "delete", "request", "to", "the", "gateway" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/PaymentMethodGateway.php#L237-L242
train
braintree/braintree_php
lib/Braintree/DocumentUploadGateway.php
DocumentUploadGateway.create
public function create($params) { Util::verifyKeys(self::createSignature(), $params); $file = $params['file']; if (!is_resource($file)) { throw new InvalidArgumentException('file must be a stream resource'); } $payload = [ 'document_upload[kind]' => $params['kind'] ]; $path = $this->_config->merchantPath() . '/document_uploads/'; $response = $this->_http->postMultipart($path, $payload, $file); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } if (isset($response['documentUpload'])) { $documentUpload = DocumentUpload::factory($response['documentUpload']); return new Result\Successful($documentUpload); } }
php
public function create($params) { Util::verifyKeys(self::createSignature(), $params); $file = $params['file']; if (!is_resource($file)) { throw new InvalidArgumentException('file must be a stream resource'); } $payload = [ 'document_upload[kind]' => $params['kind'] ]; $path = $this->_config->merchantPath() . '/document_uploads/'; $response = $this->_http->postMultipart($path, $payload, $file); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } if (isset($response['documentUpload'])) { $documentUpload = DocumentUpload::factory($response['documentUpload']); return new Result\Successful($documentUpload); } }
[ "public", "function", "create", "(", "$", "params", ")", "{", "Util", "::", "verifyKeys", "(", "self", "::", "createSignature", "(", ")", ",", "$", "params", ")", ";", "$", "file", "=", "$", "params", "[", "'file'", "]", ";", "if", "(", "!", "is_resource", "(", "$", "file", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'file must be a stream resource'", ")", ";", "}", "$", "payload", "=", "[", "'document_upload[kind]'", "=>", "$", "params", "[", "'kind'", "]", "]", ";", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/document_uploads/'", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "postMultipart", "(", "$", "path", ",", "$", "payload", ",", "$", "file", ")", ";", "if", "(", "isset", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ")", "{", "return", "new", "Result", "\\", "Error", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "response", "[", "'documentUpload'", "]", ")", ")", "{", "$", "documentUpload", "=", "DocumentUpload", "::", "factory", "(", "$", "response", "[", "'documentUpload'", "]", ")", ";", "return", "new", "Result", "\\", "Successful", "(", "$", "documentUpload", ")", ";", "}", "}" ]
Accepts a dispute, given a dispute ID @param string $id
[ "Accepts", "a", "dispute", "given", "a", "dispute", "ID" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/DocumentUploadGateway.php#L48-L72
train
braintree/braintree_php
lib/Braintree/AddressGateway.php
AddressGateway.delete
public function delete($customerOrId = null, $addressId = null) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId); $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $this->_http->delete($path); return new Result\Successful(); }
php
public function delete($customerOrId = null, $addressId = null) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId); $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $this->_http->delete($path); return new Result\Successful(); }
[ "public", "function", "delete", "(", "$", "customerOrId", "=", "null", ",", "$", "addressId", "=", "null", ")", "{", "$", "this", "->", "_validateId", "(", "$", "addressId", ")", ";", "$", "customerId", "=", "$", "this", "->", "_determineCustomerId", "(", "$", "customerOrId", ")", ";", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/customers/'", ".", "$", "customerId", ".", "'/addresses/'", ".", "$", "addressId", ";", "$", "this", "->", "_http", "->", "delete", "(", "$", "path", ")", ";", "return", "new", "Result", "\\", "Successful", "(", ")", ";", "}" ]
delete an address by id @param mixed $customerOrId @param string $addressId
[ "delete", "an", "address", "by", "id" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/AddressGateway.php#L100-L107
train
braintree/braintree_php
lib/Braintree/AddressGateway.php
AddressGateway.find
public function find($customerOrId, $addressId) { $customerId = $this->_determineCustomerId($customerOrId); $this->_validateId($addressId); try { $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $response = $this->_http->get($path); return Address::factory($response['address']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'address for customer ' . $customerId . ' with id ' . $addressId . ' not found.' ); } }
php
public function find($customerOrId, $addressId) { $customerId = $this->_determineCustomerId($customerOrId); $this->_validateId($addressId); try { $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $response = $this->_http->get($path); return Address::factory($response['address']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'address for customer ' . $customerId . ' with id ' . $addressId . ' not found.' ); } }
[ "public", "function", "find", "(", "$", "customerOrId", ",", "$", "addressId", ")", "{", "$", "customerId", "=", "$", "this", "->", "_determineCustomerId", "(", "$", "customerOrId", ")", ";", "$", "this", "->", "_validateId", "(", "$", "addressId", ")", ";", "try", "{", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/customers/'", ".", "$", "customerId", ".", "'/addresses/'", ".", "$", "addressId", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "get", "(", "$", "path", ")", ";", "return", "Address", "::", "factory", "(", "$", "response", "[", "'address'", "]", ")", ";", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'address for customer '", ".", "$", "customerId", ".", "' with id '", ".", "$", "addressId", ".", "' not found.'", ")", ";", "}", "}" ]
find an address by id Finds the address with the given <b>addressId</b> that is associated to the given <b>customerOrId</b>. If the address cannot be found, a NotFound exception will be thrown. @access public @param mixed $customerOrId @param string $addressId @return Address @throws Exception\NotFound
[ "find", "an", "address", "by", "id" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/AddressGateway.php#L123-L140
train
braintree/braintree_php
lib/Braintree/AddressGateway.php
AddressGateway.update
public function update($customerOrId, $addressId, $attributes) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId); Util::verifyKeys(self::updateSignature(), $attributes); $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $response = $this->_http->put($path, ['address' => $attributes]); return $this->_verifyGatewayResponse($response); }
php
public function update($customerOrId, $addressId, $attributes) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId); Util::verifyKeys(self::updateSignature(), $attributes); $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $response = $this->_http->put($path, ['address' => $attributes]); return $this->_verifyGatewayResponse($response); }
[ "public", "function", "update", "(", "$", "customerOrId", ",", "$", "addressId", ",", "$", "attributes", ")", "{", "$", "this", "->", "_validateId", "(", "$", "addressId", ")", ";", "$", "customerId", "=", "$", "this", "->", "_determineCustomerId", "(", "$", "customerOrId", ")", ";", "Util", "::", "verifyKeys", "(", "self", "::", "updateSignature", "(", ")", ",", "$", "attributes", ")", ";", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/customers/'", ".", "$", "customerId", ".", "'/addresses/'", ".", "$", "addressId", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "put", "(", "$", "path", ",", "[", "'address'", "=>", "$", "attributes", "]", ")", ";", "return", "$", "this", "->", "_verifyGatewayResponse", "(", "$", "response", ")", ";", "}" ]
updates the address record if calling this method in context, customerOrId is the 2nd attribute, addressId 3rd. customerOrId & addressId are not sent in object context. @access public @param array $attributes @param mixed $customerOrId (only used in call) @param string $addressId (only used in call) @return Result\Successful|Result\Error
[ "updates", "the", "address", "record" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/AddressGateway.php#L156-L167
train
braintree/braintree_php
lib/Braintree/AddressGateway.php
AddressGateway.updateNoValidate
public function updateNoValidate($customerOrId, $addressId, $attributes) { $result = $this->update($customerOrId, $addressId, $attributes); return Util::returnObjectOrThrowException(__CLASS__, $result); }
php
public function updateNoValidate($customerOrId, $addressId, $attributes) { $result = $this->update($customerOrId, $addressId, $attributes); return Util::returnObjectOrThrowException(__CLASS__, $result); }
[ "public", "function", "updateNoValidate", "(", "$", "customerOrId", ",", "$", "addressId", ",", "$", "attributes", ")", "{", "$", "result", "=", "$", "this", "->", "update", "(", "$", "customerOrId", ",", "$", "addressId", ",", "$", "attributes", ")", ";", "return", "Util", "::", "returnObjectOrThrowException", "(", "__CLASS__", ",", "$", "result", ")", ";", "}" ]
update an address record, assuming validations will pass if calling this method in context, customerOrId is the 2nd attribute, addressId 3rd. customerOrId & addressId are not sent in object context. @access public @param array $transactionAttribs @param string $customerId @return Transaction @throws Exception\ValidationsFailed @see Address::update()
[ "update", "an", "address", "record", "assuming", "validations", "will", "pass" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/AddressGateway.php#L183-L187
train
braintree/braintree_php
lib/Braintree/AddressGateway.php
AddressGateway._validateCustomerId
private function _validateCustomerId($id = null) { if (empty($id) || trim($id) == "") { throw new InvalidArgumentException( 'expected customer id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) { throw new InvalidArgumentException( $id . ' is an invalid customer id.' ); } }
php
private function _validateCustomerId($id = null) { if (empty($id) || trim($id) == "") { throw new InvalidArgumentException( 'expected customer id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) { throw new InvalidArgumentException( $id . ' is an invalid customer id.' ); } }
[ "private", "function", "_validateCustomerId", "(", "$", "id", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "id", ")", "||", "trim", "(", "$", "id", ")", "==", "\"\"", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'expected customer id to be set'", ")", ";", "}", "if", "(", "!", "preg_match", "(", "'/^[0-9A-Za-z_-]+$/'", ",", "$", "id", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "$", "id", ".", "' is an invalid customer id.'", ")", ";", "}", "}" ]
verifies that a valid customer id is being used @ignore @param string $id customer id @throws InvalidArgumentException
[ "verifies", "that", "a", "valid", "customer", "id", "is", "being", "used" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/AddressGateway.php#L239-L252
train
braintree/braintree_php
lib/Braintree/AddressGateway.php
AddressGateway._determineCustomerId
private function _determineCustomerId($customerOrId) { $customerId = ($customerOrId instanceof Customer) ? $customerOrId->id : $customerOrId; $this->_validateCustomerId($customerId); return $customerId; }
php
private function _determineCustomerId($customerOrId) { $customerId = ($customerOrId instanceof Customer) ? $customerOrId->id : $customerOrId; $this->_validateCustomerId($customerId); return $customerId; }
[ "private", "function", "_determineCustomerId", "(", "$", "customerOrId", ")", "{", "$", "customerId", "=", "(", "$", "customerOrId", "instanceof", "Customer", ")", "?", "$", "customerOrId", "->", "id", ":", "$", "customerOrId", ";", "$", "this", "->", "_validateCustomerId", "(", "$", "customerId", ")", ";", "return", "$", "customerId", ";", "}" ]
determines if a string id or Customer object was passed @ignore @param mixed $customerOrId @return string customerId
[ "determines", "if", "a", "string", "id", "or", "Customer", "object", "was", "passed" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/AddressGateway.php#L260-L266
train
braintree/braintree_php
lib/Braintree/AddressGateway.php
AddressGateway._doCreate
private function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); }
php
private function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); }
[ "private", "function", "_doCreate", "(", "$", "subPath", ",", "$", "params", ")", "{", "$", "fullPath", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "$", "subPath", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "post", "(", "$", "fullPath", ",", "$", "params", ")", ";", "return", "$", "this", "->", "_verifyGatewayResponse", "(", "$", "response", ")", ";", "}" ]
sends the create request to the gateway @ignore @param string $subPath @param array $params @return Result\Successful|Result\Error
[ "sends", "the", "create", "request", "to", "the", "gateway" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/AddressGateway.php#L276-L282
train
braintree/braintree_php
lib/Braintree/TransactionGateway.php
TransactionGateway.saleNoValidate
public function saleNoValidate($attribs) { $result = $this->sale($attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); }
php
public function saleNoValidate($attribs) { $result = $this->sale($attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); }
[ "public", "function", "saleNoValidate", "(", "$", "attribs", ")", "{", "$", "result", "=", "$", "this", "->", "sale", "(", "$", "attribs", ")", ";", "return", "Util", "::", "returnObjectOrThrowException", "(", "__CLASS__", ",", "$", "result", ")", ";", "}" ]
roughly equivalent to the ruby bang method @access public @param array $attribs @return array @throws Exception\ValidationsFailed
[ "roughly", "equivalent", "to", "the", "ruby", "bang", "method" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/TransactionGateway.php#L357-L361
train
braintree/braintree_php
lib/Braintree/SettlementBatchSummary.php
SettlementBatchSummary.generate
public static function generate($settlement_date, $groupByCustomField = NULL) { return Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField); }
php
public static function generate($settlement_date, $groupByCustomField = NULL) { return Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField); }
[ "public", "static", "function", "generate", "(", "$", "settlement_date", ",", "$", "groupByCustomField", "=", "NULL", ")", "{", "return", "Configuration", "::", "gateway", "(", ")", "->", "settlementBatchSummary", "(", ")", "->", "generate", "(", "$", "settlement_date", ",", "$", "groupByCustomField", ")", ";", "}" ]
static method redirecting to gateway @param string $settlement_date Date YYYY-MM-DD @param string $groupByCustomField @return Result\Successful|Result\Error
[ "static", "method", "redirecting", "to", "gateway" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/SettlementBatchSummary.php#L43-L46
train
braintree/braintree_php
lib/Braintree/ResourceCollection.php
ResourceCollection._getPage
private function _getPage($ids) { $object = $this->_pager['object']; $method = $this->_pager['method']; $methodArgs = []; foreach ($this->_pager['methodArgs'] as $arg) { array_push($methodArgs, $arg); } array_push($methodArgs, $ids); return call_user_func_array( [$object, $method], $methodArgs ); }
php
private function _getPage($ids) { $object = $this->_pager['object']; $method = $this->_pager['method']; $methodArgs = []; foreach ($this->_pager['methodArgs'] as $arg) { array_push($methodArgs, $arg); } array_push($methodArgs, $ids); return call_user_func_array( [$object, $method], $methodArgs ); }
[ "private", "function", "_getPage", "(", "$", "ids", ")", "{", "$", "object", "=", "$", "this", "->", "_pager", "[", "'object'", "]", ";", "$", "method", "=", "$", "this", "->", "_pager", "[", "'method'", "]", ";", "$", "methodArgs", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_pager", "[", "'methodArgs'", "]", "as", "$", "arg", ")", "{", "array_push", "(", "$", "methodArgs", ",", "$", "arg", ")", ";", "}", "array_push", "(", "$", "methodArgs", ",", "$", "ids", ")", ";", "return", "call_user_func_array", "(", "[", "$", "object", ",", "$", "method", "]", ",", "$", "methodArgs", ")", ";", "}" ]
requests the next page of results for the collection @return void
[ "requests", "the", "next", "page", "of", "results", "for", "the", "collection" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/ResourceCollection.php#L130-L144
train
braintree/braintree_php
lib/Braintree/IdealPaymentGateway.php
IdealPaymentGateway.find
public function find($idealPaymentId) { try { $path = $this->_config->merchantPath() . '/ideal_payments/' . $idealPaymentId; $response = $this->_http->get($path); return IdealPayment::factory($response['idealPayment']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'iDEAL Payment with id ' . $idealPaymentId . ' not found' ); } }
php
public function find($idealPaymentId) { try { $path = $this->_config->merchantPath() . '/ideal_payments/' . $idealPaymentId; $response = $this->_http->get($path); return IdealPayment::factory($response['idealPayment']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'iDEAL Payment with id ' . $idealPaymentId . ' not found' ); } }
[ "public", "function", "find", "(", "$", "idealPaymentId", ")", "{", "try", "{", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/ideal_payments/'", ".", "$", "idealPaymentId", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "get", "(", "$", "path", ")", ";", "return", "IdealPayment", "::", "factory", "(", "$", "response", "[", "'idealPayment'", "]", ")", ";", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'iDEAL Payment with id '", ".", "$", "idealPaymentId", ".", "' not found'", ")", ";", "}", "}" ]
find an IdealPayment by id @access public @param string $idealPaymentId @return IdealPayment @throws Exception\NotFound
[ "find", "an", "IdealPayment", "by", "id" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/IdealPaymentGateway.php#L44-L55
train
braintree/braintree_php
lib/Braintree/Xml/Parser.php
Parser.arrayFromXml
public static function arrayFromXml($xml) { $document = new DOMDocument('1.0', 'UTF-8'); $document->loadXML($xml); $root = $document->documentElement->nodeName; return Util::delimiterToCamelCaseArray([ $root => self::_nodeToValue($document->childNodes->item(0)), ]); }
php
public static function arrayFromXml($xml) { $document = new DOMDocument('1.0', 'UTF-8'); $document->loadXML($xml); $root = $document->documentElement->nodeName; return Util::delimiterToCamelCaseArray([ $root => self::_nodeToValue($document->childNodes->item(0)), ]); }
[ "public", "static", "function", "arrayFromXml", "(", "$", "xml", ")", "{", "$", "document", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "document", "->", "loadXML", "(", "$", "xml", ")", ";", "$", "root", "=", "$", "document", "->", "documentElement", "->", "nodeName", ";", "return", "Util", "::", "delimiterToCamelCaseArray", "(", "[", "$", "root", "=>", "self", "::", "_nodeToValue", "(", "$", "document", "->", "childNodes", "->", "item", "(", "0", ")", ")", ",", "]", ")", ";", "}" ]
Converts an XML string into a multidimensional array @param string $xml @return array
[ "Converts", "an", "XML", "string", "into", "a", "multidimensional", "array" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Xml/Parser.php#L22-L32
train
braintree/braintree_php
lib/Braintree/Xml/Parser.php
Parser._nodeToArray
private static function _nodeToArray($node) { $type = null; if ($node instanceof DOMElement) { $type = $node->getAttribute('type'); } switch($type) { case 'array': $array = []; foreach ($node->childNodes as $child) { $value = self::_nodeToValue($child); if ($value !== null) { $array[] = $value; } } return $array; case 'collection': $collection = []; foreach ($node->childNodes as $child) { $value = self::_nodetoValue($child); if ($value !== null) { if (!isset($collection[$child->nodeName])) { $collection[$child->nodeName] = []; } $collection[$child->nodeName][] = self::_nodeToValue($child); } } return $collection; default: $values = []; if ($node->childNodes->length === 1 && $node->childNodes->item(0) instanceof DOMText) { return $node->childNodes->item(0)->nodeValue; } else { foreach ($node->childNodes as $child) { if (!$child instanceof DOMText) { $values[$child->nodeName] = self::_nodeToValue($child); } } return $values; } } }
php
private static function _nodeToArray($node) { $type = null; if ($node instanceof DOMElement) { $type = $node->getAttribute('type'); } switch($type) { case 'array': $array = []; foreach ($node->childNodes as $child) { $value = self::_nodeToValue($child); if ($value !== null) { $array[] = $value; } } return $array; case 'collection': $collection = []; foreach ($node->childNodes as $child) { $value = self::_nodetoValue($child); if ($value !== null) { if (!isset($collection[$child->nodeName])) { $collection[$child->nodeName] = []; } $collection[$child->nodeName][] = self::_nodeToValue($child); } } return $collection; default: $values = []; if ($node->childNodes->length === 1 && $node->childNodes->item(0) instanceof DOMText) { return $node->childNodes->item(0)->nodeValue; } else { foreach ($node->childNodes as $child) { if (!$child instanceof DOMText) { $values[$child->nodeName] = self::_nodeToValue($child); } } return $values; } } }
[ "private", "static", "function", "_nodeToArray", "(", "$", "node", ")", "{", "$", "type", "=", "null", ";", "if", "(", "$", "node", "instanceof", "DOMElement", ")", "{", "$", "type", "=", "$", "node", "->", "getAttribute", "(", "'type'", ")", ";", "}", "switch", "(", "$", "type", ")", "{", "case", "'array'", ":", "$", "array", "=", "[", "]", ";", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "child", ")", "{", "$", "value", "=", "self", "::", "_nodeToValue", "(", "$", "child", ")", ";", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "array", "[", "]", "=", "$", "value", ";", "}", "}", "return", "$", "array", ";", "case", "'collection'", ":", "$", "collection", "=", "[", "]", ";", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "child", ")", "{", "$", "value", "=", "self", "::", "_nodetoValue", "(", "$", "child", ")", ";", "if", "(", "$", "value", "!==", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "collection", "[", "$", "child", "->", "nodeName", "]", ")", ")", "{", "$", "collection", "[", "$", "child", "->", "nodeName", "]", "=", "[", "]", ";", "}", "$", "collection", "[", "$", "child", "->", "nodeName", "]", "[", "]", "=", "self", "::", "_nodeToValue", "(", "$", "child", ")", ";", "}", "}", "return", "$", "collection", ";", "default", ":", "$", "values", "=", "[", "]", ";", "if", "(", "$", "node", "->", "childNodes", "->", "length", "===", "1", "&&", "$", "node", "->", "childNodes", "->", "item", "(", "0", ")", "instanceof", "DOMText", ")", "{", "return", "$", "node", "->", "childNodes", "->", "item", "(", "0", ")", "->", "nodeValue", ";", "}", "else", "{", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "!", "$", "child", "instanceof", "DOMText", ")", "{", "$", "values", "[", "$", "child", "->", "nodeName", "]", "=", "self", "::", "_nodeToValue", "(", "$", "child", ")", ";", "}", "}", "return", "$", "values", ";", "}", "}", "}" ]
Converts a node to an array of values or nodes @param DOMNode @node @return mixed
[ "Converts", "a", "node", "to", "an", "array", "of", "values", "or", "nodes" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Xml/Parser.php#L40-L82
train
braintree/braintree_php
lib/Braintree/Xml/Parser.php
Parser._nodeToValue
private static function _nodeToValue($node) { $type = null; if ($node instanceof DOMElement) { $type = $node->getAttribute('type'); } switch($type) { case 'datetime': return self::_timestampToUTC((string) $node->nodeValue); case 'date': return new DateTime((string) $node->nodeValue); case 'integer': return (int) $node->nodeValue; case 'boolean': $value = (string) $node->nodeValue; if(is_numeric($value)) { return (bool) $value; } else { return ($value !== "true") ? false : true; } case 'array': case 'collection': return self::_nodeToArray($node); default: if ($node->hasChildNodes()) { return self::_nodeToArray($node); } elseif (trim($node->nodeValue) === '') { return null; } else { return $node->nodeValue; } } }
php
private static function _nodeToValue($node) { $type = null; if ($node instanceof DOMElement) { $type = $node->getAttribute('type'); } switch($type) { case 'datetime': return self::_timestampToUTC((string) $node->nodeValue); case 'date': return new DateTime((string) $node->nodeValue); case 'integer': return (int) $node->nodeValue; case 'boolean': $value = (string) $node->nodeValue; if(is_numeric($value)) { return (bool) $value; } else { return ($value !== "true") ? false : true; } case 'array': case 'collection': return self::_nodeToArray($node); default: if ($node->hasChildNodes()) { return self::_nodeToArray($node); } elseif (trim($node->nodeValue) === '') { return null; } else { return $node->nodeValue; } } }
[ "private", "static", "function", "_nodeToValue", "(", "$", "node", ")", "{", "$", "type", "=", "null", ";", "if", "(", "$", "node", "instanceof", "DOMElement", ")", "{", "$", "type", "=", "$", "node", "->", "getAttribute", "(", "'type'", ")", ";", "}", "switch", "(", "$", "type", ")", "{", "case", "'datetime'", ":", "return", "self", "::", "_timestampToUTC", "(", "(", "string", ")", "$", "node", "->", "nodeValue", ")", ";", "case", "'date'", ":", "return", "new", "DateTime", "(", "(", "string", ")", "$", "node", "->", "nodeValue", ")", ";", "case", "'integer'", ":", "return", "(", "int", ")", "$", "node", "->", "nodeValue", ";", "case", "'boolean'", ":", "$", "value", "=", "(", "string", ")", "$", "node", "->", "nodeValue", ";", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "(", "bool", ")", "$", "value", ";", "}", "else", "{", "return", "(", "$", "value", "!==", "\"true\"", ")", "?", "false", ":", "true", ";", "}", "case", "'array'", ":", "case", "'collection'", ":", "return", "self", "::", "_nodeToArray", "(", "$", "node", ")", ";", "default", ":", "if", "(", "$", "node", "->", "hasChildNodes", "(", ")", ")", "{", "return", "self", "::", "_nodeToArray", "(", "$", "node", ")", ";", "}", "elseif", "(", "trim", "(", "$", "node", "->", "nodeValue", ")", "===", "''", ")", "{", "return", "null", ";", "}", "else", "{", "return", "$", "node", "->", "nodeValue", ";", "}", "}", "}" ]
Converts a node to a PHP value @param DOMNode $node @return mixed
[ "Converts", "a", "node", "to", "a", "PHP", "value" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Xml/Parser.php#L90-L123
train
braintree/braintree_php
lib/Braintree/Xml/Parser.php
Parser._timestampToUTC
private static function _timestampToUTC($timestamp) { $tz = new DateTimeZone('UTC'); $dateTime = new DateTime($timestamp, $tz); $dateTime->setTimezone($tz); return $dateTime; }
php
private static function _timestampToUTC($timestamp) { $tz = new DateTimeZone('UTC'); $dateTime = new DateTime($timestamp, $tz); $dateTime->setTimezone($tz); return $dateTime; }
[ "private", "static", "function", "_timestampToUTC", "(", "$", "timestamp", ")", "{", "$", "tz", "=", "new", "DateTimeZone", "(", "'UTC'", ")", ";", "$", "dateTime", "=", "new", "DateTime", "(", "$", "timestamp", ",", "$", "tz", ")", ";", "$", "dateTime", "->", "setTimezone", "(", "$", "tz", ")", ";", "return", "$", "dateTime", ";", "}" ]
Converts XML timestamps into DateTime instances @param string $timestamp @return DateTime
[ "Converts", "XML", "timestamps", "into", "DateTime", "instances" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Xml/Parser.php#L132-L138
train
braintree/braintree_php
lib/Braintree/TransparentRedirectGateway.php
TransparentRedirectGateway.init
public static function init() { self::$_createCustomerSignature = [ self::$_transparentRedirectKeys, ['customer' => CustomerGateway::createSignature()], ]; self::$_updateCustomerSignature = [ self::$_transparentRedirectKeys, 'customerId', ['customer' => CustomerGateway::updateSignature()], ]; self::$_transactionSignature = [ self::$_transparentRedirectKeys, ['transaction' => TransactionGateway::createSignature()], ]; self::$_createCreditCardSignature = [ self::$_transparentRedirectKeys, ['creditCard' => CreditCardGateway::createSignature()], ]; self::$_updateCreditCardSignature = [ self::$_transparentRedirectKeys, 'paymentMethodToken', ['creditCard' => CreditCardGateway::updateSignature()], ]; }
php
public static function init() { self::$_createCustomerSignature = [ self::$_transparentRedirectKeys, ['customer' => CustomerGateway::createSignature()], ]; self::$_updateCustomerSignature = [ self::$_transparentRedirectKeys, 'customerId', ['customer' => CustomerGateway::updateSignature()], ]; self::$_transactionSignature = [ self::$_transparentRedirectKeys, ['transaction' => TransactionGateway::createSignature()], ]; self::$_createCreditCardSignature = [ self::$_transparentRedirectKeys, ['creditCard' => CreditCardGateway::createSignature()], ]; self::$_updateCreditCardSignature = [ self::$_transparentRedirectKeys, 'paymentMethodToken', ['creditCard' => CreditCardGateway::updateSignature()], ]; }
[ "public", "static", "function", "init", "(", ")", "{", "self", "::", "$", "_createCustomerSignature", "=", "[", "self", "::", "$", "_transparentRedirectKeys", ",", "[", "'customer'", "=>", "CustomerGateway", "::", "createSignature", "(", ")", "]", ",", "]", ";", "self", "::", "$", "_updateCustomerSignature", "=", "[", "self", "::", "$", "_transparentRedirectKeys", ",", "'customerId'", ",", "[", "'customer'", "=>", "CustomerGateway", "::", "updateSignature", "(", ")", "]", ",", "]", ";", "self", "::", "$", "_transactionSignature", "=", "[", "self", "::", "$", "_transparentRedirectKeys", ",", "[", "'transaction'", "=>", "TransactionGateway", "::", "createSignature", "(", ")", "]", ",", "]", ";", "self", "::", "$", "_createCreditCardSignature", "=", "[", "self", "::", "$", "_transparentRedirectKeys", ",", "[", "'creditCard'", "=>", "CreditCardGateway", "::", "createSignature", "(", ")", "]", ",", "]", ";", "self", "::", "$", "_updateCreditCardSignature", "=", "[", "self", "::", "$", "_transparentRedirectKeys", ",", "'paymentMethodToken'", ",", "[", "'creditCard'", "=>", "CreditCardGateway", "::", "updateSignature", "(", ")", "]", ",", "]", ";", "}" ]
create signatures for different call types @ignore
[ "create", "signatures", "for", "different", "call", "types" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/TransparentRedirectGateway.php#L42-L67
train
braintree/braintree_php
lib/Braintree/TransparentRedirectGateway.php
TransparentRedirectGateway.createCreditCardData
public function createCreditCardData($params) { Util::verifyKeys( self::$_createCreditCardSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_PAYMENT_METHOD; return $this->_data($params); }
php
public function createCreditCardData($params) { Util::verifyKeys( self::$_createCreditCardSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_PAYMENT_METHOD; return $this->_data($params); }
[ "public", "function", "createCreditCardData", "(", "$", "params", ")", "{", "Util", "::", "verifyKeys", "(", "self", "::", "$", "_createCreditCardSignature", ",", "$", "params", ")", ";", "$", "params", "[", "\"kind\"", "]", "=", "TransparentRedirect", "::", "CREATE_PAYMENT_METHOD", ";", "return", "$", "this", "->", "_data", "(", "$", "params", ")", ";", "}" ]
returns the trData string for creating a credit card, @param array $params @return string
[ "returns", "the", "trData", "string", "for", "creating", "a", "credit", "card" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/TransparentRedirectGateway.php#L90-L98
train
braintree/braintree_php
lib/Braintree/TransparentRedirectGateway.php
TransparentRedirectGateway.createCustomerData
public function createCustomerData($params) { Util::verifyKeys( self::$_createCustomerSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_CUSTOMER; return $this->_data($params); }
php
public function createCustomerData($params) { Util::verifyKeys( self::$_createCustomerSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_CUSTOMER; return $this->_data($params); }
[ "public", "function", "createCustomerData", "(", "$", "params", ")", "{", "Util", "::", "verifyKeys", "(", "self", "::", "$", "_createCustomerSignature", ",", "$", "params", ")", ";", "$", "params", "[", "\"kind\"", "]", "=", "TransparentRedirect", "::", "CREATE_CUSTOMER", ";", "return", "$", "this", "->", "_data", "(", "$", "params", ")", ";", "}" ]
returns the trData string for creating a customer. @param array $params @return string
[ "returns", "the", "trData", "string", "for", "creating", "a", "customer", "." ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/TransparentRedirectGateway.php#L105-L114
train
braintree/braintree_php
lib/Braintree/TransparentRedirectGateway.php
TransparentRedirectGateway.transactionData
public function transactionData($params) { Util::verifyKeys( self::$_transactionSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_TRANSACTION; $transactionType = isset($params['transaction']['type']) ? $params['transaction']['type'] : null; if ($transactionType != Transaction::SALE && $transactionType != Transaction::CREDIT) { throw new InvalidArgumentException( 'expected transaction[type] of sale or credit, was: ' . $transactionType ); } return $this->_data($params); }
php
public function transactionData($params) { Util::verifyKeys( self::$_transactionSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_TRANSACTION; $transactionType = isset($params['transaction']['type']) ? $params['transaction']['type'] : null; if ($transactionType != Transaction::SALE && $transactionType != Transaction::CREDIT) { throw new InvalidArgumentException( 'expected transaction[type] of sale or credit, was: ' . $transactionType ); } return $this->_data($params); }
[ "public", "function", "transactionData", "(", "$", "params", ")", "{", "Util", "::", "verifyKeys", "(", "self", "::", "$", "_transactionSignature", ",", "$", "params", ")", ";", "$", "params", "[", "\"kind\"", "]", "=", "TransparentRedirect", "::", "CREATE_TRANSACTION", ";", "$", "transactionType", "=", "isset", "(", "$", "params", "[", "'transaction'", "]", "[", "'type'", "]", ")", "?", "$", "params", "[", "'transaction'", "]", "[", "'type'", "]", ":", "null", ";", "if", "(", "$", "transactionType", "!=", "Transaction", "::", "SALE", "&&", "$", "transactionType", "!=", "Transaction", "::", "CREDIT", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'expected transaction[type] of sale or credit, was: '", ".", "$", "transactionType", ")", ";", "}", "return", "$", "this", "->", "_data", "(", "$", "params", ")", ";", "}" ]
returns the trData string for creating a transaction @param array $params @return string
[ "returns", "the", "trData", "string", "for", "creating", "a", "transaction" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/TransparentRedirectGateway.php#L126-L144
train
braintree/braintree_php
lib/Braintree/TransparentRedirectGateway.php
TransparentRedirectGateway.updateCreditCardData
public function updateCreditCardData($params) { Util::verifyKeys( self::$_updateCreditCardSignature, $params ); if (!isset($params['paymentMethodToken'])) { throw new InvalidArgumentException( 'expected params to contain paymentMethodToken.' ); } $params["kind"] = TransparentRedirect::UPDATE_PAYMENT_METHOD; return $this->_data($params); }
php
public function updateCreditCardData($params) { Util::verifyKeys( self::$_updateCreditCardSignature, $params ); if (!isset($params['paymentMethodToken'])) { throw new InvalidArgumentException( 'expected params to contain paymentMethodToken.' ); } $params["kind"] = TransparentRedirect::UPDATE_PAYMENT_METHOD; return $this->_data($params); }
[ "public", "function", "updateCreditCardData", "(", "$", "params", ")", "{", "Util", "::", "verifyKeys", "(", "self", "::", "$", "_updateCreditCardSignature", ",", "$", "params", ")", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'paymentMethodToken'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'expected params to contain paymentMethodToken.'", ")", ";", "}", "$", "params", "[", "\"kind\"", "]", "=", "TransparentRedirect", "::", "UPDATE_PAYMENT_METHOD", ";", "return", "$", "this", "->", "_data", "(", "$", "params", ")", ";", "}" ]
Returns the trData string for updating a credit card. The paymentMethodToken of the credit card to update is required. <code> $trData = TransparentRedirect::updateCreditCardData(array( 'redirectUrl' => 'http://example.com/redirect_here', 'paymentMethodToken' => 'token123', )); </code> @param array $params @return string
[ "Returns", "the", "trData", "string", "for", "updating", "a", "credit", "card", "." ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/TransparentRedirectGateway.php#L161-L174
train
braintree/braintree_php
lib/Braintree/TransparentRedirectGateway.php
TransparentRedirectGateway.updateCustomerData
public function updateCustomerData($params) { Util::verifyKeys( self::$_updateCustomerSignature, $params ); if (!isset($params['customerId'])) { throw new InvalidArgumentException( 'expected params to contain customerId of customer to update' ); } $params["kind"] = TransparentRedirect::UPDATE_CUSTOMER; return $this->_data($params); }
php
public function updateCustomerData($params) { Util::verifyKeys( self::$_updateCustomerSignature, $params ); if (!isset($params['customerId'])) { throw new InvalidArgumentException( 'expected params to contain customerId of customer to update' ); } $params["kind"] = TransparentRedirect::UPDATE_CUSTOMER; return $this->_data($params); }
[ "public", "function", "updateCustomerData", "(", "$", "params", ")", "{", "Util", "::", "verifyKeys", "(", "self", "::", "$", "_updateCustomerSignature", ",", "$", "params", ")", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'customerId'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'expected params to contain customerId of customer to update'", ")", ";", "}", "$", "params", "[", "\"kind\"", "]", "=", "TransparentRedirect", "::", "UPDATE_CUSTOMER", ";", "return", "$", "this", "->", "_data", "(", "$", "params", ")", ";", "}" ]
Returns the trData string for updating a customer. The customerId of the customer to update is required. <code> $trData = TransparentRedirect::updateCustomerData(array( 'redirectUrl' => 'http://example.com/redirect_here', 'customerId' => 'customer123', )); </code> @param array $params @return string
[ "Returns", "the", "trData", "string", "for", "updating", "a", "customer", "." ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/TransparentRedirectGateway.php#L191-L204
train
braintree/braintree_php
lib/Braintree/Collection.php
Collection.set
public function set($index, $value) { if($index >= $this->count()) throw new OutOfRangeException('Index out of range'); $this->_collection[$index] = $value; }
php
public function set($index, $value) { if($index >= $this->count()) throw new OutOfRangeException('Index out of range'); $this->_collection[$index] = $value; }
[ "public", "function", "set", "(", "$", "index", ",", "$", "value", ")", "{", "if", "(", "$", "index", ">=", "$", "this", "->", "count", "(", ")", ")", "throw", "new", "OutOfRangeException", "(", "'Index out of range'", ")", ";", "$", "this", "->", "_collection", "[", "$", "index", "]", "=", "$", "value", ";", "}" ]
Set index's value @param integer $index @param mixed $value @throws OutOfRangeException
[ "Set", "index", "s", "value" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Collection.php#L45-L51
train
braintree/braintree_php
lib/Braintree/Collection.php
Collection.remove
public function remove($index) { if($index >= $this->count()) throw new OutOfRangeException('Index out of range'); array_splice($this->_collection, $index, 1); }
php
public function remove($index) { if($index >= $this->count()) throw new OutOfRangeException('Index out of range'); array_splice($this->_collection, $index, 1); }
[ "public", "function", "remove", "(", "$", "index", ")", "{", "if", "(", "$", "index", ">=", "$", "this", "->", "count", "(", ")", ")", "throw", "new", "OutOfRangeException", "(", "'Index out of range'", ")", ";", "array_splice", "(", "$", "this", "->", "_collection", ",", "$", "index", ",", "1", ")", ";", "}" ]
Remove a value from the collection @param integer $index index to remove @throws OutOfRangeException if index is out of range
[ "Remove", "a", "value", "from", "the", "collection" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Collection.php#L58-L64
train
braintree/braintree_php
lib/Braintree/Address.php
Address.isEqual
public function isEqual($other) { return !($other instanceof self) ? false : ($this->id === $other->id && $this->customerId === $other->customerId); }
php
public function isEqual($other) { return !($other instanceof self) ? false : ($this->id === $other->id && $this->customerId === $other->customerId); }
[ "public", "function", "isEqual", "(", "$", "other", ")", "{", "return", "!", "(", "$", "other", "instanceof", "self", ")", "?", "false", ":", "(", "$", "this", "->", "id", "===", "$", "other", "->", "id", "&&", "$", "this", "->", "customerId", "===", "$", "other", "->", "customerId", ")", ";", "}" ]
returns false if comparing object is not a Address, or is a Address with a different id @param object $other address to compare against @return boolean
[ "returns", "false", "if", "comparing", "object", "is", "not", "a", "Address", "or", "is", "a", "Address", "with", "a", "different", "id" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Address.php#L38-L43
train
braintree/braintree_php
lib/Braintree/PayPalAccountGateway.php
PayPalAccountGateway.find
public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token; $response = $this->_http->get($path); return PayPalAccount::factory($response['paypalAccount']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'paypal account with token ' . $token . ' not found' ); } }
php
public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token; $response = $this->_http->get($path); return PayPalAccount::factory($response['paypalAccount']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'paypal account with token ' . $token . ' not found' ); } }
[ "public", "function", "find", "(", "$", "token", ")", "{", "$", "this", "->", "_validateId", "(", "$", "token", ")", ";", "try", "{", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/payment_methods/paypal_account/'", ".", "$", "token", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "get", "(", "$", "path", ")", ";", "return", "PayPalAccount", "::", "factory", "(", "$", "response", "[", "'paypalAccount'", "]", ")", ";", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'paypal account with token '", ".", "$", "token", ".", "' not found'", ")", ";", "}", "}" ]
find a paypalAccount by token @access public @param string $token paypal accountunique id @return PayPalAccount @throws Exception\NotFound
[ "find", "a", "paypalAccount", "by", "token" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/PayPalAccountGateway.php#L45-L58
train
braintree/braintree_php
lib/Braintree/PayPalAccountGateway.php
PayPalAccountGateway.update
public function update($token, $attributes) { Util::verifyKeys(self::updateSignature(), $attributes); $this->_validateId($token); return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, ['paypalAccount' => $attributes]); }
php
public function update($token, $attributes) { Util::verifyKeys(self::updateSignature(), $attributes); $this->_validateId($token); return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, ['paypalAccount' => $attributes]); }
[ "public", "function", "update", "(", "$", "token", ",", "$", "attributes", ")", "{", "Util", "::", "verifyKeys", "(", "self", "::", "updateSignature", "(", ")", ",", "$", "attributes", ")", ";", "$", "this", "->", "_validateId", "(", "$", "token", ")", ";", "return", "$", "this", "->", "_doUpdate", "(", "'put'", ",", "'/payment_methods/paypal_account/'", ".", "$", "token", ",", "[", "'paypalAccount'", "=>", "$", "attributes", "]", ")", ";", "}" ]
updates the paypalAccount record if calling this method in context, $token is the 2nd attribute. $token is not sent in object context. @access public @param array $attributes @param string $token (optional) @return Result\Successful or Result\Error
[ "updates", "the", "paypalAccount", "record" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/PayPalAccountGateway.php#L71-L76
train
braintree/braintree_php
lib/Braintree/PayPalAccountGateway.php
PayPalAccountGateway.sale
public function sale($token, $transactionAttribs) { $this->_validateId($token); return Transaction::sale( array_merge( $transactionAttribs, ['paymentMethodToken' => $token] ) ); }
php
public function sale($token, $transactionAttribs) { $this->_validateId($token); return Transaction::sale( array_merge( $transactionAttribs, ['paymentMethodToken' => $token] ) ); }
[ "public", "function", "sale", "(", "$", "token", ",", "$", "transactionAttribs", ")", "{", "$", "this", "->", "_validateId", "(", "$", "token", ")", ";", "return", "Transaction", "::", "sale", "(", "array_merge", "(", "$", "transactionAttribs", ",", "[", "'paymentMethodToken'", "=>", "$", "token", "]", ")", ")", ";", "}" ]
create a new sale for the current PayPal account @param string $token @param array $transactionAttribs @return Result\Successful|Result\Error @see Transaction::sale()
[ "create", "a", "new", "sale", "for", "the", "current", "PayPal", "account" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/PayPalAccountGateway.php#L94-L103
train
braintree/braintree_php
lib/Braintree/PayPalAccountGateway.php
PayPalAccountGateway._validateId
private function _validateId($identifier = null, $identifierType = 'token') { if (empty($identifier)) { throw new InvalidArgumentException( 'expected paypal account id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) { throw new InvalidArgumentException( $identifier . ' is an invalid paypal account ' . $identifierType . '.' ); } }
php
private function _validateId($identifier = null, $identifierType = 'token') { if (empty($identifier)) { throw new InvalidArgumentException( 'expected paypal account id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) { throw new InvalidArgumentException( $identifier . ' is an invalid paypal account ' . $identifierType . '.' ); } }
[ "private", "function", "_validateId", "(", "$", "identifier", "=", "null", ",", "$", "identifierType", "=", "'token'", ")", "{", "if", "(", "empty", "(", "$", "identifier", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'expected paypal account id to be set'", ")", ";", "}", "if", "(", "!", "preg_match", "(", "'/^[0-9A-Za-z_-]+$/'", ",", "$", "identifier", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "$", "identifier", ".", "' is an invalid paypal account '", ".", "$", "identifierType", ".", "'.'", ")", ";", "}", "}" ]
verifies that a valid paypal account identifier is being used @ignore @param string $identifier @param Optional $string $identifierType type of identifier supplied, default 'token' @throws InvalidArgumentException
[ "verifies", "that", "a", "valid", "paypal", "account", "identifier", "is", "being", "used" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/PayPalAccountGateway.php#L164-L176
train
braintree/braintree_php
lib/Braintree/DisputeGateway.php
DisputeGateway.addFileEvidence
public function addFileEvidence($disputeId, $documentIdOrRequest) { $request = is_array($documentIdOrRequest) ? $documentIdOrRequest : ['documentId' => $documentIdOrRequest]; if (trim($disputeId) == "") { throw new Exception\NotFound('dispute with id "' . $disputeId . '" not found'); } if (trim($request['documentId']) == "") { throw new Exception\NotFound('document with id "' . $request['documentId'] . '" not found'); } try { if (array_key_exists('category', $request)) { if (trim($request['category']) == "") { throw new InvalidArgumentException('category cannot be blank'); } } $request['document_upload_id'] = $request['documentId']; unset($request['documentId']); $path = $this->_config->merchantPath() . '/disputes/' . $disputeId . '/evidence'; $response = $this->_http->post($path, ['evidence' => $request]); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } if (isset($response['evidence'])) { $evidence = new Dispute\EvidenceDetails($response['evidence']); return new Result\Successful($evidence); } } catch (Exception\NotFound $e) { throw new Exception\NotFound('dispute with id "' . $disputeId . '" not found'); } }
php
public function addFileEvidence($disputeId, $documentIdOrRequest) { $request = is_array($documentIdOrRequest) ? $documentIdOrRequest : ['documentId' => $documentIdOrRequest]; if (trim($disputeId) == "") { throw new Exception\NotFound('dispute with id "' . $disputeId . '" not found'); } if (trim($request['documentId']) == "") { throw new Exception\NotFound('document with id "' . $request['documentId'] . '" not found'); } try { if (array_key_exists('category', $request)) { if (trim($request['category']) == "") { throw new InvalidArgumentException('category cannot be blank'); } } $request['document_upload_id'] = $request['documentId']; unset($request['documentId']); $path = $this->_config->merchantPath() . '/disputes/' . $disputeId . '/evidence'; $response = $this->_http->post($path, ['evidence' => $request]); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } if (isset($response['evidence'])) { $evidence = new Dispute\EvidenceDetails($response['evidence']); return new Result\Successful($evidence); } } catch (Exception\NotFound $e) { throw new Exception\NotFound('dispute with id "' . $disputeId . '" not found'); } }
[ "public", "function", "addFileEvidence", "(", "$", "disputeId", ",", "$", "documentIdOrRequest", ")", "{", "$", "request", "=", "is_array", "(", "$", "documentIdOrRequest", ")", "?", "$", "documentIdOrRequest", ":", "[", "'documentId'", "=>", "$", "documentIdOrRequest", "]", ";", "if", "(", "trim", "(", "$", "disputeId", ")", "==", "\"\"", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'dispute with id \"'", ".", "$", "disputeId", ".", "'\" not found'", ")", ";", "}", "if", "(", "trim", "(", "$", "request", "[", "'documentId'", "]", ")", "==", "\"\"", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'document with id \"'", ".", "$", "request", "[", "'documentId'", "]", ".", "'\" not found'", ")", ";", "}", "try", "{", "if", "(", "array_key_exists", "(", "'category'", ",", "$", "request", ")", ")", "{", "if", "(", "trim", "(", "$", "request", "[", "'category'", "]", ")", "==", "\"\"", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'category cannot be blank'", ")", ";", "}", "}", "$", "request", "[", "'document_upload_id'", "]", "=", "$", "request", "[", "'documentId'", "]", ";", "unset", "(", "$", "request", "[", "'documentId'", "]", ")", ";", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/disputes/'", ".", "$", "disputeId", ".", "'/evidence'", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "post", "(", "$", "path", ",", "[", "'evidence'", "=>", "$", "request", "]", ")", ";", "if", "(", "isset", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ")", "{", "return", "new", "Result", "\\", "Error", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "response", "[", "'evidence'", "]", ")", ")", "{", "$", "evidence", "=", "new", "Dispute", "\\", "EvidenceDetails", "(", "$", "response", "[", "'evidence'", "]", ")", ";", "return", "new", "Result", "\\", "Successful", "(", "$", "evidence", ")", ";", "}", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'dispute with id \"'", ".", "$", "disputeId", ".", "'\" not found'", ")", ";", "}", "}" ]
Adds file evidence to a dispute, given a dispute ID and a document ID @param string $disputeId @param string $documentIdOrRequest
[ "Adds", "file", "evidence", "to", "a", "dispute", "given", "a", "dispute", "ID", "and", "a", "document", "ID" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/DisputeGateway.php#L74-L110
train
braintree/braintree_php
lib/Braintree/DisputeGateway.php
DisputeGateway.addTextEvidence
public function addTextEvidence($id, $contentOrRequest) { $request = is_array($contentOrRequest) ? $contentOrRequest : ['content' => $contentOrRequest]; if (trim($request['content']) == "") { throw new InvalidArgumentException('content cannot be blank'); } try { $evidence = [ 'comments' => $request['content'], ]; if (trim($id) == "") { throw new Exception\NotFound(); } if (array_key_exists('tag', $request)) { $evidence['category'] = $request['tag']; } if (array_key_exists('category', $request)) { if (trim($request['category']) == "") { throw new InvalidArgumentException('category cannot be blank'); } $evidence['category'] = $request['category']; } if (array_key_exists('sequenceNumber', $request)) { if (trim($request['sequenceNumber']) == "") { throw new InvalidArgumentException('sequenceNumber cannot be blank'); } else if ((string)(int)($request['sequenceNumber']) != $request['sequenceNumber']) { throw new InvalidArgumentException('sequenceNumber must be an integer'); } $evidence['sequenceNumber'] = (int)$request['sequenceNumber']; } $path = $this->_config->merchantPath() . '/disputes/' . $id . '/evidence'; $response = $this->_http->post($path, [ 'evidence' => $evidence ]); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } if (isset($response['evidence'])) { $evidence = new Dispute\EvidenceDetails($response['evidence']); return new Result\Successful($evidence); } } catch (Exception\NotFound $e) { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } }
php
public function addTextEvidence($id, $contentOrRequest) { $request = is_array($contentOrRequest) ? $contentOrRequest : ['content' => $contentOrRequest]; if (trim($request['content']) == "") { throw new InvalidArgumentException('content cannot be blank'); } try { $evidence = [ 'comments' => $request['content'], ]; if (trim($id) == "") { throw new Exception\NotFound(); } if (array_key_exists('tag', $request)) { $evidence['category'] = $request['tag']; } if (array_key_exists('category', $request)) { if (trim($request['category']) == "") { throw new InvalidArgumentException('category cannot be blank'); } $evidence['category'] = $request['category']; } if (array_key_exists('sequenceNumber', $request)) { if (trim($request['sequenceNumber']) == "") { throw new InvalidArgumentException('sequenceNumber cannot be blank'); } else if ((string)(int)($request['sequenceNumber']) != $request['sequenceNumber']) { throw new InvalidArgumentException('sequenceNumber must be an integer'); } $evidence['sequenceNumber'] = (int)$request['sequenceNumber']; } $path = $this->_config->merchantPath() . '/disputes/' . $id . '/evidence'; $response = $this->_http->post($path, [ 'evidence' => $evidence ]); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } if (isset($response['evidence'])) { $evidence = new Dispute\EvidenceDetails($response['evidence']); return new Result\Successful($evidence); } } catch (Exception\NotFound $e) { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } }
[ "public", "function", "addTextEvidence", "(", "$", "id", ",", "$", "contentOrRequest", ")", "{", "$", "request", "=", "is_array", "(", "$", "contentOrRequest", ")", "?", "$", "contentOrRequest", ":", "[", "'content'", "=>", "$", "contentOrRequest", "]", ";", "if", "(", "trim", "(", "$", "request", "[", "'content'", "]", ")", "==", "\"\"", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'content cannot be blank'", ")", ";", "}", "try", "{", "$", "evidence", "=", "[", "'comments'", "=>", "$", "request", "[", "'content'", "]", ",", "]", ";", "if", "(", "trim", "(", "$", "id", ")", "==", "\"\"", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", ")", ";", "}", "if", "(", "array_key_exists", "(", "'tag'", ",", "$", "request", ")", ")", "{", "$", "evidence", "[", "'category'", "]", "=", "$", "request", "[", "'tag'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'category'", ",", "$", "request", ")", ")", "{", "if", "(", "trim", "(", "$", "request", "[", "'category'", "]", ")", "==", "\"\"", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'category cannot be blank'", ")", ";", "}", "$", "evidence", "[", "'category'", "]", "=", "$", "request", "[", "'category'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'sequenceNumber'", ",", "$", "request", ")", ")", "{", "if", "(", "trim", "(", "$", "request", "[", "'sequenceNumber'", "]", ")", "==", "\"\"", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'sequenceNumber cannot be blank'", ")", ";", "}", "else", "if", "(", "(", "string", ")", "(", "int", ")", "(", "$", "request", "[", "'sequenceNumber'", "]", ")", "!=", "$", "request", "[", "'sequenceNumber'", "]", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'sequenceNumber must be an integer'", ")", ";", "}", "$", "evidence", "[", "'sequenceNumber'", "]", "=", "(", "int", ")", "$", "request", "[", "'sequenceNumber'", "]", ";", "}", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/disputes/'", ".", "$", "id", ".", "'/evidence'", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "post", "(", "$", "path", ",", "[", "'evidence'", "=>", "$", "evidence", "]", ")", ";", "if", "(", "isset", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ")", "{", "return", "new", "Result", "\\", "Error", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "response", "[", "'evidence'", "]", ")", ")", "{", "$", "evidence", "=", "new", "Dispute", "\\", "EvidenceDetails", "(", "$", "response", "[", "'evidence'", "]", ")", ";", "return", "new", "Result", "\\", "Successful", "(", "$", "evidence", ")", ";", "}", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'dispute with id \"'", ".", "$", "id", ".", "'\" not found'", ")", ";", "}", "}" ]
Adds text evidence to a dispute, given a dispute ID and content @param string $id @param string $content
[ "Adds", "text", "evidence", "to", "a", "dispute", "given", "a", "dispute", "ID", "and", "content" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/DisputeGateway.php#L118-L170
train
braintree/braintree_php
lib/Braintree/DisputeGateway.php
DisputeGateway.finalize
public function finalize($id) { try { if (trim($id) == "") { throw new Exception\NotFound(); } $path = $this->_config->merchantPath() . '/disputes/' . $id . '/finalize'; $response = $this->_http->put($path); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } return new Result\Successful(); } catch (Exception\NotFound $e) { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } }
php
public function finalize($id) { try { if (trim($id) == "") { throw new Exception\NotFound(); } $path = $this->_config->merchantPath() . '/disputes/' . $id . '/finalize'; $response = $this->_http->put($path); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } return new Result\Successful(); } catch (Exception\NotFound $e) { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } }
[ "public", "function", "finalize", "(", "$", "id", ")", "{", "try", "{", "if", "(", "trim", "(", "$", "id", ")", "==", "\"\"", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", ")", ";", "}", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/disputes/'", ".", "$", "id", ".", "'/finalize'", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "put", "(", "$", "path", ")", ";", "if", "(", "isset", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ")", "{", "return", "new", "Result", "\\", "Error", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ";", "}", "return", "new", "Result", "\\", "Successful", "(", ")", ";", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'dispute with id \"'", ".", "$", "id", ".", "'\" not found'", ")", ";", "}", "}" ]
Finalize a dispute, given a dispute ID @param string $id
[ "Finalize", "a", "dispute", "given", "a", "dispute", "ID" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/DisputeGateway.php#L177-L195
train
braintree/braintree_php
lib/Braintree/DisputeGateway.php
DisputeGateway.find
public function find($id) { if (trim($id) == "") { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } try { $path = $this->_config->merchantPath() . '/disputes/' . $id; $response = $this->_http->get($path); return Dispute::factory($response['dispute']); } catch (Exception\NotFound $e) { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } }
php
public function find($id) { if (trim($id) == "") { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } try { $path = $this->_config->merchantPath() . '/disputes/' . $id; $response = $this->_http->get($path); return Dispute::factory($response['dispute']); } catch (Exception\NotFound $e) { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } }
[ "public", "function", "find", "(", "$", "id", ")", "{", "if", "(", "trim", "(", "$", "id", ")", "==", "\"\"", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'dispute with id \"'", ".", "$", "id", ".", "'\" not found'", ")", ";", "}", "try", "{", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/disputes/'", ".", "$", "id", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "get", "(", "$", "path", ")", ";", "return", "Dispute", "::", "factory", "(", "$", "response", "[", "'dispute'", "]", ")", ";", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'dispute with id \"'", ".", "$", "id", ".", "'\" not found'", ")", ";", "}", "}" ]
Find a dispute, given a dispute ID @param string $id
[ "Find", "a", "dispute", "given", "a", "dispute", "ID" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/DisputeGateway.php#L202-L215
train
braintree/braintree_php
lib/Braintree/DisputeGateway.php
DisputeGateway.removeEvidence
public function removeEvidence($disputeId, $evidenceId) { try { if (trim($disputeId) == "" || trim($evidenceId) == "") { throw new Exception\NotFound(); } $path = $this->_config->merchantPath() . '/disputes/' . $disputeId . '/evidence/' . $evidenceId; $response = $this->_http->delete($path); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } return new Result\Successful(); } catch (Exception\NotFound $e) { throw new Exception\NotFound('evidence with id "' . $evidenceId . '" for dispute with id "' . $disputeId . '" not found'); } }
php
public function removeEvidence($disputeId, $evidenceId) { try { if (trim($disputeId) == "" || trim($evidenceId) == "") { throw new Exception\NotFound(); } $path = $this->_config->merchantPath() . '/disputes/' . $disputeId . '/evidence/' . $evidenceId; $response = $this->_http->delete($path); if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } return new Result\Successful(); } catch (Exception\NotFound $e) { throw new Exception\NotFound('evidence with id "' . $evidenceId . '" for dispute with id "' . $disputeId . '" not found'); } }
[ "public", "function", "removeEvidence", "(", "$", "disputeId", ",", "$", "evidenceId", ")", "{", "try", "{", "if", "(", "trim", "(", "$", "disputeId", ")", "==", "\"\"", "||", "trim", "(", "$", "evidenceId", ")", "==", "\"\"", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", ")", ";", "}", "$", "path", "=", "$", "this", "->", "_config", "->", "merchantPath", "(", ")", ".", "'/disputes/'", ".", "$", "disputeId", ".", "'/evidence/'", ".", "$", "evidenceId", ";", "$", "response", "=", "$", "this", "->", "_http", "->", "delete", "(", "$", "path", ")", ";", "if", "(", "isset", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ")", "{", "return", "new", "Result", "\\", "Error", "(", "$", "response", "[", "'apiErrorResponse'", "]", ")", ";", "}", "return", "new", "Result", "\\", "Successful", "(", ")", ";", "}", "catch", "(", "Exception", "\\", "NotFound", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "NotFound", "(", "'evidence with id \"'", ".", "$", "evidenceId", ".", "'\" for dispute with id \"'", ".", "$", "disputeId", ".", "'\" not found'", ")", ";", "}", "}" ]
Remove evidence from a dispute, given a dispute ID and evidence ID @param string $disputeId @param string $evidenceId
[ "Remove", "evidence", "from", "a", "dispute", "given", "a", "dispute", "ID", "and", "evidence", "ID" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/DisputeGateway.php#L223-L241
train
braintree/braintree_php
lib/Braintree/DisputeGateway.php
DisputeGateway.search
public function search($query) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $pager = [ 'object' => $this, 'method' => 'fetchDisputes', 'query' => $criteria ]; return new PaginatedCollection($pager); }
php
public function search($query) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $pager = [ 'object' => $this, 'method' => 'fetchDisputes', 'query' => $criteria ]; return new PaginatedCollection($pager); }
[ "public", "function", "search", "(", "$", "query", ")", "{", "$", "criteria", "=", "[", "]", ";", "foreach", "(", "$", "query", "as", "$", "term", ")", "{", "$", "criteria", "[", "$", "term", "->", "name", "]", "=", "$", "term", "->", "toparam", "(", ")", ";", "}", "$", "pager", "=", "[", "'object'", "=>", "$", "this", ",", "'method'", "=>", "'fetchDisputes'", ",", "'query'", "=>", "$", "criteria", "]", ";", "return", "new", "PaginatedCollection", "(", "$", "pager", ")", ";", "}" ]
Search for Disputes, given a DisputeSearch query @param DisputeSearch $query
[ "Search", "for", "Disputes", "given", "a", "DisputeSearch", "query" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/DisputeGateway.php#L248-L260
train
braintree/braintree_php
lib/Braintree/PaginatedCollection.php
PaginatedCollection.rewind
public function rewind() { $this->_index = 0; $this->_currentPage = 0; $this->_pageSize = 0; $this->_totalItems = 0; $this->_items = []; }
php
public function rewind() { $this->_index = 0; $this->_currentPage = 0; $this->_pageSize = 0; $this->_totalItems = 0; $this->_items = []; }
[ "public", "function", "rewind", "(", ")", "{", "$", "this", "->", "_index", "=", "0", ";", "$", "this", "->", "_currentPage", "=", "0", ";", "$", "this", "->", "_pageSize", "=", "0", ";", "$", "this", "->", "_totalItems", "=", "0", ";", "$", "this", "->", "_items", "=", "[", "]", ";", "}" ]
rewinds the collection to the first item when iterating with foreach
[ "rewinds", "the", "collection", "to", "the", "first", "item", "when", "iterating", "with", "foreach" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/PaginatedCollection.php#L73-L80
train
braintree/braintree_php
lib/Braintree/Configuration.php
Configuration.timeout
public static function timeout($value=null) { if (empty($value)) { return self::$global->getTimeout(); } self::$global->setTimeout($value); }
php
public static function timeout($value=null) { if (empty($value)) { return self::$global->getTimeout(); } self::$global->setTimeout($value); }
[ "public", "static", "function", "timeout", "(", "$", "value", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "self", "::", "$", "global", "->", "getTimeout", "(", ")", ";", "}", "self", "::", "$", "global", "->", "setTimeout", "(", "$", "value", ")", ";", "}" ]
Sets or gets the read timeout to use for making requests. @param integer $value If provided, sets the read timeout @return integer The read timeout used for connecting to Braintree
[ "Sets", "or", "gets", "the", "read", "timeout", "to", "use", "for", "making", "requests", "." ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Configuration.php#L130-L136
train
braintree/braintree_php
lib/Braintree/Configuration.php
Configuration.proxyHost
public static function proxyHost($value = null) { if (empty($value)) { return self::$global->getProxyHost(); } self::$global->setProxyHost($value); }
php
public static function proxyHost($value = null) { if (empty($value)) { return self::$global->getProxyHost(); } self::$global->setProxyHost($value); }
[ "public", "static", "function", "proxyHost", "(", "$", "value", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "self", "::", "$", "global", "->", "getProxyHost", "(", ")", ";", "}", "self", "::", "$", "global", "->", "setProxyHost", "(", "$", "value", ")", ";", "}" ]
Sets or gets the proxy host to use for connecting to Braintree @param string $value If provided, sets the proxy host @return string The proxy host used for connecting to Braintree
[ "Sets", "or", "gets", "the", "proxy", "host", "to", "use", "for", "connecting", "to", "Braintree" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Configuration.php#L160-L166
train
braintree/braintree_php
lib/Braintree/Configuration.php
Configuration.proxyPort
public static function proxyPort($value = null) { if (empty($value)) { return self::$global->getProxyPort(); } self::$global->setProxyPort($value); }
php
public static function proxyPort($value = null) { if (empty($value)) { return self::$global->getProxyPort(); } self::$global->setProxyPort($value); }
[ "public", "static", "function", "proxyPort", "(", "$", "value", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "self", "::", "$", "global", "->", "getProxyPort", "(", ")", ";", "}", "self", "::", "$", "global", "->", "setProxyPort", "(", "$", "value", ")", ";", "}" ]
Sets or gets the port of the proxy to use for connecting to Braintree @param string $value If provided, sets the port of the proxy @return string The port of the proxy used for connecting to Braintree
[ "Sets", "or", "gets", "the", "port", "of", "the", "proxy", "to", "use", "for", "connecting", "to", "Braintree" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Configuration.php#L174-L180
train
braintree/braintree_php
lib/Braintree/Configuration.php
Configuration.proxyType
public static function proxyType($value = null) { if (empty($value)) { return self::$global->getProxyType(); } self::$global->setProxyType($value); }
php
public static function proxyType($value = null) { if (empty($value)) { return self::$global->getProxyType(); } self::$global->setProxyType($value); }
[ "public", "static", "function", "proxyType", "(", "$", "value", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "self", "::", "$", "global", "->", "getProxyType", "(", ")", ";", "}", "self", "::", "$", "global", "->", "setProxyType", "(", "$", "value", ")", ";", "}" ]
Sets or gets the proxy type to use for connecting to Braintree. This value can be any of the CURLOPT_PROXYTYPE options in PHP cURL. @param string $value If provided, sets the proxy type @return string The proxy type used for connecting to Braintree
[ "Sets", "or", "gets", "the", "proxy", "type", "to", "use", "for", "connecting", "to", "Braintree", ".", "This", "value", "can", "be", "any", "of", "the", "CURLOPT_PROXYTYPE", "options", "in", "PHP", "cURL", "." ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Configuration.php#L189-L195
train
braintree/braintree_php
lib/Braintree/Configuration.php
Configuration.isUsingProxy
public static function isUsingProxy() { $proxyHost = self::$global->getProxyHost(); $proxyPort = self::$global->getProxyPort(); return !empty($proxyHost) && !empty($proxyPort); }
php
public static function isUsingProxy() { $proxyHost = self::$global->getProxyHost(); $proxyPort = self::$global->getProxyPort(); return !empty($proxyHost) && !empty($proxyPort); }
[ "public", "static", "function", "isUsingProxy", "(", ")", "{", "$", "proxyHost", "=", "self", "::", "$", "global", "->", "getProxyHost", "(", ")", ";", "$", "proxyPort", "=", "self", "::", "$", "global", "->", "getProxyPort", "(", ")", ";", "return", "!", "empty", "(", "$", "proxyHost", ")", "&&", "!", "empty", "(", "$", "proxyPort", ")", ";", "}" ]
Specifies whether or not a proxy is properly configured @return bool true if a proxy is configured properly, false if not
[ "Specifies", "whether", "or", "not", "a", "proxy", "is", "properly", "configured" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Configuration.php#L202-L207
train
braintree/braintree_php
lib/Braintree/Configuration.php
Configuration.isAuthenticatedProxy
public static function isAuthenticatedProxy() { $proxyUser = self::$global->getProxyUser(); $proxyPwd = self::$global->getProxyPassword(); return !empty($proxyUser) && !empty($proxyPwd); }
php
public static function isAuthenticatedProxy() { $proxyUser = self::$global->getProxyUser(); $proxyPwd = self::$global->getProxyPassword(); return !empty($proxyUser) && !empty($proxyPwd); }
[ "public", "static", "function", "isAuthenticatedProxy", "(", ")", "{", "$", "proxyUser", "=", "self", "::", "$", "global", "->", "getProxyUser", "(", ")", ";", "$", "proxyPwd", "=", "self", "::", "$", "global", "->", "getProxyPassword", "(", ")", ";", "return", "!", "empty", "(", "$", "proxyUser", ")", "&&", "!", "empty", "(", "$", "proxyPwd", ")", ";", "}" ]
Specified whether or not a username and password have been provided for use with an authenticated proxy @return bool true if both proxyUser and proxyPassword are present
[ "Specified", "whether", "or", "not", "a", "username", "and", "password", "have", "been", "provided", "for", "use", "with", "an", "authenticated", "proxy" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Configuration.php#L231-L236
train
braintree/braintree_php
lib/Braintree/Configuration.php
Configuration.acceptGzipEncoding
public static function acceptGzipEncoding($value = null) { if (is_null($value)) { return self::$global->getAcceptGzipEncoding(); } self::$global->setAcceptGzipEncoding($value); }
php
public static function acceptGzipEncoding($value = null) { if (is_null($value)) { return self::$global->getAcceptGzipEncoding(); } self::$global->setAcceptGzipEncoding($value); }
[ "public", "static", "function", "acceptGzipEncoding", "(", "$", "value", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "self", "::", "$", "global", "->", "getAcceptGzipEncoding", "(", ")", ";", "}", "self", "::", "$", "global", "->", "setAcceptGzipEncoding", "(", "$", "value", ")", ";", "}" ]
Specify if the HTTP client is able to decode gzipped responses. @param bool $value If true, will send an Accept-Encoding header with a gzip value. If false, will not send an Accept-Encoding header with a gzip value. @return bool true if an Accept-Encoding header with a gzip value will be sent, false if not
[ "Specify", "if", "the", "HTTP", "client", "is", "able", "to", "decode", "gzipped", "responses", "." ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Configuration.php#L244-L250
train
braintree/braintree_php
lib/Braintree/Configuration.php
Configuration.caFile
public function caFile($sslPath = NULL) { $sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'ssl' . DIRECTORY_SEPARATOR; $caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt'; if (!file_exists($caPath)) { throw new Exception\SSLCaFileNotFound(); } return $caPath; }
php
public function caFile($sslPath = NULL) { $sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'ssl' . DIRECTORY_SEPARATOR; $caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt'; if (!file_exists($caPath)) { throw new Exception\SSLCaFileNotFound(); } return $caPath; }
[ "public", "function", "caFile", "(", "$", "sslPath", "=", "NULL", ")", "{", "$", "sslPath", "=", "$", "sslPath", "?", "$", "sslPath", ":", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'ssl'", ".", "DIRECTORY_SEPARATOR", ";", "$", "caPath", "=", "__DIR__", ".", "$", "sslPath", ".", "'api_braintreegateway_com.ca.crt'", ";", "if", "(", "!", "file_exists", "(", "$", "caPath", ")", ")", "{", "throw", "new", "Exception", "\\", "SSLCaFileNotFound", "(", ")", ";", "}", "return", "$", "caPath", ";", "}" ]
sets the physical path for the location of the CA certs @access public @param none @return string filepath
[ "sets", "the", "physical", "path", "for", "the", "location", "of", "the", "CA", "certs" ]
840fc6ebf8d96756fed475cce94565fef178187d
https://github.com/braintree/braintree_php/blob/840fc6ebf8d96756fed475cce94565fef178187d/lib/Braintree/Configuration.php#L491-L503
train
maximebf/php-debugbar
src/DebugBar/Storage/PdoStorage.php
PdoStorage.getSqlQuery
protected function getSqlQuery($name, array $vars = array()) { $sql = $this->sqlQueries[$name]; $vars = array_merge(array('tablename' => $this->tableName), $vars); foreach ($vars as $k => $v) { $sql = str_replace("%$k%", $v, $sql); } return $sql; }
php
protected function getSqlQuery($name, array $vars = array()) { $sql = $this->sqlQueries[$name]; $vars = array_merge(array('tablename' => $this->tableName), $vars); foreach ($vars as $k => $v) { $sql = str_replace("%$k%", $v, $sql); } return $sql; }
[ "protected", "function", "getSqlQuery", "(", "$", "name", ",", "array", "$", "vars", "=", "array", "(", ")", ")", "{", "$", "sql", "=", "$", "this", "->", "sqlQueries", "[", "$", "name", "]", ";", "$", "vars", "=", "array_merge", "(", "array", "(", "'tablename'", "=>", "$", "this", "->", "tableName", ")", ",", "$", "vars", ")", ";", "foreach", "(", "$", "vars", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "sql", "=", "str_replace", "(", "\"%$k%\"", ",", "$", "v", ",", "$", "sql", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Get a SQL Query for a task, with the variables replaced @param string $name @param array $vars @return string
[ "Get", "a", "SQL", "Query", "for", "a", "task", "with", "the", "variables", "replaced" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/Storage/PdoStorage.php#L128-L136
train
maximebf/php-debugbar
src/DebugBar/DataCollector/ExceptionsCollector.php
ExceptionsCollector.addThrowable
public function addThrowable($e) { $this->exceptions[] = $e; if ($this->chainExceptions && $previous = $e->getPrevious()) { $this->addThrowable($previous); } }
php
public function addThrowable($e) { $this->exceptions[] = $e; if ($this->chainExceptions && $previous = $e->getPrevious()) { $this->addThrowable($previous); } }
[ "public", "function", "addThrowable", "(", "$", "e", ")", "{", "$", "this", "->", "exceptions", "[", "]", "=", "$", "e", ";", "if", "(", "$", "this", "->", "chainExceptions", "&&", "$", "previous", "=", "$", "e", "->", "getPrevious", "(", ")", ")", "{", "$", "this", "->", "addThrowable", "(", "$", "previous", ")", ";", "}", "}" ]
Adds a Throwable to be profiled in the debug bar @param \Throwable $e
[ "Adds", "a", "Throwable", "to", "be", "profiled", "in", "the", "debug", "bar" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataCollector/ExceptionsCollector.php#L40-L46
train
maximebf/php-debugbar
src/DebugBar/DataCollector/ExceptionsCollector.php
ExceptionsCollector.formatThrowableData
public function formatThrowableData($e) { $filePath = $e->getFile(); if ($filePath && file_exists($filePath)) { $lines = file($filePath); $start = $e->getLine() - 4; $lines = array_slice($lines, $start < 0 ? 0 : $start, 7); } else { $lines = array("Cannot open the file ($filePath) in which the exception occurred "); } return array( 'type' => get_class($e), 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $filePath, 'line' => $e->getLine(), 'stack_trace' => $e->getTraceAsString(), 'surrounding_lines' => $lines, 'xdebug_link' => $this->getXdebugLink($filePath, $e->getLine()) ); }
php
public function formatThrowableData($e) { $filePath = $e->getFile(); if ($filePath && file_exists($filePath)) { $lines = file($filePath); $start = $e->getLine() - 4; $lines = array_slice($lines, $start < 0 ? 0 : $start, 7); } else { $lines = array("Cannot open the file ($filePath) in which the exception occurred "); } return array( 'type' => get_class($e), 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $filePath, 'line' => $e->getLine(), 'stack_trace' => $e->getTraceAsString(), 'surrounding_lines' => $lines, 'xdebug_link' => $this->getXdebugLink($filePath, $e->getLine()) ); }
[ "public", "function", "formatThrowableData", "(", "$", "e", ")", "{", "$", "filePath", "=", "$", "e", "->", "getFile", "(", ")", ";", "if", "(", "$", "filePath", "&&", "file_exists", "(", "$", "filePath", ")", ")", "{", "$", "lines", "=", "file", "(", "$", "filePath", ")", ";", "$", "start", "=", "$", "e", "->", "getLine", "(", ")", "-", "4", ";", "$", "lines", "=", "array_slice", "(", "$", "lines", ",", "$", "start", "<", "0", "?", "0", ":", "$", "start", ",", "7", ")", ";", "}", "else", "{", "$", "lines", "=", "array", "(", "\"Cannot open the file ($filePath) in which the exception occurred \"", ")", ";", "}", "return", "array", "(", "'type'", "=>", "get_class", "(", "$", "e", ")", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "'code'", "=>", "$", "e", "->", "getCode", "(", ")", ",", "'file'", "=>", "$", "filePath", ",", "'line'", "=>", "$", "e", "->", "getLine", "(", ")", ",", "'stack_trace'", "=>", "$", "e", "->", "getTraceAsString", "(", ")", ",", "'surrounding_lines'", "=>", "$", "lines", ",", "'xdebug_link'", "=>", "$", "this", "->", "getXdebugLink", "(", "$", "filePath", ",", "$", "e", "->", "getLine", "(", ")", ")", ")", ";", "}" ]
Returns Throwable data as an array @param \Throwable $e @return array
[ "Returns", "Throwable", "data", "as", "an", "array" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataCollector/ExceptionsCollector.php#L94-L115
train
maximebf/php-debugbar
src/DebugBar/Storage/MemcachedStorage.php
MemcachedStorage.memcachedGetMulti
protected function memcachedGetMulti($keys, $flags) { if ($this->newGetMultiSignature === null) { $this->newGetMultiSignature = (new ReflectionMethod('Memcached', 'getMulti'))->getNumberOfParameters() === 2; } if ($this->newGetMultiSignature) { return $this->memcached->getMulti($keys, $flags); } else { $null = null; return $this->memcached->getMulti($keys, $null, $flags); } }
php
protected function memcachedGetMulti($keys, $flags) { if ($this->newGetMultiSignature === null) { $this->newGetMultiSignature = (new ReflectionMethod('Memcached', 'getMulti'))->getNumberOfParameters() === 2; } if ($this->newGetMultiSignature) { return $this->memcached->getMulti($keys, $flags); } else { $null = null; return $this->memcached->getMulti($keys, $null, $flags); } }
[ "protected", "function", "memcachedGetMulti", "(", "$", "keys", ",", "$", "flags", ")", "{", "if", "(", "$", "this", "->", "newGetMultiSignature", "===", "null", ")", "{", "$", "this", "->", "newGetMultiSignature", "=", "(", "new", "ReflectionMethod", "(", "'Memcached'", ",", "'getMulti'", ")", ")", "->", "getNumberOfParameters", "(", ")", "===", "2", ";", "}", "if", "(", "$", "this", "->", "newGetMultiSignature", ")", "{", "return", "$", "this", "->", "memcached", "->", "getMulti", "(", "$", "keys", ",", "$", "flags", ")", ";", "}", "else", "{", "$", "null", "=", "null", ";", "return", "$", "this", "->", "memcached", "->", "getMulti", "(", "$", "keys", ",", "$", "null", ",", "$", "flags", ")", ";", "}", "}" ]
The memcached getMulti function changed in version 3.0.0 to only have two parameters. @param array $keys @param int $flags
[ "The", "memcached", "getMulti", "function", "changed", "in", "version", "3", ".", "0", ".", "0", "to", "only", "have", "two", "parameters", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/Storage/MemcachedStorage.php#L146-L157
train
maximebf/php-debugbar
src/DebugBar/DataCollector/PDO/PDOCollector.php
PDOCollector.setRenderSqlWithParams
public function setRenderSqlWithParams($enabled = true, $quotationChar = '<>') { $this->renderSqlWithParams = $enabled; $this->sqlQuotationChar = $quotationChar; }
php
public function setRenderSqlWithParams($enabled = true, $quotationChar = '<>') { $this->renderSqlWithParams = $enabled; $this->sqlQuotationChar = $quotationChar; }
[ "public", "function", "setRenderSqlWithParams", "(", "$", "enabled", "=", "true", ",", "$", "quotationChar", "=", "'<>'", ")", "{", "$", "this", "->", "renderSqlWithParams", "=", "$", "enabled", ";", "$", "this", "->", "sqlQuotationChar", "=", "$", "quotationChar", ";", "}" ]
Renders the SQL of traced statements with params embeded @param boolean $enabled
[ "Renders", "the", "SQL", "of", "traced", "statements", "with", "params", "embeded" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataCollector/PDO/PDOCollector.php#L40-L44
train
maximebf/php-debugbar
src/DebugBar/DataCollector/PDO/PDOCollector.php
PDOCollector.addConnection
public function addConnection(TraceablePDO $pdo, $name = null) { if ($name === null) { $name = spl_object_hash($pdo); } $this->connections[$name] = $pdo; }
php
public function addConnection(TraceablePDO $pdo, $name = null) { if ($name === null) { $name = spl_object_hash($pdo); } $this->connections[$name] = $pdo; }
[ "public", "function", "addConnection", "(", "TraceablePDO", "$", "pdo", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "spl_object_hash", "(", "$", "pdo", ")", ";", "}", "$", "this", "->", "connections", "[", "$", "name", "]", "=", "$", "pdo", ";", "}" ]
Adds a new PDO instance to be collector @param TraceablePDO $pdo @param string $name Optional connection name
[ "Adds", "a", "new", "PDO", "instance", "to", "be", "collector" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataCollector/PDO/PDOCollector.php#L68-L74
train
maximebf/php-debugbar
src/DebugBar/DataCollector/PDO/PDOCollector.php
PDOCollector.collectPDO
protected function collectPDO(TraceablePDO $pdo, TimeDataCollector $timeCollector = null, $connectionName = null) { if (empty($connectionName) || $connectionName == 'default') { $connectionName = 'pdo'; } else { $connectionName = 'pdo ' . $connectionName; } $stmts = array(); foreach ($pdo->getExecutedStatements() as $stmt) { $stmts[] = array( 'sql' => $this->renderSqlWithParams ? $stmt->getSqlWithParams($this->sqlQuotationChar) : $stmt->getSql(), 'row_count' => $stmt->getRowCount(), 'stmt_id' => $stmt->getPreparedId(), 'prepared_stmt' => $stmt->getSql(), 'params' => (object) $stmt->getParameters(), 'duration' => $stmt->getDuration(), 'duration_str' => $this->getDataFormatter()->formatDuration($stmt->getDuration()), 'memory' => $stmt->getMemoryUsage(), 'memory_str' => $this->getDataFormatter()->formatBytes($stmt->getMemoryUsage()), 'end_memory' => $stmt->getEndMemory(), 'end_memory_str' => $this->getDataFormatter()->formatBytes($stmt->getEndMemory()), 'is_success' => $stmt->isSuccess(), 'error_code' => $stmt->getErrorCode(), 'error_message' => $stmt->getErrorMessage() ); if ($timeCollector !== null) { $timeCollector->addMeasure($stmt->getSql(), $stmt->getStartTime(), $stmt->getEndTime(), array(), $connectionName); } } return array( 'nb_statements' => count($stmts), 'nb_failed_statements' => count($pdo->getFailedExecutedStatements()), 'accumulated_duration' => $pdo->getAccumulatedStatementsDuration(), 'accumulated_duration_str' => $this->getDataFormatter()->formatDuration($pdo->getAccumulatedStatementsDuration()), 'memory_usage' => $pdo->getMemoryUsage(), 'memory_usage_str' => $this->getDataFormatter()->formatBytes($pdo->getPeakMemoryUsage()), 'peak_memory_usage' => $pdo->getPeakMemoryUsage(), 'peak_memory_usage_str' => $this->getDataFormatter()->formatBytes($pdo->getPeakMemoryUsage()), 'statements' => $stmts ); }
php
protected function collectPDO(TraceablePDO $pdo, TimeDataCollector $timeCollector = null, $connectionName = null) { if (empty($connectionName) || $connectionName == 'default') { $connectionName = 'pdo'; } else { $connectionName = 'pdo ' . $connectionName; } $stmts = array(); foreach ($pdo->getExecutedStatements() as $stmt) { $stmts[] = array( 'sql' => $this->renderSqlWithParams ? $stmt->getSqlWithParams($this->sqlQuotationChar) : $stmt->getSql(), 'row_count' => $stmt->getRowCount(), 'stmt_id' => $stmt->getPreparedId(), 'prepared_stmt' => $stmt->getSql(), 'params' => (object) $stmt->getParameters(), 'duration' => $stmt->getDuration(), 'duration_str' => $this->getDataFormatter()->formatDuration($stmt->getDuration()), 'memory' => $stmt->getMemoryUsage(), 'memory_str' => $this->getDataFormatter()->formatBytes($stmt->getMemoryUsage()), 'end_memory' => $stmt->getEndMemory(), 'end_memory_str' => $this->getDataFormatter()->formatBytes($stmt->getEndMemory()), 'is_success' => $stmt->isSuccess(), 'error_code' => $stmt->getErrorCode(), 'error_message' => $stmt->getErrorMessage() ); if ($timeCollector !== null) { $timeCollector->addMeasure($stmt->getSql(), $stmt->getStartTime(), $stmt->getEndTime(), array(), $connectionName); } } return array( 'nb_statements' => count($stmts), 'nb_failed_statements' => count($pdo->getFailedExecutedStatements()), 'accumulated_duration' => $pdo->getAccumulatedStatementsDuration(), 'accumulated_duration_str' => $this->getDataFormatter()->formatDuration($pdo->getAccumulatedStatementsDuration()), 'memory_usage' => $pdo->getMemoryUsage(), 'memory_usage_str' => $this->getDataFormatter()->formatBytes($pdo->getPeakMemoryUsage()), 'peak_memory_usage' => $pdo->getPeakMemoryUsage(), 'peak_memory_usage_str' => $this->getDataFormatter()->formatBytes($pdo->getPeakMemoryUsage()), 'statements' => $stmts ); }
[ "protected", "function", "collectPDO", "(", "TraceablePDO", "$", "pdo", ",", "TimeDataCollector", "$", "timeCollector", "=", "null", ",", "$", "connectionName", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "connectionName", ")", "||", "$", "connectionName", "==", "'default'", ")", "{", "$", "connectionName", "=", "'pdo'", ";", "}", "else", "{", "$", "connectionName", "=", "'pdo '", ".", "$", "connectionName", ";", "}", "$", "stmts", "=", "array", "(", ")", ";", "foreach", "(", "$", "pdo", "->", "getExecutedStatements", "(", ")", "as", "$", "stmt", ")", "{", "$", "stmts", "[", "]", "=", "array", "(", "'sql'", "=>", "$", "this", "->", "renderSqlWithParams", "?", "$", "stmt", "->", "getSqlWithParams", "(", "$", "this", "->", "sqlQuotationChar", ")", ":", "$", "stmt", "->", "getSql", "(", ")", ",", "'row_count'", "=>", "$", "stmt", "->", "getRowCount", "(", ")", ",", "'stmt_id'", "=>", "$", "stmt", "->", "getPreparedId", "(", ")", ",", "'prepared_stmt'", "=>", "$", "stmt", "->", "getSql", "(", ")", ",", "'params'", "=>", "(", "object", ")", "$", "stmt", "->", "getParameters", "(", ")", ",", "'duration'", "=>", "$", "stmt", "->", "getDuration", "(", ")", ",", "'duration_str'", "=>", "$", "this", "->", "getDataFormatter", "(", ")", "->", "formatDuration", "(", "$", "stmt", "->", "getDuration", "(", ")", ")", ",", "'memory'", "=>", "$", "stmt", "->", "getMemoryUsage", "(", ")", ",", "'memory_str'", "=>", "$", "this", "->", "getDataFormatter", "(", ")", "->", "formatBytes", "(", "$", "stmt", "->", "getMemoryUsage", "(", ")", ")", ",", "'end_memory'", "=>", "$", "stmt", "->", "getEndMemory", "(", ")", ",", "'end_memory_str'", "=>", "$", "this", "->", "getDataFormatter", "(", ")", "->", "formatBytes", "(", "$", "stmt", "->", "getEndMemory", "(", ")", ")", ",", "'is_success'", "=>", "$", "stmt", "->", "isSuccess", "(", ")", ",", "'error_code'", "=>", "$", "stmt", "->", "getErrorCode", "(", ")", ",", "'error_message'", "=>", "$", "stmt", "->", "getErrorMessage", "(", ")", ")", ";", "if", "(", "$", "timeCollector", "!==", "null", ")", "{", "$", "timeCollector", "->", "addMeasure", "(", "$", "stmt", "->", "getSql", "(", ")", ",", "$", "stmt", "->", "getStartTime", "(", ")", ",", "$", "stmt", "->", "getEndTime", "(", ")", ",", "array", "(", ")", ",", "$", "connectionName", ")", ";", "}", "}", "return", "array", "(", "'nb_statements'", "=>", "count", "(", "$", "stmts", ")", ",", "'nb_failed_statements'", "=>", "count", "(", "$", "pdo", "->", "getFailedExecutedStatements", "(", ")", ")", ",", "'accumulated_duration'", "=>", "$", "pdo", "->", "getAccumulatedStatementsDuration", "(", ")", ",", "'accumulated_duration_str'", "=>", "$", "this", "->", "getDataFormatter", "(", ")", "->", "formatDuration", "(", "$", "pdo", "->", "getAccumulatedStatementsDuration", "(", ")", ")", ",", "'memory_usage'", "=>", "$", "pdo", "->", "getMemoryUsage", "(", ")", ",", "'memory_usage_str'", "=>", "$", "this", "->", "getDataFormatter", "(", ")", "->", "formatBytes", "(", "$", "pdo", "->", "getPeakMemoryUsage", "(", ")", ")", ",", "'peak_memory_usage'", "=>", "$", "pdo", "->", "getPeakMemoryUsage", "(", ")", ",", "'peak_memory_usage_str'", "=>", "$", "this", "->", "getDataFormatter", "(", ")", "->", "formatBytes", "(", "$", "pdo", "->", "getPeakMemoryUsage", "(", ")", ")", ",", "'statements'", "=>", "$", "stmts", ")", ";", "}" ]
Collects data from a single TraceablePDO instance @param TraceablePDO $pdo @param TimeDataCollector $timeCollector @param string|null $connectionName the pdo connection (eg default | read | write) @return array
[ "Collects", "data", "from", "a", "single", "TraceablePDO", "instance" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataCollector/PDO/PDOCollector.php#L126-L167
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.getCloner
protected function getCloner() { if (!$this->cloner) { $clonerOptions = $this->getClonerOptions(); if (isset($clonerOptions['casters'])) { $this->cloner = new VarCloner($clonerOptions['casters']); } else { $this->cloner = new VarCloner(); } if (isset($clonerOptions['additional_casters'])) { $this->cloner->addCasters($clonerOptions['additional_casters']); } if (isset($clonerOptions['max_items'])) { $this->cloner->setMaxItems($clonerOptions['max_items']); } if (isset($clonerOptions['max_string'])) { $this->cloner->setMaxString($clonerOptions['max_string']); } // setMinDepth was added to Symfony 3.4: if (isset($clonerOptions['min_depth']) && method_exists($this->cloner, 'setMinDepth')) { $this->cloner->setMinDepth($clonerOptions['min_depth']); } } return $this->cloner; }
php
protected function getCloner() { if (!$this->cloner) { $clonerOptions = $this->getClonerOptions(); if (isset($clonerOptions['casters'])) { $this->cloner = new VarCloner($clonerOptions['casters']); } else { $this->cloner = new VarCloner(); } if (isset($clonerOptions['additional_casters'])) { $this->cloner->addCasters($clonerOptions['additional_casters']); } if (isset($clonerOptions['max_items'])) { $this->cloner->setMaxItems($clonerOptions['max_items']); } if (isset($clonerOptions['max_string'])) { $this->cloner->setMaxString($clonerOptions['max_string']); } // setMinDepth was added to Symfony 3.4: if (isset($clonerOptions['min_depth']) && method_exists($this->cloner, 'setMinDepth')) { $this->cloner->setMinDepth($clonerOptions['min_depth']); } } return $this->cloner; }
[ "protected", "function", "getCloner", "(", ")", "{", "if", "(", "!", "$", "this", "->", "cloner", ")", "{", "$", "clonerOptions", "=", "$", "this", "->", "getClonerOptions", "(", ")", ";", "if", "(", "isset", "(", "$", "clonerOptions", "[", "'casters'", "]", ")", ")", "{", "$", "this", "->", "cloner", "=", "new", "VarCloner", "(", "$", "clonerOptions", "[", "'casters'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "cloner", "=", "new", "VarCloner", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "clonerOptions", "[", "'additional_casters'", "]", ")", ")", "{", "$", "this", "->", "cloner", "->", "addCasters", "(", "$", "clonerOptions", "[", "'additional_casters'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "clonerOptions", "[", "'max_items'", "]", ")", ")", "{", "$", "this", "->", "cloner", "->", "setMaxItems", "(", "$", "clonerOptions", "[", "'max_items'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "clonerOptions", "[", "'max_string'", "]", ")", ")", "{", "$", "this", "->", "cloner", "->", "setMaxString", "(", "$", "clonerOptions", "[", "'max_string'", "]", ")", ";", "}", "// setMinDepth was added to Symfony 3.4:", "if", "(", "isset", "(", "$", "clonerOptions", "[", "'min_depth'", "]", ")", "&&", "method_exists", "(", "$", "this", "->", "cloner", ",", "'setMinDepth'", ")", ")", "{", "$", "this", "->", "cloner", "->", "setMinDepth", "(", "$", "clonerOptions", "[", "'min_depth'", "]", ")", ";", "}", "}", "return", "$", "this", "->", "cloner", ";", "}" ]
Gets the VarCloner instance with configuration options set. @return VarCloner
[ "Gets", "the", "VarCloner", "instance", "with", "configuration", "options", "set", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L56-L80
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.getDumper
protected function getDumper() { if (!$this->dumper) { $this->dumper = new DebugBarHtmlDumper(); $dumperOptions = $this->getDumperOptions(); if (isset($dumperOptions['styles'])) { $this->dumper->setStyles($dumperOptions['styles']); } } return $this->dumper; }
php
protected function getDumper() { if (!$this->dumper) { $this->dumper = new DebugBarHtmlDumper(); $dumperOptions = $this->getDumperOptions(); if (isset($dumperOptions['styles'])) { $this->dumper->setStyles($dumperOptions['styles']); } } return $this->dumper; }
[ "protected", "function", "getDumper", "(", ")", "{", "if", "(", "!", "$", "this", "->", "dumper", ")", "{", "$", "this", "->", "dumper", "=", "new", "DebugBarHtmlDumper", "(", ")", ";", "$", "dumperOptions", "=", "$", "this", "->", "getDumperOptions", "(", ")", ";", "if", "(", "isset", "(", "$", "dumperOptions", "[", "'styles'", "]", ")", ")", "{", "$", "this", "->", "dumper", "->", "setStyles", "(", "$", "dumperOptions", "[", "'styles'", "]", ")", ";", "}", "}", "return", "$", "this", "->", "dumper", ";", "}" ]
Gets the DebugBarHtmlDumper instance with configuration options set. @return DebugBarHtmlDumper
[ "Gets", "the", "DebugBarHtmlDumper", "instance", "with", "configuration", "options", "set", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L87-L97
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.getClonerOptions
public function getClonerOptions() { if ($this->clonerOptions === null) { $this->clonerOptions = self::$defaultClonerOptions; } return $this->clonerOptions; }
php
public function getClonerOptions() { if ($this->clonerOptions === null) { $this->clonerOptions = self::$defaultClonerOptions; } return $this->clonerOptions; }
[ "public", "function", "getClonerOptions", "(", ")", "{", "if", "(", "$", "this", "->", "clonerOptions", "===", "null", ")", "{", "$", "this", "->", "clonerOptions", "=", "self", "::", "$", "defaultClonerOptions", ";", "}", "return", "$", "this", "->", "clonerOptions", ";", "}" ]
Gets the array of non-default VarCloner configuration options. @return array
[ "Gets", "the", "array", "of", "non", "-", "default", "VarCloner", "configuration", "options", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L104-L110
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.mergeClonerOptions
public function mergeClonerOptions($options) { $this->clonerOptions = $options + $this->getClonerOptions(); $this->cloner = null; }
php
public function mergeClonerOptions($options) { $this->clonerOptions = $options + $this->getClonerOptions(); $this->cloner = null; }
[ "public", "function", "mergeClonerOptions", "(", "$", "options", ")", "{", "$", "this", "->", "clonerOptions", "=", "$", "options", "+", "$", "this", "->", "getClonerOptions", "(", ")", ";", "$", "this", "->", "cloner", "=", "null", ";", "}" ]
Merges an array of non-default VarCloner configuration options with the existing non-default options. Configuration options are: - casters: a map of VarDumper Caster objects to use instead of the default casters. - additional_casters: a map of VarDumper Caster objects to use in addition to the default casters. - max_items: maximum number of items to clone beyond the minimum depth. - max_string: maximum string size - min_depth: minimum tree depth to clone before counting items against the max_items limit. (Requires Symfony 3.4; ignored on older versions.) @param array $options
[ "Merges", "an", "array", "of", "non", "-", "default", "VarCloner", "configuration", "options", "with", "the", "existing", "non", "-", "default", "options", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L127-L131
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.resetClonerOptions
public function resetClonerOptions($options = null) { $this->clonerOptions = ($options ?: array()) + self::$defaultClonerOptions; $this->cloner = null; }
php
public function resetClonerOptions($options = null) { $this->clonerOptions = ($options ?: array()) + self::$defaultClonerOptions; $this->cloner = null; }
[ "public", "function", "resetClonerOptions", "(", "$", "options", "=", "null", ")", "{", "$", "this", "->", "clonerOptions", "=", "(", "$", "options", "?", ":", "array", "(", ")", ")", "+", "self", "::", "$", "defaultClonerOptions", ";", "$", "this", "->", "cloner", "=", "null", ";", "}" ]
Resets the array of non-default VarCloner configuration options without retaining any of the existing non-default options. Configuration options are: - casters: a map of VarDumper Caster objects to use instead of the default casters. - additional_casters: a map of VarDumper Caster objects to use in addition to the default casters. - max_items: maximum number of items to clone beyond the minimum depth. - max_string: maximum string size - min_depth: minimum tree depth to clone before counting items against the max_items limit. (Requires Symfony 3.4; ignored on older versions.) @param array $options
[ "Resets", "the", "array", "of", "non", "-", "default", "VarCloner", "configuration", "options", "without", "retaining", "any", "of", "the", "existing", "non", "-", "default", "options", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L148-L152
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.getDumperOptions
public function getDumperOptions() { if ($this->dumperOptions === null) { $this->dumperOptions = self::$defaultDumperOptions; } return $this->dumperOptions; }
php
public function getDumperOptions() { if ($this->dumperOptions === null) { $this->dumperOptions = self::$defaultDumperOptions; } return $this->dumperOptions; }
[ "public", "function", "getDumperOptions", "(", ")", "{", "if", "(", "$", "this", "->", "dumperOptions", "===", "null", ")", "{", "$", "this", "->", "dumperOptions", "=", "self", "::", "$", "defaultDumperOptions", ";", "}", "return", "$", "this", "->", "dumperOptions", ";", "}" ]
Gets the array of non-default HtmlDumper configuration options. @return array
[ "Gets", "the", "array", "of", "non", "-", "default", "HtmlDumper", "configuration", "options", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L159-L165
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.mergeDumperOptions
public function mergeDumperOptions($options) { $this->dumperOptions = $options + $this->getDumperOptions(); $this->dumper = null; }
php
public function mergeDumperOptions($options) { $this->dumperOptions = $options + $this->getDumperOptions(); $this->dumper = null; }
[ "public", "function", "mergeDumperOptions", "(", "$", "options", ")", "{", "$", "this", "->", "dumperOptions", "=", "$", "options", "+", "$", "this", "->", "getDumperOptions", "(", ")", ";", "$", "this", "->", "dumper", "=", "null", ";", "}" ]
Merges an array of non-default HtmlDumper configuration options with the existing non-default options. Configuration options are: - styles: a map of CSS styles to include in the assets, as documented in HtmlDumper::setStyles. - expanded_depth: the tree depth to initially expand. (Requires Symfony 3.2; ignored on older versions.) - max_string: maximum string size. (Requires Symfony 3.2; ignored on older versions.) - file_link_format: link format for files; %f expanded to file and %l expanded to line (Requires Symfony 3.2; ignored on older versions.) @param array $options
[ "Merges", "an", "array", "of", "non", "-", "default", "HtmlDumper", "configuration", "options", "with", "the", "existing", "non", "-", "default", "options", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L183-L187
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.resetDumperOptions
public function resetDumperOptions($options = null) { $this->dumperOptions = ($options ?: array()) + self::$defaultDumperOptions; $this->dumper = null; }
php
public function resetDumperOptions($options = null) { $this->dumperOptions = ($options ?: array()) + self::$defaultDumperOptions; $this->dumper = null; }
[ "public", "function", "resetDumperOptions", "(", "$", "options", "=", "null", ")", "{", "$", "this", "->", "dumperOptions", "=", "(", "$", "options", "?", ":", "array", "(", ")", ")", "+", "self", "::", "$", "defaultDumperOptions", ";", "$", "this", "->", "dumper", "=", "null", ";", "}" ]
Resets the array of non-default HtmlDumper configuration options without retaining any of the existing non-default options. Configuration options are: - styles: a map of CSS styles to include in the assets, as documented in HtmlDumper::setStyles. - expanded_depth: the tree depth to initially expand. (Requires Symfony 3.2; ignored on older versions.) - max_string: maximum string size. (Requires Symfony 3.2; ignored on older versions.) - file_link_format: link format for files; %f expanded to file and %l expanded to line (Requires Symfony 3.2; ignored on older versions.) @param array $options
[ "Resets", "the", "array", "of", "non", "-", "default", "HtmlDumper", "configuration", "options", "without", "retaining", "any", "of", "the", "existing", "non", "-", "default", "options", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L205-L209
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.getDisplayOptions
protected function getDisplayOptions() { $displayOptions = array(); $dumperOptions = $this->getDumperOptions(); // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['expanded_depth'])) { $displayOptions['maxDepth'] = $dumperOptions['expanded_depth']; } // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['max_string'])) { $displayOptions['maxStringLength'] = $dumperOptions['max_string']; } // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['file_link_format'])) { $displayOptions['fileLinkFormat'] = $dumperOptions['file_link_format']; } return $displayOptions; }
php
protected function getDisplayOptions() { $displayOptions = array(); $dumperOptions = $this->getDumperOptions(); // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['expanded_depth'])) { $displayOptions['maxDepth'] = $dumperOptions['expanded_depth']; } // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['max_string'])) { $displayOptions['maxStringLength'] = $dumperOptions['max_string']; } // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['file_link_format'])) { $displayOptions['fileLinkFormat'] = $dumperOptions['file_link_format']; } return $displayOptions; }
[ "protected", "function", "getDisplayOptions", "(", ")", "{", "$", "displayOptions", "=", "array", "(", ")", ";", "$", "dumperOptions", "=", "$", "this", "->", "getDumperOptions", "(", ")", ";", "// Only used by Symfony 3.2 and newer:", "if", "(", "isset", "(", "$", "dumperOptions", "[", "'expanded_depth'", "]", ")", ")", "{", "$", "displayOptions", "[", "'maxDepth'", "]", "=", "$", "dumperOptions", "[", "'expanded_depth'", "]", ";", "}", "// Only used by Symfony 3.2 and newer:", "if", "(", "isset", "(", "$", "dumperOptions", "[", "'max_string'", "]", ")", ")", "{", "$", "displayOptions", "[", "'maxStringLength'", "]", "=", "$", "dumperOptions", "[", "'max_string'", "]", ";", "}", "// Only used by Symfony 3.2 and newer:", "if", "(", "isset", "(", "$", "dumperOptions", "[", "'file_link_format'", "]", ")", ")", "{", "$", "displayOptions", "[", "'fileLinkFormat'", "]", "=", "$", "dumperOptions", "[", "'file_link_format'", "]", ";", "}", "return", "$", "displayOptions", ";", "}" ]
Gets the display options for the HTML dumper. @return array
[ "Gets", "the", "display", "options", "for", "the", "HTML", "dumper", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L227-L244
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.renderCapturedVar
public function renderCapturedVar($capturedData, $seekPath = array()) { $data = unserialize($capturedData); // The seek method was added in Symfony 3.2; emulate the behavior via SeekingData for older // Symfony versions. if (!method_exists($data, 'seek')) { $data = new SeekingData($data->getRawData()); } foreach ($seekPath as $key) { $data = $data->seek($key); } return $this->dump($data); }
php
public function renderCapturedVar($capturedData, $seekPath = array()) { $data = unserialize($capturedData); // The seek method was added in Symfony 3.2; emulate the behavior via SeekingData for older // Symfony versions. if (!method_exists($data, 'seek')) { $data = new SeekingData($data->getRawData()); } foreach ($seekPath as $key) { $data = $data->seek($key); } return $this->dump($data); }
[ "public", "function", "renderCapturedVar", "(", "$", "capturedData", ",", "$", "seekPath", "=", "array", "(", ")", ")", "{", "$", "data", "=", "unserialize", "(", "$", "capturedData", ")", ";", "// The seek method was added in Symfony 3.2; emulate the behavior via SeekingData for older", "// Symfony versions.", "if", "(", "!", "method_exists", "(", "$", "data", ",", "'seek'", ")", ")", "{", "$", "data", "=", "new", "SeekingData", "(", "$", "data", "->", "getRawData", "(", ")", ")", ";", "}", "foreach", "(", "$", "seekPath", "as", "$", "key", ")", "{", "$", "data", "=", "$", "data", "->", "seek", "(", "$", "key", ")", ";", "}", "return", "$", "this", "->", "dump", "(", "$", "data", ")", ";", "}" ]
Renders previously-captured data from captureVar to HTML and returns it as a string. @param string $capturedData Captured data from captureVar. @param array $seekPath Pass an array of keys to traverse if you only want to render a subset of the data. @return string HTML rendering of the variable.
[ "Renders", "previously", "-", "captured", "data", "from", "captureVar", "to", "HTML", "and", "returns", "it", "as", "a", "string", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L254-L268
train
maximebf/php-debugbar
src/DebugBar/DataFormatter/DebugBarVarDumper.php
DebugBarVarDumper.dump
protected function dump(Data $data) { $dumper = $this->getDumper(); $output = fopen('php://memory', 'r+b'); $dumper->setOutput($output); $dumper->setDumpHeader(''); // we don't actually want a dump header // NOTE: Symfony 3.2 added the third $extraDisplayOptions parameter. Older versions will // safely ignore it. $dumper->dump($data, null, $this->getDisplayOptions()); $result = stream_get_contents($output, -1, 0); fclose($output); return $result; }
php
protected function dump(Data $data) { $dumper = $this->getDumper(); $output = fopen('php://memory', 'r+b'); $dumper->setOutput($output); $dumper->setDumpHeader(''); // we don't actually want a dump header // NOTE: Symfony 3.2 added the third $extraDisplayOptions parameter. Older versions will // safely ignore it. $dumper->dump($data, null, $this->getDisplayOptions()); $result = stream_get_contents($output, -1, 0); fclose($output); return $result; }
[ "protected", "function", "dump", "(", "Data", "$", "data", ")", "{", "$", "dumper", "=", "$", "this", "->", "getDumper", "(", ")", ";", "$", "output", "=", "fopen", "(", "'php://memory'", ",", "'r+b'", ")", ";", "$", "dumper", "->", "setOutput", "(", "$", "output", ")", ";", "$", "dumper", "->", "setDumpHeader", "(", "''", ")", ";", "// we don't actually want a dump header", "// NOTE: Symfony 3.2 added the third $extraDisplayOptions parameter. Older versions will", "// safely ignore it.", "$", "dumper", "->", "dump", "(", "$", "data", ",", "null", ",", "$", "this", "->", "getDisplayOptions", "(", ")", ")", ";", "$", "result", "=", "stream_get_contents", "(", "$", "output", ",", "-", "1", ",", "0", ")", ";", "fclose", "(", "$", "output", ")", ";", "return", "$", "result", ";", "}" ]
Helper function to dump a Data object to HTML. @param Data $data @return string
[ "Helper", "function", "to", "dump", "a", "Data", "object", "to", "HTML", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataFormatter/DebugBarVarDumper.php#L302-L314
train
maximebf/php-debugbar
src/DebugBar/DataCollector/MessagesCollector.php
MessagesCollector.getVarDumper
public function getVarDumper() { if ($this->varDumper === null) { $this->varDumper = DataCollector::getDefaultVarDumper(); } return $this->varDumper; }
php
public function getVarDumper() { if ($this->varDumper === null) { $this->varDumper = DataCollector::getDefaultVarDumper(); } return $this->varDumper; }
[ "public", "function", "getVarDumper", "(", ")", "{", "if", "(", "$", "this", "->", "varDumper", "===", "null", ")", "{", "$", "this", "->", "varDumper", "=", "DataCollector", "::", "getDefaultVarDumper", "(", ")", ";", "}", "return", "$", "this", "->", "varDumper", ";", "}" ]
Gets the variable dumper instance used by this collector @return DebugBarVarDumper
[ "Gets", "the", "variable", "dumper", "instance", "used", "by", "this", "collector" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataCollector/MessagesCollector.php#L84-L90
train
maximebf/php-debugbar
src/DebugBar/DataCollector/AggregatedCollector.php
AggregatedCollector.sort
protected function sort($data) { if (is_string($this->sort)) { $p = $this->sort; usort($data, function ($a, $b) use ($p) { if ($a[$p] == $b[$p]) { return 0; } return $a[$p] < $b[$p] ? -1 : 1; }); } elseif ($this->sort === true) { sort($data); } return $data; }
php
protected function sort($data) { if (is_string($this->sort)) { $p = $this->sort; usort($data, function ($a, $b) use ($p) { if ($a[$p] == $b[$p]) { return 0; } return $a[$p] < $b[$p] ? -1 : 1; }); } elseif ($this->sort === true) { sort($data); } return $data; }
[ "protected", "function", "sort", "(", "$", "data", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "sort", ")", ")", "{", "$", "p", "=", "$", "this", "->", "sort", ";", "usort", "(", "$", "data", ",", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "p", ")", "{", "if", "(", "$", "a", "[", "$", "p", "]", "==", "$", "b", "[", "$", "p", "]", ")", "{", "return", "0", ";", "}", "return", "$", "a", "[", "$", "p", "]", "<", "$", "b", "[", "$", "p", "]", "?", "-", "1", ":", "1", ";", "}", ")", ";", "}", "elseif", "(", "$", "this", "->", "sort", "===", "true", ")", "{", "sort", "(", "$", "data", ")", ";", "}", "return", "$", "data", ";", "}" ]
Sorts the collected data @param array $data @return array
[ "Sorts", "the", "collected", "data" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataCollector/AggregatedCollector.php#L126-L140
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.setOptions
public function setOptions(array $options) { if (array_key_exists('base_path', $options)) { $this->setBasePath($options['base_path']); } if (array_key_exists('base_url', $options)) { $this->setBaseUrl($options['base_url']); } if (array_key_exists('include_vendors', $options)) { $this->setIncludeVendors($options['include_vendors']); } if (array_key_exists('javascript_class', $options)) { $this->setJavascriptClass($options['javascript_class']); } if (array_key_exists('variable_name', $options)) { $this->setVariableName($options['variable_name']); } if (array_key_exists('initialization', $options)) { $this->setInitialization($options['initialization']); } if (array_key_exists('enable_jquery_noconflict', $options)) { $this->setEnableJqueryNoConflict($options['enable_jquery_noconflict']); } if (array_key_exists('use_requirejs', $options)) { $this->setUseRequireJs($options['use_requirejs']); } if (array_key_exists('controls', $options)) { foreach ($options['controls'] as $name => $control) { $this->addControl($name, $control); } } if (array_key_exists('disable_controls', $options)) { foreach ((array) $options['disable_controls'] as $name) { $this->disableControl($name); } } if (array_key_exists('ignore_collectors', $options)) { foreach ((array) $options['ignore_collectors'] as $name) { $this->ignoreCollector($name); } } if (array_key_exists('ajax_handler_classname', $options)) { $this->setAjaxHandlerClass($options['ajax_handler_classname']); } if (array_key_exists('ajax_handler_bind_to_jquery', $options)) { $this->setBindAjaxHandlerToJquery($options['ajax_handler_bind_to_jquery']); } if (array_key_exists('ajax_handler_auto_show', $options)) { $this->setAjaxHandlerAutoShow($options['ajax_handler_auto_show']); } if (array_key_exists('open_handler_classname', $options)) { $this->setOpenHandlerClass($options['open_handler_classname']); } if (array_key_exists('open_handler_url', $options)) { $this->setOpenHandlerUrl($options['open_handler_url']); } }
php
public function setOptions(array $options) { if (array_key_exists('base_path', $options)) { $this->setBasePath($options['base_path']); } if (array_key_exists('base_url', $options)) { $this->setBaseUrl($options['base_url']); } if (array_key_exists('include_vendors', $options)) { $this->setIncludeVendors($options['include_vendors']); } if (array_key_exists('javascript_class', $options)) { $this->setJavascriptClass($options['javascript_class']); } if (array_key_exists('variable_name', $options)) { $this->setVariableName($options['variable_name']); } if (array_key_exists('initialization', $options)) { $this->setInitialization($options['initialization']); } if (array_key_exists('enable_jquery_noconflict', $options)) { $this->setEnableJqueryNoConflict($options['enable_jquery_noconflict']); } if (array_key_exists('use_requirejs', $options)) { $this->setUseRequireJs($options['use_requirejs']); } if (array_key_exists('controls', $options)) { foreach ($options['controls'] as $name => $control) { $this->addControl($name, $control); } } if (array_key_exists('disable_controls', $options)) { foreach ((array) $options['disable_controls'] as $name) { $this->disableControl($name); } } if (array_key_exists('ignore_collectors', $options)) { foreach ((array) $options['ignore_collectors'] as $name) { $this->ignoreCollector($name); } } if (array_key_exists('ajax_handler_classname', $options)) { $this->setAjaxHandlerClass($options['ajax_handler_classname']); } if (array_key_exists('ajax_handler_bind_to_jquery', $options)) { $this->setBindAjaxHandlerToJquery($options['ajax_handler_bind_to_jquery']); } if (array_key_exists('ajax_handler_auto_show', $options)) { $this->setAjaxHandlerAutoShow($options['ajax_handler_auto_show']); } if (array_key_exists('open_handler_classname', $options)) { $this->setOpenHandlerClass($options['open_handler_classname']); } if (array_key_exists('open_handler_url', $options)) { $this->setOpenHandlerUrl($options['open_handler_url']); } }
[ "public", "function", "setOptions", "(", "array", "$", "options", ")", "{", "if", "(", "array_key_exists", "(", "'base_path'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setBasePath", "(", "$", "options", "[", "'base_path'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'base_url'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setBaseUrl", "(", "$", "options", "[", "'base_url'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'include_vendors'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setIncludeVendors", "(", "$", "options", "[", "'include_vendors'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'javascript_class'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setJavascriptClass", "(", "$", "options", "[", "'javascript_class'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'variable_name'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setVariableName", "(", "$", "options", "[", "'variable_name'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'initialization'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setInitialization", "(", "$", "options", "[", "'initialization'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'enable_jquery_noconflict'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setEnableJqueryNoConflict", "(", "$", "options", "[", "'enable_jquery_noconflict'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'use_requirejs'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setUseRequireJs", "(", "$", "options", "[", "'use_requirejs'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'controls'", ",", "$", "options", ")", ")", "{", "foreach", "(", "$", "options", "[", "'controls'", "]", "as", "$", "name", "=>", "$", "control", ")", "{", "$", "this", "->", "addControl", "(", "$", "name", ",", "$", "control", ")", ";", "}", "}", "if", "(", "array_key_exists", "(", "'disable_controls'", ",", "$", "options", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "options", "[", "'disable_controls'", "]", "as", "$", "name", ")", "{", "$", "this", "->", "disableControl", "(", "$", "name", ")", ";", "}", "}", "if", "(", "array_key_exists", "(", "'ignore_collectors'", ",", "$", "options", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "options", "[", "'ignore_collectors'", "]", "as", "$", "name", ")", "{", "$", "this", "->", "ignoreCollector", "(", "$", "name", ")", ";", "}", "}", "if", "(", "array_key_exists", "(", "'ajax_handler_classname'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setAjaxHandlerClass", "(", "$", "options", "[", "'ajax_handler_classname'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'ajax_handler_bind_to_jquery'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setBindAjaxHandlerToJquery", "(", "$", "options", "[", "'ajax_handler_bind_to_jquery'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'ajax_handler_auto_show'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setAjaxHandlerAutoShow", "(", "$", "options", "[", "'ajax_handler_auto_show'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'open_handler_classname'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setOpenHandlerClass", "(", "$", "options", "[", "'open_handler_classname'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'open_handler_url'", ",", "$", "options", ")", ")", "{", "$", "this", "->", "setOpenHandlerUrl", "(", "$", "options", "[", "'open_handler_url'", "]", ")", ";", "}", "}" ]
Sets options from an array Options: - base_path - base_url - include_vendors - javascript_class - variable_name - initialization - enable_jquery_noconflict - controls - disable_controls - ignore_collectors - ajax_handler_classname - ajax_handler_bind_to_jquery - ajax_handler_auto_show - open_handler_classname - open_handler_url @param array $options [description]
[ "Sets", "options", "from", "an", "array" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L128-L184
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.setIncludeVendors
public function setIncludeVendors($enabled = true) { if (is_string($enabled)) { $enabled = array($enabled); } $this->includeVendors = $enabled; if (!$enabled || (is_array($enabled) && !in_array('js', $enabled))) { // no need to call jQuery.noConflict() if we do not include our own version $this->enableJqueryNoConflict = false; } return $this; }
php
public function setIncludeVendors($enabled = true) { if (is_string($enabled)) { $enabled = array($enabled); } $this->includeVendors = $enabled; if (!$enabled || (is_array($enabled) && !in_array('js', $enabled))) { // no need to call jQuery.noConflict() if we do not include our own version $this->enableJqueryNoConflict = false; } return $this; }
[ "public", "function", "setIncludeVendors", "(", "$", "enabled", "=", "true", ")", "{", "if", "(", "is_string", "(", "$", "enabled", ")", ")", "{", "$", "enabled", "=", "array", "(", "$", "enabled", ")", ";", "}", "$", "this", "->", "includeVendors", "=", "$", "enabled", ";", "if", "(", "!", "$", "enabled", "||", "(", "is_array", "(", "$", "enabled", ")", "&&", "!", "in_array", "(", "'js'", ",", "$", "enabled", ")", ")", ")", "{", "// no need to call jQuery.noConflict() if we do not include our own version", "$", "this", "->", "enableJqueryNoConflict", "=", "false", ";", "}", "return", "$", "this", ";", "}" ]
Whether to include vendor assets You can only include js or css vendors using setIncludeVendors('css') or setIncludeVendors('js') @param boolean $enabled
[ "Whether", "to", "include", "vendor", "assets" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L236-L249
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.disableVendor
public function disableVendor($name) { if (array_key_exists($name, $this->cssVendors)) { unset($this->cssVendors[$name]); } if (array_key_exists($name, $this->jsVendors)) { unset($this->jsVendors[$name]); } }
php
public function disableVendor($name) { if (array_key_exists($name, $this->cssVendors)) { unset($this->cssVendors[$name]); } if (array_key_exists($name, $this->jsVendors)) { unset($this->jsVendors[$name]); } }
[ "public", "function", "disableVendor", "(", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "cssVendors", ")", ")", "{", "unset", "(", "$", "this", "->", "cssVendors", "[", "$", "name", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "jsVendors", ")", ")", "{", "unset", "(", "$", "this", "->", "jsVendors", "[", "$", "name", "]", ")", ";", "}", "}" ]
Disable a specific vendor's assets. @param string $name "jquery", "fontawesome", "highlightjs" @return void
[ "Disable", "a", "specific", "vendor", "s", "assets", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L268-L276
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.addControl
public function addControl($name, array $options) { if (count(array_intersect(array_keys($options), array('icon', 'widget', 'tab', 'indicator'))) === 0) { throw new DebugBarException("Not enough options for control '$name'"); } $this->controls[$name] = $options; return $this; }
php
public function addControl($name, array $options) { if (count(array_intersect(array_keys($options), array('icon', 'widget', 'tab', 'indicator'))) === 0) { throw new DebugBarException("Not enough options for control '$name'"); } $this->controls[$name] = $options; return $this; }
[ "public", "function", "addControl", "(", "$", "name", ",", "array", "$", "options", ")", "{", "if", "(", "count", "(", "array_intersect", "(", "array_keys", "(", "$", "options", ")", ",", "array", "(", "'icon'", ",", "'widget'", ",", "'tab'", ",", "'indicator'", ")", ")", ")", "===", "0", ")", "{", "throw", "new", "DebugBarException", "(", "\"Not enough options for control '$name'\"", ")", ";", "}", "$", "this", "->", "controls", "[", "$", "name", "]", "=", "$", "options", ";", "return", "$", "this", ";", "}" ]
Adds a control to initialize Possible options: - icon: icon name - tooltip: string - widget: widget class name - title: tab title - map: a property name from the data to map the control to - default: a js string, default value of the data map "icon" or "widget" are at least needed @param string $name @param array $options
[ "Adds", "a", "control", "to", "initialize" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L404-L411
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.addAssets
public function addAssets($cssFiles, $jsFiles, $basePath = null, $baseUrl = null) { $this->additionalAssets[] = array( 'base_path' => $basePath, 'base_url' => $baseUrl, 'css' => (array) $cssFiles, 'js' => (array) $jsFiles ); return $this; }
php
public function addAssets($cssFiles, $jsFiles, $basePath = null, $baseUrl = null) { $this->additionalAssets[] = array( 'base_path' => $basePath, 'base_url' => $baseUrl, 'css' => (array) $cssFiles, 'js' => (array) $jsFiles ); return $this; }
[ "public", "function", "addAssets", "(", "$", "cssFiles", ",", "$", "jsFiles", ",", "$", "basePath", "=", "null", ",", "$", "baseUrl", "=", "null", ")", "{", "$", "this", "->", "additionalAssets", "[", "]", "=", "array", "(", "'base_path'", "=>", "$", "basePath", ",", "'base_url'", "=>", "$", "baseUrl", ",", "'css'", "=>", "(", "array", ")", "$", "cssFiles", ",", "'js'", "=>", "(", "array", ")", "$", "jsFiles", ")", ";", "return", "$", "this", ";", "}" ]
Add assets stored in files to render in the head @param array $cssFiles An array of filenames @param array $jsFiles An array of filenames @param string $basePath Base path of those files @param string $baseUrl Base url of those files @return $this
[ "Add", "assets", "stored", "in", "files", "to", "render", "in", "the", "head" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L595-L604
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.addInlineAssets
public function addInlineAssets($inlineCss, $inlineJs, $inlineHead) { $this->additionalAssets[] = array( 'inline_css' => (array) $inlineCss, 'inline_js' => (array) $inlineJs, 'inline_head' => (array) $inlineHead ); return $this; }
php
public function addInlineAssets($inlineCss, $inlineJs, $inlineHead) { $this->additionalAssets[] = array( 'inline_css' => (array) $inlineCss, 'inline_js' => (array) $inlineJs, 'inline_head' => (array) $inlineHead ); return $this; }
[ "public", "function", "addInlineAssets", "(", "$", "inlineCss", ",", "$", "inlineJs", ",", "$", "inlineHead", ")", "{", "$", "this", "->", "additionalAssets", "[", "]", "=", "array", "(", "'inline_css'", "=>", "(", "array", ")", "$", "inlineCss", ",", "'inline_js'", "=>", "(", "array", ")", "$", "inlineJs", ",", "'inline_head'", "=>", "(", "array", ")", "$", "inlineHead", ")", ";", "return", "$", "this", ";", "}" ]
Add inline assets to render inline in the head. Ideally, you should store static assets in files that you add with the addAssets function. However, adding inline assets is useful when integrating with 3rd-party libraries that require static assets that are only available in an inline format. The inline content arrays require special string array keys: they are used to deduplicate content. This is particularly useful if multiple instances of the same asset end up being added. Inline assets from all collectors are merged together into the same array, so these content IDs effectively deduplicate the inline assets. @param array $inlineCss An array map of content ID to inline CSS content (not including <style> tag) @param array $inlineJs An array map of content ID to inline JS content (not including <script> tag) @param array $inlineHead An array map of content ID to arbitrary inline HTML content (typically <style>/<script> tags); it must be embedded within the <head> element @return $this
[ "Add", "inline", "assets", "to", "render", "inline", "in", "the", "head", ".", "Ideally", "you", "should", "store", "static", "assets", "in", "files", "that", "you", "add", "with", "the", "addAssets", "function", ".", "However", "adding", "inline", "assets", "is", "useful", "when", "integrating", "with", "3rd", "-", "party", "libraries", "that", "require", "static", "assets", "that", "are", "only", "available", "in", "an", "inline", "format", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L623-L631
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.getRelativeRoot
protected function getRelativeRoot($relativeTo, $basePath, $baseUrl) { if ($relativeTo === self::RELATIVE_PATH) { return $basePath; } if ($relativeTo === self::RELATIVE_URL) { return $baseUrl; } return null; }
php
protected function getRelativeRoot($relativeTo, $basePath, $baseUrl) { if ($relativeTo === self::RELATIVE_PATH) { return $basePath; } if ($relativeTo === self::RELATIVE_URL) { return $baseUrl; } return null; }
[ "protected", "function", "getRelativeRoot", "(", "$", "relativeTo", ",", "$", "basePath", ",", "$", "baseUrl", ")", "{", "if", "(", "$", "relativeTo", "===", "self", "::", "RELATIVE_PATH", ")", "{", "return", "$", "basePath", ";", "}", "if", "(", "$", "relativeTo", "===", "self", "::", "RELATIVE_URL", ")", "{", "return", "$", "baseUrl", ";", "}", "return", "null", ";", "}" ]
Returns the correct base according to the type @param string $relativeTo @param string $basePath @param string $baseUrl @return string
[ "Returns", "the", "correct", "base", "according", "to", "the", "type" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L710-L719
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.createAsseticCollection
protected function createAsseticCollection($files = null, $content = null) { $assets = array(); if ($files) { foreach ($files as $file) { $assets[] = new \Assetic\Asset\FileAsset($file); } } if ($content) { foreach ($content as $item) { $assets[] = new \Assetic\Asset\StringAsset($item); } } return new \Assetic\Asset\AssetCollection($assets); }
php
protected function createAsseticCollection($files = null, $content = null) { $assets = array(); if ($files) { foreach ($files as $file) { $assets[] = new \Assetic\Asset\FileAsset($file); } } if ($content) { foreach ($content as $item) { $assets[] = new \Assetic\Asset\StringAsset($item); } } return new \Assetic\Asset\AssetCollection($assets); }
[ "protected", "function", "createAsseticCollection", "(", "$", "files", "=", "null", ",", "$", "content", "=", "null", ")", "{", "$", "assets", "=", "array", "(", ")", ";", "if", "(", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "assets", "[", "]", "=", "new", "\\", "Assetic", "\\", "Asset", "\\", "FileAsset", "(", "$", "file", ")", ";", "}", "}", "if", "(", "$", "content", ")", "{", "foreach", "(", "$", "content", "as", "$", "item", ")", "{", "$", "assets", "[", "]", "=", "new", "\\", "Assetic", "\\", "Asset", "\\", "StringAsset", "(", "$", "item", ")", ";", "}", "}", "return", "new", "\\", "Assetic", "\\", "Asset", "\\", "AssetCollection", "(", "$", "assets", ")", ";", "}" ]
Create an Assetic AssetCollection with the given content. Filenames will be converted to absolute path using the base path. @param array|null $files Array of asset filenames. @param array|null $content Array of inline asset content. @return \Assetic\Asset\AssetCollection
[ "Create", "an", "Assetic", "AssetCollection", "with", "the", "given", "content", ".", "Filenames", "will", "be", "converted", "to", "absolute", "path", "using", "the", "base", "path", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L795-L809
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.dumpCssAssets
public function dumpCssAssets($targetFilename = null) { $this->dumpAssets($this->getAssets('css'), $this->getAssets('inline_css'), $targetFilename); }
php
public function dumpCssAssets($targetFilename = null) { $this->dumpAssets($this->getAssets('css'), $this->getAssets('inline_css'), $targetFilename); }
[ "public", "function", "dumpCssAssets", "(", "$", "targetFilename", "=", "null", ")", "{", "$", "this", "->", "dumpAssets", "(", "$", "this", "->", "getAssets", "(", "'css'", ")", ",", "$", "this", "->", "getAssets", "(", "'inline_css'", ")", ",", "$", "targetFilename", ")", ";", "}" ]
Write all CSS assets to standard output or in a file @param string $targetFilename
[ "Write", "all", "CSS", "assets", "to", "standard", "output", "or", "in", "a", "file" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L816-L819
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.dumpJsAssets
public function dumpJsAssets($targetFilename = null) { $this->dumpAssets($this->getAssets('js'), $this->getAssets('inline_js'), $targetFilename, $this->useRequireJs); }
php
public function dumpJsAssets($targetFilename = null) { $this->dumpAssets($this->getAssets('js'), $this->getAssets('inline_js'), $targetFilename, $this->useRequireJs); }
[ "public", "function", "dumpJsAssets", "(", "$", "targetFilename", "=", "null", ")", "{", "$", "this", "->", "dumpAssets", "(", "$", "this", "->", "getAssets", "(", "'js'", ")", ",", "$", "this", "->", "getAssets", "(", "'inline_js'", ")", ",", "$", "targetFilename", ",", "$", "this", "->", "useRequireJs", ")", ";", "}" ]
Write all JS assets to standard output or in a file @param string $targetFilename
[ "Write", "all", "JS", "assets", "to", "standard", "output", "or", "in", "a", "file" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L826-L829
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.renderOnShutdown
public function renderOnShutdown($here = true, $initialize = true, $renderStackedData = true, $head = false) { register_shutdown_function(array($this, "replaceTagInBuffer"), $here, $initialize, $renderStackedData, $head); if (ob_get_level() === 0) { ob_start(); } return ($here) ? self::REPLACEABLE_TAG : ""; }
php
public function renderOnShutdown($here = true, $initialize = true, $renderStackedData = true, $head = false) { register_shutdown_function(array($this, "replaceTagInBuffer"), $here, $initialize, $renderStackedData, $head); if (ob_get_level() === 0) { ob_start(); } return ($here) ? self::REPLACEABLE_TAG : ""; }
[ "public", "function", "renderOnShutdown", "(", "$", "here", "=", "true", ",", "$", "initialize", "=", "true", ",", "$", "renderStackedData", "=", "true", ",", "$", "head", "=", "false", ")", "{", "register_shutdown_function", "(", "array", "(", "$", "this", ",", "\"replaceTagInBuffer\"", ")", ",", "$", "here", ",", "$", "initialize", ",", "$", "renderStackedData", ",", "$", "head", ")", ";", "if", "(", "ob_get_level", "(", ")", "===", "0", ")", "{", "ob_start", "(", ")", ";", "}", "return", "(", "$", "here", ")", "?", "self", "::", "REPLACEABLE_TAG", ":", "\"\"", ";", "}" ]
Register shutdown to display the debug bar @param boolean $here Set position of HTML. True if is to current position or false for end file @param boolean $initialize Whether to render the de bug bar initialization code @param bool $renderStackedData @param bool $head @return string Return "{--DEBUGBAR_OB_START_REPLACE_ME--}" or return an empty string if $here == false
[ "Register", "shutdown", "to", "display", "the", "debug", "bar" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L921-L930
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.render
public function render($initialize = true, $renderStackedData = true) { $js = ''; if ($initialize) { $js = $this->getJsInitializationCode(); } if ($renderStackedData && $this->debugBar->hasStackedData()) { foreach ($this->debugBar->getStackedData() as $id => $data) { $js .= $this->getAddDatasetCode($id, $data, '(stacked)'); } } $suffix = !$initialize ? '(ajax)' : null; $js .= $this->getAddDatasetCode($this->debugBar->getCurrentRequestId(), $this->debugBar->getData(), $suffix); if ($this->useRequireJs){ return "<script type=\"text/javascript\">\nrequire(['debugbar'], function(PhpDebugBar){ $js });\n</script>\n"; } else { return "<script type=\"text/javascript\">\n$js\n</script>\n"; } }
php
public function render($initialize = true, $renderStackedData = true) { $js = ''; if ($initialize) { $js = $this->getJsInitializationCode(); } if ($renderStackedData && $this->debugBar->hasStackedData()) { foreach ($this->debugBar->getStackedData() as $id => $data) { $js .= $this->getAddDatasetCode($id, $data, '(stacked)'); } } $suffix = !$initialize ? '(ajax)' : null; $js .= $this->getAddDatasetCode($this->debugBar->getCurrentRequestId(), $this->debugBar->getData(), $suffix); if ($this->useRequireJs){ return "<script type=\"text/javascript\">\nrequire(['debugbar'], function(PhpDebugBar){ $js });\n</script>\n"; } else { return "<script type=\"text/javascript\">\n$js\n</script>\n"; } }
[ "public", "function", "render", "(", "$", "initialize", "=", "true", ",", "$", "renderStackedData", "=", "true", ")", "{", "$", "js", "=", "''", ";", "if", "(", "$", "initialize", ")", "{", "$", "js", "=", "$", "this", "->", "getJsInitializationCode", "(", ")", ";", "}", "if", "(", "$", "renderStackedData", "&&", "$", "this", "->", "debugBar", "->", "hasStackedData", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "debugBar", "->", "getStackedData", "(", ")", "as", "$", "id", "=>", "$", "data", ")", "{", "$", "js", ".=", "$", "this", "->", "getAddDatasetCode", "(", "$", "id", ",", "$", "data", ",", "'(stacked)'", ")", ";", "}", "}", "$", "suffix", "=", "!", "$", "initialize", "?", "'(ajax)'", ":", "null", ";", "$", "js", ".=", "$", "this", "->", "getAddDatasetCode", "(", "$", "this", "->", "debugBar", "->", "getCurrentRequestId", "(", ")", ",", "$", "this", "->", "debugBar", "->", "getData", "(", ")", ",", "$", "suffix", ")", ";", "if", "(", "$", "this", "->", "useRequireJs", ")", "{", "return", "\"<script type=\\\"text/javascript\\\">\\nrequire(['debugbar'], function(PhpDebugBar){ $js });\\n</script>\\n\"", ";", "}", "else", "{", "return", "\"<script type=\\\"text/javascript\\\">\\n$js\\n</script>\\n\"", ";", "}", "}" ]
Returns the code needed to display the debug bar AJAX request should not render the initialization code. @param boolean $initialize Whether or not to render the debug bar initialization code @param boolean $renderStackedData Whether or not to render the stacked data @return string
[ "Returns", "the", "code", "needed", "to", "display", "the", "debug", "bar" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L976-L999
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.getJsControlsDefinitionCode
protected function getJsControlsDefinitionCode($varname) { $js = ''; $dataMap = array(); $excludedOptions = array('indicator', 'tab', 'map', 'default', 'widget', 'position'); // finds controls provided by collectors $widgets = array(); foreach ($this->debugBar->getCollectors() as $collector) { if (($collector instanceof Renderable) && !in_array($collector->getName(), $this->ignoredCollectors)) { if ($w = $collector->getWidgets()) { $widgets = array_merge($widgets, $w); } } } $controls = array_merge($widgets, $this->controls); foreach (array_filter($controls) as $name => $options) { $opts = array_diff_key($options, array_flip($excludedOptions)); if (isset($options['tab']) || isset($options['widget'])) { if (!isset($opts['title'])) { $opts['title'] = ucfirst(str_replace('_', ' ', $name)); } $js .= sprintf("%s.addTab(\"%s\", new %s({%s%s}));\n", $varname, $name, isset($options['tab']) ? $options['tab'] : 'PhpDebugBar.DebugBar.Tab', substr(json_encode($opts, JSON_FORCE_OBJECT), 1, -1), isset($options['widget']) ? sprintf('%s"widget": new %s()', count($opts) ? ', ' : '', $options['widget']) : '' ); } elseif (isset($options['indicator']) || isset($options['icon'])) { $js .= sprintf("%s.addIndicator(\"%s\", new %s(%s), \"%s\");\n", $varname, $name, isset($options['indicator']) ? $options['indicator'] : 'PhpDebugBar.DebugBar.Indicator', json_encode($opts, JSON_FORCE_OBJECT), isset($options['position']) ? $options['position'] : 'right' ); } if (isset($options['map']) && isset($options['default'])) { $dataMap[$name] = array($options['map'], $options['default']); } } // creates the data mapping object $mapJson = array(); foreach ($dataMap as $name => $values) { $mapJson[] = sprintf('"%s": ["%s", %s]', $name, $values[0], $values[1]); } $js .= sprintf("%s.setDataMap({\n%s\n});\n", $varname, implode(",\n", $mapJson)); // activate state restoration $js .= sprintf("%s.restoreState();\n", $varname); return $js; }
php
protected function getJsControlsDefinitionCode($varname) { $js = ''; $dataMap = array(); $excludedOptions = array('indicator', 'tab', 'map', 'default', 'widget', 'position'); // finds controls provided by collectors $widgets = array(); foreach ($this->debugBar->getCollectors() as $collector) { if (($collector instanceof Renderable) && !in_array($collector->getName(), $this->ignoredCollectors)) { if ($w = $collector->getWidgets()) { $widgets = array_merge($widgets, $w); } } } $controls = array_merge($widgets, $this->controls); foreach (array_filter($controls) as $name => $options) { $opts = array_diff_key($options, array_flip($excludedOptions)); if (isset($options['tab']) || isset($options['widget'])) { if (!isset($opts['title'])) { $opts['title'] = ucfirst(str_replace('_', ' ', $name)); } $js .= sprintf("%s.addTab(\"%s\", new %s({%s%s}));\n", $varname, $name, isset($options['tab']) ? $options['tab'] : 'PhpDebugBar.DebugBar.Tab', substr(json_encode($opts, JSON_FORCE_OBJECT), 1, -1), isset($options['widget']) ? sprintf('%s"widget": new %s()', count($opts) ? ', ' : '', $options['widget']) : '' ); } elseif (isset($options['indicator']) || isset($options['icon'])) { $js .= sprintf("%s.addIndicator(\"%s\", new %s(%s), \"%s\");\n", $varname, $name, isset($options['indicator']) ? $options['indicator'] : 'PhpDebugBar.DebugBar.Indicator', json_encode($opts, JSON_FORCE_OBJECT), isset($options['position']) ? $options['position'] : 'right' ); } if (isset($options['map']) && isset($options['default'])) { $dataMap[$name] = array($options['map'], $options['default']); } } // creates the data mapping object $mapJson = array(); foreach ($dataMap as $name => $values) { $mapJson[] = sprintf('"%s": ["%s", %s]', $name, $values[0], $values[1]); } $js .= sprintf("%s.setDataMap({\n%s\n});\n", $varname, implode(",\n", $mapJson)); // activate state restoration $js .= sprintf("%s.restoreState();\n", $varname); return $js; }
[ "protected", "function", "getJsControlsDefinitionCode", "(", "$", "varname", ")", "{", "$", "js", "=", "''", ";", "$", "dataMap", "=", "array", "(", ")", ";", "$", "excludedOptions", "=", "array", "(", "'indicator'", ",", "'tab'", ",", "'map'", ",", "'default'", ",", "'widget'", ",", "'position'", ")", ";", "// finds controls provided by collectors", "$", "widgets", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "debugBar", "->", "getCollectors", "(", ")", "as", "$", "collector", ")", "{", "if", "(", "(", "$", "collector", "instanceof", "Renderable", ")", "&&", "!", "in_array", "(", "$", "collector", "->", "getName", "(", ")", ",", "$", "this", "->", "ignoredCollectors", ")", ")", "{", "if", "(", "$", "w", "=", "$", "collector", "->", "getWidgets", "(", ")", ")", "{", "$", "widgets", "=", "array_merge", "(", "$", "widgets", ",", "$", "w", ")", ";", "}", "}", "}", "$", "controls", "=", "array_merge", "(", "$", "widgets", ",", "$", "this", "->", "controls", ")", ";", "foreach", "(", "array_filter", "(", "$", "controls", ")", "as", "$", "name", "=>", "$", "options", ")", "{", "$", "opts", "=", "array_diff_key", "(", "$", "options", ",", "array_flip", "(", "$", "excludedOptions", ")", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'tab'", "]", ")", "||", "isset", "(", "$", "options", "[", "'widget'", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "opts", "[", "'title'", "]", ")", ")", "{", "$", "opts", "[", "'title'", "]", "=", "ucfirst", "(", "str_replace", "(", "'_'", ",", "' '", ",", "$", "name", ")", ")", ";", "}", "$", "js", ".=", "sprintf", "(", "\"%s.addTab(\\\"%s\\\", new %s({%s%s}));\\n\"", ",", "$", "varname", ",", "$", "name", ",", "isset", "(", "$", "options", "[", "'tab'", "]", ")", "?", "$", "options", "[", "'tab'", "]", ":", "'PhpDebugBar.DebugBar.Tab'", ",", "substr", "(", "json_encode", "(", "$", "opts", ",", "JSON_FORCE_OBJECT", ")", ",", "1", ",", "-", "1", ")", ",", "isset", "(", "$", "options", "[", "'widget'", "]", ")", "?", "sprintf", "(", "'%s\"widget\": new %s()'", ",", "count", "(", "$", "opts", ")", "?", "', '", ":", "''", ",", "$", "options", "[", "'widget'", "]", ")", ":", "''", ")", ";", "}", "elseif", "(", "isset", "(", "$", "options", "[", "'indicator'", "]", ")", "||", "isset", "(", "$", "options", "[", "'icon'", "]", ")", ")", "{", "$", "js", ".=", "sprintf", "(", "\"%s.addIndicator(\\\"%s\\\", new %s(%s), \\\"%s\\\");\\n\"", ",", "$", "varname", ",", "$", "name", ",", "isset", "(", "$", "options", "[", "'indicator'", "]", ")", "?", "$", "options", "[", "'indicator'", "]", ":", "'PhpDebugBar.DebugBar.Indicator'", ",", "json_encode", "(", "$", "opts", ",", "JSON_FORCE_OBJECT", ")", ",", "isset", "(", "$", "options", "[", "'position'", "]", ")", "?", "$", "options", "[", "'position'", "]", ":", "'right'", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'map'", "]", ")", "&&", "isset", "(", "$", "options", "[", "'default'", "]", ")", ")", "{", "$", "dataMap", "[", "$", "name", "]", "=", "array", "(", "$", "options", "[", "'map'", "]", ",", "$", "options", "[", "'default'", "]", ")", ";", "}", "}", "// creates the data mapping object", "$", "mapJson", "=", "array", "(", ")", ";", "foreach", "(", "$", "dataMap", "as", "$", "name", "=>", "$", "values", ")", "{", "$", "mapJson", "[", "]", "=", "sprintf", "(", "'\"%s\": [\"%s\", %s]'", ",", "$", "name", ",", "$", "values", "[", "0", "]", ",", "$", "values", "[", "1", "]", ")", ";", "}", "$", "js", ".=", "sprintf", "(", "\"%s.setDataMap({\\n%s\\n});\\n\"", ",", "$", "varname", ",", "implode", "(", "\",\\n\"", ",", "$", "mapJson", ")", ")", ";", "// activate state restoration", "$", "js", ".=", "sprintf", "(", "\"%s.restoreState();\\n\"", ",", "$", "varname", ")", ";", "return", "$", "js", ";", "}" ]
Returns the js code needed to initialized the controls and data mapping of the debug bar Controls can be defined by collectors themselves or using {@see addControl()} @param string $varname Debug bar's variable name @return string
[ "Returns", "the", "js", "code", "needed", "to", "initialized", "the", "controls", "and", "data", "mapping", "of", "the", "debug", "bar" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L1049-L1106
train
maximebf/php-debugbar
src/DebugBar/JavascriptRenderer.php
JavascriptRenderer.getAddDatasetCode
protected function getAddDatasetCode($requestId, $data, $suffix = null) { $js = sprintf("%s.addDataSet(%s, \"%s\"%s);\n", $this->variableName, json_encode($data), $requestId, $suffix ? ", " . json_encode($suffix) : '' ); return $js; }
php
protected function getAddDatasetCode($requestId, $data, $suffix = null) { $js = sprintf("%s.addDataSet(%s, \"%s\"%s);\n", $this->variableName, json_encode($data), $requestId, $suffix ? ", " . json_encode($suffix) : '' ); return $js; }
[ "protected", "function", "getAddDatasetCode", "(", "$", "requestId", ",", "$", "data", ",", "$", "suffix", "=", "null", ")", "{", "$", "js", "=", "sprintf", "(", "\"%s.addDataSet(%s, \\\"%s\\\"%s);\\n\"", ",", "$", "this", "->", "variableName", ",", "json_encode", "(", "$", "data", ")", ",", "$", "requestId", ",", "$", "suffix", "?", "\", \"", ".", "json_encode", "(", "$", "suffix", ")", ":", "''", ")", ";", "return", "$", "js", ";", "}" ]
Returns the js code needed to add a dataset @param string $requestId @param array $data @param mixed $suffix @return string
[ "Returns", "the", "js", "code", "needed", "to", "add", "a", "dataset" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/JavascriptRenderer.php#L1116-L1125
train
maximebf/php-debugbar
src/DebugBar/Bridge/PropelCollector.php
PropelCollector.enablePropelProfiling
public static function enablePropelProfiling(PropelConfiguration $config = null) { if ($config === null) { $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); } $config->setParameter('debugpdo.logging.details.method.enabled', true); $config->setParameter('debugpdo.logging.details.time.enabled', true); $config->setParameter('debugpdo.logging.details.mem.enabled', true); $allMethods = array( 'PropelPDO::__construct', // logs connection opening 'PropelPDO::__destruct', // logs connection close 'PropelPDO::exec', // logs a query 'PropelPDO::query', // logs a query 'PropelPDO::beginTransaction', // logs a transaction begin 'PropelPDO::commit', // logs a transaction commit 'PropelPDO::rollBack', // logs a transaction rollBack (watch out for the capital 'B') 'DebugPDOStatement::execute', // logs a query from a prepared statement ); $config->setParameter('debugpdo.logging.methods', $allMethods, false); }
php
public static function enablePropelProfiling(PropelConfiguration $config = null) { if ($config === null) { $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); } $config->setParameter('debugpdo.logging.details.method.enabled', true); $config->setParameter('debugpdo.logging.details.time.enabled', true); $config->setParameter('debugpdo.logging.details.mem.enabled', true); $allMethods = array( 'PropelPDO::__construct', // logs connection opening 'PropelPDO::__destruct', // logs connection close 'PropelPDO::exec', // logs a query 'PropelPDO::query', // logs a query 'PropelPDO::beginTransaction', // logs a transaction begin 'PropelPDO::commit', // logs a transaction commit 'PropelPDO::rollBack', // logs a transaction rollBack (watch out for the capital 'B') 'DebugPDOStatement::execute', // logs a query from a prepared statement ); $config->setParameter('debugpdo.logging.methods', $allMethods, false); }
[ "public", "static", "function", "enablePropelProfiling", "(", "PropelConfiguration", "$", "config", "=", "null", ")", "{", "if", "(", "$", "config", "===", "null", ")", "{", "$", "config", "=", "Propel", "::", "getConfiguration", "(", "PropelConfiguration", "::", "TYPE_OBJECT", ")", ";", "}", "$", "config", "->", "setParameter", "(", "'debugpdo.logging.details.method.enabled'", ",", "true", ")", ";", "$", "config", "->", "setParameter", "(", "'debugpdo.logging.details.time.enabled'", ",", "true", ")", ";", "$", "config", "->", "setParameter", "(", "'debugpdo.logging.details.mem.enabled'", ",", "true", ")", ";", "$", "allMethods", "=", "array", "(", "'PropelPDO::__construct'", ",", "// logs connection opening", "'PropelPDO::__destruct'", ",", "// logs connection close", "'PropelPDO::exec'", ",", "// logs a query", "'PropelPDO::query'", ",", "// logs a query", "'PropelPDO::beginTransaction'", ",", "// logs a transaction begin", "'PropelPDO::commit'", ",", "// logs a transaction commit", "'PropelPDO::rollBack'", ",", "// logs a transaction rollBack (watch out for the capital 'B')", "'DebugPDOStatement::execute'", ",", "// logs a query from a prepared statement", ")", ";", "$", "config", "->", "setParameter", "(", "'debugpdo.logging.methods'", ",", "$", "allMethods", ",", "false", ")", ";", "}" ]
Sets the needed configuration option in propel to enable query logging @param PropelConfiguration $config Apply profiling on a specific config
[ "Sets", "the", "needed", "configuration", "option", "in", "propel", "to", "enable", "query", "logging" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/Bridge/PropelCollector.php#L52-L71
train
maximebf/php-debugbar
src/DebugBar/OpenHandler.php
OpenHandler.handle
public function handle($request = null, $echo = true, $sendHeader = true) { if ($request === null) { $request = $_REQUEST; } $op = 'find'; if (isset($request['op'])) { $op = $request['op']; if (!in_array($op, array('find', 'get', 'clear'))) { throw new DebugBarException("Invalid operation '{$request['op']}'"); } } if ($sendHeader) { $this->debugBar->getHttpDriver()->setHeaders(array( 'Content-Type' => 'application/json' )); } $response = json_encode(call_user_func(array($this, $op), $request)); if ($echo) { echo $response; } return $response; }
php
public function handle($request = null, $echo = true, $sendHeader = true) { if ($request === null) { $request = $_REQUEST; } $op = 'find'; if (isset($request['op'])) { $op = $request['op']; if (!in_array($op, array('find', 'get', 'clear'))) { throw new DebugBarException("Invalid operation '{$request['op']}'"); } } if ($sendHeader) { $this->debugBar->getHttpDriver()->setHeaders(array( 'Content-Type' => 'application/json' )); } $response = json_encode(call_user_func(array($this, $op), $request)); if ($echo) { echo $response; } return $response; }
[ "public", "function", "handle", "(", "$", "request", "=", "null", ",", "$", "echo", "=", "true", ",", "$", "sendHeader", "=", "true", ")", "{", "if", "(", "$", "request", "===", "null", ")", "{", "$", "request", "=", "$", "_REQUEST", ";", "}", "$", "op", "=", "'find'", ";", "if", "(", "isset", "(", "$", "request", "[", "'op'", "]", ")", ")", "{", "$", "op", "=", "$", "request", "[", "'op'", "]", ";", "if", "(", "!", "in_array", "(", "$", "op", ",", "array", "(", "'find'", ",", "'get'", ",", "'clear'", ")", ")", ")", "{", "throw", "new", "DebugBarException", "(", "\"Invalid operation '{$request['op']}'\"", ")", ";", "}", "}", "if", "(", "$", "sendHeader", ")", "{", "$", "this", "->", "debugBar", "->", "getHttpDriver", "(", ")", "->", "setHeaders", "(", "array", "(", "'Content-Type'", "=>", "'application/json'", ")", ")", ";", "}", "$", "response", "=", "json_encode", "(", "call_user_func", "(", "array", "(", "$", "this", ",", "$", "op", ")", ",", "$", "request", ")", ")", ";", "if", "(", "$", "echo", ")", "{", "echo", "$", "response", ";", "}", "return", "$", "response", ";", "}" ]
Handles the current request @param array $request Request data @param bool $echo @param bool $sendHeader @return string @throws DebugBarException
[ "Handles", "the", "current", "request" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/OpenHandler.php#L41-L66
train
maximebf/php-debugbar
src/DebugBar/DataCollector/DataCollector.php
DataCollector.getVarDumper
public function getVarDumper() { if ($this->varDumper === null) { $this->varDumper = self::getDefaultVarDumper(); } return $this->varDumper; }
php
public function getVarDumper() { if ($this->varDumper === null) { $this->varDumper = self::getDefaultVarDumper(); } return $this->varDumper; }
[ "public", "function", "getVarDumper", "(", ")", "{", "if", "(", "$", "this", "->", "varDumper", "===", "null", ")", "{", "$", "this", "->", "varDumper", "=", "self", "::", "getDefaultVarDumper", "(", ")", ";", "}", "return", "$", "this", "->", "varDumper", ";", "}" ]
Gets the variable dumper instance used by this collector; note that collectors using this instance need to be sure to return the static assets provided by the variable dumper. @return DebugBarVarDumper
[ "Gets", "the", "variable", "dumper", "instance", "used", "by", "this", "collector", ";", "note", "that", "collectors", "using", "this", "instance", "need", "to", "be", "sure", "to", "return", "the", "static", "assets", "provided", "by", "the", "variable", "dumper", "." ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DataCollector/DataCollector.php#L141-L147
train
maximebf/php-debugbar
src/DebugBar/DebugBar.php
DebugBar.getCollector
public function getCollector($name) { if (!isset($this->collectors[$name])) { throw new DebugBarException("'$name' is not a registered collector"); } return $this->collectors[$name]; }
php
public function getCollector($name) { if (!isset($this->collectors[$name])) { throw new DebugBarException("'$name' is not a registered collector"); } return $this->collectors[$name]; }
[ "public", "function", "getCollector", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "collectors", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "DebugBarException", "(", "\"'$name' is not a registered collector\"", ")", ";", "}", "return", "$", "this", "->", "collectors", "[", "$", "name", "]", ";", "}" ]
Returns a data collector @param string $name @return DataCollectorInterface @throws DebugBarException
[ "Returns", "a", "data", "collector" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DebugBar.php#L89-L95
train
maximebf/php-debugbar
src/DebugBar/DebugBar.php
DebugBar.getCurrentRequestId
public function getCurrentRequestId() { if ($this->requestId === null) { $this->requestId = $this->getRequestIdGenerator()->generate(); } return $this->requestId; }
php
public function getCurrentRequestId() { if ($this->requestId === null) { $this->requestId = $this->getRequestIdGenerator()->generate(); } return $this->requestId; }
[ "public", "function", "getCurrentRequestId", "(", ")", "{", "if", "(", "$", "this", "->", "requestId", "===", "null", ")", "{", "$", "this", "->", "requestId", "=", "$", "this", "->", "getRequestIdGenerator", "(", ")", "->", "generate", "(", ")", ";", "}", "return", "$", "this", "->", "requestId", ";", "}" ]
Returns the id of the current request @return string
[ "Returns", "the", "id", "of", "the", "current", "request" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DebugBar.php#L135-L141
train
maximebf/php-debugbar
src/DebugBar/DebugBar.php
DebugBar.getDataAsHeaders
public function getDataAsHeaders($headerName = 'phpdebugbar', $maxHeaderLength = 4096, $maxTotalHeaderLength = 250000) { $data = rawurlencode(json_encode(array( 'id' => $this->getCurrentRequestId(), 'data' => $this->getData() ))); if (strlen($data) > $maxTotalHeaderLength) { $data = rawurlencode(json_encode(array( 'error' => 'Maximum header size exceeded' ))); } $chunks = array(); while (strlen($data) > $maxHeaderLength) { $chunks[] = substr($data, 0, $maxHeaderLength); $data = substr($data, $maxHeaderLength); } $chunks[] = $data; $headers = array(); for ($i = 0, $c = count($chunks); $i < $c; $i++) { $name = $headerName . ($i > 0 ? "-$i" : ''); $headers[$name] = $chunks[$i]; } return $headers; }
php
public function getDataAsHeaders($headerName = 'phpdebugbar', $maxHeaderLength = 4096, $maxTotalHeaderLength = 250000) { $data = rawurlencode(json_encode(array( 'id' => $this->getCurrentRequestId(), 'data' => $this->getData() ))); if (strlen($data) > $maxTotalHeaderLength) { $data = rawurlencode(json_encode(array( 'error' => 'Maximum header size exceeded' ))); } $chunks = array(); while (strlen($data) > $maxHeaderLength) { $chunks[] = substr($data, 0, $maxHeaderLength); $data = substr($data, $maxHeaderLength); } $chunks[] = $data; $headers = array(); for ($i = 0, $c = count($chunks); $i < $c; $i++) { $name = $headerName . ($i > 0 ? "-$i" : ''); $headers[$name] = $chunks[$i]; } return $headers; }
[ "public", "function", "getDataAsHeaders", "(", "$", "headerName", "=", "'phpdebugbar'", ",", "$", "maxHeaderLength", "=", "4096", ",", "$", "maxTotalHeaderLength", "=", "250000", ")", "{", "$", "data", "=", "rawurlencode", "(", "json_encode", "(", "array", "(", "'id'", "=>", "$", "this", "->", "getCurrentRequestId", "(", ")", ",", "'data'", "=>", "$", "this", "->", "getData", "(", ")", ")", ")", ")", ";", "if", "(", "strlen", "(", "$", "data", ")", ">", "$", "maxTotalHeaderLength", ")", "{", "$", "data", "=", "rawurlencode", "(", "json_encode", "(", "array", "(", "'error'", "=>", "'Maximum header size exceeded'", ")", ")", ")", ";", "}", "$", "chunks", "=", "array", "(", ")", ";", "while", "(", "strlen", "(", "$", "data", ")", ">", "$", "maxHeaderLength", ")", "{", "$", "chunks", "[", "]", "=", "substr", "(", "$", "data", ",", "0", ",", "$", "maxHeaderLength", ")", ";", "$", "data", "=", "substr", "(", "$", "data", ",", "$", "maxHeaderLength", ")", ";", "}", "$", "chunks", "[", "]", "=", "$", "data", ";", "$", "headers", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ",", "$", "c", "=", "count", "(", "$", "chunks", ")", ";", "$", "i", "<", "$", "c", ";", "$", "i", "++", ")", "{", "$", "name", "=", "$", "headerName", ".", "(", "$", "i", ">", "0", "?", "\"-$i\"", ":", "''", ")", ";", "$", "headers", "[", "$", "name", "]", "=", "$", "chunks", "[", "$", "i", "]", ";", "}", "return", "$", "headers", ";", "}" ]
Returns an array of HTTP headers containing the data @param string $headerName @param integer $maxHeaderLength @return array
[ "Returns", "an", "array", "of", "HTTP", "headers", "containing", "the", "data" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DebugBar.php#L277-L305
train
maximebf/php-debugbar
src/DebugBar/DebugBar.php
DebugBar.sendDataInHeaders
public function sendDataInHeaders($useOpenHandler = null, $headerName = 'phpdebugbar', $maxHeaderLength = 4096) { if ($useOpenHandler === null) { $useOpenHandler = self::$useOpenHandlerWhenSendingDataHeaders; } if ($useOpenHandler && $this->storage !== null) { $this->getData(); $headerName .= '-id'; $headers = array($headerName => $this->getCurrentRequestId()); } else { $headers = $this->getDataAsHeaders($headerName, $maxHeaderLength); } $this->getHttpDriver()->setHeaders($headers); return $this; }
php
public function sendDataInHeaders($useOpenHandler = null, $headerName = 'phpdebugbar', $maxHeaderLength = 4096) { if ($useOpenHandler === null) { $useOpenHandler = self::$useOpenHandlerWhenSendingDataHeaders; } if ($useOpenHandler && $this->storage !== null) { $this->getData(); $headerName .= '-id'; $headers = array($headerName => $this->getCurrentRequestId()); } else { $headers = $this->getDataAsHeaders($headerName, $maxHeaderLength); } $this->getHttpDriver()->setHeaders($headers); return $this; }
[ "public", "function", "sendDataInHeaders", "(", "$", "useOpenHandler", "=", "null", ",", "$", "headerName", "=", "'phpdebugbar'", ",", "$", "maxHeaderLength", "=", "4096", ")", "{", "if", "(", "$", "useOpenHandler", "===", "null", ")", "{", "$", "useOpenHandler", "=", "self", "::", "$", "useOpenHandlerWhenSendingDataHeaders", ";", "}", "if", "(", "$", "useOpenHandler", "&&", "$", "this", "->", "storage", "!==", "null", ")", "{", "$", "this", "->", "getData", "(", ")", ";", "$", "headerName", ".=", "'-id'", ";", "$", "headers", "=", "array", "(", "$", "headerName", "=>", "$", "this", "->", "getCurrentRequestId", "(", ")", ")", ";", "}", "else", "{", "$", "headers", "=", "$", "this", "->", "getDataAsHeaders", "(", "$", "headerName", ",", "$", "maxHeaderLength", ")", ";", "}", "$", "this", "->", "getHttpDriver", "(", ")", "->", "setHeaders", "(", "$", "headers", ")", ";", "return", "$", "this", ";", "}" ]
Sends the data through the HTTP headers @param bool $useOpenHandler @param string $headerName @param integer $maxHeaderLength @return $this
[ "Sends", "the", "data", "through", "the", "HTTP", "headers" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DebugBar.php#L315-L329
train
maximebf/php-debugbar
src/DebugBar/DebugBar.php
DebugBar.stackData
public function stackData() { $http = $this->initStackSession(); $data = null; if (!$this->isDataPersisted() || $this->stackAlwaysUseSessionStorage) { $data = $this->getData(); } elseif ($this->data === null) { $this->collect(); } $stack = $http->getSessionValue($this->stackSessionNamespace); $stack[$this->getCurrentRequestId()] = $data; $http->setSessionValue($this->stackSessionNamespace, $stack); return $this; }
php
public function stackData() { $http = $this->initStackSession(); $data = null; if (!$this->isDataPersisted() || $this->stackAlwaysUseSessionStorage) { $data = $this->getData(); } elseif ($this->data === null) { $this->collect(); } $stack = $http->getSessionValue($this->stackSessionNamespace); $stack[$this->getCurrentRequestId()] = $data; $http->setSessionValue($this->stackSessionNamespace, $stack); return $this; }
[ "public", "function", "stackData", "(", ")", "{", "$", "http", "=", "$", "this", "->", "initStackSession", "(", ")", ";", "$", "data", "=", "null", ";", "if", "(", "!", "$", "this", "->", "isDataPersisted", "(", ")", "||", "$", "this", "->", "stackAlwaysUseSessionStorage", ")", "{", "$", "data", "=", "$", "this", "->", "getData", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "data", "===", "null", ")", "{", "$", "this", "->", "collect", "(", ")", ";", "}", "$", "stack", "=", "$", "http", "->", "getSessionValue", "(", "$", "this", "->", "stackSessionNamespace", ")", ";", "$", "stack", "[", "$", "this", "->", "getCurrentRequestId", "(", ")", "]", "=", "$", "data", ";", "$", "http", "->", "setSessionValue", "(", "$", "this", "->", "stackSessionNamespace", ",", "$", "stack", ")", ";", "return", "$", "this", ";", "}" ]
Stacks the data in the session for later rendering
[ "Stacks", "the", "data", "in", "the", "session", "for", "later", "rendering" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DebugBar.php#L334-L349
train
maximebf/php-debugbar
src/DebugBar/DebugBar.php
DebugBar.hasStackedData
public function hasStackedData() { try { $http = $this->initStackSession(); } catch (DebugBarException $e) { return false; } return count($http->getSessionValue($this->stackSessionNamespace)) > 0; }
php
public function hasStackedData() { try { $http = $this->initStackSession(); } catch (DebugBarException $e) { return false; } return count($http->getSessionValue($this->stackSessionNamespace)) > 0; }
[ "public", "function", "hasStackedData", "(", ")", "{", "try", "{", "$", "http", "=", "$", "this", "->", "initStackSession", "(", ")", ";", "}", "catch", "(", "DebugBarException", "$", "e", ")", "{", "return", "false", ";", "}", "return", "count", "(", "$", "http", "->", "getSessionValue", "(", "$", "this", "->", "stackSessionNamespace", ")", ")", ">", "0", ";", "}" ]
Checks if there is stacked data in the session @return boolean
[ "Checks", "if", "there", "is", "stacked", "data", "in", "the", "session" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DebugBar.php#L356-L364
train
maximebf/php-debugbar
src/DebugBar/DebugBar.php
DebugBar.getStackedData
public function getStackedData($delete = true) { $http = $this->initStackSession(); $stackedData = $http->getSessionValue($this->stackSessionNamespace); if ($delete) { $http->deleteSessionValue($this->stackSessionNamespace); } $datasets = array(); if ($this->isDataPersisted() && !$this->stackAlwaysUseSessionStorage) { foreach ($stackedData as $id => $data) { $datasets[$id] = $this->getStorage()->get($id); } } else { $datasets = $stackedData; } return $datasets; }
php
public function getStackedData($delete = true) { $http = $this->initStackSession(); $stackedData = $http->getSessionValue($this->stackSessionNamespace); if ($delete) { $http->deleteSessionValue($this->stackSessionNamespace); } $datasets = array(); if ($this->isDataPersisted() && !$this->stackAlwaysUseSessionStorage) { foreach ($stackedData as $id => $data) { $datasets[$id] = $this->getStorage()->get($id); } } else { $datasets = $stackedData; } return $datasets; }
[ "public", "function", "getStackedData", "(", "$", "delete", "=", "true", ")", "{", "$", "http", "=", "$", "this", "->", "initStackSession", "(", ")", ";", "$", "stackedData", "=", "$", "http", "->", "getSessionValue", "(", "$", "this", "->", "stackSessionNamespace", ")", ";", "if", "(", "$", "delete", ")", "{", "$", "http", "->", "deleteSessionValue", "(", "$", "this", "->", "stackSessionNamespace", ")", ";", "}", "$", "datasets", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "isDataPersisted", "(", ")", "&&", "!", "$", "this", "->", "stackAlwaysUseSessionStorage", ")", "{", "foreach", "(", "$", "stackedData", "as", "$", "id", "=>", "$", "data", ")", "{", "$", "datasets", "[", "$", "id", "]", "=", "$", "this", "->", "getStorage", "(", ")", "->", "get", "(", "$", "id", ")", ";", "}", "}", "else", "{", "$", "datasets", "=", "$", "stackedData", ";", "}", "return", "$", "datasets", ";", "}" ]
Returns the data stacked in the session @param boolean $delete Whether to delete the data in the session @return array
[ "Returns", "the", "data", "stacked", "in", "the", "session" ]
5d44b5e5bc27779438ccb9d5691d4716d396c326
https://github.com/maximebf/php-debugbar/blob/5d44b5e5bc27779438ccb9d5691d4716d396c326/src/DebugBar/DebugBar.php#L372-L390
train
Rudloff/alltube
classes/ViewFactory.php
ViewFactory.create
public static function create(ContainerInterface $container, Request $request = null) { if (!isset($request)) { $request = $container['request']; } $view = new Smarty(__DIR__.'/../templates/'); if (in_array('https', $request->getHeader('X-Forwarded-Proto'))) { $request = $request->withUri($request->getUri()->withScheme('https')->withPort(443)); } $smartyPlugins = new SmartyPlugins($container['router'], $request->getUri()->withUserInfo(null)); $view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']); $view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']); return $view; }
php
public static function create(ContainerInterface $container, Request $request = null) { if (!isset($request)) { $request = $container['request']; } $view = new Smarty(__DIR__.'/../templates/'); if (in_array('https', $request->getHeader('X-Forwarded-Proto'))) { $request = $request->withUri($request->getUri()->withScheme('https')->withPort(443)); } $smartyPlugins = new SmartyPlugins($container['router'], $request->getUri()->withUserInfo(null)); $view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']); $view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']); return $view; }
[ "public", "static", "function", "create", "(", "ContainerInterface", "$", "container", ",", "Request", "$", "request", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "request", ")", ")", "{", "$", "request", "=", "$", "container", "[", "'request'", "]", ";", "}", "$", "view", "=", "new", "Smarty", "(", "__DIR__", ".", "'/../templates/'", ")", ";", "if", "(", "in_array", "(", "'https'", ",", "$", "request", "->", "getHeader", "(", "'X-Forwarded-Proto'", ")", ")", ")", "{", "$", "request", "=", "$", "request", "->", "withUri", "(", "$", "request", "->", "getUri", "(", ")", "->", "withScheme", "(", "'https'", ")", "->", "withPort", "(", "443", ")", ")", ";", "}", "$", "smartyPlugins", "=", "new", "SmartyPlugins", "(", "$", "container", "[", "'router'", "]", ",", "$", "request", "->", "getUri", "(", ")", "->", "withUserInfo", "(", "null", ")", ")", ";", "$", "view", "->", "registerPlugin", "(", "'function'", ",", "'path_for'", ",", "[", "$", "smartyPlugins", ",", "'pathFor'", "]", ")", ";", "$", "view", "->", "registerPlugin", "(", "'function'", ",", "'base_url'", ",", "[", "$", "smartyPlugins", ",", "'baseUrl'", "]", ")", ";", "return", "$", "view", ";", "}" ]
Create Smarty view object. @param ContainerInterface $container Slim dependency container @param Request $request PSR-7 request @return Smarty
[ "Create", "Smarty", "view", "object", "." ]
a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a
https://github.com/Rudloff/alltube/blob/a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a/classes/ViewFactory.php#L26-L42
train
Rudloff/alltube
classes/Video.php
Video.getProcess
private static function getProcess(array $arguments) { $config = Config::getInstance(); return new Process( array_merge( [$config->python, $config->youtubedl], $config->params, $arguments ) ); }
php
private static function getProcess(array $arguments) { $config = Config::getInstance(); return new Process( array_merge( [$config->python, $config->youtubedl], $config->params, $arguments ) ); }
[ "private", "static", "function", "getProcess", "(", "array", "$", "arguments", ")", "{", "$", "config", "=", "Config", "::", "getInstance", "(", ")", ";", "return", "new", "Process", "(", "array_merge", "(", "[", "$", "config", "->", "python", ",", "$", "config", "->", "youtubedl", "]", ",", "$", "config", "->", "params", ",", "$", "arguments", ")", ")", ";", "}" ]
Return a youtube-dl process with the specified arguments. @param string[] $arguments Arguments @return Process
[ "Return", "a", "youtube", "-", "dl", "process", "with", "the", "specified", "arguments", "." ]
a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a
https://github.com/Rudloff/alltube/blob/a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a/classes/Video.php#L97-L108
train
Rudloff/alltube
classes/Video.php
Video.callYoutubedl
private static function callYoutubedl(array $arguments) { $config = Config::getInstance(); $process = self::getProcess($arguments); //This is needed by the openload extractor because it runs PhantomJS $process->setEnv(['PATH'=>$config->phantomjsDir]); $process->inheritEnvironmentVariables(); $process->run(); if (!$process->isSuccessful()) { $errorOutput = trim($process->getErrorOutput()); $exitCode = $process->getExitCode(); if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') { throw new PasswordException($errorOutput, $exitCode); } elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') { throw new Exception(_('Wrong password'), $exitCode); } else { throw new Exception($errorOutput, $exitCode); } } else { return trim($process->getOutput()); } }
php
private static function callYoutubedl(array $arguments) { $config = Config::getInstance(); $process = self::getProcess($arguments); //This is needed by the openload extractor because it runs PhantomJS $process->setEnv(['PATH'=>$config->phantomjsDir]); $process->inheritEnvironmentVariables(); $process->run(); if (!$process->isSuccessful()) { $errorOutput = trim($process->getErrorOutput()); $exitCode = $process->getExitCode(); if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') { throw new PasswordException($errorOutput, $exitCode); } elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') { throw new Exception(_('Wrong password'), $exitCode); } else { throw new Exception($errorOutput, $exitCode); } } else { return trim($process->getOutput()); } }
[ "private", "static", "function", "callYoutubedl", "(", "array", "$", "arguments", ")", "{", "$", "config", "=", "Config", "::", "getInstance", "(", ")", ";", "$", "process", "=", "self", "::", "getProcess", "(", "$", "arguments", ")", ";", "//This is needed by the openload extractor because it runs PhantomJS", "$", "process", "->", "setEnv", "(", "[", "'PATH'", "=>", "$", "config", "->", "phantomjsDir", "]", ")", ";", "$", "process", "->", "inheritEnvironmentVariables", "(", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "$", "errorOutput", "=", "trim", "(", "$", "process", "->", "getErrorOutput", "(", ")", ")", ";", "$", "exitCode", "=", "$", "process", "->", "getExitCode", "(", ")", ";", "if", "(", "$", "errorOutput", "==", "'ERROR: This video is protected by a password, use the --video-password option'", ")", "{", "throw", "new", "PasswordException", "(", "$", "errorOutput", ",", "$", "exitCode", ")", ";", "}", "elseif", "(", "substr", "(", "$", "errorOutput", ",", "0", ",", "21", ")", "==", "'ERROR: Wrong password'", ")", "{", "throw", "new", "Exception", "(", "_", "(", "'Wrong password'", ")", ",", "$", "exitCode", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "$", "errorOutput", ",", "$", "exitCode", ")", ";", "}", "}", "else", "{", "return", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ";", "}", "}" ]
Call youtube-dl. @param array $arguments Arguments @throws PasswordException If the video is protected by a password and no password was specified @throws Exception If the password is wrong @throws Exception If youtube-dl returns an error @return string Result
[ "Call", "youtube", "-", "dl", "." ]
a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a
https://github.com/Rudloff/alltube/blob/a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a/classes/Video.php#L131-L153
train
Rudloff/alltube
classes/Video.php
Video.getProp
private function getProp($prop = 'dump-json') { $arguments = ['--'.$prop]; if (isset($this->webpageUrl)) { $arguments[] = $this->webpageUrl; } if (isset($this->requestedFormat)) { $arguments[] = '-f'; $arguments[] = $this->requestedFormat; } if (isset($this->password)) { $arguments[] = '--video-password'; $arguments[] = $this->password; } return $this::callYoutubedl($arguments); }
php
private function getProp($prop = 'dump-json') { $arguments = ['--'.$prop]; if (isset($this->webpageUrl)) { $arguments[] = $this->webpageUrl; } if (isset($this->requestedFormat)) { $arguments[] = '-f'; $arguments[] = $this->requestedFormat; } if (isset($this->password)) { $arguments[] = '--video-password'; $arguments[] = $this->password; } return $this::callYoutubedl($arguments); }
[ "private", "function", "getProp", "(", "$", "prop", "=", "'dump-json'", ")", "{", "$", "arguments", "=", "[", "'--'", ".", "$", "prop", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "webpageUrl", ")", ")", "{", "$", "arguments", "[", "]", "=", "$", "this", "->", "webpageUrl", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "requestedFormat", ")", ")", "{", "$", "arguments", "[", "]", "=", "'-f'", ";", "$", "arguments", "[", "]", "=", "$", "this", "->", "requestedFormat", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "password", ")", ")", "{", "$", "arguments", "[", "]", "=", "'--video-password'", ";", "$", "arguments", "[", "]", "=", "$", "this", "->", "password", ";", "}", "return", "$", "this", "::", "callYoutubedl", "(", "$", "arguments", ")", ";", "}" ]
Get a property from youtube-dl. @param string $prop Property @return string
[ "Get", "a", "property", "from", "youtube", "-", "dl", "." ]
a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a
https://github.com/Rudloff/alltube/blob/a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a/classes/Video.php#L162-L179
train
Rudloff/alltube
classes/Video.php
Video.getJson
public function getJson() { if (!isset($this->json)) { $this->json = json_decode($this->getProp('dump-single-json')); } return $this->json; }
php
public function getJson() { if (!isset($this->json)) { $this->json = json_decode($this->getProp('dump-single-json')); } return $this->json; }
[ "public", "function", "getJson", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "json", ")", ")", "{", "$", "this", "->", "json", "=", "json_decode", "(", "$", "this", "->", "getProp", "(", "'dump-single-json'", ")", ")", ";", "}", "return", "$", "this", "->", "json", ";", "}" ]
Get all information about a video. @return stdClass Decoded JSON
[ "Get", "all", "information", "about", "a", "video", "." ]
a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a
https://github.com/Rudloff/alltube/blob/a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a/classes/Video.php#L186-L193
train
Rudloff/alltube
classes/Video.php
Video.getUrl
public function getUrl() { // Cache the URLs. if (!isset($this->urls)) { $this->urls = explode("\n", $this->getProp('get-url')); if (empty($this->urls[0])) { throw new EmptyUrlException(_('youtube-dl returned an empty URL.')); } } return $this->urls; }
php
public function getUrl() { // Cache the URLs. if (!isset($this->urls)) { $this->urls = explode("\n", $this->getProp('get-url')); if (empty($this->urls[0])) { throw new EmptyUrlException(_('youtube-dl returned an empty URL.')); } } return $this->urls; }
[ "public", "function", "getUrl", "(", ")", "{", "// Cache the URLs.", "if", "(", "!", "isset", "(", "$", "this", "->", "urls", ")", ")", "{", "$", "this", "->", "urls", "=", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "getProp", "(", "'get-url'", ")", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "urls", "[", "0", "]", ")", ")", "{", "throw", "new", "EmptyUrlException", "(", "_", "(", "'youtube-dl returned an empty URL.'", ")", ")", ";", "}", "}", "return", "$", "this", "->", "urls", ";", "}" ]
Get URL of video from URL of page. It generally returns only one URL. But it can return two URLs when multiple formats are specified (eg. bestvideo+bestaudio). @return string[] URLs of video
[ "Get", "URL", "of", "video", "from", "URL", "of", "page", "." ]
a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a
https://github.com/Rudloff/alltube/blob/a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a/classes/Video.php#L230-L242
train
Rudloff/alltube
classes/Video.php
Video.getRtmpArguments
private function getRtmpArguments() { $arguments = []; if ($this->protocol == 'rtmp') { foreach ([ 'url' => '-rtmp_tcurl', 'webpage_url' => '-rtmp_pageurl', 'player_url' => '-rtmp_swfverify', 'flash_version' => '-rtmp_flashver', 'play_path' => '-rtmp_playpath', 'app' => '-rtmp_app', ] as $property => $option) { if (isset($this->{$property})) { $arguments[] = $option; $arguments[] = $this->{$property}; } } if (isset($this->rtmp_conn)) { foreach ($this->rtmp_conn as $conn) { $arguments[] = '-rtmp_conn'; $arguments[] = $conn; } } } return $arguments; }
php
private function getRtmpArguments() { $arguments = []; if ($this->protocol == 'rtmp') { foreach ([ 'url' => '-rtmp_tcurl', 'webpage_url' => '-rtmp_pageurl', 'player_url' => '-rtmp_swfverify', 'flash_version' => '-rtmp_flashver', 'play_path' => '-rtmp_playpath', 'app' => '-rtmp_app', ] as $property => $option) { if (isset($this->{$property})) { $arguments[] = $option; $arguments[] = $this->{$property}; } } if (isset($this->rtmp_conn)) { foreach ($this->rtmp_conn as $conn) { $arguments[] = '-rtmp_conn'; $arguments[] = $conn; } } } return $arguments; }
[ "private", "function", "getRtmpArguments", "(", ")", "{", "$", "arguments", "=", "[", "]", ";", "if", "(", "$", "this", "->", "protocol", "==", "'rtmp'", ")", "{", "foreach", "(", "[", "'url'", "=>", "'-rtmp_tcurl'", ",", "'webpage_url'", "=>", "'-rtmp_pageurl'", ",", "'player_url'", "=>", "'-rtmp_swfverify'", ",", "'flash_version'", "=>", "'-rtmp_flashver'", ",", "'play_path'", "=>", "'-rtmp_playpath'", ",", "'app'", "=>", "'-rtmp_app'", ",", "]", "as", "$", "property", "=>", "$", "option", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "{", "$", "property", "}", ")", ")", "{", "$", "arguments", "[", "]", "=", "$", "option", ";", "$", "arguments", "[", "]", "=", "$", "this", "->", "{", "$", "property", "}", ";", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "rtmp_conn", ")", ")", "{", "foreach", "(", "$", "this", "->", "rtmp_conn", "as", "$", "conn", ")", "{", "$", "arguments", "[", "]", "=", "'-rtmp_conn'", ";", "$", "arguments", "[", "]", "=", "$", "conn", ";", "}", "}", "}", "return", "$", "arguments", ";", "}" ]
Return arguments used to run rtmp for a specific video. @return array Arguments
[ "Return", "arguments", "used", "to", "run", "rtmp", "for", "a", "specific", "video", "." ]
a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a
https://github.com/Rudloff/alltube/blob/a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a/classes/Video.php#L278-L306
train
Rudloff/alltube
classes/Video.php
Video.getAvconvProcess
private function getAvconvProcess( $audioBitrate, $filetype = 'mp3', $audioOnly = true, $from = null, $to = null ) { if (!$this->checkCommand([$this->config->avconv, '-version'])) { throw new Exception(_('Can\'t find avconv or ffmpeg at ').$this->config->avconv.'.'); } $durationRegex = '/(\d+:)?(\d+:)?(\d+)/'; $afterArguments = []; if ($audioOnly) { $afterArguments[] = '-vn'; } if (!empty($from)) { if (!preg_match($durationRegex, $from)) { throw new Exception(_('Invalid start time: ').$from.'.'); } $afterArguments[] = '-ss'; $afterArguments[] = $from; } if (!empty($to)) { if (!preg_match($durationRegex, $to)) { throw new Exception(_('Invalid end time: ').$to.'.'); } $afterArguments[] = '-to'; $afterArguments[] = $to; } $urls = $this->getUrl(); $arguments = array_merge( [ $this->config->avconv, '-v', $this->config->avconvVerbosity, ], $this->getRtmpArguments(), [ '-i', $urls[0], '-f', $filetype, '-b:a', $audioBitrate.'k', ], $afterArguments, [ 'pipe:1', ] ); //Vimeo needs a correct user-agent $arguments[] = '-user_agent'; $arguments[] = $this->getProp('dump-user-agent'); return new Process($arguments); }
php
private function getAvconvProcess( $audioBitrate, $filetype = 'mp3', $audioOnly = true, $from = null, $to = null ) { if (!$this->checkCommand([$this->config->avconv, '-version'])) { throw new Exception(_('Can\'t find avconv or ffmpeg at ').$this->config->avconv.'.'); } $durationRegex = '/(\d+:)?(\d+:)?(\d+)/'; $afterArguments = []; if ($audioOnly) { $afterArguments[] = '-vn'; } if (!empty($from)) { if (!preg_match($durationRegex, $from)) { throw new Exception(_('Invalid start time: ').$from.'.'); } $afterArguments[] = '-ss'; $afterArguments[] = $from; } if (!empty($to)) { if (!preg_match($durationRegex, $to)) { throw new Exception(_('Invalid end time: ').$to.'.'); } $afterArguments[] = '-to'; $afterArguments[] = $to; } $urls = $this->getUrl(); $arguments = array_merge( [ $this->config->avconv, '-v', $this->config->avconvVerbosity, ], $this->getRtmpArguments(), [ '-i', $urls[0], '-f', $filetype, '-b:a', $audioBitrate.'k', ], $afterArguments, [ 'pipe:1', ] ); //Vimeo needs a correct user-agent $arguments[] = '-user_agent'; $arguments[] = $this->getProp('dump-user-agent'); return new Process($arguments); }
[ "private", "function", "getAvconvProcess", "(", "$", "audioBitrate", ",", "$", "filetype", "=", "'mp3'", ",", "$", "audioOnly", "=", "true", ",", "$", "from", "=", "null", ",", "$", "to", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "checkCommand", "(", "[", "$", "this", "->", "config", "->", "avconv", ",", "'-version'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "_", "(", "'Can\\'t find avconv or ffmpeg at '", ")", ".", "$", "this", "->", "config", "->", "avconv", ".", "'.'", ")", ";", "}", "$", "durationRegex", "=", "'/(\\d+:)?(\\d+:)?(\\d+)/'", ";", "$", "afterArguments", "=", "[", "]", ";", "if", "(", "$", "audioOnly", ")", "{", "$", "afterArguments", "[", "]", "=", "'-vn'", ";", "}", "if", "(", "!", "empty", "(", "$", "from", ")", ")", "{", "if", "(", "!", "preg_match", "(", "$", "durationRegex", ",", "$", "from", ")", ")", "{", "throw", "new", "Exception", "(", "_", "(", "'Invalid start time: '", ")", ".", "$", "from", ".", "'.'", ")", ";", "}", "$", "afterArguments", "[", "]", "=", "'-ss'", ";", "$", "afterArguments", "[", "]", "=", "$", "from", ";", "}", "if", "(", "!", "empty", "(", "$", "to", ")", ")", "{", "if", "(", "!", "preg_match", "(", "$", "durationRegex", ",", "$", "to", ")", ")", "{", "throw", "new", "Exception", "(", "_", "(", "'Invalid end time: '", ")", ".", "$", "to", ".", "'.'", ")", ";", "}", "$", "afterArguments", "[", "]", "=", "'-to'", ";", "$", "afterArguments", "[", "]", "=", "$", "to", ";", "}", "$", "urls", "=", "$", "this", "->", "getUrl", "(", ")", ";", "$", "arguments", "=", "array_merge", "(", "[", "$", "this", "->", "config", "->", "avconv", ",", "'-v'", ",", "$", "this", "->", "config", "->", "avconvVerbosity", ",", "]", ",", "$", "this", "->", "getRtmpArguments", "(", ")", ",", "[", "'-i'", ",", "$", "urls", "[", "0", "]", ",", "'-f'", ",", "$", "filetype", ",", "'-b:a'", ",", "$", "audioBitrate", ".", "'k'", ",", "]", ",", "$", "afterArguments", ",", "[", "'pipe:1'", ",", "]", ")", ";", "//Vimeo needs a correct user-agent", "$", "arguments", "[", "]", "=", "'-user_agent'", ";", "$", "arguments", "[", "]", "=", "$", "this", "->", "getProp", "(", "'dump-user-agent'", ")", ";", "return", "new", "Process", "(", "$", "arguments", ")", ";", "}" ]
Get a process that runs avconv in order to convert a video. @param int $audioBitrate Audio bitrate of the converted file @param string $filetype Filetype of the converted file @param bool $audioOnly True to return an audio-only file @param string $from Start the conversion at this time @param string $to End the conversion at this time @throws Exception If avconv/ffmpeg is missing @return Process Process
[ "Get", "a", "process", "that", "runs", "avconv", "in", "order", "to", "convert", "a", "video", "." ]
a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a
https://github.com/Rudloff/alltube/blob/a0811c6dc4a7ac6102aede1b439fa8e53ab1ed3a/classes/Video.php#L336-L394
train