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
stymiee/authnetjson
src/authnet/AuthnetWebhook.php
AuthnetWebhook.isValid
public function isValid() { $hashedBody = strtoupper(hash_hmac('sha512', $this->webhookJson, $this->signature)); return (isset($this->headers['X-ANET-SIGNATURE']) && strtoupper(explode('=', $this->headers['X-ANET-SIGNATURE'])[1]) === $hashedBody); }
php
public function isValid() { $hashedBody = strtoupper(hash_hmac('sha512', $this->webhookJson, $this->signature)); return (isset($this->headers['X-ANET-SIGNATURE']) && strtoupper(explode('=', $this->headers['X-ANET-SIGNATURE'])[1]) === $hashedBody); }
[ "public", "function", "isValid", "(", ")", "{", "$", "hashedBody", "=", "strtoupper", "(", "hash_hmac", "(", "'sha512'", ",", "$", "this", "->", "webhookJson", ",", "$", "this", "->", "signature", ")", ")", ";", "return", "(", "isset", "(", "$", "this", "->", "headers", "[", "'X-ANET-SIGNATURE'", "]", ")", "&&", "strtoupper", "(", "explode", "(", "'='", ",", "$", "this", "->", "headers", "[", "'X-ANET-SIGNATURE'", "]", ")", "[", "1", "]", ")", "===", "$", "hashedBody", ")", ";", "}" ]
Validates a webhook signature to determine if the webhook is valid @return bool
[ "Validates", "a", "webhook", "signature", "to", "determine", "if", "the", "webhook", "is", "valid" ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetWebhook.php#L109-L113
train
stymiee/authnetjson
src/authnet/AuthnetWebhook.php
AuthnetWebhook.getAllHeaders
protected function getAllHeaders() { if (function_exists('apache_request_headers')) { $headers = apache_request_headers(); } else { $headers = array_filter($_SERVER, function($key) { return strpos($key, 'HTTP_') === 0; }, ARRAY_FILTER_USE_KEY); } return $headers; }
php
protected function getAllHeaders() { if (function_exists('apache_request_headers')) { $headers = apache_request_headers(); } else { $headers = array_filter($_SERVER, function($key) { return strpos($key, 'HTTP_') === 0; }, ARRAY_FILTER_USE_KEY); } return $headers; }
[ "protected", "function", "getAllHeaders", "(", ")", "{", "if", "(", "function_exists", "(", "'apache_request_headers'", ")", ")", "{", "$", "headers", "=", "apache_request_headers", "(", ")", ";", "}", "else", "{", "$", "headers", "=", "array_filter", "(", "$", "_SERVER", ",", "function", "(", "$", "key", ")", "{", "return", "strpos", "(", "$", "key", ",", "'HTTP_'", ")", "===", "0", ";", "}", ",", "ARRAY_FILTER_USE_KEY", ")", ";", "}", "return", "$", "headers", ";", "}" ]
Retrieves all HTTP headers of a given request @return array
[ "Retrieves", "all", "HTTP", "headers", "of", "a", "given", "request" ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetWebhook.php#L130-L140
train
Aerendir/stripe-bundle
src/Service/StripeManager.php
StripeManager.callStripeApi
public function callStripeApi(string $endpoint, string $action, array $arguments) { try { switch (count($arguments)) { // Method with 1 argument only accept "options" case 1: // If the value is an empty array, then set it as null $options = empty($arguments['options']) ? null : $arguments['options']; $return = $endpoint::$action($options); break; case 2: // If the ID exists, we have to call for sure a method that in the signature has the ID and the options if (isset($arguments['id'])) { // If the value is an empty array, then set it as null $options = empty($arguments['options']) ? null : $arguments['options']; $return = $endpoint::$action($arguments['id'], $options); } // Else the method has params and options else { // If the value is an empty array, then set it as null $params = empty($arguments['params']) ? null : $arguments['params']; $options = empty($arguments['options']) ? null : $arguments['options']; $return = $endpoint::$action($params, $options); } break; // Method with 3 arguments accept id, params and options case 3: // If the value is an empty array, then set it as null $params = empty($arguments['params']) ? null : $arguments['params']; $options = empty($arguments['options']) ? null : $arguments['options']; $return = $endpoint::$action($arguments['id'], $params, $options); break; default: throw new \RuntimeException('The arguments passed don\'t correspond to the allowed number. Please, review them.'); } } catch (Base $e) { $return = $this->handleException($e); if ('retry' === $return) { $return = $this->callStripeApi($endpoint, $action, $arguments); } } // Reset the number of retries $this->retries = 0; return $return; }
php
public function callStripeApi(string $endpoint, string $action, array $arguments) { try { switch (count($arguments)) { // Method with 1 argument only accept "options" case 1: // If the value is an empty array, then set it as null $options = empty($arguments['options']) ? null : $arguments['options']; $return = $endpoint::$action($options); break; case 2: // If the ID exists, we have to call for sure a method that in the signature has the ID and the options if (isset($arguments['id'])) { // If the value is an empty array, then set it as null $options = empty($arguments['options']) ? null : $arguments['options']; $return = $endpoint::$action($arguments['id'], $options); } // Else the method has params and options else { // If the value is an empty array, then set it as null $params = empty($arguments['params']) ? null : $arguments['params']; $options = empty($arguments['options']) ? null : $arguments['options']; $return = $endpoint::$action($params, $options); } break; // Method with 3 arguments accept id, params and options case 3: // If the value is an empty array, then set it as null $params = empty($arguments['params']) ? null : $arguments['params']; $options = empty($arguments['options']) ? null : $arguments['options']; $return = $endpoint::$action($arguments['id'], $params, $options); break; default: throw new \RuntimeException('The arguments passed don\'t correspond to the allowed number. Please, review them.'); } } catch (Base $e) { $return = $this->handleException($e); if ('retry' === $return) { $return = $this->callStripeApi($endpoint, $action, $arguments); } } // Reset the number of retries $this->retries = 0; return $return; }
[ "public", "function", "callStripeApi", "(", "string", "$", "endpoint", ",", "string", "$", "action", ",", "array", "$", "arguments", ")", "{", "try", "{", "switch", "(", "count", "(", "$", "arguments", ")", ")", "{", "// Method with 1 argument only accept \"options\"", "case", "1", ":", "// If the value is an empty array, then set it as null", "$", "options", "=", "empty", "(", "$", "arguments", "[", "'options'", "]", ")", "?", "null", ":", "$", "arguments", "[", "'options'", "]", ";", "$", "return", "=", "$", "endpoint", "::", "$", "action", "(", "$", "options", ")", ";", "break", ";", "case", "2", ":", "// If the ID exists, we have to call for sure a method that in the signature has the ID and the options", "if", "(", "isset", "(", "$", "arguments", "[", "'id'", "]", ")", ")", "{", "// If the value is an empty array, then set it as null", "$", "options", "=", "empty", "(", "$", "arguments", "[", "'options'", "]", ")", "?", "null", ":", "$", "arguments", "[", "'options'", "]", ";", "$", "return", "=", "$", "endpoint", "::", "$", "action", "(", "$", "arguments", "[", "'id'", "]", ",", "$", "options", ")", ";", "}", "// Else the method has params and options", "else", "{", "// If the value is an empty array, then set it as null", "$", "params", "=", "empty", "(", "$", "arguments", "[", "'params'", "]", ")", "?", "null", ":", "$", "arguments", "[", "'params'", "]", ";", "$", "options", "=", "empty", "(", "$", "arguments", "[", "'options'", "]", ")", "?", "null", ":", "$", "arguments", "[", "'options'", "]", ";", "$", "return", "=", "$", "endpoint", "::", "$", "action", "(", "$", "params", ",", "$", "options", ")", ";", "}", "break", ";", "// Method with 3 arguments accept id, params and options", "case", "3", ":", "// If the value is an empty array, then set it as null", "$", "params", "=", "empty", "(", "$", "arguments", "[", "'params'", "]", ")", "?", "null", ":", "$", "arguments", "[", "'params'", "]", ";", "$", "options", "=", "empty", "(", "$", "arguments", "[", "'options'", "]", ")", "?", "null", ":", "$", "arguments", "[", "'options'", "]", ";", "$", "return", "=", "$", "endpoint", "::", "$", "action", "(", "$", "arguments", "[", "'id'", "]", ",", "$", "params", ",", "$", "options", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "RuntimeException", "(", "'The arguments passed don\\'t correspond to the allowed number. Please, review them.'", ")", ";", "}", "}", "catch", "(", "Base", "$", "e", ")", "{", "$", "return", "=", "$", "this", "->", "handleException", "(", "$", "e", ")", ";", "if", "(", "'retry'", "===", "$", "return", ")", "{", "$", "return", "=", "$", "this", "->", "callStripeApi", "(", "$", "endpoint", ",", "$", "action", ",", "$", "arguments", ")", ";", "}", "}", "// Reset the number of retries", "$", "this", "->", "retries", "=", "0", ";", "return", "$", "return", ";", "}" ]
Method to call the Stripe PHP SDK's static methods. This method wraps the calls in a try / catch statement to intercept exceptions raised by the Stripe client. It receives three arguments: 1) The FQN of the Stripe Entity class; 2) The method of the class to invoke; 3) The arguments to pass to the method. As the methods of the Stripe PHP SDK have all the same structure, it is possible to extract a pattern. So, the alternatives are as following: 1) options 2) id, options 3) params, options 4) id, params, options Only the case 2 and 3 are confusable. To make this method able to match the right Stripe SDK's method signature, always set all the required arguments. If one argument is not required (only options or params are allowed to be missed), anyway set it as an empty array. BUT ANYWAY SET IT to make the switch able to match the proper method signature. So, to call a Stripe API's entity with a method with signature that matches case 1: $arguments = [ 'options' => [...] // Or an empty array ]; $this->callStripe(Customer::class, 'save', $arguments) To call a Stripe API's entity with a method with signature that matches case 2: $arguments = [ 'id' => 'the_id_of_the_entity', 'options' => [...] // Or an empty array ]; $this->callStripe(Customer::class, 'save', $arguments) To call a Stripe API's entity with a method with signature that matches case 3: $arguments = [ 'params' => [...] // Or an empty array, 'options' => [...] // Or an empty array ]; $this->callStripe(Customer::class, 'save', $arguments) To call a Stripe API's entity with a method with signature that matches case 4: $arguments = [ 'id' => 'the_id_of_the_entity', 'params' => [...] // Or an empty array, 'options' => [...] // Or an empty array ]; $this->callStripe(Customer::class, 'save', $arguments) @param string $endpoint @param string $action @param array $arguments @return ApiResource|bool
[ "Method", "to", "call", "the", "Stripe", "PHP", "SDK", "s", "static", "methods", "." ]
5d74a3c2a133fe6d97e838cbcbecad939d32626f
https://github.com/Aerendir/stripe-bundle/blob/5d74a3c2a133fe6d97e838cbcbecad939d32626f/src/Service/StripeManager.php#L169-L216
train
Aerendir/stripe-bundle
src/Service/StripeManager.php
StripeManager.callStripeObject
public function callStripeObject(ApiResource $object, string $method, array $arguments = []) { try { switch (count($arguments)) { // Method has no signature (it doesn't accept any argument) case 0: $return = $object->$method(); break; // Method with 1 argument only accept one between "options" or "params" case 1: // So we simply use the unique value in the array $return = $object->$method($arguments[0]); break; // Method with 3 arguments accept id, params and options case 2: // If the value is an empty array, then set it as null $params = empty($arguments['params']) ? null : $arguments['params']; $options = empty($arguments['options']) ? null : $arguments['options']; $return = $object->$method($params, $options); break; default: throw new \RuntimeException('The arguments passed don\'t correspond to the allowed number. Please, review them.'); } } catch (Base $e) { $return = $this->handleException($e); if ('retry' === $return) { $return = $this->callStripeObject($object, $method); } } // Reset the number of retries $this->retries = 0; return $return; }
php
public function callStripeObject(ApiResource $object, string $method, array $arguments = []) { try { switch (count($arguments)) { // Method has no signature (it doesn't accept any argument) case 0: $return = $object->$method(); break; // Method with 1 argument only accept one between "options" or "params" case 1: // So we simply use the unique value in the array $return = $object->$method($arguments[0]); break; // Method with 3 arguments accept id, params and options case 2: // If the value is an empty array, then set it as null $params = empty($arguments['params']) ? null : $arguments['params']; $options = empty($arguments['options']) ? null : $arguments['options']; $return = $object->$method($params, $options); break; default: throw new \RuntimeException('The arguments passed don\'t correspond to the allowed number. Please, review them.'); } } catch (Base $e) { $return = $this->handleException($e); if ('retry' === $return) { $return = $this->callStripeObject($object, $method); } } // Reset the number of retries $this->retries = 0; return $return; }
[ "public", "function", "callStripeObject", "(", "ApiResource", "$", "object", ",", "string", "$", "method", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "try", "{", "switch", "(", "count", "(", "$", "arguments", ")", ")", "{", "// Method has no signature (it doesn't accept any argument)", "case", "0", ":", "$", "return", "=", "$", "object", "->", "$", "method", "(", ")", ";", "break", ";", "// Method with 1 argument only accept one between \"options\" or \"params\"", "case", "1", ":", "// So we simply use the unique value in the array", "$", "return", "=", "$", "object", "->", "$", "method", "(", "$", "arguments", "[", "0", "]", ")", ";", "break", ";", "// Method with 3 arguments accept id, params and options", "case", "2", ":", "// If the value is an empty array, then set it as null", "$", "params", "=", "empty", "(", "$", "arguments", "[", "'params'", "]", ")", "?", "null", ":", "$", "arguments", "[", "'params'", "]", ";", "$", "options", "=", "empty", "(", "$", "arguments", "[", "'options'", "]", ")", "?", "null", ":", "$", "arguments", "[", "'options'", "]", ";", "$", "return", "=", "$", "object", "->", "$", "method", "(", "$", "params", ",", "$", "options", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "RuntimeException", "(", "'The arguments passed don\\'t correspond to the allowed number. Please, review them.'", ")", ";", "}", "}", "catch", "(", "Base", "$", "e", ")", "{", "$", "return", "=", "$", "this", "->", "handleException", "(", "$", "e", ")", ";", "if", "(", "'retry'", "===", "$", "return", ")", "{", "$", "return", "=", "$", "this", "->", "callStripeObject", "(", "$", "object", ",", "$", "method", ")", ";", "}", "}", "// Reset the number of retries", "$", "this", "->", "retries", "=", "0", ";", "return", "$", "return", ";", "}" ]
Method to call the Stripe PHP SDK's NON static methods. This method is usually used to call methods of a Stripe entity that is already initialized. For example, it can be used to call "cancel" or "save" methods after they have been retrieved through $this->callStripe(...). This method wraps the calls in a try / catch statement to intercept exceptions raised by the Stripe client. It receives three arguments: 1) The FQN of the Stripe Entity class; 2) The method of the class to invoke; 3) The arguments to pass to the method. As the methods of the Stripe PHP SDK have all the same structure, it is possible to extract a pattern. So, the alternatives are as following: 1) options 2) params, options 3) params 4) [No arguments] There are no confusable cases. To make this method able to match the right Stripe SDK's method signature, set all the required arguments only for methods that match the case 2 and if If one argument is not required, anyway set it as an empty array BUT ANYWAY SET IT to make the switch able to match the proper method signature. So, to call a Stripe SDK's method with signature that matches case 1 or case 3: $arguments = [ [...] // Or an empty array ]; $this->callStripeObject(Customer::class, 'save', $arguments) You can give the key a name for clarity, but in the callStripeObject method it is anyway referenced to as $arguments[0], so is irrelevant you give a key or not. To call a Stripe SDK's method with signature that matches case 2: $arguments = [ 'params' => [...] // Or an empty array, 'options' => [...] // Or an empty array ]; $this->callStripeObject(Customer::class, 'cancel', $arguments) You can give the key a name for clarity, but in the callStripeObject method it is anyway referenced to as $arguments[0], so is irrelevant you give a key or not. @param ApiResource $object @param string $method @param array $arguments @return ApiResource|bool
[ "Method", "to", "call", "the", "Stripe", "PHP", "SDK", "s", "NON", "static", "methods", "." ]
5d74a3c2a133fe6d97e838cbcbecad939d32626f
https://github.com/Aerendir/stripe-bundle/blob/5d74a3c2a133fe6d97e838cbcbecad939d32626f/src/Service/StripeManager.php#L276-L311
train
danielstjules/pho
src/Expectation/Matcher/LengthMatcher.php
LengthMatcher.match
public function match($actual) { if (is_string($actual)) { $this->type = 'string'; $this->actual = strlen($actual); } elseif (is_array($actual)) { $this->type = 'array'; $this->actual = count($actual); } else { throw new \Exception('LengthMatcher::match() requires an array or string'); } return ($this->actual === $this->expected); }
php
public function match($actual) { if (is_string($actual)) { $this->type = 'string'; $this->actual = strlen($actual); } elseif (is_array($actual)) { $this->type = 'array'; $this->actual = count($actual); } else { throw new \Exception('LengthMatcher::match() requires an array or string'); } return ($this->actual === $this->expected); }
[ "public", "function", "match", "(", "$", "actual", ")", "{", "if", "(", "is_string", "(", "$", "actual", ")", ")", "{", "$", "this", "->", "type", "=", "'string'", ";", "$", "this", "->", "actual", "=", "strlen", "(", "$", "actual", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "actual", ")", ")", "{", "$", "this", "->", "type", "=", "'array'", ";", "$", "this", "->", "actual", "=", "count", "(", "$", "actual", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'LengthMatcher::match() requires an array or string'", ")", ";", "}", "return", "(", "$", "this", "->", "actual", "===", "$", "this", "->", "expected", ")", ";", "}" ]
Compares the length of the given array or string to the expected value. Returns true if the value is of the expected length, else false. @param mixed $actual An array or string for which to test the length @return boolean Whether or not the value is of the expected length @throws \Exception If $actual isn't of type array or string
[ "Compares", "the", "length", "of", "the", "given", "array", "or", "string", "to", "the", "expected", "value", ".", "Returns", "true", "if", "the", "value", "is", "of", "the", "expected", "length", "else", "false", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Expectation/Matcher/LengthMatcher.php#L31-L44
train
stymiee/authnetjson
src/authnet/AuthnetJsonResponse.php
AuthnetJsonResponse.checkTransactionStatus
protected function checkTransactionStatus($status) { if ($this->transactionInfo instanceof TransactionResponse) { $match = (int) $this->transactionInfo->getTransactionResponseField('ResponseCode') === (int) $status; } else { $match = (int) $this->transactionResponse->responseCode === $status; } return $match; }
php
protected function checkTransactionStatus($status) { if ($this->transactionInfo instanceof TransactionResponse) { $match = (int) $this->transactionInfo->getTransactionResponseField('ResponseCode') === (int) $status; } else { $match = (int) $this->transactionResponse->responseCode === $status; } return $match; }
[ "protected", "function", "checkTransactionStatus", "(", "$", "status", ")", "{", "if", "(", "$", "this", "->", "transactionInfo", "instanceof", "TransactionResponse", ")", "{", "$", "match", "=", "(", "int", ")", "$", "this", "->", "transactionInfo", "->", "getTransactionResponseField", "(", "'ResponseCode'", ")", "===", "(", "int", ")", "$", "status", ";", "}", "else", "{", "$", "match", "=", "(", "int", ")", "$", "this", "->", "transactionResponse", "->", "responseCode", "===", "$", "status", ";", "}", "return", "$", "match", ";", "}" ]
Check to see if the ResponseCode matches the expected value @param integer $status @return bool Check to see if the ResponseCode matches the expected value
[ "Check", "to", "see", "if", "the", "ResponseCode", "matches", "the", "expected", "value" ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetJsonResponse.php#L199-L207
train
stymiee/authnetjson
src/authnet/AuthnetJsonResponse.php
AuthnetJsonResponse.getTransactionResponseField
public function getTransactionResponseField($field) { if ($this->transactionInfo instanceof TransactionResponse) { return $this->transactionInfo->getTransactionResponseField($field); } throw new AuthnetTransactionResponseCallException('This API call does not have any transaction response data'); }
php
public function getTransactionResponseField($field) { if ($this->transactionInfo instanceof TransactionResponse) { return $this->transactionInfo->getTransactionResponseField($field); } throw new AuthnetTransactionResponseCallException('This API call does not have any transaction response data'); }
[ "public", "function", "getTransactionResponseField", "(", "$", "field", ")", "{", "if", "(", "$", "this", "->", "transactionInfo", "instanceof", "TransactionResponse", ")", "{", "return", "$", "this", "->", "transactionInfo", "->", "getTransactionResponseField", "(", "$", "field", ")", ";", "}", "throw", "new", "AuthnetTransactionResponseCallException", "(", "'This API call does not have any transaction response data'", ")", ";", "}" ]
Gets the transaction response field for AIM and CIM transactions. @param mixed $field Name or key of the transaction field to be retrieved @return string Transaction field to be retrieved @throws \JohnConde\Authnet\AuthnetTransactionResponseCallException
[ "Gets", "the", "transaction", "response", "field", "for", "AIM", "and", "CIM", "transactions", "." ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetJsonResponse.php#L216-L222
train
danielstjules/pho
src/Expectation/Matcher/AbstractMatcher.php
AbstractMatcher.getStringValue
protected function getStringValue($value) { if ($value === true) { return 'true'; } elseif ($value === false) { return 'false'; } elseif ($value === null) { return 'null'; } elseif (is_string($value)) { return "\"$value\""; } return rtrim(print_r($value, true)); }
php
protected function getStringValue($value) { if ($value === true) { return 'true'; } elseif ($value === false) { return 'false'; } elseif ($value === null) { return 'null'; } elseif (is_string($value)) { return "\"$value\""; } return rtrim(print_r($value, true)); }
[ "protected", "function", "getStringValue", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "true", ")", "{", "return", "'true'", ";", "}", "elseif", "(", "$", "value", "===", "false", ")", "{", "return", "'false'", ";", "}", "elseif", "(", "$", "value", "===", "null", ")", "{", "return", "'null'", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "\"\\\"$value\\\"\"", ";", "}", "return", "rtrim", "(", "print_r", "(", "$", "value", ",", "true", ")", ")", ";", "}" ]
Returns a string representation of the given value, used for printing the failure message. @param mixed $value The value for which to get a string representation @returns string The string in question
[ "Returns", "a", "string", "representation", "of", "the", "given", "value", "used", "for", "printing", "the", "failure", "message", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Expectation/Matcher/AbstractMatcher.php#L14-L27
train
NanneHuiges/JSend
src/JSend/JSendResponse.php
JSendResponse.asArray
public function asArray(): array { $theArray = [static::KEY_STATUS => $this->status]; if ($this->data) { $theArray[static::KEY_DATA] = $this->data; } if (!$this->data && !$this->isError()) { // Data is optional for errors, so it should not be set // rather than be null. $theArray[static::KEY_DATA] = null; } if ($this->isError()) { $theArray[static::KEY_MESSAGE] = (string)$this->errorMessage; if (!empty($this->errorCode)) { $theArray[static::KEY_CODE] = (int)$this->errorCode; } } return $theArray; }
php
public function asArray(): array { $theArray = [static::KEY_STATUS => $this->status]; if ($this->data) { $theArray[static::KEY_DATA] = $this->data; } if (!$this->data && !$this->isError()) { // Data is optional for errors, so it should not be set // rather than be null. $theArray[static::KEY_DATA] = null; } if ($this->isError()) { $theArray[static::KEY_MESSAGE] = (string)$this->errorMessage; if (!empty($this->errorCode)) { $theArray[static::KEY_CODE] = (int)$this->errorCode; } } return $theArray; }
[ "public", "function", "asArray", "(", ")", ":", "array", "{", "$", "theArray", "=", "[", "static", "::", "KEY_STATUS", "=>", "$", "this", "->", "status", "]", ";", "if", "(", "$", "this", "->", "data", ")", "{", "$", "theArray", "[", "static", "::", "KEY_DATA", "]", "=", "$", "this", "->", "data", ";", "}", "if", "(", "!", "$", "this", "->", "data", "&&", "!", "$", "this", "->", "isError", "(", ")", ")", "{", "// Data is optional for errors, so it should not be set", "// rather than be null.", "$", "theArray", "[", "static", "::", "KEY_DATA", "]", "=", "null", ";", "}", "if", "(", "$", "this", "->", "isError", "(", ")", ")", "{", "$", "theArray", "[", "static", "::", "KEY_MESSAGE", "]", "=", "(", "string", ")", "$", "this", "->", "errorMessage", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "errorCode", ")", ")", "{", "$", "theArray", "[", "static", "::", "KEY_CODE", "]", "=", "(", "int", ")", "$", "this", "->", "errorCode", ";", "}", "}", "return", "$", "theArray", ";", "}" ]
Serializes the class into an array @return array the serialized array
[ "Serializes", "the", "class", "into", "an", "array" ]
62ea244ecd09e0e2be35c79cab384dc86ced7e00
https://github.com/NanneHuiges/JSend/blob/62ea244ecd09e0e2be35c79cab384dc86ced7e00/src/JSend/JSendResponse.php#L166-L188
train
danielstjules/pho
src/Runnable/Spec.php
Spec.setException
public function setException(\Exception $exception = null) { $this->exception = $exception; $this->result = self::FAILED; }
php
public function setException(\Exception $exception = null) { $this->exception = $exception; $this->result = self::FAILED; }
[ "public", "function", "setException", "(", "\\", "Exception", "$", "exception", "=", "null", ")", "{", "$", "this", "->", "exception", "=", "$", "exception", ";", "$", "this", "->", "result", "=", "self", "::", "FAILED", ";", "}" ]
Sets the spec exception, also marking it as failed. @param \Exception The exception
[ "Sets", "the", "spec", "exception", "also", "marking", "it", "as", "failed", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Runnable/Spec.php#L122-L126
train
danielstjules/pho
src/Suite/Suite.php
Suite.getHook
public function getHook($key) { if (isset($this->hooks[$key])) { return $this->hooks[$key]; } return null; }
php
public function getHook($key) { if (isset($this->hooks[$key])) { return $this->hooks[$key]; } return null; }
[ "public", "function", "getHook", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "hooks", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "hooks", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
Returns the hook found at the specified key. Usually one of before, after, beforeEach, or afterEach. @param string $key The key for the hook @return Hook The given hook
[ "Returns", "the", "hook", "found", "at", "the", "specified", "key", ".", "Usually", "one", "of", "before", "after", "beforeEach", "or", "afterEach", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Suite/Suite.php#L83-L90
train
danielstjules/pho
src/Suite/Suite.php
Suite.addSuite
public function addSuite($suite) { if (true === $this->pending) { $suite->setPending(); } $this->suites[] = $suite; }
php
public function addSuite($suite) { if (true === $this->pending) { $suite->setPending(); } $this->suites[] = $suite; }
[ "public", "function", "addSuite", "(", "$", "suite", ")", "{", "if", "(", "true", "===", "$", "this", "->", "pending", ")", "{", "$", "suite", "->", "setPending", "(", ")", ";", "}", "$", "this", "->", "suites", "[", "]", "=", "$", "suite", ";", "}" ]
Adds a suite to the list of nested suites. @param Suite $suite The suite to add
[ "Adds", "a", "suite", "to", "the", "list", "of", "nested", "suites", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Suite/Suite.php#L126-L132
train
Aerendir/stripe-bundle
src/Model/StripeLocalCharge.php
StripeLocalCharge.setAmount
public function setAmount(MoneyInterface $amount): self { if (null === $this->amount) { $this->amount = $amount; } return $this; }
php
public function setAmount(MoneyInterface $amount): self { if (null === $this->amount) { $this->amount = $amount; } return $this; }
[ "public", "function", "setAmount", "(", "MoneyInterface", "$", "amount", ")", ":", "self", "{", "if", "(", "null", "===", "$", "this", "->", "amount", ")", "{", "$", "this", "->", "amount", "=", "$", "amount", ";", "}", "return", "$", "this", ";", "}" ]
This sets the amount only if it is null. This is to prevent an accidental overwriting of it. @param Money|MoneyInterface $amount @throws \InvalidArgumentException If the amount is not an integer @return StripeLocalCharge
[ "This", "sets", "the", "amount", "only", "if", "it", "is", "null", "." ]
5d74a3c2a133fe6d97e838cbcbecad939d32626f
https://github.com/Aerendir/stripe-bundle/blob/5d74a3c2a133fe6d97e838cbcbecad939d32626f/src/Model/StripeLocalCharge.php#L297-L304
train
stymiee/authnetjson
src/authnet/AuthnetSim.php
AuthnetSim.getFingerprint
public function getFingerprint($amount) { if (!filter_var($amount, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND)) { throw new AuthnetInvalidAmountException('You must enter a valid amount greater than zero.'); } return strtoupper(hash_hmac('sha512', sprintf('%s^%s^%s^%s^', $this->login, $this->sequence, $this->timestamp, $amount ), hex2bin($this->signature))); }
php
public function getFingerprint($amount) { if (!filter_var($amount, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND)) { throw new AuthnetInvalidAmountException('You must enter a valid amount greater than zero.'); } return strtoupper(hash_hmac('sha512', sprintf('%s^%s^%s^%s^', $this->login, $this->sequence, $this->timestamp, $amount ), hex2bin($this->signature))); }
[ "public", "function", "getFingerprint", "(", "$", "amount", ")", "{", "if", "(", "!", "filter_var", "(", "$", "amount", ",", "FILTER_VALIDATE_FLOAT", ",", "FILTER_FLAG_ALLOW_THOUSAND", ")", ")", "{", "throw", "new", "AuthnetInvalidAmountException", "(", "'You must enter a valid amount greater than zero.'", ")", ";", "}", "return", "strtoupper", "(", "hash_hmac", "(", "'sha512'", ",", "sprintf", "(", "'%s^%s^%s^%s^'", ",", "$", "this", "->", "login", ",", "$", "this", "->", "sequence", ",", "$", "this", "->", "timestamp", ",", "$", "amount", ")", ",", "hex2bin", "(", "$", "this", "->", "signature", ")", ")", ")", ";", "}" ]
Returns the hash for the SIM transaction @param float $amount The amount of the transaction @return string Hash of five different unique transaction parameters @throws \JohnConde\Authnet\AuthnetInvalidAmountException
[ "Returns", "the", "hash", "for", "the", "SIM", "transaction" ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetSim.php#L74-L86
train
Aerendir/stripe-bundle
src/Syncer/CustomerSyncer.php
CustomerSyncer.sourceExists
private function sourceExists(StripeLocalCard $card, Collection $sources) { /** @var Card $source */ foreach ($sources->data as $source) { if ($card->getId() === $source->id) { return true; } } return false; }
php
private function sourceExists(StripeLocalCard $card, Collection $sources) { /** @var Card $source */ foreach ($sources->data as $source) { if ($card->getId() === $source->id) { return true; } } return false; }
[ "private", "function", "sourceExists", "(", "StripeLocalCard", "$", "card", ",", "Collection", "$", "sources", ")", "{", "/** @var Card $source */", "foreach", "(", "$", "sources", "->", "data", "as", "$", "source", ")", "{", "if", "(", "$", "card", "->", "getId", "(", ")", "===", "$", "source", "->", "id", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the given card is set source in the StripeCustomer object. Perfrom this check guarantees that the local database is ever in sync with the Stripe Account. @param StripeLocalCard $card @param Collection $sources @return bool
[ "Checks", "if", "the", "given", "card", "is", "set", "source", "in", "the", "StripeCustomer", "object", "." ]
5d74a3c2a133fe6d97e838cbcbecad939d32626f
https://github.com/Aerendir/stripe-bundle/blob/5d74a3c2a133fe6d97e838cbcbecad939d32626f/src/Syncer/CustomerSyncer.php#L240-L250
train
NtimYeboah/laravel-database-trigger
src/Schema/MySqlBuilder.php
MySqlBuilder.hasTrigger
public function hasTrigger($trigger) { return count($this->connection->select( $this->grammar->compileTriggerExists(), [$trigger] )) > 0; }
php
public function hasTrigger($trigger) { return count($this->connection->select( $this->grammar->compileTriggerExists(), [$trigger] )) > 0; }
[ "public", "function", "hasTrigger", "(", "$", "trigger", ")", "{", "return", "count", "(", "$", "this", "->", "connection", "->", "select", "(", "$", "this", "->", "grammar", "->", "compileTriggerExists", "(", ")", ",", "[", "$", "trigger", "]", ")", ")", ">", "0", ";", "}" ]
Determine if the given trigger exists. @param string $trigger @return bool
[ "Determine", "if", "the", "given", "trigger", "exists", "." ]
1f9e44ad0faf351ae60cbb025d33d63af9ec2e41
https://github.com/NtimYeboah/laravel-database-trigger/blob/1f9e44ad0faf351ae60cbb025d33d63af9ec2e41/src/Schema/MySqlBuilder.php#L174-L180
train
NtimYeboah/laravel-database-trigger
src/Schema/MySqlBuilder.php
MySqlBuilder.dropIfExists
public function dropIfExists($trigger) { $this->build(tap($this->createBlueprint($trigger), function ($blueprint) { $blueprint->dropIfExists(); })); }
php
public function dropIfExists($trigger) { $this->build(tap($this->createBlueprint($trigger), function ($blueprint) { $blueprint->dropIfExists(); })); }
[ "public", "function", "dropIfExists", "(", "$", "trigger", ")", "{", "$", "this", "->", "build", "(", "tap", "(", "$", "this", "->", "createBlueprint", "(", "$", "trigger", ")", ",", "function", "(", "$", "blueprint", ")", "{", "$", "blueprint", "->", "dropIfExists", "(", ")", ";", "}", ")", ")", ";", "}" ]
Drop trigger. @return void
[ "Drop", "trigger", "." ]
1f9e44ad0faf351ae60cbb025d33d63af9ec2e41
https://github.com/NtimYeboah/laravel-database-trigger/blob/1f9e44ad0faf351ae60cbb025d33d63af9ec2e41/src/Schema/MySqlBuilder.php#L187-L192
train
NtimYeboah/laravel-database-trigger
src/Schema/MySqlBuilder.php
MySqlBuilder.callBuild
public function callBuild() { $eventObjectTable = $this->getEventObjectTable(); $callback = $this->getStatement(); $actionTiming = $this->getActionTiming(); $event = $this->getEvent(); $this->build(tap( $this->createBlueprint($this->trigger), function (Blueprint $blueprint) use ($eventObjectTable, $callback, $actionTiming, $event) { $blueprint->create(); $blueprint->on($eventObjectTable); $blueprint->statement($callback); $blueprint->$actionTiming(); $blueprint->$event(); } )); }
php
public function callBuild() { $eventObjectTable = $this->getEventObjectTable(); $callback = $this->getStatement(); $actionTiming = $this->getActionTiming(); $event = $this->getEvent(); $this->build(tap( $this->createBlueprint($this->trigger), function (Blueprint $blueprint) use ($eventObjectTable, $callback, $actionTiming, $event) { $blueprint->create(); $blueprint->on($eventObjectTable); $blueprint->statement($callback); $blueprint->$actionTiming(); $blueprint->$event(); } )); }
[ "public", "function", "callBuild", "(", ")", "{", "$", "eventObjectTable", "=", "$", "this", "->", "getEventObjectTable", "(", ")", ";", "$", "callback", "=", "$", "this", "->", "getStatement", "(", ")", ";", "$", "actionTiming", "=", "$", "this", "->", "getActionTiming", "(", ")", ";", "$", "event", "=", "$", "this", "->", "getEvent", "(", ")", ";", "$", "this", "->", "build", "(", "tap", "(", "$", "this", "->", "createBlueprint", "(", "$", "this", "->", "trigger", ")", ",", "function", "(", "Blueprint", "$", "blueprint", ")", "use", "(", "$", "eventObjectTable", ",", "$", "callback", ",", "$", "actionTiming", ",", "$", "event", ")", "{", "$", "blueprint", "->", "create", "(", ")", ";", "$", "blueprint", "->", "on", "(", "$", "eventObjectTable", ")", ";", "$", "blueprint", "->", "statement", "(", "$", "callback", ")", ";", "$", "blueprint", "->", "$", "actionTiming", "(", ")", ";", "$", "blueprint", "->", "$", "event", "(", ")", ";", "}", ")", ")", ";", "}" ]
Call build to execute blueprint to build trigger. @return void
[ "Call", "build", "to", "execute", "blueprint", "to", "build", "trigger", "." ]
1f9e44ad0faf351ae60cbb025d33d63af9ec2e41
https://github.com/NtimYeboah/laravel-database-trigger/blob/1f9e44ad0faf351ae60cbb025d33d63af9ec2e41/src/Schema/MySqlBuilder.php#L239-L256
train
danielstjules/pho
src/Console/Console.php
Console.getReporterClass
public function getReporterClass() { $reporter = $this->options['reporter']; if ($reporter === false) { return self::DEFAULT_REPORTER; } $reporterClass = ucfirst($reporter) . 'Reporter'; $reporterClass = "pho\\Reporter\\$reporterClass"; try { $reflection = new ReflectionClass($reporterClass); } catch (ReflectionException $exception) { throw new ReporterNotFoundException($exception); } return $reflection->getName(); }
php
public function getReporterClass() { $reporter = $this->options['reporter']; if ($reporter === false) { return self::DEFAULT_REPORTER; } $reporterClass = ucfirst($reporter) . 'Reporter'; $reporterClass = "pho\\Reporter\\$reporterClass"; try { $reflection = new ReflectionClass($reporterClass); } catch (ReflectionException $exception) { throw new ReporterNotFoundException($exception); } return $reflection->getName(); }
[ "public", "function", "getReporterClass", "(", ")", "{", "$", "reporter", "=", "$", "this", "->", "options", "[", "'reporter'", "]", ";", "if", "(", "$", "reporter", "===", "false", ")", "{", "return", "self", "::", "DEFAULT_REPORTER", ";", "}", "$", "reporterClass", "=", "ucfirst", "(", "$", "reporter", ")", ".", "'Reporter'", ";", "$", "reporterClass", "=", "\"pho\\\\Reporter\\\\$reporterClass\"", ";", "try", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "reporterClass", ")", ";", "}", "catch", "(", "ReflectionException", "$", "exception", ")", "{", "throw", "new", "ReporterNotFoundException", "(", "$", "exception", ")", ";", "}", "return", "$", "reflection", "->", "getName", "(", ")", ";", "}" ]
Returns the namespaced name of the reporter class requested via the command line arguments, defaulting to DotReporter if not specified. @return string The namespaced class name of the reporter @throws \pho\Exception\ReporterNotFoundException
[ "Returns", "the", "namespaced", "name", "of", "the", "reporter", "class", "requested", "via", "the", "command", "line", "arguments", "defaulting", "to", "DotReporter", "if", "not", "specified", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Console/Console.php#L80-L98
train
danielstjules/pho
src/Reporter/AbstractReporter.php
AbstractReporter.afterSuite
public function afterSuite(Suite $suite) { $hook = $suite->getHook('after'); if ($hook && $hook->getException()) { $this->handleHookFailure($hook); } }
php
public function afterSuite(Suite $suite) { $hook = $suite->getHook('after'); if ($hook && $hook->getException()) { $this->handleHookFailure($hook); } }
[ "public", "function", "afterSuite", "(", "Suite", "$", "suite", ")", "{", "$", "hook", "=", "$", "suite", "->", "getHook", "(", "'after'", ")", ";", "if", "(", "$", "hook", "&&", "$", "hook", "->", "getException", "(", ")", ")", "{", "$", "this", "->", "handleHookFailure", "(", "$", "hook", ")", ";", "}", "}" ]
Ran after the containing test suite is invoked. @param Suite $suite The test suite after which to run this method
[ "Ran", "after", "the", "containing", "test", "suite", "is", "invoked", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Reporter/AbstractReporter.php#L79-L85
train
danielstjules/pho
src/Reporter/AbstractReporter.php
AbstractReporter.afterRun
public function afterRun() { if (count($this->failures)) { $this->console->writeLn("\nFailures:"); } foreach ($this->failures as $spec) { $failedText = $this->formatter->red("\n\"$spec\" FAILED"); $this->console->writeLn($failedText); $this->console->writeLn($spec->getException()); } if ($this->startTime) { $endTime = microtime(true); $runningTime = round($endTime - $this->startTime, 5); $this->console->writeLn("\nFinished in $runningTime seconds"); } $failedCount = count($this->failures); $incompleteCount = count($this->incompleteSpecs); $pendingCount = count($this->pendingSpecs); $specs = ($this->specCount == 1) ? 'spec' : 'specs'; $failures = ($failedCount == 1) ? 'failure' : 'failures'; $incomplete = ($incompleteCount) ? ", $incompleteCount incomplete" : ''; $pending = ($pendingCount) ? ", $pendingCount pending" : ''; // Print ASCII art if enabled if ($this->console->options['ascii']) { $this->console->writeLn(''); $this->drawAscii(); } $summaryText = "\n{$this->specCount} $specs, $failedCount $failures" . $incomplete . $pending; // Generate the summary based on whether or not it passed if ($failedCount) { $summary = $this->formatter->red($summaryText); } else { $summary = $this->formatter->green($summaryText); } $summary = $this->formatter->bold($summary); $this->console->writeLn($summary); }
php
public function afterRun() { if (count($this->failures)) { $this->console->writeLn("\nFailures:"); } foreach ($this->failures as $spec) { $failedText = $this->formatter->red("\n\"$spec\" FAILED"); $this->console->writeLn($failedText); $this->console->writeLn($spec->getException()); } if ($this->startTime) { $endTime = microtime(true); $runningTime = round($endTime - $this->startTime, 5); $this->console->writeLn("\nFinished in $runningTime seconds"); } $failedCount = count($this->failures); $incompleteCount = count($this->incompleteSpecs); $pendingCount = count($this->pendingSpecs); $specs = ($this->specCount == 1) ? 'spec' : 'specs'; $failures = ($failedCount == 1) ? 'failure' : 'failures'; $incomplete = ($incompleteCount) ? ", $incompleteCount incomplete" : ''; $pending = ($pendingCount) ? ", $pendingCount pending" : ''; // Print ASCII art if enabled if ($this->console->options['ascii']) { $this->console->writeLn(''); $this->drawAscii(); } $summaryText = "\n{$this->specCount} $specs, $failedCount $failures" . $incomplete . $pending; // Generate the summary based on whether or not it passed if ($failedCount) { $summary = $this->formatter->red($summaryText); } else { $summary = $this->formatter->green($summaryText); } $summary = $this->formatter->bold($summary); $this->console->writeLn($summary); }
[ "public", "function", "afterRun", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "failures", ")", ")", "{", "$", "this", "->", "console", "->", "writeLn", "(", "\"\\nFailures:\"", ")", ";", "}", "foreach", "(", "$", "this", "->", "failures", "as", "$", "spec", ")", "{", "$", "failedText", "=", "$", "this", "->", "formatter", "->", "red", "(", "\"\\n\\\"$spec\\\" FAILED\"", ")", ";", "$", "this", "->", "console", "->", "writeLn", "(", "$", "failedText", ")", ";", "$", "this", "->", "console", "->", "writeLn", "(", "$", "spec", "->", "getException", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "startTime", ")", "{", "$", "endTime", "=", "microtime", "(", "true", ")", ";", "$", "runningTime", "=", "round", "(", "$", "endTime", "-", "$", "this", "->", "startTime", ",", "5", ")", ";", "$", "this", "->", "console", "->", "writeLn", "(", "\"\\nFinished in $runningTime seconds\"", ")", ";", "}", "$", "failedCount", "=", "count", "(", "$", "this", "->", "failures", ")", ";", "$", "incompleteCount", "=", "count", "(", "$", "this", "->", "incompleteSpecs", ")", ";", "$", "pendingCount", "=", "count", "(", "$", "this", "->", "pendingSpecs", ")", ";", "$", "specs", "=", "(", "$", "this", "->", "specCount", "==", "1", ")", "?", "'spec'", ":", "'specs'", ";", "$", "failures", "=", "(", "$", "failedCount", "==", "1", ")", "?", "'failure'", ":", "'failures'", ";", "$", "incomplete", "=", "(", "$", "incompleteCount", ")", "?", "\", $incompleteCount incomplete\"", ":", "''", ";", "$", "pending", "=", "(", "$", "pendingCount", ")", "?", "\", $pendingCount pending\"", ":", "''", ";", "// Print ASCII art if enabled", "if", "(", "$", "this", "->", "console", "->", "options", "[", "'ascii'", "]", ")", "{", "$", "this", "->", "console", "->", "writeLn", "(", "''", ")", ";", "$", "this", "->", "drawAscii", "(", ")", ";", "}", "$", "summaryText", "=", "\"\\n{$this->specCount} $specs, $failedCount $failures\"", ".", "$", "incomplete", ".", "$", "pending", ";", "// Generate the summary based on whether or not it passed", "if", "(", "$", "failedCount", ")", "{", "$", "summary", "=", "$", "this", "->", "formatter", "->", "red", "(", "$", "summaryText", ")", ";", "}", "else", "{", "$", "summary", "=", "$", "this", "->", "formatter", "->", "green", "(", "$", "summaryText", ")", ";", "}", "$", "summary", "=", "$", "this", "->", "formatter", "->", "bold", "(", "$", "summary", ")", ";", "$", "this", "->", "console", "->", "writeLn", "(", "$", "summary", ")", ";", "}" ]
Invoked after the test suite has ran, allowing for the display of test results and related statistics.
[ "Invoked", "after", "the", "test", "suite", "has", "ran", "allowing", "for", "the", "display", "of", "test", "results", "and", "related", "statistics", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Reporter/AbstractReporter.php#L101-L145
train
danielstjules/pho
src/Console/ConsoleFormatter.php
ConsoleFormatter.alignText
public function alignText($array, $delimiter = '') { // Get max column widths $widths = []; foreach ($array as $row) { $lengths = array_map('strlen', $row); for ($i = 0; $i < count($lengths); $i++) { if (isset($widths[$i])) { $widths[$i] = max($widths[$i], $lengths[$i]); } else { $widths[$i] = $lengths[$i]; } } } // Pad lines columns and return an array $output = []; foreach($array as $row) { $entries = []; for ($i = 0; $i < count($row); $i++) { $entries[] = str_pad($row[$i], $widths[$i]); } $output[] = implode($entries, $delimiter); } return $output; }
php
public function alignText($array, $delimiter = '') { // Get max column widths $widths = []; foreach ($array as $row) { $lengths = array_map('strlen', $row); for ($i = 0; $i < count($lengths); $i++) { if (isset($widths[$i])) { $widths[$i] = max($widths[$i], $lengths[$i]); } else { $widths[$i] = $lengths[$i]; } } } // Pad lines columns and return an array $output = []; foreach($array as $row) { $entries = []; for ($i = 0; $i < count($row); $i++) { $entries[] = str_pad($row[$i], $widths[$i]); } $output[] = implode($entries, $delimiter); } return $output; }
[ "public", "function", "alignText", "(", "$", "array", ",", "$", "delimiter", "=", "''", ")", "{", "// Get max column widths", "$", "widths", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "row", ")", "{", "$", "lengths", "=", "array_map", "(", "'strlen'", ",", "$", "row", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "lengths", ")", ";", "$", "i", "++", ")", "{", "if", "(", "isset", "(", "$", "widths", "[", "$", "i", "]", ")", ")", "{", "$", "widths", "[", "$", "i", "]", "=", "max", "(", "$", "widths", "[", "$", "i", "]", ",", "$", "lengths", "[", "$", "i", "]", ")", ";", "}", "else", "{", "$", "widths", "[", "$", "i", "]", "=", "$", "lengths", "[", "$", "i", "]", ";", "}", "}", "}", "// Pad lines columns and return an array", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "row", ")", "{", "$", "entries", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "row", ")", ";", "$", "i", "++", ")", "{", "$", "entries", "[", "]", "=", "str_pad", "(", "$", "row", "[", "$", "i", "]", ",", "$", "widths", "[", "$", "i", "]", ")", ";", "}", "$", "output", "[", "]", "=", "implode", "(", "$", "entries", ",", "$", "delimiter", ")", ";", "}", "return", "$", "output", ";", "}" ]
Given a multidimensional array, formats the text such that each entry is left aligned with all other entries in the given column. The method also takes an optional delimiter for specifying a sequence of characters to separate each column. @param array $array The multidimensional array to format @param string $delimiter The delimiter to be used between columns @return array An array of strings containing the formatted entries
[ "Given", "a", "multidimensional", "array", "formats", "the", "text", "such", "that", "each", "entry", "is", "left", "aligned", "with", "all", "other", "entries", "in", "the", "given", "column", ".", "The", "method", "also", "takes", "an", "optional", "delimiter", "for", "specifying", "a", "sequence", "of", "characters", "to", "separate", "each", "column", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Console/ConsoleFormatter.php#L58-L86
train
danielstjules/pho
src/Watcher/Watcher.php
Watcher.watchPath
public function watchPath($path) { if (!$this->inotify) { $this->paths[] = $path; $this->addModifiedTimes($path); return; } $mask = IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | IN_MOVE | IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MOVE_SELF; $directoryIterator = new \RecursiveDirectoryIterator(realpath($path)); $subPaths = new \RecursiveIteratorIterator($directoryIterator); // Iterate over instances of \SplFileObject foreach ($subpaths as $subPath) { if ($subPath->isDir()) { $watchDescriptor = inotify_add_watch($this->inotify, $subPath->getRealPath(), $mask); $this->paths[$watchDescriptor] = $subPath->getRealPath(); } } }
php
public function watchPath($path) { if (!$this->inotify) { $this->paths[] = $path; $this->addModifiedTimes($path); return; } $mask = IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | IN_MOVE | IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MOVE_SELF; $directoryIterator = new \RecursiveDirectoryIterator(realpath($path)); $subPaths = new \RecursiveIteratorIterator($directoryIterator); // Iterate over instances of \SplFileObject foreach ($subpaths as $subPath) { if ($subPath->isDir()) { $watchDescriptor = inotify_add_watch($this->inotify, $subPath->getRealPath(), $mask); $this->paths[$watchDescriptor] = $subPath->getRealPath(); } } }
[ "public", "function", "watchPath", "(", "$", "path", ")", "{", "if", "(", "!", "$", "this", "->", "inotify", ")", "{", "$", "this", "->", "paths", "[", "]", "=", "$", "path", ";", "$", "this", "->", "addModifiedTimes", "(", "$", "path", ")", ";", "return", ";", "}", "$", "mask", "=", "IN_MODIFY", "|", "IN_ATTRIB", "|", "IN_CLOSE_WRITE", "|", "IN_MOVE", "|", "IN_CREATE", "|", "IN_DELETE", "|", "IN_DELETE_SELF", "|", "IN_MOVE_SELF", ";", "$", "directoryIterator", "=", "new", "\\", "RecursiveDirectoryIterator", "(", "realpath", "(", "$", "path", ")", ")", ";", "$", "subPaths", "=", "new", "\\", "RecursiveIteratorIterator", "(", "$", "directoryIterator", ")", ";", "// Iterate over instances of \\SplFileObject", "foreach", "(", "$", "subpaths", "as", "$", "subPath", ")", "{", "if", "(", "$", "subPath", "->", "isDir", "(", ")", ")", "{", "$", "watchDescriptor", "=", "inotify_add_watch", "(", "$", "this", "->", "inotify", ",", "$", "subPath", "->", "getRealPath", "(", ")", ",", "$", "mask", ")", ";", "$", "this", "->", "paths", "[", "$", "watchDescriptor", "]", "=", "$", "subPath", "->", "getRealPath", "(", ")", ";", "}", "}", "}" ]
Adds the path to the list of files and folders to monitor for changes. If the path is a file, its modification time is stored for comparison. If a directory, the modification times for each sub-directory and file are recursively stored. @param string $path A valid path to a file or directory
[ "Adds", "the", "path", "to", "the", "list", "of", "files", "and", "folders", "to", "monitor", "for", "changes", ".", "If", "the", "path", "is", "a", "file", "its", "modification", "time", "is", "stored", "for", "comparison", ".", "If", "a", "directory", "the", "modification", "times", "for", "each", "sub", "-", "directory", "and", "file", "are", "recursively", "stored", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Watcher/Watcher.php#L68-L91
train
danielstjules/pho
src/Watcher/Watcher.php
Watcher.addModifiedTimes
private function addModifiedTimes($path) { if (is_file($path)) { $stat = stat($path); $this->modifiedTimes[realpath($path)] = $stat['mtime']; return; } $directoryIterator = new \RecursiveDirectoryIterator(realpath($path)); $files = new \RecursiveIteratorIterator($directoryIterator); // Iterate over instances of \SplFileObject foreach ($files as $file) { $modifiedTime = $file->getMTime(); $this->modifiedTimes[$file->getRealPath()] = $modifiedTime; } }
php
private function addModifiedTimes($path) { if (is_file($path)) { $stat = stat($path); $this->modifiedTimes[realpath($path)] = $stat['mtime']; return; } $directoryIterator = new \RecursiveDirectoryIterator(realpath($path)); $files = new \RecursiveIteratorIterator($directoryIterator); // Iterate over instances of \SplFileObject foreach ($files as $file) { $modifiedTime = $file->getMTime(); $this->modifiedTimes[$file->getRealPath()] = $modifiedTime; } }
[ "private", "function", "addModifiedTimes", "(", "$", "path", ")", "{", "if", "(", "is_file", "(", "$", "path", ")", ")", "{", "$", "stat", "=", "stat", "(", "$", "path", ")", ";", "$", "this", "->", "modifiedTimes", "[", "realpath", "(", "$", "path", ")", "]", "=", "$", "stat", "[", "'mtime'", "]", ";", "return", ";", "}", "$", "directoryIterator", "=", "new", "\\", "RecursiveDirectoryIterator", "(", "realpath", "(", "$", "path", ")", ")", ";", "$", "files", "=", "new", "\\", "RecursiveIteratorIterator", "(", "$", "directoryIterator", ")", ";", "// Iterate over instances of \\SplFileObject", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "modifiedTime", "=", "$", "file", "->", "getMTime", "(", ")", ";", "$", "this", "->", "modifiedTimes", "[", "$", "file", "->", "getRealPath", "(", ")", "]", "=", "$", "modifiedTime", ";", "}", "}" ]
Given the path to a file or directory, recursively adds the modified times of any nested folders to the modifiedTimes property. @param string $path A valid path to a file or directory
[ "Given", "the", "path", "to", "a", "file", "or", "directory", "recursively", "adds", "the", "modified", "times", "of", "any", "nested", "folders", "to", "the", "modifiedTimes", "property", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Watcher/Watcher.php#L171-L188
train
danielstjules/pho
src/Expectation/Matcher/SuffixMatcher.php
SuffixMatcher.match
public function match($subject) { $this->subject = $subject; $suffixLength = strlen($this->suffix); if (!$suffixLength) { return true; } return (substr($subject, -$suffixLength) === $this->suffix); }
php
public function match($subject) { $this->subject = $subject; $suffixLength = strlen($this->suffix); if (!$suffixLength) { return true; } return (substr($subject, -$suffixLength) === $this->suffix); }
[ "public", "function", "match", "(", "$", "subject", ")", "{", "$", "this", "->", "subject", "=", "$", "subject", ";", "$", "suffixLength", "=", "strlen", "(", "$", "this", "->", "suffix", ")", ";", "if", "(", "!", "$", "suffixLength", ")", "{", "return", "true", ";", "}", "return", "(", "substr", "(", "$", "subject", ",", "-", "$", "suffixLength", ")", "===", "$", "this", "->", "suffix", ")", ";", "}" ]
Returns true if the subject ends with the given suffix, false otherwise. @param mixed $subject The string to test @return boolean Whether or not the string contains the suffix
[ "Returns", "true", "if", "the", "subject", "ends", "with", "the", "given", "suffix", "false", "otherwise", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Expectation/Matcher/SuffixMatcher.php#L27-L37
train
NtimYeboah/laravel-database-trigger
src/Migrations/MigrationCreator.php
MigrationCreator.populate
protected function populate($name, $eventObjectTable, $actionTiming, $event, $stub) { $stub = str_replace('DummyClass', $this->getClassName($name), $stub); $stub = str_replace('DummyName', $name, $stub); $stub = str_replace('DummyEventObjectTable', $eventObjectTable, $stub); $stub = str_replace('DummyActionTiming', $actionTiming, $stub); $stub = str_replace('DummyEvent', $event, $stub); return $stub; }
php
protected function populate($name, $eventObjectTable, $actionTiming, $event, $stub) { $stub = str_replace('DummyClass', $this->getClassName($name), $stub); $stub = str_replace('DummyName', $name, $stub); $stub = str_replace('DummyEventObjectTable', $eventObjectTable, $stub); $stub = str_replace('DummyActionTiming', $actionTiming, $stub); $stub = str_replace('DummyEvent', $event, $stub); return $stub; }
[ "protected", "function", "populate", "(", "$", "name", ",", "$", "eventObjectTable", ",", "$", "actionTiming", ",", "$", "event", ",", "$", "stub", ")", "{", "$", "stub", "=", "str_replace", "(", "'DummyClass'", ",", "$", "this", "->", "getClassName", "(", "$", "name", ")", ",", "$", "stub", ")", ";", "$", "stub", "=", "str_replace", "(", "'DummyName'", ",", "$", "name", ",", "$", "stub", ")", ";", "$", "stub", "=", "str_replace", "(", "'DummyEventObjectTable'", ",", "$", "eventObjectTable", ",", "$", "stub", ")", ";", "$", "stub", "=", "str_replace", "(", "'DummyActionTiming'", ",", "$", "actionTiming", ",", "$", "stub", ")", ";", "$", "stub", "=", "str_replace", "(", "'DummyEvent'", ",", "$", "event", ",", "$", "stub", ")", ";", "return", "$", "stub", ";", "}" ]
Populate migration stub. @param string $name @param string $eventObjectTable @param string $actionTiming @param string $event @param string $stub @return string;
[ "Populate", "migration", "stub", "." ]
1f9e44ad0faf351ae60cbb025d33d63af9ec2e41
https://github.com/NtimYeboah/laravel-database-trigger/blob/1f9e44ad0faf351ae60cbb025d33d63af9ec2e41/src/Migrations/MigrationCreator.php#L44-L53
train
danielstjules/pho
src/Console/ConsoleOptionParser.php
ConsoleOptionParser.getConsoleOption
public function getConsoleOption($name) { if (isset($this->options[$name])) { return $this->options[$name]; } foreach ($this->options as $option) { $longName = $option->getLongName(); $shortName = $option->getShortName(); if ($name == $longName || $name == $shortName) { return $option; } } }
php
public function getConsoleOption($name) { if (isset($this->options[$name])) { return $this->options[$name]; } foreach ($this->options as $option) { $longName = $option->getLongName(); $shortName = $option->getShortName(); if ($name == $longName || $name == $shortName) { return $option; } } }
[ "public", "function", "getConsoleOption", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "options", "[", "$", "name", "]", ";", "}", "foreach", "(", "$", "this", "->", "options", "as", "$", "option", ")", "{", "$", "longName", "=", "$", "option", "->", "getLongName", "(", ")", ";", "$", "shortName", "=", "$", "option", "->", "getShortName", "(", ")", ";", "if", "(", "$", "name", "==", "$", "longName", "||", "$", "name", "==", "$", "shortName", ")", "{", "return", "$", "option", ";", "}", "}", "}" ]
Returns the ConsoleOption object either found at the key with the supplied name, or whose short name or long name matches. @param string $name The name, shortName, or longName of the option @return ConsoleOption The option matching the supplied name, if it exists
[ "Returns", "the", "ConsoleOption", "object", "either", "found", "at", "the", "key", "with", "the", "supplied", "name", "or", "whose", "short", "name", "or", "long", "name", "matches", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Console/ConsoleOptionParser.php#L33-L47
train
danielstjules/pho
src/Console/ConsoleOptionParser.php
ConsoleOptionParser.getOptions
public function getOptions() { $options = []; foreach ($this->options as $name => $option) { $options[$name] = $option->getValue(); } return $options; }
php
public function getOptions() { $options = []; foreach ($this->options as $name => $option) { $options[$name] = $option->getValue(); } return $options; }
[ "public", "function", "getOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "name", "=>", "$", "option", ")", "{", "$", "options", "[", "$", "name", "]", "=", "$", "option", "->", "getValue", "(", ")", ";", "}", "return", "$", "options", ";", "}" ]
Returns an associative array consisting of the names of the ConsoleOptions added to the parser, and their values. @return array The names of the options and their values
[ "Returns", "an", "associative", "array", "consisting", "of", "the", "names", "of", "the", "ConsoleOptions", "added", "to", "the", "parser", "and", "their", "values", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Console/ConsoleOptionParser.php#L55-L63
train
danielstjules/pho
src/Console/ConsoleOptionParser.php
ConsoleOptionParser.getOptionNames
public function getOptionNames() { $names = []; foreach ($this->options as $option) { $names[] = $option->getLongName(); $names[] = $option->getShortName(); } return $names; }
php
public function getOptionNames() { $names = []; foreach ($this->options as $option) { $names[] = $option->getLongName(); $names[] = $option->getShortName(); } return $names; }
[ "public", "function", "getOptionNames", "(", ")", "{", "$", "names", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "option", ")", "{", "$", "names", "[", "]", "=", "$", "option", "->", "getLongName", "(", ")", ";", "$", "names", "[", "]", "=", "$", "option", "->", "getShortName", "(", ")", ";", "}", "return", "$", "names", ";", "}" ]
Returns an array containing the long and short names of all options. @return array The short and long names of the options
[ "Returns", "an", "array", "containing", "the", "long", "and", "short", "names", "of", "all", "options", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Console/ConsoleOptionParser.php#L91-L100
train
danielstjules/pho
src/Expectation/Matcher/ExceptionMatcher.php
ExceptionMatcher.match
public function match($callable) { try { $callable(); } catch(\Exception $exception) { $this->thrown = $exception; } return ($this->thrown instanceof $this->expected); }
php
public function match($callable) { try { $callable(); } catch(\Exception $exception) { $this->thrown = $exception; } return ($this->thrown instanceof $this->expected); }
[ "public", "function", "match", "(", "$", "callable", ")", "{", "try", "{", "$", "callable", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "this", "->", "thrown", "=", "$", "exception", ";", "}", "return", "(", "$", "this", "->", "thrown", "instanceof", "$", "this", "->", "expected", ")", ";", "}" ]
Compares the exception thrown by the callable, if any, to the expected exception. Returns true if an exception of the expected class is thrown, false otherwise. @param callable $callable The function to invoke @return boolean Whether or not the function threw the expected exception
[ "Compares", "the", "exception", "thrown", "by", "the", "callable", "if", "any", "to", "the", "expected", "exception", ".", "Returns", "true", "if", "an", "exception", "of", "the", "expected", "class", "is", "thrown", "false", "otherwise", "." ]
1514be7fc15632bd04ba1c3f0cccc57859c7969f
https://github.com/danielstjules/pho/blob/1514be7fc15632bd04ba1c3f0cccc57859c7969f/src/Expectation/Matcher/ExceptionMatcher.php#L29-L38
train
stymiee/authnetjson
src/authnet/AuthnetApiFactory.php
AuthnetApiFactory.getJsonApiHandler
public static function getJsonApiHandler($login, $transaction_key, $server = self::USE_AKAMAI_SERVER) { $login = trim($login); $transaction_key = trim($transaction_key); $api_url = static::getWebServiceURL($server); if (empty($login) || empty($transaction_key)) { throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.'); } $curl = new Curl(); $curl->setOpt(CURLOPT_RETURNTRANSFER, true); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); $curl->setOpt(CURLOPT_HEADER, false); $curl->setHeader('Content-Type', 'text/json'); $object = new AuthnetJsonRequest($login, $transaction_key, $api_url); $object->setProcessHandler($curl); return $object; }
php
public static function getJsonApiHandler($login, $transaction_key, $server = self::USE_AKAMAI_SERVER) { $login = trim($login); $transaction_key = trim($transaction_key); $api_url = static::getWebServiceURL($server); if (empty($login) || empty($transaction_key)) { throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.'); } $curl = new Curl(); $curl->setOpt(CURLOPT_RETURNTRANSFER, true); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); $curl->setOpt(CURLOPT_HEADER, false); $curl->setHeader('Content-Type', 'text/json'); $object = new AuthnetJsonRequest($login, $transaction_key, $api_url); $object->setProcessHandler($curl); return $object; }
[ "public", "static", "function", "getJsonApiHandler", "(", "$", "login", ",", "$", "transaction_key", ",", "$", "server", "=", "self", "::", "USE_AKAMAI_SERVER", ")", "{", "$", "login", "=", "trim", "(", "$", "login", ")", ";", "$", "transaction_key", "=", "trim", "(", "$", "transaction_key", ")", ";", "$", "api_url", "=", "static", "::", "getWebServiceURL", "(", "$", "server", ")", ";", "if", "(", "empty", "(", "$", "login", ")", "||", "empty", "(", "$", "transaction_key", ")", ")", "{", "throw", "new", "AuthnetInvalidCredentialsException", "(", "'You have not configured your login credentials properly.'", ")", ";", "}", "$", "curl", "=", "new", "Curl", "(", ")", ";", "$", "curl", "->", "setOpt", "(", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "curl", "->", "setOpt", "(", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "$", "curl", "->", "setOpt", "(", "CURLOPT_HEADER", ",", "false", ")", ";", "$", "curl", "->", "setHeader", "(", "'Content-Type'", ",", "'text/json'", ")", ";", "$", "object", "=", "new", "AuthnetJsonRequest", "(", "$", "login", ",", "$", "transaction_key", ",", "$", "api_url", ")", ";", "$", "object", "->", "setProcessHandler", "(", "$", "curl", ")", ";", "return", "$", "object", ";", "}" ]
Validates the Authorize.Net credentials and returns a Request object to be used to make an API call @param string $login Authorize.Net API Login ID @param string $transaction_key Authorize.Net API Transaction Key @param integer $server ID of which server to use (optional) @return \JohnConde\Authnet\AuthnetJsonRequest @throws \ErrorException @throws \JohnConde\Authnet\AuthnetInvalidCredentialsException @throws \JohnConde\Authnet\AuthnetInvalidServerException
[ "Validates", "the", "Authorize", ".", "Net", "credentials", "and", "returns", "a", "Request", "object", "to", "be", "used", "to", "make", "an", "API", "call" ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetApiFactory.php#L55-L75
train
stymiee/authnetjson
src/authnet/AuthnetApiFactory.php
AuthnetApiFactory.getWebServiceURL
protected static function getWebServiceURL($server) { $urls = [ static::USE_PRODUCTION_SERVER => 'https://api.authorize.net/xml/v1/request.api', static::USE_DEVELOPMENT_SERVER => 'https://apitest.authorize.net/xml/v1/request.api', static::USE_AKAMAI_SERVER => 'https://api2.authorize.net/xml/v1/request.api' ]; if (array_key_exists($server, $urls)) { return $urls[$server]; } throw new AuthnetInvalidServerException('You did not provide a valid server.'); }
php
protected static function getWebServiceURL($server) { $urls = [ static::USE_PRODUCTION_SERVER => 'https://api.authorize.net/xml/v1/request.api', static::USE_DEVELOPMENT_SERVER => 'https://apitest.authorize.net/xml/v1/request.api', static::USE_AKAMAI_SERVER => 'https://api2.authorize.net/xml/v1/request.api' ]; if (array_key_exists($server, $urls)) { return $urls[$server]; } throw new AuthnetInvalidServerException('You did not provide a valid server.'); }
[ "protected", "static", "function", "getWebServiceURL", "(", "$", "server", ")", "{", "$", "urls", "=", "[", "static", "::", "USE_PRODUCTION_SERVER", "=>", "'https://api.authorize.net/xml/v1/request.api'", ",", "static", "::", "USE_DEVELOPMENT_SERVER", "=>", "'https://apitest.authorize.net/xml/v1/request.api'", ",", "static", "::", "USE_AKAMAI_SERVER", "=>", "'https://api2.authorize.net/xml/v1/request.api'", "]", ";", "if", "(", "array_key_exists", "(", "$", "server", ",", "$", "urls", ")", ")", "{", "return", "$", "urls", "[", "$", "server", "]", ";", "}", "throw", "new", "AuthnetInvalidServerException", "(", "'You did not provide a valid server.'", ")", ";", "}" ]
Gets the API endpoint to be used for a JSON API call @param integer $server ID of which server to use @return string The URL endpoint the request is to be sent to @throws \JohnConde\Authnet\AuthnetInvalidServerException
[ "Gets", "the", "API", "endpoint", "to", "be", "used", "for", "a", "JSON", "API", "call" ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetApiFactory.php#L84-L95
train
stymiee/authnetjson
src/authnet/AuthnetApiFactory.php
AuthnetApiFactory.getSimHandler
public static function getSimHandler($login, $transaction_key, $server = self::USE_PRODUCTION_SERVER) { $login = trim($login); $transaction_key = trim($transaction_key); $api_url = static::getSimURL($server); if (empty($login) || empty($transaction_key)) { throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.'); } return new AuthnetSim($login, $transaction_key, $api_url); }
php
public static function getSimHandler($login, $transaction_key, $server = self::USE_PRODUCTION_SERVER) { $login = trim($login); $transaction_key = trim($transaction_key); $api_url = static::getSimURL($server); if (empty($login) || empty($transaction_key)) { throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.'); } return new AuthnetSim($login, $transaction_key, $api_url); }
[ "public", "static", "function", "getSimHandler", "(", "$", "login", ",", "$", "transaction_key", ",", "$", "server", "=", "self", "::", "USE_PRODUCTION_SERVER", ")", "{", "$", "login", "=", "trim", "(", "$", "login", ")", ";", "$", "transaction_key", "=", "trim", "(", "$", "transaction_key", ")", ";", "$", "api_url", "=", "static", "::", "getSimURL", "(", "$", "server", ")", ";", "if", "(", "empty", "(", "$", "login", ")", "||", "empty", "(", "$", "transaction_key", ")", ")", "{", "throw", "new", "AuthnetInvalidCredentialsException", "(", "'You have not configured your login credentials properly.'", ")", ";", "}", "return", "new", "AuthnetSim", "(", "$", "login", ",", "$", "transaction_key", ",", "$", "api_url", ")", ";", "}" ]
Validates the Authorize.Net credentials and returns a SIM object to be used to make a SIM API call @param string $login Authorize.Net API Login ID @param string $transaction_key Authorize.Net API Transaction Key @param integer $server ID of which server to use (optional) @return \JohnConde\Authnet\AuthnetSim @throws \JohnConde\Authnet\AuthnetInvalidCredentialsException @throws \JohnConde\Authnet\AuthnetInvalidServerException
[ "Validates", "the", "Authorize", ".", "Net", "credentials", "and", "returns", "a", "SIM", "object", "to", "be", "used", "to", "make", "a", "SIM", "API", "call" ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetApiFactory.php#L107-L118
train
stymiee/authnetjson
src/authnet/AuthnetApiFactory.php
AuthnetApiFactory.getWebhooksHandler
public static function getWebhooksHandler($login, $transaction_key, $server = self::USE_PRODUCTION_SERVER) { $login = trim($login); $transaction_key = trim($transaction_key); $api_url = static::getWebhooksURL($server); if (empty($login) || empty($transaction_key)) { throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.'); } $base64credentials = base64_encode(sprintf('%s:%s', $login, $transaction_key)); $curl = new Curl(); $curl->setOpt(CURLOPT_RETURNTRANSFER, true); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); $curl->setOpt(CURLOPT_HEADER, false); $curl->setHeader('Content-Type', 'application/json'); $curl->setHeader('Authorization', sprintf('Basic %s', $base64credentials)); $object = new AuthnetWebhooksRequest($api_url); $object->setProcessHandler($curl); return $object; }
php
public static function getWebhooksHandler($login, $transaction_key, $server = self::USE_PRODUCTION_SERVER) { $login = trim($login); $transaction_key = trim($transaction_key); $api_url = static::getWebhooksURL($server); if (empty($login) || empty($transaction_key)) { throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.'); } $base64credentials = base64_encode(sprintf('%s:%s', $login, $transaction_key)); $curl = new Curl(); $curl->setOpt(CURLOPT_RETURNTRANSFER, true); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); $curl->setOpt(CURLOPT_HEADER, false); $curl->setHeader('Content-Type', 'application/json'); $curl->setHeader('Authorization', sprintf('Basic %s', $base64credentials)); $object = new AuthnetWebhooksRequest($api_url); $object->setProcessHandler($curl); return $object; }
[ "public", "static", "function", "getWebhooksHandler", "(", "$", "login", ",", "$", "transaction_key", ",", "$", "server", "=", "self", "::", "USE_PRODUCTION_SERVER", ")", "{", "$", "login", "=", "trim", "(", "$", "login", ")", ";", "$", "transaction_key", "=", "trim", "(", "$", "transaction_key", ")", ";", "$", "api_url", "=", "static", "::", "getWebhooksURL", "(", "$", "server", ")", ";", "if", "(", "empty", "(", "$", "login", ")", "||", "empty", "(", "$", "transaction_key", ")", ")", "{", "throw", "new", "AuthnetInvalidCredentialsException", "(", "'You have not configured your login credentials properly.'", ")", ";", "}", "$", "base64credentials", "=", "base64_encode", "(", "sprintf", "(", "'%s:%s'", ",", "$", "login", ",", "$", "transaction_key", ")", ")", ";", "$", "curl", "=", "new", "Curl", "(", ")", ";", "$", "curl", "->", "setOpt", "(", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "curl", "->", "setOpt", "(", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "$", "curl", "->", "setOpt", "(", "CURLOPT_HEADER", ",", "false", ")", ";", "$", "curl", "->", "setHeader", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "$", "curl", "->", "setHeader", "(", "'Authorization'", ",", "sprintf", "(", "'Basic %s'", ",", "$", "base64credentials", ")", ")", ";", "$", "object", "=", "new", "AuthnetWebhooksRequest", "(", "$", "api_url", ")", ";", "$", "object", "->", "setProcessHandler", "(", "$", "curl", ")", ";", "return", "$", "object", ";", "}" ]
Validates the Authorize.Net credentials and returns a Webhooks Request object to be used to make an Webhook call @param string $login Authorize.Net API Login ID @param string $transaction_key Authorize.Net API Transaction Key @param integer $server ID of which server to use (optional) @throws \ErrorException @return \JohnConde\Authnet\AuthnetWebhooksRequest @throws \JohnConde\Authnet\AuthnetInvalidCredentialsException @throws \JohnConde\Authnet\AuthnetInvalidServerException
[ "Validates", "the", "Authorize", ".", "Net", "credentials", "and", "returns", "a", "Webhooks", "Request", "object", "to", "be", "used", "to", "make", "an", "Webhook", "call" ]
fb871877d978b5571d94163b59d4d1c97395eb8f
https://github.com/stymiee/authnetjson/blob/fb871877d978b5571d94163b59d4d1c97395eb8f/src/authnet/AuthnetApiFactory.php#L150-L173
train
NtimYeboah/laravel-database-trigger
src/Schema/Grammars/MySqlGrammar.php
MySqlGrammar.validateEvent
private function validateEvent(Blueprint $blueprint) { if (! in_array(strtolower($blueprint->event), $this->events)) { throw new InvalidArgumentException("Cannot use {$blueprint->event} as trigger event."); } return $blueprint->event; }
php
private function validateEvent(Blueprint $blueprint) { if (! in_array(strtolower($blueprint->event), $this->events)) { throw new InvalidArgumentException("Cannot use {$blueprint->event} as trigger event."); } return $blueprint->event; }
[ "private", "function", "validateEvent", "(", "Blueprint", "$", "blueprint", ")", "{", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "blueprint", "->", "event", ")", ",", "$", "this", "->", "events", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Cannot use {$blueprint->event} as trigger event.\"", ")", ";", "}", "return", "$", "blueprint", "->", "event", ";", "}" ]
Validate event. @param string $event @return string
[ "Validate", "event", "." ]
1f9e44ad0faf351ae60cbb025d33d63af9ec2e41
https://github.com/NtimYeboah/laravel-database-trigger/blob/1f9e44ad0faf351ae60cbb025d33d63af9ec2e41/src/Schema/Grammars/MySqlGrammar.php#L56-L63
train
NtimYeboah/laravel-database-trigger
src/Schema/Grammars/MySqlGrammar.php
MySqlGrammar.validateActionTiming
private function validateActionTiming(Blueprint $blueprint) { if (! in_array(strtolower($blueprint->actionTiming), $this->actionTimes)) { throw new InvalidArgumentException("Cannot use {$blueprint->actionTiming} as trigger action timing."); } return $blueprint->actionTiming; }
php
private function validateActionTiming(Blueprint $blueprint) { if (! in_array(strtolower($blueprint->actionTiming), $this->actionTimes)) { throw new InvalidArgumentException("Cannot use {$blueprint->actionTiming} as trigger action timing."); } return $blueprint->actionTiming; }
[ "private", "function", "validateActionTiming", "(", "Blueprint", "$", "blueprint", ")", "{", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "blueprint", "->", "actionTiming", ")", ",", "$", "this", "->", "actionTimes", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Cannot use {$blueprint->actionTiming} as trigger action timing.\"", ")", ";", "}", "return", "$", "blueprint", "->", "actionTiming", ";", "}" ]
Validate action time. @param string $actionTime @return string
[ "Validate", "action", "time", "." ]
1f9e44ad0faf351ae60cbb025d33d63af9ec2e41
https://github.com/NtimYeboah/laravel-database-trigger/blob/1f9e44ad0faf351ae60cbb025d33d63af9ec2e41/src/Schema/Grammars/MySqlGrammar.php#L71-L78
train
GrahamCampbell/Laravel-GitHub
src/GitHubFactory.php
GitHubFactory.make
public function make(array $config) { $client = new Client($this->getBuilder($config), array_get($config, 'version'), array_get($config, 'enterprise')); if (!array_key_exists('method', $config)) { throw new InvalidArgumentException('The github factory requires an auth method.'); } if ($config['method'] === 'none') { return $client; } return $this->auth->make($config['method'])->with($client)->authenticate($config); }
php
public function make(array $config) { $client = new Client($this->getBuilder($config), array_get($config, 'version'), array_get($config, 'enterprise')); if (!array_key_exists('method', $config)) { throw new InvalidArgumentException('The github factory requires an auth method.'); } if ($config['method'] === 'none') { return $client; } return $this->auth->make($config['method'])->with($client)->authenticate($config); }
[ "public", "function", "make", "(", "array", "$", "config", ")", "{", "$", "client", "=", "new", "Client", "(", "$", "this", "->", "getBuilder", "(", "$", "config", ")", ",", "array_get", "(", "$", "config", ",", "'version'", ")", ",", "array_get", "(", "$", "config", ",", "'enterprise'", ")", ")", ";", "if", "(", "!", "array_key_exists", "(", "'method'", ",", "$", "config", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The github factory requires an auth method.'", ")", ";", "}", "if", "(", "$", "config", "[", "'method'", "]", "===", "'none'", ")", "{", "return", "$", "client", ";", "}", "return", "$", "this", "->", "auth", "->", "make", "(", "$", "config", "[", "'method'", "]", ")", "->", "with", "(", "$", "client", ")", "->", "authenticate", "(", "$", "config", ")", ";", "}" ]
Make a new github client. @param string[] $config @throws \InvalidArgumentException @return \Github\Client
[ "Make", "a", "new", "github", "client", "." ]
eb61a055a03a5151cbbeedb3b0a357c4eeb2640d
https://github.com/GrahamCampbell/Laravel-GitHub/blob/eb61a055a03a5151cbbeedb3b0a357c4eeb2640d/src/GitHubFactory.php#L68-L81
train
GrahamCampbell/Laravel-GitHub
src/GitHubFactory.php
GitHubFactory.getBuilder
protected function getBuilder(array $config) { $builder = new ClientBuilder(); if ($backoff = array_get($config, 'backoff')) { $builder->addPlugin(new RetryPlugin(['retries' => $backoff === true ? 2 : $backoff])); } if ($this->cache && class_exists(CacheItemPool::class) && $cache = array_get($config, 'cache')) { $builder->addCache(new CacheItemPool($this->cache->store($cache === true ? null : $cache))); } return $builder; }
php
protected function getBuilder(array $config) { $builder = new ClientBuilder(); if ($backoff = array_get($config, 'backoff')) { $builder->addPlugin(new RetryPlugin(['retries' => $backoff === true ? 2 : $backoff])); } if ($this->cache && class_exists(CacheItemPool::class) && $cache = array_get($config, 'cache')) { $builder->addCache(new CacheItemPool($this->cache->store($cache === true ? null : $cache))); } return $builder; }
[ "protected", "function", "getBuilder", "(", "array", "$", "config", ")", "{", "$", "builder", "=", "new", "ClientBuilder", "(", ")", ";", "if", "(", "$", "backoff", "=", "array_get", "(", "$", "config", ",", "'backoff'", ")", ")", "{", "$", "builder", "->", "addPlugin", "(", "new", "RetryPlugin", "(", "[", "'retries'", "=>", "$", "backoff", "===", "true", "?", "2", ":", "$", "backoff", "]", ")", ")", ";", "}", "if", "(", "$", "this", "->", "cache", "&&", "class_exists", "(", "CacheItemPool", "::", "class", ")", "&&", "$", "cache", "=", "array_get", "(", "$", "config", ",", "'cache'", ")", ")", "{", "$", "builder", "->", "addCache", "(", "new", "CacheItemPool", "(", "$", "this", "->", "cache", "->", "store", "(", "$", "cache", "===", "true", "?", "null", ":", "$", "cache", ")", ")", ")", ";", "}", "return", "$", "builder", ";", "}" ]
Get the http client builder. @param string[] $config @return \GrahamCampbell\GitHub\Http\ClientBuilder
[ "Get", "the", "http", "client", "builder", "." ]
eb61a055a03a5151cbbeedb3b0a357c4eeb2640d
https://github.com/GrahamCampbell/Laravel-GitHub/blob/eb61a055a03a5151cbbeedb3b0a357c4eeb2640d/src/GitHubFactory.php#L90-L103
train
GrahamCampbell/Laravel-GitHub
src/GitHubServiceProvider.php
GitHubServiceProvider.registerGitHubFactory
protected function registerGitHubFactory() { $this->app->singleton('github.factory', function (Container $app) { $auth = $app['github.authfactory']; $cache = $app['cache']; return new GitHubFactory($auth, $cache); }); $this->app->alias('github.factory', GitHubFactory::class); }
php
protected function registerGitHubFactory() { $this->app->singleton('github.factory', function (Container $app) { $auth = $app['github.authfactory']; $cache = $app['cache']; return new GitHubFactory($auth, $cache); }); $this->app->alias('github.factory', GitHubFactory::class); }
[ "protected", "function", "registerGitHubFactory", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'github.factory'", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "auth", "=", "$", "app", "[", "'github.authfactory'", "]", ";", "$", "cache", "=", "$", "app", "[", "'cache'", "]", ";", "return", "new", "GitHubFactory", "(", "$", "auth", ",", "$", "cache", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "'github.factory'", ",", "GitHubFactory", "::", "class", ")", ";", "}" ]
Register the github factory class. @return void
[ "Register", "the", "github", "factory", "class", "." ]
eb61a055a03a5151cbbeedb3b0a357c4eeb2640d
https://github.com/GrahamCampbell/Laravel-GitHub/blob/eb61a055a03a5151cbbeedb3b0a357c4eeb2640d/src/GitHubServiceProvider.php#L90-L100
train
GrahamCampbell/Laravel-GitHub
src/Http/ClientBuilder.php
ClientBuilder.getProperty
protected static function getProperty(string $name) { $prop = (new ReflectionClass(Builder::class))->getProperty($name); $prop->setAccessible(true); return $prop; }
php
protected static function getProperty(string $name) { $prop = (new ReflectionClass(Builder::class))->getProperty($name); $prop->setAccessible(true); return $prop; }
[ "protected", "static", "function", "getProperty", "(", "string", "$", "name", ")", "{", "$", "prop", "=", "(", "new", "ReflectionClass", "(", "Builder", "::", "class", ")", ")", "->", "getProperty", "(", "$", "name", ")", ";", "$", "prop", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "prop", ";", "}" ]
Get the builder reflection property for the given name. @param string $name @return \ReflectionProperty
[ "Get", "the", "builder", "reflection", "property", "for", "the", "given", "name", "." ]
eb61a055a03a5151cbbeedb3b0a357c4eeb2640d
https://github.com/GrahamCampbell/Laravel-GitHub/blob/eb61a055a03a5151cbbeedb3b0a357c4eeb2640d/src/Http/ClientBuilder.php#L92-L99
train
tivie/php-os-detector
src/Detector.php
Detector.normalizePHPOS
protected function normalizePHPOS($name) { //Cygwin if (stripos($name, 'CYGWIN') !== false) { return 'CYGWIN'; } //MinGW if (stripos($name, 'MSYS') !== false || stripos($name, 'MINGW') !== false) { return 'MINGW'; } return $name; }
php
protected function normalizePHPOS($name) { //Cygwin if (stripos($name, 'CYGWIN') !== false) { return 'CYGWIN'; } //MinGW if (stripos($name, 'MSYS') !== false || stripos($name, 'MINGW') !== false) { return 'MINGW'; } return $name; }
[ "protected", "function", "normalizePHPOS", "(", "$", "name", ")", "{", "//Cygwin", "if", "(", "stripos", "(", "$", "name", ",", "'CYGWIN'", ")", "!==", "false", ")", "{", "return", "'CYGWIN'", ";", "}", "//MinGW", "if", "(", "stripos", "(", "$", "name", ",", "'MSYS'", ")", "!==", "false", "||", "stripos", "(", "$", "name", ",", "'MINGW'", ")", "!==", "false", ")", "{", "return", "'MINGW'", ";", "}", "return", "$", "name", ";", "}" ]
This method normalizes some names for future compliance @param $name @return string
[ "This", "method", "normalizes", "some", "names", "for", "future", "compliance" ]
469cec5708b5e066ba910c5f6ed481e5c11a57ae
https://github.com/tivie/php-os-detector/blob/469cec5708b5e066ba910c5f6ed481e5c11a57ae/src/Detector.php#L255-L268
train
acquia/acquia-sdk-php
src/Acquia/Rest/SignatureAbstract.php
SignatureAbstract.getNoncer
public function getNoncer() { if (!isset($this->noncer)) { $this->noncer = new self::$defaultNoncerClass($this->noncerLength); if (!$this->noncer instanceof NoncerInterface) { throw new \UnexpectedValueException('Noncer must implement Acquia\Rest\NoncerInterface'); } } return $this->noncer; }
php
public function getNoncer() { if (!isset($this->noncer)) { $this->noncer = new self::$defaultNoncerClass($this->noncerLength); if (!$this->noncer instanceof NoncerInterface) { throw new \UnexpectedValueException('Noncer must implement Acquia\Rest\NoncerInterface'); } } return $this->noncer; }
[ "public", "function", "getNoncer", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "noncer", ")", ")", "{", "$", "this", "->", "noncer", "=", "new", "self", "::", "$", "defaultNoncerClass", "(", "$", "this", "->", "noncerLength", ")", ";", "if", "(", "!", "$", "this", "->", "noncer", "instanceof", "NoncerInterface", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Noncer must implement Acquia\\Rest\\NoncerInterface'", ")", ";", "}", "}", "return", "$", "this", "->", "noncer", ";", "}" ]
Returns a noncer, instantiates it if it doesn't exist. @return \Acquia\Rest\NoncerInterface @throws \UnexpectedValueException
[ "Returns", "a", "noncer", "instantiates", "it", "if", "it", "doesn", "t", "exist", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Rest/SignatureAbstract.php#L80-L89
train
appaydin/pd-menu
Twig/MenuExtension.php
MenuExtension.getMenu
public function getMenu(string $menuClass, $options = []): ItemInterface { // Merge Options $options = array_merge($this->defaultOptions, $options); // Get Menu $menu = $this->container->has($menuClass) ? $this->container->get($menuClass) : new $menuClass(); // Render if ($menu instanceof MenuInterface) { return $this->itemProcess->processMenu($menu->createMenu($options), $options); } return false; }
php
public function getMenu(string $menuClass, $options = []): ItemInterface { // Merge Options $options = array_merge($this->defaultOptions, $options); // Get Menu $menu = $this->container->has($menuClass) ? $this->container->get($menuClass) : new $menuClass(); // Render if ($menu instanceof MenuInterface) { return $this->itemProcess->processMenu($menu->createMenu($options), $options); } return false; }
[ "public", "function", "getMenu", "(", "string", "$", "menuClass", ",", "$", "options", "=", "[", "]", ")", ":", "ItemInterface", "{", "// Merge Options", "$", "options", "=", "array_merge", "(", "$", "this", "->", "defaultOptions", ",", "$", "options", ")", ";", "// Get Menu", "$", "menu", "=", "$", "this", "->", "container", "->", "has", "(", "$", "menuClass", ")", "?", "$", "this", "->", "container", "->", "get", "(", "$", "menuClass", ")", ":", "new", "$", "menuClass", "(", ")", ";", "// Render", "if", "(", "$", "menu", "instanceof", "MenuInterface", ")", "{", "return", "$", "this", "->", "itemProcess", "->", "processMenu", "(", "$", "menu", "->", "createMenu", "(", "$", "options", ")", ",", "$", "options", ")", ";", "}", "return", "false", ";", "}" ]
Get Menu Array. @param string $menuClass @param array $options @return ItemInterface|bool
[ "Get", "Menu", "Array", "." ]
fc4d9d107fe168a80af6e1bb99dd61939ebc54be
https://github.com/appaydin/pd-menu/blob/fc4d9d107fe168a80af6e1bb99dd61939ebc54be/Twig/MenuExtension.php#L129-L143
train
appaydin/pd-menu
Twig/MenuExtension.php
MenuExtension.arrayToAttr
public function arrayToAttr(array $array = [], array $append = [], array $options = []) { $array = array_merge_recursive($array, $append); $attr = ''; foreach ($array as $key => $value) { if (\is_array($value)) { $value = implode(' ', $value); } if ('title' === mb_strtolower($key)) { if (!isset($array['title_translate'])) { $value = $this->translator->trans($value, [], $options['trans_domain'] ?? null); } } $attr .= sprintf('%s="%s"', $key, $value); } return $attr; }
php
public function arrayToAttr(array $array = [], array $append = [], array $options = []) { $array = array_merge_recursive($array, $append); $attr = ''; foreach ($array as $key => $value) { if (\is_array($value)) { $value = implode(' ', $value); } if ('title' === mb_strtolower($key)) { if (!isset($array['title_translate'])) { $value = $this->translator->trans($value, [], $options['trans_domain'] ?? null); } } $attr .= sprintf('%s="%s"', $key, $value); } return $attr; }
[ "public", "function", "arrayToAttr", "(", "array", "$", "array", "=", "[", "]", ",", "array", "$", "append", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "array", "=", "array_merge_recursive", "(", "$", "array", ",", "$", "append", ")", ";", "$", "attr", "=", "''", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "\\", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "implode", "(", "' '", ",", "$", "value", ")", ";", "}", "if", "(", "'title'", "===", "mb_strtolower", "(", "$", "key", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "array", "[", "'title_translate'", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "translator", "->", "trans", "(", "$", "value", ",", "[", "]", ",", "$", "options", "[", "'trans_domain'", "]", "??", "null", ")", ";", "}", "}", "$", "attr", ".=", "sprintf", "(", "'%s=\"%s\"'", ",", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "attr", ";", "}" ]
Array to Html Attr Convert. @param array $array @param array $append @return string
[ "Array", "to", "Html", "Attr", "Convert", "." ]
fc4d9d107fe168a80af6e1bb99dd61939ebc54be
https://github.com/appaydin/pd-menu/blob/fc4d9d107fe168a80af6e1bb99dd61939ebc54be/Twig/MenuExtension.php#L153-L173
train
acquia/acquia-sdk-php
src/Acquia/Cloud/Api/CloudApiClient.php
CloudApiClient.installDistroByProject
public function installDistroByProject($site, $env, $projectName, $version) { $source = 'http://ftp.drupal.org/files/projects/' . $projectName . '-' . $version . '-core.tar.gz'; return $this->installDistro($site, $env, self::INSTALL_PROJECT, $source); }
php
public function installDistroByProject($site, $env, $projectName, $version) { $source = 'http://ftp.drupal.org/files/projects/' . $projectName . '-' . $version . '-core.tar.gz'; return $this->installDistro($site, $env, self::INSTALL_PROJECT, $source); }
[ "public", "function", "installDistroByProject", "(", "$", "site", ",", "$", "env", ",", "$", "projectName", ",", "$", "version", ")", "{", "$", "source", "=", "'http://ftp.drupal.org/files/projects/'", ".", "$", "projectName", ".", "'-'", ".", "$", "version", ".", "'-core.tar.gz'", ";", "return", "$", "this", "->", "installDistro", "(", "$", "site", ",", "$", "env", ",", "self", "::", "INSTALL_PROJECT", ",", "$", "source", ")", ";", "}" ]
Install any publicly accessible, standard Drupal distribution. @param string $site @param string $env @param string $projectName @param string $version @return \Acquia\Cloud\Api\Response\Task @throws \Guzzle\Http\Exception\ClientErrorResponseException
[ "Install", "any", "publicly", "accessible", "standard", "Drupal", "distribution", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Cloud/Api/CloudApiClient.php#L166-L170
train
acquia/acquia-sdk-php
src/Acquia/Cloud/Api/CloudApiClient.php
CloudApiClient.installDistroByMakefile
public function installDistroByMakefile($site, $env, $makefileUrl) { return $this->installDistro($site, $env, self::INSTALL_MAKEFILE, $makefileUrl); }
php
public function installDistroByMakefile($site, $env, $makefileUrl) { return $this->installDistro($site, $env, self::INSTALL_MAKEFILE, $makefileUrl); }
[ "public", "function", "installDistroByMakefile", "(", "$", "site", ",", "$", "env", ",", "$", "makefileUrl", ")", "{", "return", "$", "this", "->", "installDistro", "(", "$", "site", ",", "$", "env", ",", "self", "::", "INSTALL_MAKEFILE", ",", "$", "makefileUrl", ")", ";", "}" ]
Install a distro by passing a URL to a Drush makefile. @param string $site @param string $env @param string $makefileUrl @return \Acquia\Cloud\Api\Response\Task @throws \Guzzle\Http\Exception\ClientErrorResponseException
[ "Install", "a", "distro", "by", "passing", "a", "URL", "to", "a", "Drush", "makefile", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Cloud/Api/CloudApiClient.php#L183-L186
train
acquia/acquia-sdk-php
src/Acquia/Cloud/Api/CloudApiClient.php
CloudApiClient.moveDomain
public function moveDomain($site, $domains, $sourceEnv, $targetEnv, $skipSiteUpdate = FALSE) { $paths = '{+base_path}/sites/{site}/domain-move/{source}/{target}.json'; $update_site = ''; if ($skipSiteUpdate) { $update_site = '1'; $paths .= '?skip_site_update={update_site}'; } $variables = array( 'site' => $site, 'source' => $sourceEnv, 'target' => $targetEnv, 'update_site' => $update_site, ); $body = Json::encode(array('domains' => (array) $domains)); $request = $this->post(array($paths, $variables), null, $body); return new Response\Task($request); }
php
public function moveDomain($site, $domains, $sourceEnv, $targetEnv, $skipSiteUpdate = FALSE) { $paths = '{+base_path}/sites/{site}/domain-move/{source}/{target}.json'; $update_site = ''; if ($skipSiteUpdate) { $update_site = '1'; $paths .= '?skip_site_update={update_site}'; } $variables = array( 'site' => $site, 'source' => $sourceEnv, 'target' => $targetEnv, 'update_site' => $update_site, ); $body = Json::encode(array('domains' => (array) $domains)); $request = $this->post(array($paths, $variables), null, $body); return new Response\Task($request); }
[ "public", "function", "moveDomain", "(", "$", "site", ",", "$", "domains", ",", "$", "sourceEnv", ",", "$", "targetEnv", ",", "$", "skipSiteUpdate", "=", "FALSE", ")", "{", "$", "paths", "=", "'{+base_path}/sites/{site}/domain-move/{source}/{target}.json'", ";", "$", "update_site", "=", "''", ";", "if", "(", "$", "skipSiteUpdate", ")", "{", "$", "update_site", "=", "'1'", ";", "$", "paths", ".=", "'?skip_site_update={update_site}'", ";", "}", "$", "variables", "=", "array", "(", "'site'", "=>", "$", "site", ",", "'source'", "=>", "$", "sourceEnv", ",", "'target'", "=>", "$", "targetEnv", ",", "'update_site'", "=>", "$", "update_site", ",", ")", ";", "$", "body", "=", "Json", "::", "encode", "(", "array", "(", "'domains'", "=>", "(", "array", ")", "$", "domains", ")", ")", ";", "$", "request", "=", "$", "this", "->", "post", "(", "array", "(", "$", "paths", ",", "$", "variables", ")", ",", "null", ",", "$", "body", ")", ";", "return", "new", "Response", "\\", "Task", "(", "$", "request", ")", ";", "}" ]
Moves domains atomically from one environment to another. @param string $site The site. @param string|array $domains The domain name(s) as an array of strings, or the string '*' to move all domains. @param string $sourceEnv The environment which currently has this domain. @param string $targetEnv The destination environment for the domain. @param bool $skipSiteUpdate Optional. If set to TRUE this will inhibit running fields-config-web.php for this domain move. @return \Acquia\Cloud\Api\Response\Task @throws \Guzzle\Http\Exception\ClientErrorResponseException @see http://cloudapi.acquia.com/#POST__sites__site_domain_move__source__target-instance_route
[ "Moves", "domains", "atomically", "from", "one", "environment", "to", "another", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Cloud/Api/CloudApiClient.php#L813-L830
train
acquia/acquia-sdk-php
src/Acquia/Cloud/Api/CloudApiClient.php
CloudApiClient.deployCode
public function deployCode($site, $sourceEnv, $targetEnv) { $variables = array( 'site' => $site, 'source' => $sourceEnv, 'target' => $targetEnv, ); $request = $this->post(array('{+base_path}/sites/{site}/code-deploy/{source}/{target}.json', $variables)); return new Response\Task($request); }
php
public function deployCode($site, $sourceEnv, $targetEnv) { $variables = array( 'site' => $site, 'source' => $sourceEnv, 'target' => $targetEnv, ); $request = $this->post(array('{+base_path}/sites/{site}/code-deploy/{source}/{target}.json', $variables)); return new Response\Task($request); }
[ "public", "function", "deployCode", "(", "$", "site", ",", "$", "sourceEnv", ",", "$", "targetEnv", ")", "{", "$", "variables", "=", "array", "(", "'site'", "=>", "$", "site", ",", "'source'", "=>", "$", "sourceEnv", ",", "'target'", "=>", "$", "targetEnv", ",", ")", ";", "$", "request", "=", "$", "this", "->", "post", "(", "array", "(", "'{+base_path}/sites/{site}/code-deploy/{source}/{target}.json'", ",", "$", "variables", ")", ")", ";", "return", "new", "Response", "\\", "Task", "(", "$", "request", ")", ";", "}" ]
Deploy code from on environment to another. @param string $site @param string $sourceEnv @param string $targetEnv @return \Acquia\Cloud\Api\Response\Task @throws \Guzzle\Http\Exception\ClientErrorResponseException @see http://cloudapi.acquia.com/#POST__sites__site_code_deploy__source__target-instance_route
[ "Deploy", "code", "from", "on", "environment", "to", "another", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Cloud/Api/CloudApiClient.php#L987-L996
train
acquia/acquia-sdk-php
src/Acquia/Cloud/Api/CloudApiClient.php
CloudApiClient.pushCode
public function pushCode($site, $env, $vcsPath) { $variables = array( 'site' => $site, 'env' => $env, 'path' => $vcsPath, ); $request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/code-deploy.json?path={path}', $variables)); return new Response\Task($request); }
php
public function pushCode($site, $env, $vcsPath) { $variables = array( 'site' => $site, 'env' => $env, 'path' => $vcsPath, ); $request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/code-deploy.json?path={path}', $variables)); return new Response\Task($request); }
[ "public", "function", "pushCode", "(", "$", "site", ",", "$", "env", ",", "$", "vcsPath", ")", "{", "$", "variables", "=", "array", "(", "'site'", "=>", "$", "site", ",", "'env'", "=>", "$", "env", ",", "'path'", "=>", "$", "vcsPath", ",", ")", ";", "$", "request", "=", "$", "this", "->", "post", "(", "array", "(", "'{+base_path}/sites/{site}/envs/{env}/code-deploy.json?path={path}'", ",", "$", "variables", ")", ")", ";", "return", "new", "Response", "\\", "Task", "(", "$", "request", ")", ";", "}" ]
Deploy a tag or branch to an environment. @param string $site @param string $env @param string $vcsPath @return \Acquia\Cloud\Api\Response\Task @throws \Guzzle\Http\Exception\ClientErrorResponseException @see http://cloudapi.acquia.com/#POST__sites__site_envs__env_code_deploy-instance_route
[ "Deploy", "a", "tag", "or", "branch", "to", "an", "environment", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Cloud/Api/CloudApiClient.php#L1011-L1020
train
boekkooi/JqueryValidationBundle
src/Form/FormDataConstraintFinder.php
FormDataConstraintFinder.resolveDataClass
private function resolveDataClass(FormInterface $form) { // Nothing to do if root if ($form->isRoot()) { return $form->getConfig()->getDataClass(); } $propertyPath = $form->getPropertyPath(); /** @var FormInterface $dataForm */ $dataForm = $form; // If we have a index then we need to use it's parent if ($propertyPath->getLength() === 1 && $propertyPath->isIndex(0) && $form->getConfig()->getCompound()) { return $this->resolveDataClass($form->getParent()); } // Now locate the closest data class // TODO what is the length really for? for ($i = $propertyPath->getLength(); $i !== 0; $i--) { $dataForm = $dataForm->getParent(); # When a data class is found then use that form # This happend when property_path contains multiple parts aka `entity.prop` if ($dataForm->getConfig()->getDataClass() !== null) { break; } } // If the root inherits data, then grab the parent if ($dataForm->getConfig()->getInheritData()) { $dataForm = $dataForm->getParent(); } return $dataForm->getConfig()->getDataClass(); }
php
private function resolveDataClass(FormInterface $form) { // Nothing to do if root if ($form->isRoot()) { return $form->getConfig()->getDataClass(); } $propertyPath = $form->getPropertyPath(); /** @var FormInterface $dataForm */ $dataForm = $form; // If we have a index then we need to use it's parent if ($propertyPath->getLength() === 1 && $propertyPath->isIndex(0) && $form->getConfig()->getCompound()) { return $this->resolveDataClass($form->getParent()); } // Now locate the closest data class // TODO what is the length really for? for ($i = $propertyPath->getLength(); $i !== 0; $i--) { $dataForm = $dataForm->getParent(); # When a data class is found then use that form # This happend when property_path contains multiple parts aka `entity.prop` if ($dataForm->getConfig()->getDataClass() !== null) { break; } } // If the root inherits data, then grab the parent if ($dataForm->getConfig()->getInheritData()) { $dataForm = $dataForm->getParent(); } return $dataForm->getConfig()->getDataClass(); }
[ "private", "function", "resolveDataClass", "(", "FormInterface", "$", "form", ")", "{", "// Nothing to do if root", "if", "(", "$", "form", "->", "isRoot", "(", ")", ")", "{", "return", "$", "form", "->", "getConfig", "(", ")", "->", "getDataClass", "(", ")", ";", "}", "$", "propertyPath", "=", "$", "form", "->", "getPropertyPath", "(", ")", ";", "/** @var FormInterface $dataForm */", "$", "dataForm", "=", "$", "form", ";", "// If we have a index then we need to use it's parent", "if", "(", "$", "propertyPath", "->", "getLength", "(", ")", "===", "1", "&&", "$", "propertyPath", "->", "isIndex", "(", "0", ")", "&&", "$", "form", "->", "getConfig", "(", ")", "->", "getCompound", "(", ")", ")", "{", "return", "$", "this", "->", "resolveDataClass", "(", "$", "form", "->", "getParent", "(", ")", ")", ";", "}", "// Now locate the closest data class", "// TODO what is the length really for?", "for", "(", "$", "i", "=", "$", "propertyPath", "->", "getLength", "(", ")", ";", "$", "i", "!==", "0", ";", "$", "i", "--", ")", "{", "$", "dataForm", "=", "$", "dataForm", "->", "getParent", "(", ")", ";", "# When a data class is found then use that form", "# This happend when property_path contains multiple parts aka `entity.prop`", "if", "(", "$", "dataForm", "->", "getConfig", "(", ")", "->", "getDataClass", "(", ")", "!==", "null", ")", "{", "break", ";", "}", "}", "// If the root inherits data, then grab the parent", "if", "(", "$", "dataForm", "->", "getConfig", "(", ")", "->", "getInheritData", "(", ")", ")", "{", "$", "dataForm", "=", "$", "dataForm", "->", "getParent", "(", ")", ";", "}", "return", "$", "dataForm", "->", "getConfig", "(", ")", "->", "getDataClass", "(", ")", ";", "}" ]
Gets the form root data class used by the given form. @param FormInterface $form @return string|null
[ "Gets", "the", "form", "root", "data", "class", "used", "by", "the", "given", "form", "." ]
7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5
https://github.com/boekkooi/JqueryValidationBundle/blob/7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5/src/Form/FormDataConstraintFinder.php#L173-L207
train
boekkooi/JqueryValidationBundle
src/Form/FormDataConstraintFinder.php
FormDataConstraintFinder.resolveDataSource
private function resolveDataSource(FormInterface $form) { if ($form->isRoot()) { // Nothing to do if root $dataForm = $form->getData(); } else { $dataForm = $form; while ($dataForm->getConfig()->getDataClass() === null) { $dataForm = $form->getParent(); } } $data = $dataForm->getData(); return array( $data, $data === null ? $dataForm->getConfig()->getDataClass() : get_class($data) ); }
php
private function resolveDataSource(FormInterface $form) { if ($form->isRoot()) { // Nothing to do if root $dataForm = $form->getData(); } else { $dataForm = $form; while ($dataForm->getConfig()->getDataClass() === null) { $dataForm = $form->getParent(); } } $data = $dataForm->getData(); return array( $data, $data === null ? $dataForm->getConfig()->getDataClass() : get_class($data) ); }
[ "private", "function", "resolveDataSource", "(", "FormInterface", "$", "form", ")", "{", "if", "(", "$", "form", "->", "isRoot", "(", ")", ")", "{", "// Nothing to do if root", "$", "dataForm", "=", "$", "form", "->", "getData", "(", ")", ";", "}", "else", "{", "$", "dataForm", "=", "$", "form", ";", "while", "(", "$", "dataForm", "->", "getConfig", "(", ")", "->", "getDataClass", "(", ")", "===", "null", ")", "{", "$", "dataForm", "=", "$", "form", "->", "getParent", "(", ")", ";", "}", "}", "$", "data", "=", "$", "dataForm", "->", "getData", "(", ")", ";", "return", "array", "(", "$", "data", ",", "$", "data", "===", "null", "?", "$", "dataForm", "->", "getConfig", "(", ")", "->", "getDataClass", "(", ")", ":", "get_class", "(", "$", "data", ")", ")", ";", "}" ]
Gets the form data to which a property path applies @param FormInterface $form @return object|null
[ "Gets", "the", "form", "data", "to", "which", "a", "property", "path", "applies" ]
7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5
https://github.com/boekkooi/JqueryValidationBundle/blob/7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5/src/Form/FormDataConstraintFinder.php#L215-L232
train
boekkooi/JqueryValidationBundle
src/Form/FormDataConstraintFinder.php
FormDataConstraintFinder.guessProperty
private function guessProperty(ClassMetadata $metadata, $element) { // Is it the element the actual property if ($metadata->hasPropertyMetadata($element)) { return $element; } // Is it a camelized property $camelized = $this->camelize($element); if ($metadata->hasPropertyMetadata($camelized)) { return $camelized; } return null; }
php
private function guessProperty(ClassMetadata $metadata, $element) { // Is it the element the actual property if ($metadata->hasPropertyMetadata($element)) { return $element; } // Is it a camelized property $camelized = $this->camelize($element); if ($metadata->hasPropertyMetadata($camelized)) { return $camelized; } return null; }
[ "private", "function", "guessProperty", "(", "ClassMetadata", "$", "metadata", ",", "$", "element", ")", "{", "// Is it the element the actual property", "if", "(", "$", "metadata", "->", "hasPropertyMetadata", "(", "$", "element", ")", ")", "{", "return", "$", "element", ";", "}", "// Is it a camelized property", "$", "camelized", "=", "$", "this", "->", "camelize", "(", "$", "element", ")", ";", "if", "(", "$", "metadata", "->", "hasPropertyMetadata", "(", "$", "camelized", ")", ")", "{", "return", "$", "camelized", ";", "}", "return", "null", ";", "}" ]
Guess what property a given element belongs to. @param ClassMetadata $metadata @param string $element @return null|string
[ "Guess", "what", "property", "a", "given", "element", "belongs", "to", "." ]
7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5
https://github.com/boekkooi/JqueryValidationBundle/blob/7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5/src/Form/FormDataConstraintFinder.php#L265-L279
train
boekkooi/JqueryValidationBundle
src/Form/RuleCollection.php
RuleCollection.addCollection
public function addCollection(RuleCollection $collection) { foreach ($collection as $name => $rule) { $this->set($name, $rule); } }
php
public function addCollection(RuleCollection $collection) { foreach ($collection as $name => $rule) { $this->set($name, $rule); } }
[ "public", "function", "addCollection", "(", "RuleCollection", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "name", "=>", "$", "rule", ")", "{", "$", "this", "->", "set", "(", "$", "name", ",", "$", "rule", ")", ";", "}", "}" ]
Adds a rule collection at the end of the current set by appending all rule of the added collection. @param RuleCollection $collection A RuleCollection instance
[ "Adds", "a", "rule", "collection", "at", "the", "end", "of", "the", "current", "set", "by", "appending", "all", "rule", "of", "the", "added", "collection", "." ]
7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5
https://github.com/boekkooi/JqueryValidationBundle/blob/7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5/src/Form/RuleCollection.php#L39-L44
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Locale/Standard.php
Standard.compare
public function compare( $operator, $key, $value ) { $this->conditions[] = $this->filter->compare( $operator, $key, $value ); return $this; }
php
public function compare( $operator, $key, $value ) { $this->conditions[] = $this->filter->compare( $operator, $key, $value ); return $this; }
[ "public", "function", "compare", "(", "$", "operator", ",", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "$", "operator", ",", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Adds generic condition for filtering @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~=" @param string $key Search key defined by the locale manager, e.g. "locale.status" @param array|string $value Value or list of values to compare to @return \Aimeos\Controller\Frontend\Locale\Iface Locale controller for fluent interface @since 2019.04
[ "Adds", "generic", "condition", "for", "filtering" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Locale/Standard.php#L64-L68
train
ARCANEDEV/LaravelSettings
src/SettingsServiceProvider.php
SettingsServiceProvider.registerSettingsManager
private function registerSettingsManager() { $this->singleton(Contracts\Manager::class, function ($app) { return new SettingsManager($app); }); $this->singleton(Contracts\Store::class, function ($app) { /** @var \Arcanedev\LaravelSettings\Contracts\Manager $manager */ $manager = $app[Contracts\Manager::class]; return $manager->driver(); }); }
php
private function registerSettingsManager() { $this->singleton(Contracts\Manager::class, function ($app) { return new SettingsManager($app); }); $this->singleton(Contracts\Store::class, function ($app) { /** @var \Arcanedev\LaravelSettings\Contracts\Manager $manager */ $manager = $app[Contracts\Manager::class]; return $manager->driver(); }); }
[ "private", "function", "registerSettingsManager", "(", ")", "{", "$", "this", "->", "singleton", "(", "Contracts", "\\", "Manager", "::", "class", ",", "function", "(", "$", "app", ")", "{", "return", "new", "SettingsManager", "(", "$", "app", ")", ";", "}", ")", ";", "$", "this", "->", "singleton", "(", "Contracts", "\\", "Store", "::", "class", ",", "function", "(", "$", "app", ")", "{", "/** @var \\Arcanedev\\LaravelSettings\\Contracts\\Manager $manager */", "$", "manager", "=", "$", "app", "[", "Contracts", "\\", "Manager", "::", "class", "]", ";", "return", "$", "manager", "->", "driver", "(", ")", ";", "}", ")", ";", "}" ]
Register the Settings Manager.
[ "Register", "the", "Settings", "Manager", "." ]
b6c43bf6a2c2aef1cfb41e90361201393a8eed35
https://github.com/ARCANEDEV/LaravelSettings/blob/b6c43bf6a2c2aef1cfb41e90361201393a8eed35/src/SettingsServiceProvider.php#L75-L87
train
acquia/acquia-sdk-php
src/Acquia/Cloud/Environment/LocalEnvironment.php
LocalEnvironment.addDatabaseCredentials
public function addDatabaseCredentials($acquiaDbName, $localDbName, $username, $password = null, $host = 'localhost', $port = 3306) { $connString = $username; if ($password !== null) { $connString . ':' . $password; } $this->creds['databases'][$acquiaDbName] = array( 'id' => '1', 'role' => $this->sitegroup, // Is this right? For local doesn't really matter. 'name' => $localDbName, 'user' => $username, 'pass' => $password, 'db_url_ha' => array( $host => "mysqli://$connString@$host:$port/mysiteprod" ), 'db_cluster_id' => '1', 'port' => $port, ); return $this; }
php
public function addDatabaseCredentials($acquiaDbName, $localDbName, $username, $password = null, $host = 'localhost', $port = 3306) { $connString = $username; if ($password !== null) { $connString . ':' . $password; } $this->creds['databases'][$acquiaDbName] = array( 'id' => '1', 'role' => $this->sitegroup, // Is this right? For local doesn't really matter. 'name' => $localDbName, 'user' => $username, 'pass' => $password, 'db_url_ha' => array( $host => "mysqli://$connString@$host:$port/mysiteprod" ), 'db_cluster_id' => '1', 'port' => $port, ); return $this; }
[ "public", "function", "addDatabaseCredentials", "(", "$", "acquiaDbName", ",", "$", "localDbName", ",", "$", "username", ",", "$", "password", "=", "null", ",", "$", "host", "=", "'localhost'", ",", "$", "port", "=", "3306", ")", "{", "$", "connString", "=", "$", "username", ";", "if", "(", "$", "password", "!==", "null", ")", "{", "$", "connString", ".", "':'", ".", "$", "password", ";", "}", "$", "this", "->", "creds", "[", "'databases'", "]", "[", "$", "acquiaDbName", "]", "=", "array", "(", "'id'", "=>", "'1'", ",", "'role'", "=>", "$", "this", "->", "sitegroup", ",", "// Is this right? For local doesn't really matter.", "'name'", "=>", "$", "localDbName", ",", "'user'", "=>", "$", "username", ",", "'pass'", "=>", "$", "password", ",", "'db_url_ha'", "=>", "array", "(", "$", "host", "=>", "\"mysqli://$connString@$host:$port/mysiteprod\"", ")", ",", "'db_cluster_id'", "=>", "'1'", ",", "'port'", "=>", "$", "port", ",", ")", ";", "return", "$", "this", ";", "}" ]
Adds credentials to a database server. @param string $acquiaDbName @param string $localDbName @param string $username @param string|null $password @param string $host @param integer $port @return \Acquia\Cloud\Environment\LocalEnvironment
[ "Adds", "credentials", "to", "a", "database", "server", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Cloud/Environment/LocalEnvironment.php#L86-L107
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Catalog/Decorator/Base.php
Base.compare
public function compare( $operator, $key, $value ) { $this->controller->compare( $operator, $key, $value ); return $this; }
php
public function compare( $operator, $key, $value ) { $this->controller->compare( $operator, $key, $value ); return $this; }
[ "public", "function", "compare", "(", "$", "operator", ",", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "controller", "->", "compare", "(", "$", "operator", ",", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Adds generic condition for filtering attributes @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~=" @param string $key Search key defined by the catalog manager, e.g. "catalog.status" @param array|string $value Value or list of values to compare to @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface @since 2019.04
[ "Adds", "generic", "condition", "for", "filtering", "attributes" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Catalog/Decorator/Base.php#L74-L78
train
boekkooi/JqueryValidationBundle
src/Twig/JqueryValidationExtension.php
JqueryValidationExtension.buttonsViewData
protected function buttonsViewData(FormRuleContext $context) { $buttonNames = $context->getButtons(); $buttons = array(); foreach ($buttonNames as $name) { $groups = $context->getGroup($name); $buttons[] = array( 'name' => $name, 'cancel' => count($groups) === 0, 'validation_groups' => $groups, ); } return $buttons; }
php
protected function buttonsViewData(FormRuleContext $context) { $buttonNames = $context->getButtons(); $buttons = array(); foreach ($buttonNames as $name) { $groups = $context->getGroup($name); $buttons[] = array( 'name' => $name, 'cancel' => count($groups) === 0, 'validation_groups' => $groups, ); } return $buttons; }
[ "protected", "function", "buttonsViewData", "(", "FormRuleContext", "$", "context", ")", "{", "$", "buttonNames", "=", "$", "context", "->", "getButtons", "(", ")", ";", "$", "buttons", "=", "array", "(", ")", ";", "foreach", "(", "$", "buttonNames", "as", "$", "name", ")", "{", "$", "groups", "=", "$", "context", "->", "getGroup", "(", "$", "name", ")", ";", "$", "buttons", "[", "]", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'cancel'", "=>", "count", "(", "$", "groups", ")", "===", "0", ",", "'validation_groups'", "=>", "$", "groups", ",", ")", ";", "}", "return", "$", "buttons", ";", "}" ]
Transform the buttons in the given form into a array that can easily be used by twig. @param FormRuleContext $context @return array
[ "Transform", "the", "buttons", "in", "the", "given", "form", "into", "a", "array", "that", "can", "easily", "be", "used", "by", "twig", "." ]
7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5
https://github.com/boekkooi/JqueryValidationBundle/blob/7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5/src/Twig/JqueryValidationExtension.php#L88-L104
train
appaydin/pd-menu
Builder/ItemProcess.php
ItemProcess.processMenu
public function processMenu(ItemInterface $menu, array $options = []): ItemInterface { // Dispatch Event if ($menu->isEvent()) { $this->eventDispatcher->dispatch($menu->getId() . '.event', new PdMenuEvent($menu)); } // Set Current URI $this->currentUri = $this->router->getContext()->getPathInfo(); // Process Menu $this->recursiveProcess($menu, $options); return $menu; }
php
public function processMenu(ItemInterface $menu, array $options = []): ItemInterface { // Dispatch Event if ($menu->isEvent()) { $this->eventDispatcher->dispatch($menu->getId() . '.event', new PdMenuEvent($menu)); } // Set Current URI $this->currentUri = $this->router->getContext()->getPathInfo(); // Process Menu $this->recursiveProcess($menu, $options); return $menu; }
[ "public", "function", "processMenu", "(", "ItemInterface", "$", "menu", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ItemInterface", "{", "// Dispatch Event", "if", "(", "$", "menu", "->", "isEvent", "(", ")", ")", "{", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "$", "menu", "->", "getId", "(", ")", ".", "'.event'", ",", "new", "PdMenuEvent", "(", "$", "menu", ")", ")", ";", "}", "// Set Current URI", "$", "this", "->", "currentUri", "=", "$", "this", "->", "router", "->", "getContext", "(", ")", "->", "getPathInfo", "(", ")", ";", "// Process Menu", "$", "this", "->", "recursiveProcess", "(", "$", "menu", ",", "$", "options", ")", ";", "return", "$", "menu", ";", "}" ]
Menu Processor. @param ItemInterface $menu @param array $options @return ItemInterface
[ "Menu", "Processor", "." ]
fc4d9d107fe168a80af6e1bb99dd61939ebc54be
https://github.com/appaydin/pd-menu/blob/fc4d9d107fe168a80af6e1bb99dd61939ebc54be/Builder/ItemProcess.php#L69-L83
train
appaydin/pd-menu
Builder/ItemProcess.php
ItemProcess.recursiveProcess
private function recursiveProcess(ItemInterface $menu, $options) { // Get Child Menus $childs = $menu->getChild(); // Parent Menu Route if (isset($menu->getChildAttr()['data-parent'])) { $menu->setChildAttr(['data-parent' => $this->router->generate($menu->getChildAttr()['data-parent'])]); } // Sort Current Child foreach ($childs as $child) { // Generate Route Link if ($child->getRoute()) { $child->setLink($this->router->generate($child->getRoute()['name'], $child->getRoute()['params'])); // Link Active Class if ($this->currentUri === $child->getLink()) { $child->setListAttr(array_merge_recursive($child->getListAttr(), ['class' => $options['currentClass']])); } } // Item Security if ($child->getRoles()) { if (!$this->security->isGranted($child->getRoles())) { unset($childs[$child->getId()]); } } // Set Child Process if ($child->getChild()) { // Set Menu Depth if (null !== $options['depth'] && ($child->getLevel() >= $options['depth'])) { $child->setChild([]); break; } // Set Child List Class $child->setChildAttr(array_merge_recursive($child->getChildAttr(), ['class' => 'menu_level_' . $child->getLevel()])); $this->recursiveProcess($child, $options); } } // Sort Item usort($childs, function ($a, $b) { return $a->getOrder() > $b->getOrder(); }); // Set Childs $menu->setChild($childs); }
php
private function recursiveProcess(ItemInterface $menu, $options) { // Get Child Menus $childs = $menu->getChild(); // Parent Menu Route if (isset($menu->getChildAttr()['data-parent'])) { $menu->setChildAttr(['data-parent' => $this->router->generate($menu->getChildAttr()['data-parent'])]); } // Sort Current Child foreach ($childs as $child) { // Generate Route Link if ($child->getRoute()) { $child->setLink($this->router->generate($child->getRoute()['name'], $child->getRoute()['params'])); // Link Active Class if ($this->currentUri === $child->getLink()) { $child->setListAttr(array_merge_recursive($child->getListAttr(), ['class' => $options['currentClass']])); } } // Item Security if ($child->getRoles()) { if (!$this->security->isGranted($child->getRoles())) { unset($childs[$child->getId()]); } } // Set Child Process if ($child->getChild()) { // Set Menu Depth if (null !== $options['depth'] && ($child->getLevel() >= $options['depth'])) { $child->setChild([]); break; } // Set Child List Class $child->setChildAttr(array_merge_recursive($child->getChildAttr(), ['class' => 'menu_level_' . $child->getLevel()])); $this->recursiveProcess($child, $options); } } // Sort Item usort($childs, function ($a, $b) { return $a->getOrder() > $b->getOrder(); }); // Set Childs $menu->setChild($childs); }
[ "private", "function", "recursiveProcess", "(", "ItemInterface", "$", "menu", ",", "$", "options", ")", "{", "// Get Child Menus", "$", "childs", "=", "$", "menu", "->", "getChild", "(", ")", ";", "// Parent Menu Route", "if", "(", "isset", "(", "$", "menu", "->", "getChildAttr", "(", ")", "[", "'data-parent'", "]", ")", ")", "{", "$", "menu", "->", "setChildAttr", "(", "[", "'data-parent'", "=>", "$", "this", "->", "router", "->", "generate", "(", "$", "menu", "->", "getChildAttr", "(", ")", "[", "'data-parent'", "]", ")", "]", ")", ";", "}", "// Sort Current Child", "foreach", "(", "$", "childs", "as", "$", "child", ")", "{", "// Generate Route Link", "if", "(", "$", "child", "->", "getRoute", "(", ")", ")", "{", "$", "child", "->", "setLink", "(", "$", "this", "->", "router", "->", "generate", "(", "$", "child", "->", "getRoute", "(", ")", "[", "'name'", "]", ",", "$", "child", "->", "getRoute", "(", ")", "[", "'params'", "]", ")", ")", ";", "// Link Active Class", "if", "(", "$", "this", "->", "currentUri", "===", "$", "child", "->", "getLink", "(", ")", ")", "{", "$", "child", "->", "setListAttr", "(", "array_merge_recursive", "(", "$", "child", "->", "getListAttr", "(", ")", ",", "[", "'class'", "=>", "$", "options", "[", "'currentClass'", "]", "]", ")", ")", ";", "}", "}", "// Item Security", "if", "(", "$", "child", "->", "getRoles", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "security", "->", "isGranted", "(", "$", "child", "->", "getRoles", "(", ")", ")", ")", "{", "unset", "(", "$", "childs", "[", "$", "child", "->", "getId", "(", ")", "]", ")", ";", "}", "}", "// Set Child Process", "if", "(", "$", "child", "->", "getChild", "(", ")", ")", "{", "// Set Menu Depth", "if", "(", "null", "!==", "$", "options", "[", "'depth'", "]", "&&", "(", "$", "child", "->", "getLevel", "(", ")", ">=", "$", "options", "[", "'depth'", "]", ")", ")", "{", "$", "child", "->", "setChild", "(", "[", "]", ")", ";", "break", ";", "}", "// Set Child List Class", "$", "child", "->", "setChildAttr", "(", "array_merge_recursive", "(", "$", "child", "->", "getChildAttr", "(", ")", ",", "[", "'class'", "=>", "'menu_level_'", ".", "$", "child", "->", "getLevel", "(", ")", "]", ")", ")", ";", "$", "this", "->", "recursiveProcess", "(", "$", "child", ",", "$", "options", ")", ";", "}", "}", "// Sort Item", "usort", "(", "$", "childs", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "$", "a", "->", "getOrder", "(", ")", ">", "$", "b", "->", "getOrder", "(", ")", ";", "}", ")", ";", "// Set Childs", "$", "menu", "->", "setChild", "(", "$", "childs", ")", ";", "}" ]
Process Menu Item. @param ItemInterface $menu @param $options
[ "Process", "Menu", "Item", "." ]
fc4d9d107fe168a80af6e1bb99dd61939ebc54be
https://github.com/appaydin/pd-menu/blob/fc4d9d107fe168a80af6e1bb99dd61939ebc54be/Builder/ItemProcess.php#L91-L142
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Basket/Base.php
Base.checkListRef
protected function checkListRef( $prodId, $domain, array $refMap ) { if( empty( $refMap ) ) { return; } $context = $this->getContext(); $productManager = \Aimeos\MShop::create( $context, 'product' ); $search = $productManager->createSearch( true ); $expr = [$search->getConditions()]; $expr[] = $search->compare( '==', 'product.id', $prodId ); foreach( $refMap as $listType => $refIds ) { foreach( $refIds as $refId ) { $cmpfunc = $search->createFunction( 'product:has', [$domain, $listType, (string) $refId] ); $expr[] = $search->compare( '!=', $cmpfunc, null ); } } $search->setConditions( $search->combine( '&&', $expr ) ); if( count( $productManager->searchItems( $search, [] ) ) === 0 ) { $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid "%1$s" references for product with ID %2$s' ); throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, json_encode( $prodId ) ) ); } }
php
protected function checkListRef( $prodId, $domain, array $refMap ) { if( empty( $refMap ) ) { return; } $context = $this->getContext(); $productManager = \Aimeos\MShop::create( $context, 'product' ); $search = $productManager->createSearch( true ); $expr = [$search->getConditions()]; $expr[] = $search->compare( '==', 'product.id', $prodId ); foreach( $refMap as $listType => $refIds ) { foreach( $refIds as $refId ) { $cmpfunc = $search->createFunction( 'product:has', [$domain, $listType, (string) $refId] ); $expr[] = $search->compare( '!=', $cmpfunc, null ); } } $search->setConditions( $search->combine( '&&', $expr ) ); if( count( $productManager->searchItems( $search, [] ) ) === 0 ) { $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid "%1$s" references for product with ID %2$s' ); throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, json_encode( $prodId ) ) ); } }
[ "protected", "function", "checkListRef", "(", "$", "prodId", ",", "$", "domain", ",", "array", "$", "refMap", ")", "{", "if", "(", "empty", "(", "$", "refMap", ")", ")", "{", "return", ";", "}", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "productManager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "context", ",", "'product'", ")", ";", "$", "search", "=", "$", "productManager", "->", "createSearch", "(", "true", ")", ";", "$", "expr", "=", "[", "$", "search", "->", "getConditions", "(", ")", "]", ";", "$", "expr", "[", "]", "=", "$", "search", "->", "compare", "(", "'=='", ",", "'product.id'", ",", "$", "prodId", ")", ";", "foreach", "(", "$", "refMap", "as", "$", "listType", "=>", "$", "refIds", ")", "{", "foreach", "(", "$", "refIds", "as", "$", "refId", ")", "{", "$", "cmpfunc", "=", "$", "search", "->", "createFunction", "(", "'product:has'", ",", "[", "$", "domain", ",", "$", "listType", ",", "(", "string", ")", "$", "refId", "]", ")", ";", "$", "expr", "[", "]", "=", "$", "search", "->", "compare", "(", "'!='", ",", "$", "cmpfunc", ",", "null", ")", ";", "}", "}", "$", "search", "->", "setConditions", "(", "$", "search", "->", "combine", "(", "'&&'", ",", "$", "expr", ")", ")", ";", "if", "(", "count", "(", "$", "productManager", "->", "searchItems", "(", "$", "search", ",", "[", "]", ")", ")", "===", "0", ")", "{", "$", "msg", "=", "$", "context", "->", "getI18n", "(", ")", "->", "dt", "(", "'controller/frontend'", ",", "'Invalid \"%1$s\" references for product with ID %2$s'", ")", ";", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Basket", "\\", "Exception", "(", "sprintf", "(", "$", "msg", ",", "$", "domain", ",", "json_encode", "(", "$", "prodId", ")", ")", ")", ";", "}", "}" ]
Checks if the reference IDs are really associated to the product @param string|array $prodId Unique ID of the product or list of product IDs @param string $domain Domain the references must be of @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
[ "Checks", "if", "the", "reference", "IDs", "are", "really", "associated", "to", "the", "product" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Basket/Base.php#L88-L117
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Basket/Base.php
Base.createSubscriptions
protected function createSubscriptions( \Aimeos\MShop\Order\Item\Base\Iface $basket ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'subscription' ); foreach( $basket->getProducts() as $orderProduct ) { if( ( $interval = $orderProduct->getAttribute( 'interval', 'config' ) ) !== null ) { $item = $manager->createItem()->setInterval( $interval ) ->setOrderProductId( $orderProduct->getId() ) ->setOrderBaseId( $basket->getId() ); if( ( $end = $orderProduct->getAttribute( 'intervalend', 'custom' ) ) !== null || ( $end = $orderProduct->getAttribute( 'intervalend', 'config' ) ) !== null || ( $end = $orderProduct->getAttribute( 'intervalend', 'hidden' ) ) !== null ) { $item = $item->setDateEnd( $end ); } $manager->saveItem( $item, false ); } } }
php
protected function createSubscriptions( \Aimeos\MShop\Order\Item\Base\Iface $basket ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'subscription' ); foreach( $basket->getProducts() as $orderProduct ) { if( ( $interval = $orderProduct->getAttribute( 'interval', 'config' ) ) !== null ) { $item = $manager->createItem()->setInterval( $interval ) ->setOrderProductId( $orderProduct->getId() ) ->setOrderBaseId( $basket->getId() ); if( ( $end = $orderProduct->getAttribute( 'intervalend', 'custom' ) ) !== null || ( $end = $orderProduct->getAttribute( 'intervalend', 'config' ) ) !== null || ( $end = $orderProduct->getAttribute( 'intervalend', 'hidden' ) ) !== null ) { $item = $item->setDateEnd( $end ); } $manager->saveItem( $item, false ); } } }
[ "protected", "function", "createSubscriptions", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Order", "\\", "Item", "\\", "Base", "\\", "Iface", "$", "basket", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'subscription'", ")", ";", "foreach", "(", "$", "basket", "->", "getProducts", "(", ")", "as", "$", "orderProduct", ")", "{", "if", "(", "(", "$", "interval", "=", "$", "orderProduct", "->", "getAttribute", "(", "'interval'", ",", "'config'", ")", ")", "!==", "null", ")", "{", "$", "item", "=", "$", "manager", "->", "createItem", "(", ")", "->", "setInterval", "(", "$", "interval", ")", "->", "setOrderProductId", "(", "$", "orderProduct", "->", "getId", "(", ")", ")", "->", "setOrderBaseId", "(", "$", "basket", "->", "getId", "(", ")", ")", ";", "if", "(", "(", "$", "end", "=", "$", "orderProduct", "->", "getAttribute", "(", "'intervalend'", ",", "'custom'", ")", ")", "!==", "null", "||", "(", "$", "end", "=", "$", "orderProduct", "->", "getAttribute", "(", "'intervalend'", ",", "'config'", ")", ")", "!==", "null", "||", "(", "$", "end", "=", "$", "orderProduct", "->", "getAttribute", "(", "'intervalend'", ",", "'hidden'", ")", ")", "!==", "null", ")", "{", "$", "item", "=", "$", "item", "->", "setDateEnd", "(", "$", "end", ")", ";", "}", "$", "manager", "->", "saveItem", "(", "$", "item", ",", "false", ")", ";", "}", "}", "}" ]
Creates the subscription entries for the ordered products with interval attributes @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
[ "Creates", "the", "subscription", "entries", "for", "the", "ordered", "products", "with", "interval", "attributes" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Basket/Base.php#L326-L348
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Basket/Base.php
Base.getOrderProductAttributes
protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] ) { $list = []; if( !empty( $ids ) ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'order/base/product/attribute' ); foreach( $this->getAttributes( $ids ) as $id => $attrItem ) { $list[] = $manager->createItem()->copyFrom( $attrItem )->setType( $type ) ->setValue( isset( $values[$id] ) ? $values[$id] : $attrItem->getCode() ) ->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 ); } } return $list; }
php
protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] ) { $list = []; if( !empty( $ids ) ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'order/base/product/attribute' ); foreach( $this->getAttributes( $ids ) as $id => $attrItem ) { $list[] = $manager->createItem()->copyFrom( $attrItem )->setType( $type ) ->setValue( isset( $values[$id] ) ? $values[$id] : $attrItem->getCode() ) ->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 ); } } return $list; }
[ "protected", "function", "getOrderProductAttributes", "(", "$", "type", ",", "array", "$", "ids", ",", "array", "$", "values", "=", "[", "]", ",", "array", "$", "quantities", "=", "[", "]", ")", "{", "$", "list", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "ids", ")", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'order/base/product/attribute'", ")", ";", "foreach", "(", "$", "this", "->", "getAttributes", "(", "$", "ids", ")", "as", "$", "id", "=>", "$", "attrItem", ")", "{", "$", "list", "[", "]", "=", "$", "manager", "->", "createItem", "(", ")", "->", "copyFrom", "(", "$", "attrItem", ")", "->", "setType", "(", "$", "type", ")", "->", "setValue", "(", "isset", "(", "$", "values", "[", "$", "id", "]", ")", "?", "$", "values", "[", "$", "id", "]", ":", "$", "attrItem", "->", "getCode", "(", ")", ")", "->", "setQuantity", "(", "isset", "(", "$", "quantities", "[", "$", "id", "]", ")", "?", "$", "quantities", "[", "$", "id", "]", ":", "1", ")", ";", "}", "}", "return", "$", "list", ";", "}" ]
Returns the order product attribute items for the given IDs and values @param string $type Attribute type code @param array $ids List of attributes IDs of the given type @param array $values Associative list of attribute IDs as keys and their codes as values @param array $quantities Associative list of attribute IDs as keys and their quantities as values @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
[ "Returns", "the", "order", "product", "attribute", "items", "for", "the", "given", "IDs", "and", "values" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Basket/Base.php#L433-L450
train
acquia/acquia-sdk-php
src/Acquia/Cloud/Environment/CloudEnvironment.php
CloudEnvironment.getenv
protected function getenv($key) { $value = getenv($key); if ($value === false) { if (isset($_ENV[$key])) { $value = $_ENV[$key]; } if (isset($_SERVER[$key])) { $value = $_SERVER[$key]; } } return $value; }
php
protected function getenv($key) { $value = getenv($key); if ($value === false) { if (isset($_ENV[$key])) { $value = $_ENV[$key]; } if (isset($_SERVER[$key])) { $value = $_SERVER[$key]; } } return $value; }
[ "protected", "function", "getenv", "(", "$", "key", ")", "{", "$", "value", "=", "getenv", "(", "$", "key", ")", ";", "if", "(", "$", "value", "===", "false", ")", "{", "if", "(", "isset", "(", "$", "_ENV", "[", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", "_ENV", "[", "$", "key", "]", ";", "}", "if", "(", "isset", "(", "$", "_SERVER", "[", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", "_SERVER", "[", "$", "key", "]", ";", "}", "}", "return", "$", "value", ";", "}" ]
Acquia Cloud variables may be set in settings.inc after PHP init, so make sure that we are loading them. @param string $key @return string The value of the environment variable or false if not found @see https://github.com/acquia/acquia-sdk-php/pull/58#issuecomment-45167451
[ "Acquia", "Cloud", "variables", "may", "be", "set", "in", "settings", ".", "inc", "after", "PHP", "init", "so", "make", "sure", "that", "we", "are", "loading", "them", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Cloud/Environment/CloudEnvironment.php#L36-L48
train
ARCANEDEV/LaravelSettings
src/Stores/DatabaseStore.php
DatabaseStore.prepareInsertData
protected function prepareInsertData(array $data) { $dbData = []; $extraColumns = $this->extraColumns ? $this->extraColumns : []; foreach ($data as $key => $value) { $dbData[] = array_merge($extraColumns, [ $this->keyColumn => $key, $this->valueColumn => $value, ]); } return $dbData; }
php
protected function prepareInsertData(array $data) { $dbData = []; $extraColumns = $this->extraColumns ? $this->extraColumns : []; foreach ($data as $key => $value) { $dbData[] = array_merge($extraColumns, [ $this->keyColumn => $key, $this->valueColumn => $value, ]); } return $dbData; }
[ "protected", "function", "prepareInsertData", "(", "array", "$", "data", ")", "{", "$", "dbData", "=", "[", "]", ";", "$", "extraColumns", "=", "$", "this", "->", "extraColumns", "?", "$", "this", "->", "extraColumns", ":", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "dbData", "[", "]", "=", "array_merge", "(", "$", "extraColumns", ",", "[", "$", "this", "->", "keyColumn", "=>", "$", "key", ",", "$", "this", "->", "valueColumn", "=>", "$", "value", ",", "]", ")", ";", "}", "return", "$", "dbData", ";", "}" ]
Transforms settings data into an array ready to be inserted into the database. Call array_dot on a multidimensional array before passing it into this method! @param array $data @return array
[ "Transforms", "settings", "data", "into", "an", "array", "ready", "to", "be", "inserted", "into", "the", "database", ".", "Call", "array_dot", "on", "a", "multidimensional", "array", "before", "passing", "it", "into", "this", "method!" ]
b6c43bf6a2c2aef1cfb41e90361201393a8eed35
https://github.com/ARCANEDEV/LaravelSettings/blob/b6c43bf6a2c2aef1cfb41e90361201393a8eed35/src/Stores/DatabaseStore.php#L268-L281
train
ARCANEDEV/LaravelSettings
src/Stores/DatabaseStore.php
DatabaseStore.getChanges
private function getChanges(array $data) { $changes = [ 'inserted' => Arr::dot($data), 'updated' => [], 'deleted' => [], ]; foreach ($this->newQuery()->pluck($this->keyColumn) as $key) { if (Arr::has($changes['inserted'], $key)) $changes['updated'][$key] = $changes['inserted'][$key]; else $changes['deleted'][] = $key; Arr::forget($changes['inserted'], $key); } return $changes; }
php
private function getChanges(array $data) { $changes = [ 'inserted' => Arr::dot($data), 'updated' => [], 'deleted' => [], ]; foreach ($this->newQuery()->pluck($this->keyColumn) as $key) { if (Arr::has($changes['inserted'], $key)) $changes['updated'][$key] = $changes['inserted'][$key]; else $changes['deleted'][] = $key; Arr::forget($changes['inserted'], $key); } return $changes; }
[ "private", "function", "getChanges", "(", "array", "$", "data", ")", "{", "$", "changes", "=", "[", "'inserted'", "=>", "Arr", "::", "dot", "(", "$", "data", ")", ",", "'updated'", "=>", "[", "]", ",", "'deleted'", "=>", "[", "]", ",", "]", ";", "foreach", "(", "$", "this", "->", "newQuery", "(", ")", "->", "pluck", "(", "$", "this", "->", "keyColumn", ")", "as", "$", "key", ")", "{", "if", "(", "Arr", "::", "has", "(", "$", "changes", "[", "'inserted'", "]", ",", "$", "key", ")", ")", "$", "changes", "[", "'updated'", "]", "[", "$", "key", "]", "=", "$", "changes", "[", "'inserted'", "]", "[", "$", "key", "]", ";", "else", "$", "changes", "[", "'deleted'", "]", "[", "]", "=", "$", "key", ";", "Arr", "::", "forget", "(", "$", "changes", "[", "'inserted'", "]", ",", "$", "key", ")", ";", "}", "return", "$", "changes", ";", "}" ]
Get the changed settings data. @param array $data @return array
[ "Get", "the", "changed", "settings", "data", "." ]
b6c43bf6a2c2aef1cfb41e90361201393a8eed35
https://github.com/ARCANEDEV/LaravelSettings/blob/b6c43bf6a2c2aef1cfb41e90361201393a8eed35/src/Stores/DatabaseStore.php#L300-L318
train
ARCANEDEV/LaravelSettings
src/Stores/DatabaseStore.php
DatabaseStore.syncUpdated
private function syncUpdated(array $updated) { foreach ($updated as $key => $value) { $this->newQuery() ->where($this->keyColumn, '=', $key) ->update([$this->valueColumn => $value]); } }
php
private function syncUpdated(array $updated) { foreach ($updated as $key => $value) { $this->newQuery() ->where($this->keyColumn, '=', $key) ->update([$this->valueColumn => $value]); } }
[ "private", "function", "syncUpdated", "(", "array", "$", "updated", ")", "{", "foreach", "(", "$", "updated", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "newQuery", "(", ")", "->", "where", "(", "$", "this", "->", "keyColumn", ",", "'='", ",", "$", "key", ")", "->", "update", "(", "[", "$", "this", "->", "valueColumn", "=>", "$", "value", "]", ")", ";", "}", "}" ]
Sync the updated records. @param array $updated
[ "Sync", "the", "updated", "records", "." ]
b6c43bf6a2c2aef1cfb41e90361201393a8eed35
https://github.com/ARCANEDEV/LaravelSettings/blob/b6c43bf6a2c2aef1cfb41e90361201393a8eed35/src/Stores/DatabaseStore.php#L325-L332
train
ARCANEDEV/LaravelSettings
src/Stores/DatabaseStore.php
DatabaseStore.syncInserted
private function syncInserted(array $inserted) { if ( ! empty($inserted)) { $this->newQuery(true)->insert( $this->prepareInsertData($inserted) ); } }
php
private function syncInserted(array $inserted) { if ( ! empty($inserted)) { $this->newQuery(true)->insert( $this->prepareInsertData($inserted) ); } }
[ "private", "function", "syncInserted", "(", "array", "$", "inserted", ")", "{", "if", "(", "!", "empty", "(", "$", "inserted", ")", ")", "{", "$", "this", "->", "newQuery", "(", "true", ")", "->", "insert", "(", "$", "this", "->", "prepareInsertData", "(", "$", "inserted", ")", ")", ";", "}", "}" ]
Sync the inserted records. @param array $inserted
[ "Sync", "the", "inserted", "records", "." ]
b6c43bf6a2c2aef1cfb41e90361201393a8eed35
https://github.com/ARCANEDEV/LaravelSettings/blob/b6c43bf6a2c2aef1cfb41e90361201393a8eed35/src/Stores/DatabaseStore.php#L339-L346
train
ARCANEDEV/LaravelSettings
src/Stores/DatabaseStore.php
DatabaseStore.syncDeleted
private function syncDeleted(array $deleted) { if ( ! empty($deleted)) { $this->newQuery()->whereIn($this->keyColumn, $deleted)->delete(); } }
php
private function syncDeleted(array $deleted) { if ( ! empty($deleted)) { $this->newQuery()->whereIn($this->keyColumn, $deleted)->delete(); } }
[ "private", "function", "syncDeleted", "(", "array", "$", "deleted", ")", "{", "if", "(", "!", "empty", "(", "$", "deleted", ")", ")", "{", "$", "this", "->", "newQuery", "(", ")", "->", "whereIn", "(", "$", "this", "->", "keyColumn", ",", "$", "deleted", ")", "->", "delete", "(", ")", ";", "}", "}" ]
Sync the deleted records. @param array $deleted
[ "Sync", "the", "deleted", "records", "." ]
b6c43bf6a2c2aef1cfb41e90361201393a8eed35
https://github.com/ARCANEDEV/LaravelSettings/blob/b6c43bf6a2c2aef1cfb41e90361201393a8eed35/src/Stores/DatabaseStore.php#L353-L358
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Stock/Standard.php
Standard.code
public function code( $codes ) { if( !empty( $codes ) ) { $this->conditions[] = $this->filter->compare( '==', 'stock.productcode', $codes ); } return $this; }
php
public function code( $codes ) { if( !empty( $codes ) ) { $this->conditions[] = $this->filter->compare( '==', 'stock.productcode', $codes ); } return $this; }
[ "public", "function", "code", "(", "$", "codes", ")", "{", "if", "(", "!", "empty", "(", "$", "codes", ")", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'=='", ",", "'stock.productcode'", ",", "$", "codes", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds the SKUs of the products for filtering @param array|string $codes Codes of the products @return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface @since 2019.04
[ "Adds", "the", "SKUs", "of", "the", "products", "for", "filtering" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Stock/Standard.php#L60-L67
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Stock/Standard.php
Standard.type
public function type( $types ) { if( !empty( $types ) ) { $this->conditions[] = $this->filter->compare( '==', 'stock.type', $types ); } return $this; }
php
public function type( $types ) { if( !empty( $types ) ) { $this->conditions[] = $this->filter->compare( '==', 'stock.type', $types ); } return $this; }
[ "public", "function", "type", "(", "$", "types", ")", "{", "if", "(", "!", "empty", "(", "$", "types", ")", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'=='", ",", "'stock.type'", ",", "$", "types", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds stock types for filtering @param array|string $types Stock type codes @return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface @since 2019.04
[ "Adds", "stock", "types", "for", "filtering" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Stock/Standard.php#L199-L206
train
boekkooi/JqueryValidationBundle
src/Form/Extension/FormTypeExtension.php
FormTypeExtension.findConstraints
protected function findConstraints(FormInterface $form) { $constraints = new ConstraintCollection(); // Find constraints configured with the form $formConstraints = $form->getConfig()->getOption('constraints'); if (!empty($formConstraints)) { if (is_array($formConstraints)) { $constraints->addCollection( new ConstraintCollection($formConstraints) ); } else { $constraints->add($formConstraints); } } // Find constraints bound by data if ($form->getConfig()->getMapped()) { $constraints->addCollection( $this->constraintFinder->find($form) ); } return $constraints; }
php
protected function findConstraints(FormInterface $form) { $constraints = new ConstraintCollection(); // Find constraints configured with the form $formConstraints = $form->getConfig()->getOption('constraints'); if (!empty($formConstraints)) { if (is_array($formConstraints)) { $constraints->addCollection( new ConstraintCollection($formConstraints) ); } else { $constraints->add($formConstraints); } } // Find constraints bound by data if ($form->getConfig()->getMapped()) { $constraints->addCollection( $this->constraintFinder->find($form) ); } return $constraints; }
[ "protected", "function", "findConstraints", "(", "FormInterface", "$", "form", ")", "{", "$", "constraints", "=", "new", "ConstraintCollection", "(", ")", ";", "// Find constraints configured with the form", "$", "formConstraints", "=", "$", "form", "->", "getConfig", "(", ")", "->", "getOption", "(", "'constraints'", ")", ";", "if", "(", "!", "empty", "(", "$", "formConstraints", ")", ")", "{", "if", "(", "is_array", "(", "$", "formConstraints", ")", ")", "{", "$", "constraints", "->", "addCollection", "(", "new", "ConstraintCollection", "(", "$", "formConstraints", ")", ")", ";", "}", "else", "{", "$", "constraints", "->", "add", "(", "$", "formConstraints", ")", ";", "}", "}", "// Find constraints bound by data", "if", "(", "$", "form", "->", "getConfig", "(", ")", "->", "getMapped", "(", ")", ")", "{", "$", "constraints", "->", "addCollection", "(", "$", "this", "->", "constraintFinder", "->", "find", "(", "$", "form", ")", ")", ";", "}", "return", "$", "constraints", ";", "}" ]
Find all constraints for the given FormInterface. @param FormInterface $form @return ConstraintCollection
[ "Find", "all", "constraints", "for", "the", "given", "FormInterface", "." ]
7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5
https://github.com/boekkooi/JqueryValidationBundle/blob/7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5/src/Form/Extension/FormTypeExtension.php#L177-L201
train
boekkooi/JqueryValidationBundle
src/Form/FormRuleContext.php
FormRuleContext.get
public function get($name) { return isset($this->rules[$name]) ? $this->rules[$name] : null; }
php
public function get($name) { return isset($this->rules[$name]) ? $this->rules[$name] : null; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "rules", "[", "$", "name", "]", ")", "?", "$", "this", "->", "rules", "[", "$", "name", "]", ":", "null", ";", "}" ]
Gets a rule list by name. @param string $name The form full_name @return RuleCollection|null A array of Rule instances or null when not found
[ "Gets", "a", "rule", "list", "by", "name", "." ]
7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5
https://github.com/boekkooi/JqueryValidationBundle/blob/7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5/src/Form/FormRuleContext.php#L46-L49
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Customer/Standard.php
Standard.add
public function add( array $values ) { $item = $this->item->fromArray( $values ); $addrItem = $item->getPaymentAddress(); if( $item->getLabel() === '' ) { $label = $addrItem->getLastname(); if( ( $firstName = $addrItem->getFirstname() ) !== '' ) { $label = $firstName . ' ' . $label; } if( ( $company = $addrItem->getCompany() ) !== '' ) { $label .= ' (' . $company . ')'; } $item = $item->setLabel( $label ); } if( $item->getCode() === '' ) { $item = $item->setCode( $addrItem->getEmail() ); } $this->item = $item; return $this; }
php
public function add( array $values ) { $item = $this->item->fromArray( $values ); $addrItem = $item->getPaymentAddress(); if( $item->getLabel() === '' ) { $label = $addrItem->getLastname(); if( ( $firstName = $addrItem->getFirstname() ) !== '' ) { $label = $firstName . ' ' . $label; } if( ( $company = $addrItem->getCompany() ) !== '' ) { $label .= ' (' . $company . ')'; } $item = $item->setLabel( $label ); } if( $item->getCode() === '' ) { $item = $item->setCode( $addrItem->getEmail() ); } $this->item = $item; return $this; }
[ "public", "function", "add", "(", "array", "$", "values", ")", "{", "$", "item", "=", "$", "this", "->", "item", "->", "fromArray", "(", "$", "values", ")", ";", "$", "addrItem", "=", "$", "item", "->", "getPaymentAddress", "(", ")", ";", "if", "(", "$", "item", "->", "getLabel", "(", ")", "===", "''", ")", "{", "$", "label", "=", "$", "addrItem", "->", "getLastname", "(", ")", ";", "if", "(", "(", "$", "firstName", "=", "$", "addrItem", "->", "getFirstname", "(", ")", ")", "!==", "''", ")", "{", "$", "label", "=", "$", "firstName", ".", "' '", ".", "$", "label", ";", "}", "if", "(", "(", "$", "company", "=", "$", "addrItem", "->", "getCompany", "(", ")", ")", "!==", "''", ")", "{", "$", "label", ".=", "' ('", ".", "$", "company", ".", "')'", ";", "}", "$", "item", "=", "$", "item", "->", "setLabel", "(", "$", "label", ")", ";", "}", "if", "(", "$", "item", "->", "getCode", "(", ")", "===", "''", ")", "{", "$", "item", "=", "$", "item", "->", "setCode", "(", "$", "addrItem", "->", "getEmail", "(", ")", ")", ";", "}", "$", "this", "->", "item", "=", "$", "item", ";", "return", "$", "this", ";", "}" ]
Creates a new customer item object pre-filled with the given values but not yet stored @param array $values Values added to the customer item (new or existing) like "customer.code" @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface @since 2019.04
[ "Creates", "a", "new", "customer", "item", "object", "pre", "-", "filled", "with", "the", "given", "values", "but", "not", "yet", "stored" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Customer/Standard.php#L73-L99
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Customer/Standard.php
Standard.createAddressItem
public function createAddressItem( array $values = [] ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/address' ); return $manager->createItem()->fromArray( $values ); }
php
public function createAddressItem( array $values = [] ) { $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/address' ); return $manager->createItem()->fromArray( $values ); }
[ "public", "function", "createAddressItem", "(", "array", "$", "values", "=", "[", "]", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'customer/address'", ")", ";", "return", "$", "manager", "->", "createItem", "(", ")", "->", "fromArray", "(", "$", "values", ")", ";", "}" ]
Creates a new address item object pre-filled with the given values @return \Aimeos\MShop\Customer\Item\Address\Iface Address item @since 2019.04
[ "Creates", "a", "new", "address", "item", "object", "pre", "-", "filled", "with", "the", "given", "values" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Customer/Standard.php#L153-L157
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Customer/Standard.php
Standard.delete
public function delete() { if( $this->item && $this->item->getId() ) { \Aimeos\MShop::create( $this->getContext(), 'customer' )->deleteItem( $this->item->getId() ); } return $this; }
php
public function delete() { if( $this->item && $this->item->getId() ) { \Aimeos\MShop::create( $this->getContext(), 'customer' )->deleteItem( $this->item->getId() ); } return $this; }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "$", "this", "->", "item", "&&", "$", "this", "->", "item", "->", "getId", "(", ")", ")", "{", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'customer'", ")", "->", "deleteItem", "(", "$", "this", "->", "item", "->", "getId", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Deletes a customer item that belongs to the current authenticated user @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items @since 2019.04
[ "Deletes", "a", "customer", "item", "that", "belongs", "to", "the", "current", "authenticated", "user" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Customer/Standard.php#L192-L199
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Customer/Standard.php
Standard.store
public function store() { ( $id = $this->item->getId() ) !== null ? $this->checkId( $id ) : $this->checkLimit(); $context = $this->getContext(); if( $id === null ) { $msg = $this->item->toArray(); $msg['customer.password'] = null; // Show only generated passwords in account creation e-mails if( $this->item->getPassword() === '' ) { $msg['customer.password'] = substr( sha1( microtime( true ) . getmypid() . rand() ), -8 ); } $context->getMessageQueue( 'mq-email', 'customer/email/account' )->add( json_encode( $msg ) ); } $this->item = $this->manager->saveItem( $this->item ); return $this; }
php
public function store() { ( $id = $this->item->getId() ) !== null ? $this->checkId( $id ) : $this->checkLimit(); $context = $this->getContext(); if( $id === null ) { $msg = $this->item->toArray(); $msg['customer.password'] = null; // Show only generated passwords in account creation e-mails if( $this->item->getPassword() === '' ) { $msg['customer.password'] = substr( sha1( microtime( true ) . getmypid() . rand() ), -8 ); } $context->getMessageQueue( 'mq-email', 'customer/email/account' )->add( json_encode( $msg ) ); } $this->item = $this->manager->saveItem( $this->item ); return $this; }
[ "public", "function", "store", "(", ")", "{", "(", "$", "id", "=", "$", "this", "->", "item", "->", "getId", "(", ")", ")", "!==", "null", "?", "$", "this", "->", "checkId", "(", "$", "id", ")", ":", "$", "this", "->", "checkLimit", "(", ")", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "if", "(", "$", "id", "===", "null", ")", "{", "$", "msg", "=", "$", "this", "->", "item", "->", "toArray", "(", ")", ";", "$", "msg", "[", "'customer.password'", "]", "=", "null", ";", "// Show only generated passwords in account creation e-mails", "if", "(", "$", "this", "->", "item", "->", "getPassword", "(", ")", "===", "''", ")", "{", "$", "msg", "[", "'customer.password'", "]", "=", "substr", "(", "sha1", "(", "microtime", "(", "true", ")", ".", "getmypid", "(", ")", ".", "rand", "(", ")", ")", ",", "-", "8", ")", ";", "}", "$", "context", "->", "getMessageQueue", "(", "'mq-email'", ",", "'customer/email/account'", ")", "->", "add", "(", "json_encode", "(", "$", "msg", ")", ")", ";", "}", "$", "this", "->", "item", "=", "$", "this", "->", "manager", "->", "saveItem", "(", "$", "this", "->", "item", ")", ";", "return", "$", "this", ";", "}" ]
Adds or updates a modified customer item in the storage @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface @since 2019.04
[ "Adds", "or", "updates", "a", "modified", "customer", "item", "in", "the", "storage" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Customer/Standard.php#L276-L296
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Customer/Standard.php
Standard.uses
public function uses( array $domains ) { $this->domains = $domains; if( ( $id = $this->getContext()->getUserId() ) !== null ) { $this->item = $this->manager->getItem( $id, $domains, true ); } return $this; }
php
public function uses( array $domains ) { $this->domains = $domains; if( ( $id = $this->getContext()->getUserId() ) !== null ) { $this->item = $this->manager->getItem( $id, $domains, true ); } return $this; }
[ "public", "function", "uses", "(", "array", "$", "domains", ")", "{", "$", "this", "->", "domains", "=", "$", "domains", ";", "if", "(", "(", "$", "id", "=", "$", "this", "->", "getContext", "(", ")", "->", "getUserId", "(", ")", ")", "!==", "null", ")", "{", "$", "this", "->", "item", "=", "$", "this", "->", "manager", "->", "getItem", "(", "$", "id", ",", "$", "domains", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the domains that will be used when working with the customer item @param array $domains Domain names of the referenced items that should be fetched too @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface @since 2019.04
[ "Sets", "the", "domains", "that", "will", "be", "used", "when", "working", "with", "the", "customer", "item" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Customer/Standard.php#L306-L315
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Customer/Standard.php
Standard.checkLimit
protected function checkLimit() { $total = 0; $context = $this->getContext(); $config = $context->getConfig(); /** controller/frontend/customer/limit-count * Maximum number of customers within the time frame * * Creating new customers is limited to avoid abuse and mitigate denial of * service attacks. The number of customer accountss created within the * time frame configured by "controller/frontend/customer/limit-seconds" * are counted before a new customer account (identified by the IP address) * is created. If the number of accounts is higher than the configured value, * an error message will be shown to the user instead of creating a new account. * * @param integer Number of customer accounts allowed within the time frame * @since 2017.07 * @category Developer * @see controller/frontend/customer/limit-seconds */ $count = $config->get( 'controller/frontend/customer/limit-count', 5 ); /** controller/frontend/customer/limit-seconds * Customer account limitation time frame in seconds * * Creating new customer accounts is limited to avoid abuse and mitigate * denial of service attacks. Within the configured time frame, only a * limited number of customer accounts can be created. All accounts from * the same source (identified by the IP address) within the last X * seconds are counted. If the total value is higher then the number * configured in "controller/frontend/customer/limit-count", an error * message will be shown to the user instead of creating a new account. * * @param integer Number of seconds to check customer accounts within * @since 2017.07 * @category Developer * @see controller/frontend/customer/limit-count */ $seconds = $config->get( 'controller/frontend/customer/limit-seconds', 300 ); $search = $this->manager->createSearch()->setSlice( 0, 0 ); $expr = [ $search->compare( '==', 'customer.editor', $context->getEditor() ), $search->compare( '>=', 'customer.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), ]; $search->setConditions( $search->combine( '&&', $expr ) ); $this->manager->searchItems( $search, [], $total ); if( $total > $count ) { throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'Temporary limit reached' ) ); } }
php
protected function checkLimit() { $total = 0; $context = $this->getContext(); $config = $context->getConfig(); /** controller/frontend/customer/limit-count * Maximum number of customers within the time frame * * Creating new customers is limited to avoid abuse and mitigate denial of * service attacks. The number of customer accountss created within the * time frame configured by "controller/frontend/customer/limit-seconds" * are counted before a new customer account (identified by the IP address) * is created. If the number of accounts is higher than the configured value, * an error message will be shown to the user instead of creating a new account. * * @param integer Number of customer accounts allowed within the time frame * @since 2017.07 * @category Developer * @see controller/frontend/customer/limit-seconds */ $count = $config->get( 'controller/frontend/customer/limit-count', 5 ); /** controller/frontend/customer/limit-seconds * Customer account limitation time frame in seconds * * Creating new customer accounts is limited to avoid abuse and mitigate * denial of service attacks. Within the configured time frame, only a * limited number of customer accounts can be created. All accounts from * the same source (identified by the IP address) within the last X * seconds are counted. If the total value is higher then the number * configured in "controller/frontend/customer/limit-count", an error * message will be shown to the user instead of creating a new account. * * @param integer Number of seconds to check customer accounts within * @since 2017.07 * @category Developer * @see controller/frontend/customer/limit-count */ $seconds = $config->get( 'controller/frontend/customer/limit-seconds', 300 ); $search = $this->manager->createSearch()->setSlice( 0, 0 ); $expr = [ $search->compare( '==', 'customer.editor', $context->getEditor() ), $search->compare( '>=', 'customer.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), ]; $search->setConditions( $search->combine( '&&', $expr ) ); $this->manager->searchItems( $search, [], $total ); if( $total > $count ) { throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'Temporary limit reached' ) ); } }
[ "protected", "function", "checkLimit", "(", ")", "{", "$", "total", "=", "0", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "config", "=", "$", "context", "->", "getConfig", "(", ")", ";", "/** controller/frontend/customer/limit-count\n\t\t * Maximum number of customers within the time frame\n\t\t *\n\t\t * Creating new customers is limited to avoid abuse and mitigate denial of\n\t\t * service attacks. The number of customer accountss created within the\n\t\t * time frame configured by \"controller/frontend/customer/limit-seconds\"\n\t\t * are counted before a new customer account (identified by the IP address)\n\t\t * is created. If the number of accounts is higher than the configured value,\n\t\t * an error message will be shown to the user instead of creating a new account.\n\t\t *\n\t\t * @param integer Number of customer accounts allowed within the time frame\n\t\t * @since 2017.07\n\t\t * @category Developer\n\t\t * @see controller/frontend/customer/limit-seconds\n\t\t */", "$", "count", "=", "$", "config", "->", "get", "(", "'controller/frontend/customer/limit-count'", ",", "5", ")", ";", "/** controller/frontend/customer/limit-seconds\n\t\t * Customer account limitation time frame in seconds\n\t\t *\n\t\t * Creating new customer accounts is limited to avoid abuse and mitigate\n\t\t * denial of service attacks. Within the configured time frame, only a\n\t\t * limited number of customer accounts can be created. All accounts from\n\t\t * the same source (identified by the IP address) within the last X\n\t\t * seconds are counted. If the total value is higher then the number\n\t\t * configured in \"controller/frontend/customer/limit-count\", an error\n\t\t * message will be shown to the user instead of creating a new account.\n\t\t *\n\t\t * @param integer Number of seconds to check customer accounts within\n\t\t * @since 2017.07\n\t\t * @category Developer\n\t\t * @see controller/frontend/customer/limit-count\n\t\t */", "$", "seconds", "=", "$", "config", "->", "get", "(", "'controller/frontend/customer/limit-seconds'", ",", "300", ")", ";", "$", "search", "=", "$", "this", "->", "manager", "->", "createSearch", "(", ")", "->", "setSlice", "(", "0", ",", "0", ")", ";", "$", "expr", "=", "[", "$", "search", "->", "compare", "(", "'=='", ",", "'customer.editor'", ",", "$", "context", "->", "getEditor", "(", ")", ")", ",", "$", "search", "->", "compare", "(", "'>='", ",", "'customer.ctime'", ",", "date", "(", "'Y-m-d H:i:s'", ",", "time", "(", ")", "-", "$", "seconds", ")", ")", ",", "]", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "combine", "(", "'&&'", ",", "$", "expr", ")", ")", ";", "$", "this", "->", "manager", "->", "searchItems", "(", "$", "search", ",", "[", "]", ",", "$", "total", ")", ";", "if", "(", "$", "total", ">", "$", "count", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Customer", "\\", "Exception", "(", "sprintf", "(", "'Temporary limit reached'", ")", ")", ";", "}", "}" ]
Checks if the current user is allowed to create more customer accounts @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed
[ "Checks", "if", "the", "current", "user", "is", "allowed", "to", "create", "more", "customer", "accounts" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Customer/Standard.php#L323-L376
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Customer/Standard.php
Standard.checkId
protected function checkId( $id ) { if( $id != $this->getContext()->getUserId() ) { $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); } return $id; }
php
protected function checkId( $id ) { if( $id != $this->getContext()->getUserId() ) { $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); } return $id; }
[ "protected", "function", "checkId", "(", "$", "id", ")", "{", "if", "(", "$", "id", "!=", "$", "this", "->", "getContext", "(", ")", "->", "getUserId", "(", ")", ")", "{", "$", "msg", "=", "sprintf", "(", "'Not allowed to access customer data for ID \"%1$s\"'", ",", "$", "id", ")", ";", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Customer", "\\", "Exception", "(", "$", "msg", ")", ";", "}", "return", "$", "id", ";", "}" ]
Checks if the current user is allowed to retrieve the customer data for the given ID @param string $id Unique customer ID @return string Unique customer ID @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed
[ "Checks", "if", "the", "current", "user", "is", "allowed", "to", "retrieve", "the", "customer", "data", "for", "the", "given", "ID" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Customer/Standard.php#L386-L395
train
acquia/acquia-sdk-php
src/Acquia/Network/AcquiaNetworkClient.php
AcquiaNetworkClient.defaultRequestParams
protected function defaultRequestParams() { $params = array( 'authenticator' => $this->buildAuthenticator(), 'ssl' => $this->https === true ? 1 : 0, 'ip' => $this->serverAddress, 'host' => $this->httpHost, ); return $params; }
php
protected function defaultRequestParams() { $params = array( 'authenticator' => $this->buildAuthenticator(), 'ssl' => $this->https === true ? 1 : 0, 'ip' => $this->serverAddress, 'host' => $this->httpHost, ); return $params; }
[ "protected", "function", "defaultRequestParams", "(", ")", "{", "$", "params", "=", "array", "(", "'authenticator'", "=>", "$", "this", "->", "buildAuthenticator", "(", ")", ",", "'ssl'", "=>", "$", "this", "->", "https", "===", "true", "?", "1", ":", "0", ",", "'ip'", "=>", "$", "this", "->", "serverAddress", ",", "'host'", "=>", "$", "this", "->", "httpHost", ",", ")", ";", "return", "$", "params", ";", "}" ]
Returns default paramaters for request. Not every call requires these. @return array
[ "Returns", "default", "paramaters", "for", "request", ".", "Not", "every", "call", "requires", "these", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Network/AcquiaNetworkClient.php#L119-L128
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.allOf
public function allOf( $attrIds ) { if( !empty( $attrIds ) && ( $ids = array_unique( $this->validateIds( (array) $attrIds ) ) ) !== [] ) { $func = $this->filter->createFunction( 'index.attribute:allof', [$ids] ); $this->conditions[] = $this->filter->compare( '!=', $func, null ); } return $this; }
php
public function allOf( $attrIds ) { if( !empty( $attrIds ) && ( $ids = array_unique( $this->validateIds( (array) $attrIds ) ) ) !== [] ) { $func = $this->filter->createFunction( 'index.attribute:allof', [$ids] ); $this->conditions[] = $this->filter->compare( '!=', $func, null ); } return $this; }
[ "public", "function", "allOf", "(", "$", "attrIds", ")", "{", "if", "(", "!", "empty", "(", "$", "attrIds", ")", "&&", "(", "$", "ids", "=", "array_unique", "(", "$", "this", "->", "validateIds", "(", "(", "array", ")", "$", "attrIds", ")", ")", ")", "!==", "[", "]", ")", "{", "$", "func", "=", "$", "this", "->", "filter", "->", "createFunction", "(", "'index.attribute:allof'", ",", "[", "$", "ids", "]", ")", ";", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'!='", ",", "$", "func", ",", "null", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds attribute IDs for filtering where products must reference all IDs @param array|string $attrIds Attribute ID or list of IDs @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface @since 2019.04
[ "Adds", "attribute", "IDs", "for", "filtering", "where", "products", "must", "reference", "all", "IDs" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L77-L86
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.find
public function find( $code ) { return $this->manager->findItem( $code, $this->domains, 'product', null, true ); }
php
public function find( $code ) { return $this->manager->findItem( $code, $this->domains, 'product', null, true ); }
[ "public", "function", "find", "(", "$", "code", ")", "{", "return", "$", "this", "->", "manager", "->", "findItem", "(", "$", "code", ",", "$", "this", "->", "domains", ",", "'product'", ",", "null", ",", "true", ")", ";", "}" ]
Returns the product for the given product code @param string $code Unique product code @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items @since 2019.04
[ "Returns", "the", "product", "for", "the", "given", "product", "code" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L150-L153
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.oneOf
public function oneOf( $attrIds ) { $attrIds = (array) $attrIds; foreach( $attrIds as $key => $entry ) { if( is_array( $entry ) && ( $ids = array_unique( $this->validateIds( $entry ) ) ) !== [] ) { $func = $this->filter->createFunction( 'index.attribute:oneof', [$ids] ); $this->conditions[] = $this->filter->compare( '!=', $func, null ); unset( $attrIds[$key] ); } } if( ( $ids = array_unique( $this->validateIds( $attrIds ) ) ) !== [] ) { $func = $this->filter->createFunction( 'index.attribute:oneof', [$ids] ); $this->conditions[] = $this->filter->compare( '!=', $func, null ); } return $this; }
php
public function oneOf( $attrIds ) { $attrIds = (array) $attrIds; foreach( $attrIds as $key => $entry ) { if( is_array( $entry ) && ( $ids = array_unique( $this->validateIds( $entry ) ) ) !== [] ) { $func = $this->filter->createFunction( 'index.attribute:oneof', [$ids] ); $this->conditions[] = $this->filter->compare( '!=', $func, null ); unset( $attrIds[$key] ); } } if( ( $ids = array_unique( $this->validateIds( $attrIds ) ) ) !== [] ) { $func = $this->filter->createFunction( 'index.attribute:oneof', [$ids] ); $this->conditions[] = $this->filter->compare( '!=', $func, null ); } return $this; }
[ "public", "function", "oneOf", "(", "$", "attrIds", ")", "{", "$", "attrIds", "=", "(", "array", ")", "$", "attrIds", ";", "foreach", "(", "$", "attrIds", "as", "$", "key", "=>", "$", "entry", ")", "{", "if", "(", "is_array", "(", "$", "entry", ")", "&&", "(", "$", "ids", "=", "array_unique", "(", "$", "this", "->", "validateIds", "(", "$", "entry", ")", ")", ")", "!==", "[", "]", ")", "{", "$", "func", "=", "$", "this", "->", "filter", "->", "createFunction", "(", "'index.attribute:oneof'", ",", "[", "$", "ids", "]", ")", ";", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'!='", ",", "$", "func", ",", "null", ")", ";", "unset", "(", "$", "attrIds", "[", "$", "key", "]", ")", ";", "}", "}", "if", "(", "(", "$", "ids", "=", "array_unique", "(", "$", "this", "->", "validateIds", "(", "$", "attrIds", ")", ")", ")", "!==", "[", "]", ")", "{", "$", "func", "=", "$", "this", "->", "filter", "->", "createFunction", "(", "'index.attribute:oneof'", ",", "[", "$", "ids", "]", ")", ";", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'!='", ",", "$", "func", ",", "null", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds attribute IDs for filtering where products must reference at least one ID If an array of ID lists is given, each ID list is added separately as condition. @param array|string $attrIds Attribute ID, list of IDs or array of lists with IDs @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface @since 2019.04
[ "Adds", "attribute", "IDs", "for", "filtering", "where", "products", "must", "reference", "at", "least", "one", "ID" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L199-L220
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.product
public function product( $prodIds ) { if( !empty( $prodIds ) && ( $ids = array_unique( $this->validateIds( (array) $prodIds ) ) ) !== [] ) { $this->conditions[] = $this->filter->compare( '==', 'product.id', $ids ); } return $this; }
php
public function product( $prodIds ) { if( !empty( $prodIds ) && ( $ids = array_unique( $this->validateIds( (array) $prodIds ) ) ) !== [] ) { $this->conditions[] = $this->filter->compare( '==', 'product.id', $ids ); } return $this; }
[ "public", "function", "product", "(", "$", "prodIds", ")", "{", "if", "(", "!", "empty", "(", "$", "prodIds", ")", "&&", "(", "$", "ids", "=", "array_unique", "(", "$", "this", "->", "validateIds", "(", "(", "array", ")", "$", "prodIds", ")", ")", ")", "!==", "[", "]", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'=='", ",", "'product.id'", ",", "$", "ids", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds product IDs for filtering @param array|string $prodIds Product ID or list of IDs @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface @since 2019.04
[ "Adds", "product", "IDs", "for", "filtering" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L244-L251
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.resolve
public function resolve( $name ) { $langid = $this->getContext()->getLocale()->getLanguageId(); $search = $this->manager->createSearch(); $func = $search->createFunction( 'index.text:url', [$langid] ); $search->setConditions( $search->compare( '==', $func, $name ) ); $items = $this->manager->searchItems( $search, $this->domains ); if( ( $item = reset( $items ) ) !== false ) { return $item; } throw new \Aimeos\Controller\Frontend\Product\Exception( sprintf( 'Unable to find product "%1$s"', $name ) ); }
php
public function resolve( $name ) { $langid = $this->getContext()->getLocale()->getLanguageId(); $search = $this->manager->createSearch(); $func = $search->createFunction( 'index.text:url', [$langid] ); $search->setConditions( $search->compare( '==', $func, $name ) ); $items = $this->manager->searchItems( $search, $this->domains ); if( ( $item = reset( $items ) ) !== false ) { return $item; } throw new \Aimeos\Controller\Frontend\Product\Exception( sprintf( 'Unable to find product "%1$s"', $name ) ); }
[ "public", "function", "resolve", "(", "$", "name", ")", "{", "$", "langid", "=", "$", "this", "->", "getContext", "(", ")", "->", "getLocale", "(", ")", "->", "getLanguageId", "(", ")", ";", "$", "search", "=", "$", "this", "->", "manager", "->", "createSearch", "(", ")", ";", "$", "func", "=", "$", "search", "->", "createFunction", "(", "'index.text:url'", ",", "[", "$", "langid", "]", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "$", "func", ",", "$", "name", ")", ")", ";", "$", "items", "=", "$", "this", "->", "manager", "->", "searchItems", "(", "$", "search", ",", "$", "this", "->", "domains", ")", ";", "if", "(", "(", "$", "item", "=", "reset", "(", "$", "items", ")", ")", "!==", "false", ")", "{", "return", "$", "item", ";", "}", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Product", "\\", "Exception", "(", "sprintf", "(", "'Unable to find product \"%1$s\"'", ",", "$", "name", ")", ")", ";", "}" ]
Returns the product for the given product URL name @param string $name Product URL name @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items @since 2019.04
[ "Returns", "the", "product", "for", "the", "given", "product", "URL", "name" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L278-L293
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.search
public function search( &$total = null ) { $this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) ); return $this->manager->searchItems( $this->filter, $this->domains, $total ); }
php
public function search( &$total = null ) { $this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) ); return $this->manager->searchItems( $this->filter, $this->domains, $total ); }
[ "public", "function", "search", "(", "&", "$", "total", "=", "null", ")", "{", "$", "this", "->", "filter", "->", "setConditions", "(", "$", "this", "->", "filter", "->", "combine", "(", "'&&'", ",", "$", "this", "->", "conditions", ")", ")", ";", "return", "$", "this", "->", "manager", "->", "searchItems", "(", "$", "this", "->", "filter", ",", "$", "this", "->", "domains", ",", "$", "total", ")", ";", "}" ]
Returns the products filtered by the previously assigned conditions @param integer &$total Parameter where the total number of found products will be stored in @return \Aimeos\MShop\Product\Item\Iface[] Ordered list of product items @since 2019.04
[ "Returns", "the", "products", "filtered", "by", "the", "previously", "assigned", "conditions" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L303-L307
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.supplier
public function supplier( $supIds, $listtype = 'default' ) { if( !empty( $supIds ) && ( $ids = array_unique( $this->validateIds( (array) $supIds ) ) ) !== [] ) { $func = $this->filter->createFunction( 'index.supplier:position', [$listtype, $ids] ); $this->conditions[] = $this->filter->compare( '==', 'index.supplier.id', $ids ); $this->conditions[] = $this->filter->compare( '>=', $func, 0 ); $func = $this->filter->createFunction( 'sort:index.supplier:position', [$listtype, $ids] ); $this->sort = $this->filter->sort( '+', $func ); } return $this; }
php
public function supplier( $supIds, $listtype = 'default' ) { if( !empty( $supIds ) && ( $ids = array_unique( $this->validateIds( (array) $supIds ) ) ) !== [] ) { $func = $this->filter->createFunction( 'index.supplier:position', [$listtype, $ids] ); $this->conditions[] = $this->filter->compare( '==', 'index.supplier.id', $ids ); $this->conditions[] = $this->filter->compare( '>=', $func, 0 ); $func = $this->filter->createFunction( 'sort:index.supplier:position', [$listtype, $ids] ); $this->sort = $this->filter->sort( '+', $func ); } return $this; }
[ "public", "function", "supplier", "(", "$", "supIds", ",", "$", "listtype", "=", "'default'", ")", "{", "if", "(", "!", "empty", "(", "$", "supIds", ")", "&&", "(", "$", "ids", "=", "array_unique", "(", "$", "this", "->", "validateIds", "(", "(", "array", ")", "$", "supIds", ")", ")", ")", "!==", "[", "]", ")", "{", "$", "func", "=", "$", "this", "->", "filter", "->", "createFunction", "(", "'index.supplier:position'", ",", "[", "$", "listtype", ",", "$", "ids", "]", ")", ";", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'=='", ",", "'index.supplier.id'", ",", "$", "ids", ")", ";", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'>='", ",", "$", "func", ",", "0", ")", ";", "$", "func", "=", "$", "this", "->", "filter", "->", "createFunction", "(", "'sort:index.supplier:position'", ",", "[", "$", "listtype", ",", "$", "ids", "]", ")", ";", "$", "this", "->", "sort", "=", "$", "this", "->", "filter", "->", "sort", "(", "'+'", ",", "$", "func", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds supplier IDs for filtering @param array|string $supIds Supplier ID or list of IDs @param string $listtype List type of the products referenced by the suppliers @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface @since 2019.04
[ "Adds", "supplier", "IDs", "for", "filtering" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L419-L433
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.text
public function text( $text ) { if( !empty( $text ) ) { $langid = $this->getContext()->getLocale()->getLanguageId(); $func = $this->filter->createFunction( 'index.text:relevance', [$langid, $text] ); $this->conditions[] = $this->filter->compare( '>', $func, 0 ); } return $this; }
php
public function text( $text ) { if( !empty( $text ) ) { $langid = $this->getContext()->getLocale()->getLanguageId(); $func = $this->filter->createFunction( 'index.text:relevance', [$langid, $text] ); $this->conditions[] = $this->filter->compare( '>', $func, 0 ); } return $this; }
[ "public", "function", "text", "(", "$", "text", ")", "{", "if", "(", "!", "empty", "(", "$", "text", ")", ")", "{", "$", "langid", "=", "$", "this", "->", "getContext", "(", ")", "->", "getLocale", "(", ")", "->", "getLanguageId", "(", ")", ";", "$", "func", "=", "$", "this", "->", "filter", "->", "createFunction", "(", "'index.text:relevance'", ",", "[", "$", "langid", ",", "$", "text", "]", ")", ";", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'>'", ",", "$", "func", ",", "0", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds input string for full text search @param string|null $text User input for full text search @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface @since 2019.04
[ "Adds", "input", "string", "for", "full", "text", "search" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L443-L454
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.getCatalogIdsFromTree
protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) { if( $item->getStatus() < 1 ) { return []; } $list = [ $item->getId() ]; foreach( $item->getChildren() as $child ) { $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); } return $list; }
php
protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) { if( $item->getStatus() < 1 ) { return []; } $list = [ $item->getId() ]; foreach( $item->getChildren() as $child ) { $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); } return $list; }
[ "protected", "function", "getCatalogIdsFromTree", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Catalog", "\\", "Item", "\\", "Iface", "$", "item", ")", "{", "if", "(", "$", "item", "->", "getStatus", "(", ")", "<", "1", ")", "{", "return", "[", "]", ";", "}", "$", "list", "=", "[", "$", "item", "->", "getId", "(", ")", "]", ";", "foreach", "(", "$", "item", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "list", "=", "array_merge", "(", "$", "list", ",", "$", "this", "->", "getCatalogIdsFromTree", "(", "$", "child", ")", ")", ";", "}", "return", "$", "list", ";", "}" ]
Returns the list of catalog IDs for the given catalog tree @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children @return array List of catalog IDs
[ "Returns", "the", "list", "of", "catalog", "IDs", "for", "the", "given", "catalog", "tree" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L477-L490
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Product/Standard.php
Standard.validateIds
protected function validateIds( array $ids ) { $list = []; foreach( $ids as $id ) { if( $id != '' && preg_match( '/^[A-Za-z0-9\-\_]+$/', $id ) === 1 ) { $list[] = (string) $id; } } return $list; }
php
protected function validateIds( array $ids ) { $list = []; foreach( $ids as $id ) { if( $id != '' && preg_match( '/^[A-Za-z0-9\-\_]+$/', $id ) === 1 ) { $list[] = (string) $id; } } return $list; }
[ "protected", "function", "validateIds", "(", "array", "$", "ids", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "ids", "as", "$", "id", ")", "{", "if", "(", "$", "id", "!=", "''", "&&", "preg_match", "(", "'/^[A-Za-z0-9\\-\\_]+$/'", ",", "$", "id", ")", "===", "1", ")", "{", "$", "list", "[", "]", "=", "(", "string", ")", "$", "id", ";", "}", "}", "return", "$", "list", ";", "}" ]
Validates the given IDs as integers @param array $ids List of IDs to validate @return array List of validated IDs
[ "Validates", "the", "given", "IDs", "as", "integers" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Product/Standard.php#L499-L511
train
facebookarchive/FBMock
AssertionHelpers.php
FBMock_AssertionHelpers.assertNumCalls
public static function assertNumCalls( FBMock_Mock $mock, $method_name, $expected_num_calls, $msg = '') { FBMock_Utils::assertString($method_name); FBMock_Utils::assertInt($expected_num_calls); $call_count = count($mock->mockGetCalls($method_name)); PHPUnit\Framework\TestCase::assertEquals( $expected_num_calls, $call_count, $msg ?: "$method_name called wrong number of times" ); }
php
public static function assertNumCalls( FBMock_Mock $mock, $method_name, $expected_num_calls, $msg = '') { FBMock_Utils::assertString($method_name); FBMock_Utils::assertInt($expected_num_calls); $call_count = count($mock->mockGetCalls($method_name)); PHPUnit\Framework\TestCase::assertEquals( $expected_num_calls, $call_count, $msg ?: "$method_name called wrong number of times" ); }
[ "public", "static", "function", "assertNumCalls", "(", "FBMock_Mock", "$", "mock", ",", "$", "method_name", ",", "$", "expected_num_calls", ",", "$", "msg", "=", "''", ")", "{", "FBMock_Utils", "::", "assertString", "(", "$", "method_name", ")", ";", "FBMock_Utils", "::", "assertInt", "(", "$", "expected_num_calls", ")", ";", "$", "call_count", "=", "count", "(", "$", "mock", "->", "mockGetCalls", "(", "$", "method_name", ")", ")", ";", "PHPUnit", "\\", "Framework", "\\", "TestCase", "::", "assertEquals", "(", "$", "expected_num_calls", ",", "$", "call_count", ",", "$", "msg", "?", ":", "\"$method_name called wrong number of times\"", ")", ";", "}" ]
Assert that the method was called a certain number of times on a mock @param $mock a mock object @param $method_name name of method to check @param $expected_num_calls expected number of calls @param $msg message for assert (optional)
[ "Assert", "that", "the", "method", "was", "called", "a", "certain", "number", "of", "times", "on", "a", "mock" ]
a0719c0e16a6cc6ad4edf86a05a08fc2d0efde2b
https://github.com/facebookarchive/FBMock/blob/a0719c0e16a6cc6ad4edf86a05a08fc2d0efde2b/AssertionHelpers.php#L15-L28
train
facebookarchive/FBMock
AssertionHelpers.php
FBMock_AssertionHelpers.assertNotCalled
public static function assertNotCalled( FBMock_Mock $mock, $method_name, $msg='') { FBMock_Utils::assertString($method_name); self::assertNumCalls($mock, $method_name, 0, $msg); }
php
public static function assertNotCalled( FBMock_Mock $mock, $method_name, $msg='') { FBMock_Utils::assertString($method_name); self::assertNumCalls($mock, $method_name, 0, $msg); }
[ "public", "static", "function", "assertNotCalled", "(", "FBMock_Mock", "$", "mock", ",", "$", "method_name", ",", "$", "msg", "=", "''", ")", "{", "FBMock_Utils", "::", "assertString", "(", "$", "method_name", ")", ";", "self", "::", "assertNumCalls", "(", "$", "mock", ",", "$", "method_name", ",", "0", ",", "$", "msg", ")", ";", "}" ]
Assert that the method was not called. @param $mock a mock object @param $method_name name of method to check @param $msg message for assert (optional)
[ "Assert", "that", "the", "method", "was", "not", "called", "." ]
a0719c0e16a6cc6ad4edf86a05a08fc2d0efde2b
https://github.com/facebookarchive/FBMock/blob/a0719c0e16a6cc6ad4edf86a05a08fc2d0efde2b/AssertionHelpers.php#L63-L69
train
facebookarchive/FBMock
AssertionHelpers.php
FBMock_AssertionHelpers.assertCalls
public static function assertCalls( FBMock_Mock $mock, $method_name /* array $expected_first_call, array $expected_second_call, $msg = ''*/) { FBMock_Utils::assertString($method_name); $args = func_get_args(); $msg = ''; if (is_string(end($args))) { $msg = array_pop($args); } $expected_calls = array_slice($args, 2); self::assertNumCalls($mock, $method_name, count($expected_calls), $msg); $actual_calls = $mock->mockGetCalls($method_name); foreach ($expected_calls as $i => $call) { PHPUnit\Framework\TestCase::assertEquals( $call, $actual_calls[$i], $msg ?: "Call $i for method $method_name did not match expected call" ); } }
php
public static function assertCalls( FBMock_Mock $mock, $method_name /* array $expected_first_call, array $expected_second_call, $msg = ''*/) { FBMock_Utils::assertString($method_name); $args = func_get_args(); $msg = ''; if (is_string(end($args))) { $msg = array_pop($args); } $expected_calls = array_slice($args, 2); self::assertNumCalls($mock, $method_name, count($expected_calls), $msg); $actual_calls = $mock->mockGetCalls($method_name); foreach ($expected_calls as $i => $call) { PHPUnit\Framework\TestCase::assertEquals( $call, $actual_calls[$i], $msg ?: "Call $i for method $method_name did not match expected call" ); } }
[ "public", "static", "function", "assertCalls", "(", "FBMock_Mock", "$", "mock", ",", "$", "method_name", "/* array $expected_first_call, array $expected_second_call, $msg = ''*/", ")", "{", "FBMock_Utils", "::", "assertString", "(", "$", "method_name", ")", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "msg", "=", "''", ";", "if", "(", "is_string", "(", "end", "(", "$", "args", ")", ")", ")", "{", "$", "msg", "=", "array_pop", "(", "$", "args", ")", ";", "}", "$", "expected_calls", "=", "array_slice", "(", "$", "args", ",", "2", ")", ";", "self", "::", "assertNumCalls", "(", "$", "mock", ",", "$", "method_name", ",", "count", "(", "$", "expected_calls", ")", ",", "$", "msg", ")", ";", "$", "actual_calls", "=", "$", "mock", "->", "mockGetCalls", "(", "$", "method_name", ")", ";", "foreach", "(", "$", "expected_calls", "as", "$", "i", "=>", "$", "call", ")", "{", "PHPUnit", "\\", "Framework", "\\", "TestCase", "::", "assertEquals", "(", "$", "call", ",", "$", "actual_calls", "[", "$", "i", "]", ",", "$", "msg", "?", ":", "\"Call $i for method $method_name did not match expected call\"", ")", ";", "}", "}" ]
Assert that the method calls match the array of calls. Example usage: // Code under test calls method $mock->testMethod(1,2,3); $mock->testMethod('a', 'b', 'c'); // Test asserts calls self::assertCalls( $mock, 'testMethod', array(1,2,3), array('a', 'b', 'c') ); @param $mock a mock object @param $method_name name of method to check @param ... arrays of expected arguments for each call @param $msg message for assert (optional)
[ "Assert", "that", "the", "method", "calls", "match", "the", "array", "of", "calls", "." ]
a0719c0e16a6cc6ad4edf86a05a08fc2d0efde2b
https://github.com/facebookarchive/FBMock/blob/a0719c0e16a6cc6ad4edf86a05a08fc2d0efde2b/AssertionHelpers.php#L93-L116
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Order/Standard.php
Standard.store
public function store() { $this->checkLimit( $this->item->getBaseId() ); $cntl = \Aimeos\Controller\Common\Order\Factory::create( $this->getContext() ); $this->item = $this->manager->saveItem( $this->item ); return $cntl->block( $this->item ); }
php
public function store() { $this->checkLimit( $this->item->getBaseId() ); $cntl = \Aimeos\Controller\Common\Order\Factory::create( $this->getContext() ); $this->item = $this->manager->saveItem( $this->item ); return $cntl->block( $this->item ); }
[ "public", "function", "store", "(", ")", "{", "$", "this", "->", "checkLimit", "(", "$", "this", "->", "item", "->", "getBaseId", "(", ")", ")", ";", "$", "cntl", "=", "\\", "Aimeos", "\\", "Controller", "\\", "Common", "\\", "Order", "\\", "Factory", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ")", ";", "$", "this", "->", "item", "=", "$", "this", "->", "manager", "->", "saveItem", "(", "$", "this", "->", "item", ")", ";", "return", "$", "cntl", "->", "block", "(", "$", "this", "->", "item", ")", ";", "}" ]
Saves the modified order item in the storage and blocks the stock and coupon codes @return \Aimeos\MShop\Order\Item\Iface New or updated order item object @since 2019.04
[ "Saves", "the", "modified", "order", "item", "in", "the", "storage", "and", "blocks", "the", "stock", "and", "coupon", "codes" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Order/Standard.php#L200-L208
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Order/Standard.php
Standard.checkLimit
protected function checkLimit( $baseId ) { /** controller/frontend/order/limit-seconds * Order limitation time frame in seconds * * Creating new orders is limited to avoid abuse and mitigate denial of * service attacks. Within the configured time frame, only one order * item can be created per order base item. All orders for the order * base item within the last X seconds are counted. If there's already * one available, an error message will be shown to the user instead of * creating the new order item. * * @param integer Number of seconds to check order items within * @since 2017.05 * @category Developer * @see controller/frontend/basket/limit-count * @see controller/frontend/basket/limit-seconds */ $seconds = $this->getContext()->getConfig()->get( 'controller/frontend/order/limit-seconds', 300 ); $search = $this->manager->createSearch()->setSlice( 0, 0 ); $search->setConditions( $search->combine( '&&', [ $search->compare( '==', 'order.baseid', $baseId ), $search->compare( '>=', 'order.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), ] ) ); $total = 0; $this->manager->searchItems( $search, [], $total ); if( $total > 0 ) { throw new \Aimeos\Controller\Frontend\Order\Exception( sprintf( 'The order has already been created' ) ); } return $this; }
php
protected function checkLimit( $baseId ) { /** controller/frontend/order/limit-seconds * Order limitation time frame in seconds * * Creating new orders is limited to avoid abuse and mitigate denial of * service attacks. Within the configured time frame, only one order * item can be created per order base item. All orders for the order * base item within the last X seconds are counted. If there's already * one available, an error message will be shown to the user instead of * creating the new order item. * * @param integer Number of seconds to check order items within * @since 2017.05 * @category Developer * @see controller/frontend/basket/limit-count * @see controller/frontend/basket/limit-seconds */ $seconds = $this->getContext()->getConfig()->get( 'controller/frontend/order/limit-seconds', 300 ); $search = $this->manager->createSearch()->setSlice( 0, 0 ); $search->setConditions( $search->combine( '&&', [ $search->compare( '==', 'order.baseid', $baseId ), $search->compare( '>=', 'order.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), ] ) ); $total = 0; $this->manager->searchItems( $search, [], $total ); if( $total > 0 ) { throw new \Aimeos\Controller\Frontend\Order\Exception( sprintf( 'The order has already been created' ) ); } return $this; }
[ "protected", "function", "checkLimit", "(", "$", "baseId", ")", "{", "/** controller/frontend/order/limit-seconds\n\t\t * Order limitation time frame in seconds\n\t\t *\n\t\t * Creating new orders is limited to avoid abuse and mitigate denial of\n\t\t * service attacks. Within the configured time frame, only one order\n\t\t * item can be created per order base item. All orders for the order\n\t\t * base item within the last X seconds are counted. If there's already\n\t\t * one available, an error message will be shown to the user instead of\n\t\t * creating the new order item.\n\t\t *\n\t\t * @param integer Number of seconds to check order items within\n\t\t * @since 2017.05\n\t\t * @category Developer\n\t\t * @see controller/frontend/basket/limit-count\n\t\t * @see controller/frontend/basket/limit-seconds\n\t\t */", "$", "seconds", "=", "$", "this", "->", "getContext", "(", ")", "->", "getConfig", "(", ")", "->", "get", "(", "'controller/frontend/order/limit-seconds'", ",", "300", ")", ";", "$", "search", "=", "$", "this", "->", "manager", "->", "createSearch", "(", ")", "->", "setSlice", "(", "0", ",", "0", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "combine", "(", "'&&'", ",", "[", "$", "search", "->", "compare", "(", "'=='", ",", "'order.baseid'", ",", "$", "baseId", ")", ",", "$", "search", "->", "compare", "(", "'>='", ",", "'order.ctime'", ",", "date", "(", "'Y-m-d H:i:s'", ",", "time", "(", ")", "-", "$", "seconds", ")", ")", ",", "]", ")", ")", ";", "$", "total", "=", "0", ";", "$", "this", "->", "manager", "->", "searchItems", "(", "$", "search", ",", "[", "]", ",", "$", "total", ")", ";", "if", "(", "$", "total", ">", "0", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Order", "\\", "Exception", "(", "sprintf", "(", "'The order has already been created'", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Checks if more orders than allowed have been created by the user @param string $baseId Unique ID of the order base item (basket) @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface @throws \Aimeos\Controller\Frontend\Order\Exception If limit is exceeded
[ "Checks", "if", "more", "orders", "than", "allowed", "have", "been", "created", "by", "the", "user" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Order/Standard.php#L218-L252
train
willwashburn/phpamo
src/Phpamo.php
Phpamo.camo
public function camo($url) { return $this->formatter->formatCamoUrl( $this->domain, $this->getDigest($url), $url ); }
php
public function camo($url) { return $this->formatter->formatCamoUrl( $this->domain, $this->getDigest($url), $url ); }
[ "public", "function", "camo", "(", "$", "url", ")", "{", "return", "$", "this", "->", "formatter", "->", "formatCamoUrl", "(", "$", "this", "->", "domain", ",", "$", "this", "->", "getDigest", "(", "$", "url", ")", ",", "$", "url", ")", ";", "}" ]
Camoflauge all urls @param $url @return string
[ "Camoflauge", "all", "urls" ]
0dfa941e41c03cfd03e5d86026b19375b3986677
https://github.com/willwashburn/phpamo/blob/0dfa941e41c03cfd03e5d86026b19375b3986677/src/Phpamo.php#L55-L62
train
willwashburn/phpamo
src/Phpamo.php
Phpamo.camoHttpOnly
public function camoHttpOnly($url) { $parsed = parse_url($url); if ( $parsed['scheme'] == 'https' ) { return $url; } return $this->camo($url); }
php
public function camoHttpOnly($url) { $parsed = parse_url($url); if ( $parsed['scheme'] == 'https' ) { return $url; } return $this->camo($url); }
[ "public", "function", "camoHttpOnly", "(", "$", "url", ")", "{", "$", "parsed", "=", "parse_url", "(", "$", "url", ")", ";", "if", "(", "$", "parsed", "[", "'scheme'", "]", "==", "'https'", ")", "{", "return", "$", "url", ";", "}", "return", "$", "this", "->", "camo", "(", "$", "url", ")", ";", "}" ]
Camoflauge only the urls that are not currently https @param $url @return mixed
[ "Camoflauge", "only", "the", "urls", "that", "are", "not", "currently", "https" ]
0dfa941e41c03cfd03e5d86026b19375b3986677
https://github.com/willwashburn/phpamo/blob/0dfa941e41c03cfd03e5d86026b19375b3986677/src/Phpamo.php#L71-L80
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Attribute/Standard.php
Standard.attribute
public function attribute( $attrIds ) { if( !empty( $attrIds ) ) { $this->conditions[] = $this->filter->compare( '==', 'attribute.id', $attrIds ); } return $this; }
php
public function attribute( $attrIds ) { if( !empty( $attrIds ) ) { $this->conditions[] = $this->filter->compare( '==', 'attribute.id', $attrIds ); } return $this; }
[ "public", "function", "attribute", "(", "$", "attrIds", ")", "{", "if", "(", "!", "empty", "(", "$", "attrIds", ")", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'=='", ",", "'attribute.id'", ",", "$", "attrIds", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds attribute IDs for filtering @param array|string $attrIds Attribute ID or list of IDs @return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface @since 2019.04
[ "Adds", "attribute", "IDs", "for", "filtering" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Attribute/Standard.php#L62-L69
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Attribute/Standard.php
Standard.find
public function find( $code, $type ) { return $this->manager->findItem( $code, $this->domains, $this->domain, $type, true ); }
php
public function find( $code, $type ) { return $this->manager->findItem( $code, $this->domains, $this->domain, $type, true ); }
[ "public", "function", "find", "(", "$", "code", ",", "$", "type", ")", "{", "return", "$", "this", "->", "manager", "->", "findItem", "(", "$", "code", ",", "$", "this", "->", "domains", ",", "$", "this", "->", "domain", ",", "$", "type", ",", "true", ")", ";", "}" ]
Returns the attribute for the given attribute code @param string $code Unique attribute code @param string $type Type assigned to the attribute @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items @since 2019.04
[ "Returns", "the", "attribute", "for", "the", "given", "attribute", "code" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Attribute/Standard.php#L110-L113
train