repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfigOld.getLogFilePath
final public static function getLogFilePath($type = ShopgateLogger::LOGTYPE_ERROR) { self::deprecated(__METHOD__); switch (strtolower($type)) { default: $type = 'error'; // no break case "access": case "request": case "debug": } if (isset(self::$config['path_to_' . strtolower($type) . '_log_file'])) { return self::$config['path_to_' . strtolower($type) . '_log_file']; } else { return SHOPGATE_BASE_DIR . '/temp/logs/' . strtolower($type) . '.log'; } }
php
final public static function getLogFilePath($type = ShopgateLogger::LOGTYPE_ERROR) { self::deprecated(__METHOD__); switch (strtolower($type)) { default: $type = 'error'; // no break case "access": case "request": case "debug": } if (isset(self::$config['path_to_' . strtolower($type) . '_log_file'])) { return self::$config['path_to_' . strtolower($type) . '_log_file']; } else { return SHOPGATE_BASE_DIR . '/temp/logs/' . strtolower($type) . '.log'; } }
[ "final", "public", "static", "function", "getLogFilePath", "(", "$", "type", "=", "ShopgateLogger", "::", "LOGTYPE_ERROR", ")", "{", "self", "::", "deprecated", "(", "__METHOD__", ")", ";", "switch", "(", "strtolower", "(", "$", "type", ")", ")", "{", "def...
Gibt den Pfad zur Error-Log-Datei zurück. Für diese Datei sollten Schreib- und leserechte gewährt werden. @deprecated
[ "Gibt", "den", "Pfad", "zur", "Error", "-", "Log", "-", "Datei", "zurück", ".", "Für", "diese", "Datei", "sollten", "Schreib", "-", "und", "leserechte", "gewährt", "werden", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2618-L2636
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfigOld.getItemsCsvFilePath
final public static function getItemsCsvFilePath() { self::deprecated(__METHOD__); if (isset(self::$config['path_to_items_csv_file'])) { return self::$config['path_to_items_csv_file']; } else { return SHOPGATE_BASE_DIR . '/temp/items.csv'; } }
php
final public static function getItemsCsvFilePath() { self::deprecated(__METHOD__); if (isset(self::$config['path_to_items_csv_file'])) { return self::$config['path_to_items_csv_file']; } else { return SHOPGATE_BASE_DIR . '/temp/items.csv'; } }
[ "final", "public", "static", "function", "getItemsCsvFilePath", "(", ")", "{", "self", "::", "deprecated", "(", "__METHOD__", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "config", "[", "'path_to_items_csv_file'", "]", ")", ")", "{", "return", "se...
Gibt den Pfad zur items-csv-Datei zurück. Für diese Datei sollten Schreib- und leserechte gewährt werden. @deprecated
[ "Gibt", "den", "Pfad", "zur", "items", "-", "csv", "-", "Datei", "zurück", ".", "Für", "diese", "Datei", "sollten", "Schreib", "-", "und", "leserechte", "gewährt", "werden", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2644-L2653
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfigOld.getReviewsCsvFilePath
final public static function getReviewsCsvFilePath() { self::deprecated(__METHOD__); if (isset(self::$config['path_to_reviews_csv_file'])) { return self::$config['path_to_reviews_csv_file']; } else { return SHOPGATE_BASE_DIR . '/temp/reviews.csv'; } }
php
final public static function getReviewsCsvFilePath() { self::deprecated(__METHOD__); if (isset(self::$config['path_to_reviews_csv_file'])) { return self::$config['path_to_reviews_csv_file']; } else { return SHOPGATE_BASE_DIR . '/temp/reviews.csv'; } }
[ "final", "public", "static", "function", "getReviewsCsvFilePath", "(", ")", "{", "self", "::", "deprecated", "(", "__METHOD__", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "config", "[", "'path_to_reviews_csv_file'", "]", ")", ")", "{", "return", ...
Gibt den Pfad zur review-csv-Datei zurück Für diese Datei sollten Schreib- und leserechte gewährt werden @deprecated
[ "Gibt", "den", "Pfad", "zur", "review", "-", "csv", "-", "Datei", "zurück", "Für", "diese", "Datei", "sollten", "Schreib", "-", "und", "leserechte", "gewährt", "werden" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2675-L2684
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfigOld.getPagesCsvFilePath
final public static function getPagesCsvFilePath() { self::deprecated(__METHOD__); if (isset(self::$config['path_to_pages_csv_file'])) { return self::$config['path_to_pages_csv_file']; } else { return SHOPGATE_BASE_DIR . '/temp/pages.csv'; } }
php
final public static function getPagesCsvFilePath() { self::deprecated(__METHOD__); if (isset(self::$config['path_to_pages_csv_file'])) { return self::$config['path_to_pages_csv_file']; } else { return SHOPGATE_BASE_DIR . '/temp/pages.csv'; } }
[ "final", "public", "static", "function", "getPagesCsvFilePath", "(", ")", "{", "self", "::", "deprecated", "(", "__METHOD__", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "config", "[", "'path_to_pages_csv_file'", "]", ")", ")", "{", "return", "se...
Gibt den Pfad zur pages-csv-Datei zurück. Für diese Datei sollten Schreib- und leserechte gewährt werden. @deprecated
[ "Gibt", "den", "Pfad", "zur", "pages", "-", "csv", "-", "Datei", "zurück", ".", "Für", "diese", "Datei", "sollten", "Schreib", "-", "und", "leserechte", "gewährt", "werden", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2692-L2701
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfigOld.validateConfig
private static function validateConfig(array $newConfig) { self::deprecated(__METHOD__); //Pflichtfelder überprüfen if (!preg_match("/^\S+/", $newConfig['apikey'])) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_INVALID_VALUE, "Field 'apikey' contains invalid value '{$newConfig['apikey']}'." ); } if (!preg_match("/^\d{5,}$/", $newConfig['customer_number'])) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_INVALID_VALUE, "Field 'customer_number' contains invalid value '{$newConfig['customer_number']}'." ); } if (!preg_match("/^\d{5,}$/", $newConfig['shop_number'])) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_INVALID_VALUE, "Field 'shop_number' contains invalid value '{$newConfig['shop_number']}'." ); } //////////////////////////////////////////////////////////////////////// // Server URL setzen //////////////////////////////////////////////////////////////////////// if (!empty($newConfig["server"]) && $newConfig["server"] === "pg") { // Playground? self::$config["api_url"] = "https://api.shopgatepg.com/merchant/"; } else { if (!empty($newConfig["server"]) && $newConfig["server"] === "custom" && !empty($newConfig["server_custom_url"]) ) { // Eigener Test-Server? self::$config["api_url"] = $newConfig["server_custom_url"]; } else { // Live-Server? self::$config["api_url"] = "https://api.shopgate.com/merchant/"; } } }
php
private static function validateConfig(array $newConfig) { self::deprecated(__METHOD__); //Pflichtfelder überprüfen if (!preg_match("/^\S+/", $newConfig['apikey'])) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_INVALID_VALUE, "Field 'apikey' contains invalid value '{$newConfig['apikey']}'." ); } if (!preg_match("/^\d{5,}$/", $newConfig['customer_number'])) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_INVALID_VALUE, "Field 'customer_number' contains invalid value '{$newConfig['customer_number']}'." ); } if (!preg_match("/^\d{5,}$/", $newConfig['shop_number'])) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_INVALID_VALUE, "Field 'shop_number' contains invalid value '{$newConfig['shop_number']}'." ); } //////////////////////////////////////////////////////////////////////// // Server URL setzen //////////////////////////////////////////////////////////////////////// if (!empty($newConfig["server"]) && $newConfig["server"] === "pg") { // Playground? self::$config["api_url"] = "https://api.shopgatepg.com/merchant/"; } else { if (!empty($newConfig["server"]) && $newConfig["server"] === "custom" && !empty($newConfig["server_custom_url"]) ) { // Eigener Test-Server? self::$config["api_url"] = $newConfig["server_custom_url"]; } else { // Live-Server? self::$config["api_url"] = "https://api.shopgate.com/merchant/"; } } }
[ "private", "static", "function", "validateConfig", "(", "array", "$", "newConfig", ")", "{", "self", "::", "deprecated", "(", "__METHOD__", ")", ";", "//Pflichtfelder überprüfen", "if", "(", "!", "preg_match", "(", "\"/^\\S+/\"", ",", "$", "newConfig", "[", "'...
Prüft, ob alle Pflichtfelder gesetzt sind und setzt die api_url. @deprecated @param array $newConfig @throws ShopgateLibraryException
[ "Prüft", "ob", "alle", "Pflichtfelder", "gesetzt", "sind", "und", "setzt", "die", "api_url", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2742-L2782
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfigOld.deprecated
private static function deprecated($methodName) { $message = 'Use of ' . $methodName . ' and the whole ShopgateConfigOld class is deprecated.'; trigger_error($message, E_USER_DEPRECATED); ShopgateLogger::getInstance()->log($message); }
php
private static function deprecated($methodName) { $message = 'Use of ' . $methodName . ' and the whole ShopgateConfigOld class is deprecated.'; trigger_error($message, E_USER_DEPRECATED); ShopgateLogger::getInstance()->log($message); }
[ "private", "static", "function", "deprecated", "(", "$", "methodName", ")", "{", "$", "message", "=", "'Use of '", ".", "$", "methodName", ".", "' and the whole ShopgateConfigOld class is deprecated.'", ";", "trigger_error", "(", "$", "message", ",", "E_USER_DEPRECATE...
Issues a PHP deprecated warning and log entry for calls to deprecated ShopgateConfigOld methods. @param string $methodName The name of the called method.
[ "Issues", "a", "PHP", "deprecated", "warning", "and", "log", "entry", "for", "calls", "to", "deprecated", "ShopgateConfigOld", "methods", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2838-L2843
stephweb/daw-php-orm
example/core/Http/Input.php
Input.post
public static function post(string $name) { return (isset($_POST[$name]) && $_POST[$name] != '') ? $_POST[$name] : ''; }
php
public static function post(string $name) { return (isset($_POST[$name]) && $_POST[$name] != '') ? $_POST[$name] : ''; }
[ "public", "static", "function", "post", "(", "string", "$", "name", ")", "{", "return", "(", "isset", "(", "$", "_POST", "[", "$", "name", "]", ")", "&&", "$", "_POST", "[", "$", "name", "]", "!=", "''", ")", "?", "$", "_POST", "[", "$", "name"...
Si donnée envoye en POST, et si ce $name existe -> return $_POST['name'] @param string $name @return array|null
[ "Si", "donnée", "envoye", "en", "POST", "et", "si", "ce", "$name", "existe", "-", ">", "return", "$_POST", "[", "name", "]" ]
train
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Http/Input.php#L27-L30
stephweb/daw-php-orm
example/core/Http/Input.php
Input.get
public static function get(string $name) { return (isset($_GET[$name]) && $_GET[$name] != '') ? $_GET[$name] : ''; }
php
public static function get(string $name) { return (isset($_GET[$name]) && $_GET[$name] != '') ? $_GET[$name] : ''; }
[ "public", "static", "function", "get", "(", "string", "$", "name", ")", "{", "return", "(", "isset", "(", "$", "_GET", "[", "$", "name", "]", ")", "&&", "$", "_GET", "[", "$", "name", "]", "!=", "''", ")", "?", "$", "_GET", "[", "$", "name", ...
Si donnée envoye en GET, et si ce $name existe -> return $_GET['name'] @param string $name @return array|null - Donnée envoyée en GET
[ "Si", "donnée", "envoye", "en", "GET", "et", "si", "ce", "$name", "existe", "-", ">", "return", "$_GET", "[", "name", "]" ]
train
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Http/Input.php#L49-L52
umpirsky/list-generator
src/Umpirsky/ListGenerator/Exporter/Format/Html.php
Html.export
public function export(array $data) { $selectElement = $this->getDocument()->createElement('select'); $selectElement->setAttribute('name', 'value'); foreach ($data as $id => $name) { $optionElement = $this->getDocument()->createElement( 'option', htmlentities($name) ); $optionElement->setAttribute('value', $id); $selectElement->appendChild($optionElement); } return $this->exportHtml($selectElement); }
php
public function export(array $data) { $selectElement = $this->getDocument()->createElement('select'); $selectElement->setAttribute('name', 'value'); foreach ($data as $id => $name) { $optionElement = $this->getDocument()->createElement( 'option', htmlentities($name) ); $optionElement->setAttribute('value', $id); $selectElement->appendChild($optionElement); } return $this->exportHtml($selectElement); }
[ "public", "function", "export", "(", "array", "$", "data", ")", "{", "$", "selectElement", "=", "$", "this", "->", "getDocument", "(", ")", "->", "createElement", "(", "'select'", ")", ";", "$", "selectElement", "->", "setAttribute", "(", "'name'", ",", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/umpirsky/list-generator/blob/103182faf6e48611901263a49e7a9ba33e7515b8/src/Umpirsky/ListGenerator/Exporter/Format/Html.php#L12-L26
oasmobile/php-aws-wrappers
src/AwsWrappers/SqsQueue.php
SqsQueue.receiveMessage
public function receiveMessage($wait = null, $visibility_timeout = null, $metas = [], $message_attributes = []) { $ret = $this->receiveMessageBatch(1, $wait, $visibility_timeout, $metas, $message_attributes); if (!$ret) { return null; } else { return $ret[0]; } }
php
public function receiveMessage($wait = null, $visibility_timeout = null, $metas = [], $message_attributes = []) { $ret = $this->receiveMessageBatch(1, $wait, $visibility_timeout, $metas, $message_attributes); if (!$ret) { return null; } else { return $ret[0]; } }
[ "public", "function", "receiveMessage", "(", "$", "wait", "=", "null", ",", "$", "visibility_timeout", "=", "null", ",", "$", "metas", "=", "[", "]", ",", "$", "message_attributes", "=", "[", "]", ")", "{", "$", "ret", "=", "$", "this", "->", "receiv...
@param int $wait @param int $visibility_timeout @param array $metas @param array $message_attributes @return SqsReceivedMessage
[ "@param", "int", "$wait", "@param", "int", "$visibility_timeout", "@param", "array", "$metas", "@param", "array", "$message_attributes" ]
train
https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/SqsQueue.php#L171-L180
oasmobile/php-aws-wrappers
src/AwsWrappers/SqsQueue.php
SqsQueue.receiveMessageWithAttributes
public function receiveMessageWithAttributes(array $expected_message_attributes, $wait = null, $visibility_timeout = null, $metas = []) { return $this->receiveMessage($wait, $visibility_timeout, $metas, $expected_message_attributes); }
php
public function receiveMessageWithAttributes(array $expected_message_attributes, $wait = null, $visibility_timeout = null, $metas = []) { return $this->receiveMessage($wait, $visibility_timeout, $metas, $expected_message_attributes); }
[ "public", "function", "receiveMessageWithAttributes", "(", "array", "$", "expected_message_attributes", ",", "$", "wait", "=", "null", ",", "$", "visibility_timeout", "=", "null", ",", "$", "metas", "=", "[", "]", ")", "{", "return", "$", "this", "->", "rece...
@param array $expected_message_attributes @param int $wait @param int $visibility_timeout @param array $metas @return SqsReceivedMessage
[ "@param", "array", "$expected_message_attributes", "@param", "int", "$wait", "@param", "int", "$visibility_timeout", "@param", "array", "$metas" ]
train
https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/SqsQueue.php#L190-L196
oasmobile/php-aws-wrappers
src/AwsWrappers/SqsQueue.php
SqsQueue.receiveMessages
public function receiveMessages($max_count, $wait = null, $visibility_timeout = null, $metas = [], $message_attributes = []) { if ($max_count <= 0) { return []; } $buffer = []; $one_batch = 10; while ($msgs = $this->receiveMessageBatch( $one_batch, $wait, $visibility_timeout, $metas, $message_attributes )) { $buffer = array_merge($buffer, $msgs); $this->dispatch(self::READ_PROGRESS, count($buffer) / $max_count); // commented out because sometimes a full queue will somehow return less than 10 messages in a batch //if (count($msgs) < 10) { // break; //} $one_batch = min(10, $max_count - count($buffer)); if ($one_batch <= 0) { break; } } return $buffer; }
php
public function receiveMessages($max_count, $wait = null, $visibility_timeout = null, $metas = [], $message_attributes = []) { if ($max_count <= 0) { return []; } $buffer = []; $one_batch = 10; while ($msgs = $this->receiveMessageBatch( $one_batch, $wait, $visibility_timeout, $metas, $message_attributes )) { $buffer = array_merge($buffer, $msgs); $this->dispatch(self::READ_PROGRESS, count($buffer) / $max_count); // commented out because sometimes a full queue will somehow return less than 10 messages in a batch //if (count($msgs) < 10) { // break; //} $one_batch = min(10, $max_count - count($buffer)); if ($one_batch <= 0) { break; } } return $buffer; }
[ "public", "function", "receiveMessages", "(", "$", "max_count", ",", "$", "wait", "=", "null", ",", "$", "visibility_timeout", "=", "null", ",", "$", "metas", "=", "[", "]", ",", "$", "message_attributes", "=", "[", "]", ")", "{", "if", "(", "$", "ma...
@param int $max_count @param int $wait @param int $visibility_timeout @param array $metas @param array $message_attributes @return SqsReceivedMessage[]
[ "@param", "int", "$max_count", "@param", "int", "$wait", "@param", "int", "$visibility_timeout", "@param", "array", "$metas" ]
train
https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/SqsQueue.php#L208-L242
oasmobile/php-aws-wrappers
src/AwsWrappers/SqsQueue.php
SqsQueue.sendMessage
public function sendMessage($payroll, $delay = 0, $attributes = []) { $sentMessages = $this->sendMessages([$payroll], $delay, [$attributes]); if (!$sentMessages) { return false; } else { return $sentMessages[0]; } }
php
public function sendMessage($payroll, $delay = 0, $attributes = []) { $sentMessages = $this->sendMessages([$payroll], $delay, [$attributes]); if (!$sentMessages) { return false; } else { return $sentMessages[0]; } }
[ "public", "function", "sendMessage", "(", "$", "payroll", ",", "$", "delay", "=", "0", ",", "$", "attributes", "=", "[", "]", ")", "{", "$", "sentMessages", "=", "$", "this", "->", "sendMessages", "(", "[", "$", "payroll", "]", ",", "$", "delay", "...
@param $payroll @param int $delay @param array $attributes @return bool|SqsSentMessage
[ "@param", "$payroll", "@param", "int", "$delay", "@param", "array", "$attributes" ]
train
https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/SqsQueue.php#L251-L260
oasmobile/php-aws-wrappers
src/AwsWrappers/SqsQueue.php
SqsQueue.sendMessages
public function sendMessages(array $payrolls, $delay = 0, array $attributesList = [], $concurrency = 10) { if ($attributesList && count($payrolls) != count($attributesList)) { throw new \UnexpectedValueException("Attribute list size is different than num of payrolls!"); } $total = count($payrolls); $progressCount = 0; $promises = []; $sentMessages = []; $this->sendFailureMessages = []; $buffer = []; $bufferedAttributes = []; $md5Expectation = []; foreach ($payrolls as $idx => $payroll) { $buffer[$idx] = $payroll; if (isset($attributesList[$idx])) { $bufferedAttributes[$idx] = $attributesList[$idx]; } else { $bufferedAttributes[$idx] = []; } if (!is_string($buffer[$idx])) { $buffer[$idx] = base64_encode(serialize($buffer[$idx])); $bufferedAttributes[$idx][self::SERIALIZATION_FLAG] = 'base64_serialize'; } $md5Expectation[$idx] = md5($buffer[$idx]); if (count($buffer) == 10) { $promise = $this->getSendMessageBatchAsyncPromise($buffer, $bufferedAttributes, $delay); $promises[] = $promise; $buffer = $bufferedAttributes = []; } } if (count($buffer) > 0) { $promise = $this->getSendMessageBatchAsyncPromise($buffer, $bufferedAttributes, $delay); $promises[] = $promise; } \GuzzleHttp\Promise\each_limit( $promises, $concurrency, function (Result $result) use ( &$sentMessages, &$progressCount, &$md5Expectation, $total ) { if (isset($result['Failed'])) { foreach ($result['Failed'] as $failed) { mwarning( "Batch sending message failed, code = %s, id = %s, msg = %s, senderfault = %s", $failed['Code'], $failed['Id'], $failed['Message'], $failed['SenderFault'] ); $this->sendFailureMessages[$failed['Id']] = $failed['Message']; } $progressCount += count($result['Failed']); } if (isset($result['Successful'])) { foreach ($result['Successful'] as $successful) { $sentMessage = new SqsSentMessage($successful); if ($sentMessage->getMd5OfBody() != $md5Expectation[$successful['Id']]) { $failedMessages[$successful['Id']] = "MD5 mismatch of sent message!"; } else { $sentMessages[$successful['Id']] = $sentMessage; } } $progressCount += count($result['Successful']); } $this->dispatch(self::SEND_PROGRESS, $progressCount / $total); }, function ($e) { merror("Exception got: %s!", get_class($e)); if ($e instanceof SqsException) { mtrace( $e, sprintf( "Exception while batch sending SQS messages, aws code = %s, type = %s", $e->getAwsErrorCode(), $e->getAwsErrorType() ), "error" ); } throw $e; } )->wait(); return $sentMessages; }
php
public function sendMessages(array $payrolls, $delay = 0, array $attributesList = [], $concurrency = 10) { if ($attributesList && count($payrolls) != count($attributesList)) { throw new \UnexpectedValueException("Attribute list size is different than num of payrolls!"); } $total = count($payrolls); $progressCount = 0; $promises = []; $sentMessages = []; $this->sendFailureMessages = []; $buffer = []; $bufferedAttributes = []; $md5Expectation = []; foreach ($payrolls as $idx => $payroll) { $buffer[$idx] = $payroll; if (isset($attributesList[$idx])) { $bufferedAttributes[$idx] = $attributesList[$idx]; } else { $bufferedAttributes[$idx] = []; } if (!is_string($buffer[$idx])) { $buffer[$idx] = base64_encode(serialize($buffer[$idx])); $bufferedAttributes[$idx][self::SERIALIZATION_FLAG] = 'base64_serialize'; } $md5Expectation[$idx] = md5($buffer[$idx]); if (count($buffer) == 10) { $promise = $this->getSendMessageBatchAsyncPromise($buffer, $bufferedAttributes, $delay); $promises[] = $promise; $buffer = $bufferedAttributes = []; } } if (count($buffer) > 0) { $promise = $this->getSendMessageBatchAsyncPromise($buffer, $bufferedAttributes, $delay); $promises[] = $promise; } \GuzzleHttp\Promise\each_limit( $promises, $concurrency, function (Result $result) use ( &$sentMessages, &$progressCount, &$md5Expectation, $total ) { if (isset($result['Failed'])) { foreach ($result['Failed'] as $failed) { mwarning( "Batch sending message failed, code = %s, id = %s, msg = %s, senderfault = %s", $failed['Code'], $failed['Id'], $failed['Message'], $failed['SenderFault'] ); $this->sendFailureMessages[$failed['Id']] = $failed['Message']; } $progressCount += count($result['Failed']); } if (isset($result['Successful'])) { foreach ($result['Successful'] as $successful) { $sentMessage = new SqsSentMessage($successful); if ($sentMessage->getMd5OfBody() != $md5Expectation[$successful['Id']]) { $failedMessages[$successful['Id']] = "MD5 mismatch of sent message!"; } else { $sentMessages[$successful['Id']] = $sentMessage; } } $progressCount += count($result['Successful']); } $this->dispatch(self::SEND_PROGRESS, $progressCount / $total); }, function ($e) { merror("Exception got: %s!", get_class($e)); if ($e instanceof SqsException) { mtrace( $e, sprintf( "Exception while batch sending SQS messages, aws code = %s, type = %s", $e->getAwsErrorCode(), $e->getAwsErrorType() ), "error" ); } throw $e; } )->wait(); return $sentMessages; }
[ "public", "function", "sendMessages", "(", "array", "$", "payrolls", ",", "$", "delay", "=", "0", ",", "array", "$", "attributesList", "=", "[", "]", ",", "$", "concurrency", "=", "10", ")", "{", "if", "(", "$", "attributesList", "&&", "count", "(", ...
@param array $payrolls @param int $delay @param array $attributesList @param int $concurrency @return SqsSentMessage[] successful messages @NOTE: for failed messages, you can call getSendFailureMessages()
[ "@param", "array", "$payrolls", "@param", "int", "$delay", "@param", "array", "$attributesList", "@param", "int", "$concurrency" ]
train
https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/SqsQueue.php#L272-L369
oasmobile/php-aws-wrappers
src/AwsWrappers/SqsQueue.php
SqsQueue.receiveMessageBatch
protected function receiveMessageBatch($maxCount = 1, $wait = null, $visibilityTimeout = null, $metas = [], $messageAttributes = []) { if ($maxCount > 10 || $maxCount < 1) { throw new \InvalidArgumentException("Max count for SQS message receiving is 10"); } $messageAttributes[] = self::SERIALIZATION_FLAG; $args = [ "QueueUrl" => $this->getQueueUrl(), "MaxNumberOfMessages" => $maxCount, 'MessageAttributeNames' => $messageAttributes, ]; if ($wait !== null && is_int($wait)) { $args['WaitTimeSeconds'] = $wait; } if ($visibilityTimeout !== null && is_int($visibilityTimeout)) { $args['VisibilityTimeout'] = $visibilityTimeout; } if ($metas && is_array($metas)) { $args['AttributeNames'] = $metas; } $result = $this->client->receiveMessage($args); $messages = $result['Messages']; if (!$messages) { return []; } $ret = []; foreach ($messages as $data) { $msg = new SqsReceivedMessage($data); $ret[] = $msg; } return $ret; }
php
protected function receiveMessageBatch($maxCount = 1, $wait = null, $visibilityTimeout = null, $metas = [], $messageAttributes = []) { if ($maxCount > 10 || $maxCount < 1) { throw new \InvalidArgumentException("Max count for SQS message receiving is 10"); } $messageAttributes[] = self::SERIALIZATION_FLAG; $args = [ "QueueUrl" => $this->getQueueUrl(), "MaxNumberOfMessages" => $maxCount, 'MessageAttributeNames' => $messageAttributes, ]; if ($wait !== null && is_int($wait)) { $args['WaitTimeSeconds'] = $wait; } if ($visibilityTimeout !== null && is_int($visibilityTimeout)) { $args['VisibilityTimeout'] = $visibilityTimeout; } if ($metas && is_array($metas)) { $args['AttributeNames'] = $metas; } $result = $this->client->receiveMessage($args); $messages = $result['Messages']; if (!$messages) { return []; } $ret = []; foreach ($messages as $data) { $msg = new SqsReceivedMessage($data); $ret[] = $msg; } return $ret; }
[ "protected", "function", "receiveMessageBatch", "(", "$", "maxCount", "=", "1", ",", "$", "wait", "=", "null", ",", "$", "visibilityTimeout", "=", "null", ",", "$", "metas", "=", "[", "]", ",", "$", "messageAttributes", "=", "[", "]", ")", "{", "if", ...
@param int $maxCount @param int $wait @param int $visibilityTimeout @param array $metas @param array $messageAttributes @return SqsReceivedMessage[]
[ "@param", "int", "$maxCount", "@param", "int", "$wait", "@param", "int", "$visibilityTimeout", "@param", "array", "$metas", "@param", "array", "$messageAttributes" ]
train
https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/SqsQueue.php#L501-L541
mosbth/Anax-MVC
src/View/CViewContainerBasic.php
CViewContainerBasic.add
public function add($template, $data = [], $region = 'main', $sort = 0) { $view = $this->di->get('view'); if (is_string($template)) { $tpl = $this->path . $template . $this->suffix; $type = 'file'; } elseif (is_array($template)) { $tpl = $template; $type = 'callback'; } $view->set($tpl, $data, $sort, $type); $view->setDI($this->di); $this->views[$region][] = $view; return $this; }
php
public function add($template, $data = [], $region = 'main', $sort = 0) { $view = $this->di->get('view'); if (is_string($template)) { $tpl = $this->path . $template . $this->suffix; $type = 'file'; } elseif (is_array($template)) { $tpl = $template; $type = 'callback'; } $view->set($tpl, $data, $sort, $type); $view->setDI($this->di); $this->views[$region][] = $view; return $this; }
[ "public", "function", "add", "(", "$", "template", ",", "$", "data", "=", "[", "]", ",", "$", "region", "=", "'main'", ",", "$", "sort", "=", "0", ")", "{", "$", "view", "=", "$", "this", "->", "di", "->", "get", "(", "'view'", ")", ";", "if"...
Add a view to be included as a template file. @param string $template the name of the template file to include @param array $data variables to make available to the view, default is empty @param string $region which region to attach the view @param int $sort which order to display the views @return $this
[ "Add", "a", "view", "to", "be", "included", "as", "a", "template", "file", "." ]
train
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L35-L52
mosbth/Anax-MVC
src/View/CViewContainerBasic.php
CViewContainerBasic.addString
public function addString($content, $region = 'main', $sort = 0) { $view = $this->di->get('view'); $view->set($content, [], $sort, 'string'); $view->setDI($this->di); $this->views[$region][] = $view; return $this; }
php
public function addString($content, $region = 'main', $sort = 0) { $view = $this->di->get('view'); $view->set($content, [], $sort, 'string'); $view->setDI($this->di); $this->views[$region][] = $view; return $this; }
[ "public", "function", "addString", "(", "$", "content", ",", "$", "region", "=", "'main'", ",", "$", "sort", "=", "0", ")", "{", "$", "view", "=", "$", "this", "->", "di", "->", "get", "(", "'view'", ")", ";", "$", "view", "->", "set", "(", "$"...
Add a string as a view. @param string $content the content @param string $region which region to attach the view @param int $sort which order to display the views @return $this
[ "Add", "a", "string", "as", "a", "view", "." ]
train
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L88-L96
mosbth/Anax-MVC
src/View/CViewContainerBasic.php
CViewContainerBasic.setBasePath
public function setBasePath($path) { if (!is_dir($path)) { throw new \Exception("Base path for views is not a directory: " . $path); } $this->path = rtrim($path, '/') . '/'; }
php
public function setBasePath($path) { if (!is_dir($path)) { throw new \Exception("Base path for views is not a directory: " . $path); } $this->path = rtrim($path, '/') . '/'; }
[ "public", "function", "setBasePath", "(", "$", "path", ")", "{", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Base path for views is not a directory: \"", ".", "$", "path", ")", ";", "}", "$", "thi...
Set base path where to find views. @param string $path where all views reside @return $this @throws \Exception
[ "Set", "base", "path", "where", "to", "find", "views", "." ]
train
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L121-L127
mosbth/Anax-MVC
src/View/CViewContainerBasic.php
CViewContainerBasic.render
public function render($region = 'main') { if (!isset($this->views[$region])) { return $this; } mergesort($this->views[$region], function ($a, $b) { $sa = $a->sortOrder(); $sb = $b->sortOrder(); if ($sa == $sb) { return 0; } return $sa < $sb ? -1 : 1; }); foreach ($this->views[$region] as $view) { $view->render(); } return $this; }
php
public function render($region = 'main') { if (!isset($this->views[$region])) { return $this; } mergesort($this->views[$region], function ($a, $b) { $sa = $a->sortOrder(); $sb = $b->sortOrder(); if ($sa == $sb) { return 0; } return $sa < $sb ? -1 : 1; }); foreach ($this->views[$region] as $view) { $view->render(); } return $this; }
[ "public", "function", "render", "(", "$", "region", "=", "'main'", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "views", "[", "$", "region", "]", ")", ")", "{", "return", "$", "this", ";", "}", "mergesort", "(", "$", "this", "->", ...
Render all views for a specific region. @param string $region which region to use @return $this
[ "Render", "all", "views", "for", "a", "specific", "region", "." ]
train
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L152-L174
shopgate/cart-integration-sdk
src/models/Abstract.php
Shopgate_Model_Abstract.setData
public function setData($key, $value = null) { if (is_array($key)) { foreach ($key as $key => $value) { if (!is_array($value) && !is_object($value)) { $this->$key = $value; } } } else { $this->$key = $value; } return $this; }
php
public function setData($key, $value = null) { if (is_array($key)) { foreach ($key as $key => $value) { if (!is_array($value) && !is_object($value)) { $this->$key = $value; } } } else { $this->$key = $value; } return $this; }
[ "public", "function", "setData", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "foreach", "(", "$", "key", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is...
set the data by key or array @param $key @param null $value @return Shopgate_Model_Abstract
[ "set", "the", "data", "by", "key", "or", "array" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/Abstract.php#L108-L121
shopgate/cart-integration-sdk
src/models/Abstract.php
Shopgate_Model_Abstract.getData
public function getData($key = '', $index = null) { if ('' === $key) { return $this->data; } $default = null; if (isset($this->data[$key])) { if (is_null($index)) { return $this->data[$key]; } $value = $this->data[$key]; if (is_array($value)) { if (isset($value[$index])) { return $value[$index]; } return null; } return $default; } return $default; }
php
public function getData($key = '', $index = null) { if ('' === $key) { return $this->data; } $default = null; if (isset($this->data[$key])) { if (is_null($index)) { return $this->data[$key]; } $value = $this->data[$key]; if (is_array($value)) { if (isset($value[$index])) { return $value[$index]; } return null; } return $default; } return $default; }
[ "public", "function", "getData", "(", "$", "key", "=", "''", ",", "$", "index", "=", "null", ")", "{", "if", "(", "''", "===", "$", "key", ")", "{", "return", "$", "this", "->", "data", ";", "}", "$", "default", "=", "null", ";", "if", "(", "...
returns data from key or all @param string $key @param null $index @return array|null
[ "returns", "data", "from", "key", "or", "all" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/Abstract.php#L131-L156
shopgate/cart-integration-sdk
src/models/Abstract.php
Shopgate_Model_Abstract.underscore
protected function underscore($name) { if (isset(self::$underscoreCache[$name])) { return self::$underscoreCache[$name]; } $result = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name)); self::$underscoreCache[$name] = $result; return $result; }
php
protected function underscore($name) { if (isset(self::$underscoreCache[$name])) { return self::$underscoreCache[$name]; } $result = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name)); self::$underscoreCache[$name] = $result; return $result; }
[ "protected", "function", "underscore", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "underscoreCache", "[", "$", "name", "]", ")", ")", "{", "return", "self", "::", "$", "underscoreCache", "[", "$", "name", "]", ";", "}", ...
@param $name @return string
[ "@param", "$name" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/Abstract.php#L175-L184
BugBuster1701/contao-xing-bundle
src/Resources/contao/classes/XingImage.php
XingImage.getXingImageLink
public function getXingImageLink($xinglayout, $xing_source = 'xing_local') { $arrXingImageDefinitions= array(); $xingSrcProfile = '//www.xing.com/img/buttons/'; $xingSrcCompany = '//www.xing.com/img/xing/xe/corporate_pages/'; $xingSrcLocal = 'bundles/bugbusterxing/'; if (file_exists(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php")) { include(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php"); } if (isset($arrXingImageDefinitions[$xinglayout])) { $this->image_file = $arrXingImageDefinitions[$xinglayout]['image_file']; $this->image_size = $arrXingImageDefinitions[$xinglayout]['image_size']; $this->image_title = $arrXingImageDefinitions[$xinglayout]['image_title']; } if ('xing_local' == $xing_source || '' == $xing_source) { $xingSrcProfile = $xingSrcLocal; $xingSrcCompany = $xingSrcLocal; } if ($xinglayout < 999) { $xing_images = '<img src="'.$xingSrcProfile.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">'; } else { $xing_images = '<img src="'.$xingSrcCompany.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">'; } return $xing_images; }
php
public function getXingImageLink($xinglayout, $xing_source = 'xing_local') { $arrXingImageDefinitions= array(); $xingSrcProfile = '//www.xing.com/img/buttons/'; $xingSrcCompany = '//www.xing.com/img/xing/xe/corporate_pages/'; $xingSrcLocal = 'bundles/bugbusterxing/'; if (file_exists(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php")) { include(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php"); } if (isset($arrXingImageDefinitions[$xinglayout])) { $this->image_file = $arrXingImageDefinitions[$xinglayout]['image_file']; $this->image_size = $arrXingImageDefinitions[$xinglayout]['image_size']; $this->image_title = $arrXingImageDefinitions[$xinglayout]['image_title']; } if ('xing_local' == $xing_source || '' == $xing_source) { $xingSrcProfile = $xingSrcLocal; $xingSrcCompany = $xingSrcLocal; } if ($xinglayout < 999) { $xing_images = '<img src="'.$xingSrcProfile.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">'; } else { $xing_images = '<img src="'.$xingSrcCompany.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">'; } return $xing_images; }
[ "public", "function", "getXingImageLink", "(", "$", "xinglayout", ",", "$", "xing_source", "=", "'xing_local'", ")", "{", "$", "arrXingImageDefinitions", "=", "array", "(", ")", ";", "$", "xingSrcProfile", "=", "'//www.xing.com/img/buttons/'", ";", "$", "xingSrcCo...
get Image Link
[ "get", "Image", "Link" ]
train
https://github.com/BugBuster1701/contao-xing-bundle/blob/e2816a6e6ff439812de6599712c5b8b756e4738a/src/Resources/contao/classes/XingImage.php#L32-L66
umpirsky/list-generator
src/Umpirsky/ListGenerator/Exporter/Format/Txt.php
Txt.export
public function export(array $data) { $txt = ''; foreach ($data as $id => $name) { $txt .= sprintf('%s (%s)%s', $name, $id, PHP_EOL); } return $txt; }
php
public function export(array $data) { $txt = ''; foreach ($data as $id => $name) { $txt .= sprintf('%s (%s)%s', $name, $id, PHP_EOL); } return $txt; }
[ "public", "function", "export", "(", "array", "$", "data", ")", "{", "$", "txt", "=", "''", ";", "foreach", "(", "$", "data", "as", "$", "id", "=>", "$", "name", ")", "{", "$", "txt", ".=", "sprintf", "(", "'%s (%s)%s'", ",", "$", "name", ",", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/umpirsky/list-generator/blob/103182faf6e48611901263a49e7a9ba33e7515b8/src/Umpirsky/ListGenerator/Exporter/Format/Txt.php#L12-L20
shopgate/cart-integration-sdk
src/models/catalog/Review.php
Shopgate_Model_Catalog_Review.asXml
public function asXml(Shopgate_Model_XmlResultObject $itemNode) { /** * @var Shopgate_Model_XmlResultObject $reviewNode */ $reviewNode = $itemNode->addChild('review'); $reviewNode->addAttribute('uid', $this->getUid()); $reviewNode->addChild('item_uid', $this->getItemUid()); $reviewNode->addChild('score', $this->getScore()); $reviewNode->addChildWithCDATA('reviewer_name', $this->getReviewerName()); $reviewNode->addChild('date', $this->getDate()); $reviewNode->addChildWithCDATA('title', $this->getTitle()); $reviewNode->addChildWithCDATA('text', $this->getText()); return $itemNode; }
php
public function asXml(Shopgate_Model_XmlResultObject $itemNode) { /** * @var Shopgate_Model_XmlResultObject $reviewNode */ $reviewNode = $itemNode->addChild('review'); $reviewNode->addAttribute('uid', $this->getUid()); $reviewNode->addChild('item_uid', $this->getItemUid()); $reviewNode->addChild('score', $this->getScore()); $reviewNode->addChildWithCDATA('reviewer_name', $this->getReviewerName()); $reviewNode->addChild('date', $this->getDate()); $reviewNode->addChildWithCDATA('title', $this->getTitle()); $reviewNode->addChildWithCDATA('text', $this->getText()); return $itemNode; }
[ "public", "function", "asXml", "(", "Shopgate_Model_XmlResultObject", "$", "itemNode", ")", "{", "/**\n * @var Shopgate_Model_XmlResultObject $reviewNode\n */", "$", "reviewNode", "=", "$", "itemNode", "->", "addChild", "(", "'review'", ")", ";", "$", "rev...
@param Shopgate_Model_XmlResultObject $itemNode @return Shopgate_Model_XmlResultObject
[ "@param", "Shopgate_Model_XmlResultObject", "$itemNode" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Review.php#L100-L115
garoevans/php-enum
src/Enum.php
Enum.match
public static function match($value, $expect, $strict = true) { if ($strict) { if (!array_search((string)$expect, (new static)->getConstList())) { return false; } } return (string)$value === (string)$expect; }
php
public static function match($value, $expect, $strict = true) { if ($strict) { if (!array_search((string)$expect, (new static)->getConstList())) { return false; } } return (string)$value === (string)$expect; }
[ "public", "static", "function", "match", "(", "$", "value", ",", "$", "expect", ",", "$", "strict", "=", "true", ")", "{", "if", "(", "$", "strict", ")", "{", "if", "(", "!", "array_search", "(", "(", "string", ")", "$", "expect", ",", "(", "new"...
@param string|Enum $value @param string|Enum $expect @param bool $strict @return bool
[ "@param", "string|Enum", "$value", "@param", "string|Enum", "$expect", "@param", "bool", "$strict" ]
train
https://github.com/garoevans/php-enum/blob/ef76bbc711bf52f63556fb91904cea0d762343c4/src/Enum.php#L112-L121
saxulum/saxulum-elasticsearch-querybuilder
src/Node/FloatNode.php
FloatNode.create
public static function create(float $value = null, bool $allowSerializeEmpty = false): FloatNode { $node = new self(); $node->value = $value; $node->allowSerializeEmpty = $allowSerializeEmpty; return $node; }
php
public static function create(float $value = null, bool $allowSerializeEmpty = false): FloatNode { $node = new self(); $node->value = $value; $node->allowSerializeEmpty = $allowSerializeEmpty; return $node; }
[ "public", "static", "function", "create", "(", "float", "$", "value", "=", "null", ",", "bool", "$", "allowSerializeEmpty", "=", "false", ")", ":", "FloatNode", "{", "$", "node", "=", "new", "self", "(", ")", ";", "$", "node", "->", "value", "=", "$"...
@param float|null $value @param bool $allowSerializeEmpty @return FloatNode
[ "@param", "float|null", "$value", "@param", "bool", "$allowSerializeEmpty" ]
train
https://github.com/saxulum/saxulum-elasticsearch-querybuilder/blob/2f5a15925f3f3afe6a8efabf1f2c9af42f81d9b1/src/Node/FloatNode.php#L20-L27
shopgate/cart-integration-sdk
src/models/AbstractExport.php
Shopgate_Model_AbstractExport.setData
public function setData($key, $value = null) { if (is_array($key)) { foreach ($key as $key => $value) { if (!is_array($value) && !is_object($value)) { $value = $this->stripInvalidUnicodeSequences( $this->stringToUtf8( $value, ShopgateObject::$sourceEncodings ) ); } $this->$key = $value; } } else { if (!is_array($value) && !is_object($value)) { if (!is_null($value)) { $value = $this->stripInvalidUnicodeSequences( $this->stringToUtf8( $value, ShopgateObject::$sourceEncodings ) ); } } $this->$key = $value; } return $this; }
php
public function setData($key, $value = null) { if (is_array($key)) { foreach ($key as $key => $value) { if (!is_array($value) && !is_object($value)) { $value = $this->stripInvalidUnicodeSequences( $this->stringToUtf8( $value, ShopgateObject::$sourceEncodings ) ); } $this->$key = $value; } } else { if (!is_array($value) && !is_object($value)) { if (!is_null($value)) { $value = $this->stripInvalidUnicodeSequences( $this->stringToUtf8( $value, ShopgateObject::$sourceEncodings ) ); } } $this->$key = $value; } return $this; }
[ "public", "function", "setData", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "foreach", "(", "$", "key", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is...
set the data by key or array @param $key @param null $value @return Shopgate_Model_AbstractExport
[ "set", "the", "data", "by", "key", "or", "array" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/AbstractExport.php#L56-L85
shopgate/cart-integration-sdk
src/models/AbstractExport.php
Shopgate_Model_AbstractExport.generateData
public function generateData() { foreach ($this->fireMethods as $method) { $this->log( "Calling function \"{$method}\": Actual memory usage before method: " . $this->getMemoryUsageString(), ShopgateLogger::LOGTYPE_DEBUG ); $this->{$method}(); } return $this; }
php
public function generateData() { foreach ($this->fireMethods as $method) { $this->log( "Calling function \"{$method}\": Actual memory usage before method: " . $this->getMemoryUsageString(), ShopgateLogger::LOGTYPE_DEBUG ); $this->{$method}(); } return $this; }
[ "public", "function", "generateData", "(", ")", "{", "foreach", "(", "$", "this", "->", "fireMethods", "as", "$", "method", ")", "{", "$", "this", "->", "log", "(", "\"Calling function \\\"{$method}\\\": Actual memory usage before method: \"", ".", "$", "this", "-...
generate data dom object @return $this
[ "generate", "data", "dom", "object" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/AbstractExport.php#L134-L146
accompli/accompli
src/Console/Logger/ConsoleLogger.php
ConsoleLogger.getOutput
public function getOutput($level = LogLevel::NOTICE) { $output = $this->output; if ($this->output instanceof ConsoleOutputInterface && in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) { $output = $this->output->getErrorOutput(); } return $output; }
php
public function getOutput($level = LogLevel::NOTICE) { $output = $this->output; if ($this->output instanceof ConsoleOutputInterface && in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) { $output = $this->output->getErrorOutput(); } return $output; }
[ "public", "function", "getOutput", "(", "$", "level", "=", "LogLevel", "::", "NOTICE", ")", "{", "$", "output", "=", "$", "this", "->", "output", ";", "if", "(", "$", "this", "->", "output", "instanceof", "ConsoleOutputInterface", "&&", "in_array", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L143-L151
accompli/accompli
src/Console/Logger/ConsoleLogger.php
ConsoleLogger.log
public function log($level, $message, array $context = array()) { if (isset($this->logLevelToVerbosityLevelMap[$level]) === false) { throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); } $output = $this->getOutput($level); if ($output->getVerbosity() >= $this->logLevelToVerbosityLevelMap[$level]) { $messageSections = $this->getMessageSectionsFromContext($context); if ($output->isDecorated() && isset($context['output.resetLine']) && $context['output.resetLine'] === true) { $output->write(sprintf(self::ANSI_CURSOR_UP_FORMAT.self::ANSI_CURSOR_FORWARD_FORMAT.self::ANSI_CLEAR_SCREEN_FROM_CURSOR_TO_END, $this->previousMessageLineCount, FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $messageSections))); $messageSections = ''; } $message = sprintf('%1$s %2$s <%3$s>%4$s</%3$s>', $messageSections, $this->getTaskActionStatusSectionFromContext($context), $level, $this->interpolate($message, $context)); $output->writeln($message); $this->previousMessageLineCount = $this->getMessageLineCount($message); $this->previousContext = $context; } }
php
public function log($level, $message, array $context = array()) { if (isset($this->logLevelToVerbosityLevelMap[$level]) === false) { throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); } $output = $this->getOutput($level); if ($output->getVerbosity() >= $this->logLevelToVerbosityLevelMap[$level]) { $messageSections = $this->getMessageSectionsFromContext($context); if ($output->isDecorated() && isset($context['output.resetLine']) && $context['output.resetLine'] === true) { $output->write(sprintf(self::ANSI_CURSOR_UP_FORMAT.self::ANSI_CURSOR_FORWARD_FORMAT.self::ANSI_CLEAR_SCREEN_FROM_CURSOR_TO_END, $this->previousMessageLineCount, FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $messageSections))); $messageSections = ''; } $message = sprintf('%1$s %2$s <%3$s>%4$s</%3$s>', $messageSections, $this->getTaskActionStatusSectionFromContext($context), $level, $this->interpolate($message, $context)); $output->writeln($message); $this->previousMessageLineCount = $this->getMessageLineCount($message); $this->previousContext = $context; } }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "logLevelToVerbosityLevelMap", "[", "$", "level", "]", ")", "===", "false...
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L156-L178
accompli/accompli
src/Console/Logger/ConsoleLogger.php
ConsoleLogger.getMessageSectionsFromContext
private function getMessageSectionsFromContext(array $context) { $messageSections = ''; foreach ($this->contextToOutputSectionMap as $sectionContextName => $section) { if (isset($context[$sectionContextName])) { $messageSection = str_repeat(' ', $section['paddedLength']); if (isset($this->previousContext[$sectionContextName]) === false || $this->previousContext[$sectionContextName] != $context[$sectionContextName]) { $messageSection = sprintf($section['format'], str_pad($context[$sectionContextName], $section['paddedLength'] - 2)); } $messageSections .= $messageSection; } } return $messageSections; }
php
private function getMessageSectionsFromContext(array $context) { $messageSections = ''; foreach ($this->contextToOutputSectionMap as $sectionContextName => $section) { if (isset($context[$sectionContextName])) { $messageSection = str_repeat(' ', $section['paddedLength']); if (isset($this->previousContext[$sectionContextName]) === false || $this->previousContext[$sectionContextName] != $context[$sectionContextName]) { $messageSection = sprintf($section['format'], str_pad($context[$sectionContextName], $section['paddedLength'] - 2)); } $messageSections .= $messageSection; } } return $messageSections; }
[ "private", "function", "getMessageSectionsFromContext", "(", "array", "$", "context", ")", "{", "$", "messageSections", "=", "''", ";", "foreach", "(", "$", "this", "->", "contextToOutputSectionMap", "as", "$", "sectionContextName", "=>", "$", "section", ")", "{...
Returns the unique message sections (enclosed by brackets) from the message context. @param array $context @return string
[ "Returns", "the", "unique", "message", "sections", "(", "enclosed", "by", "brackets", ")", "from", "the", "message", "context", "." ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L209-L224
accompli/accompli
src/Console/Logger/ConsoleLogger.php
ConsoleLogger.getTaskActionStatusSectionFromContext
private function getTaskActionStatusSectionFromContext(array $context) { $actionStatusSection = ''; if ($this->output->isDecorated()) { $actionStatusSection = sprintf(self::ANSI_CURSOR_BACKWARD_FORMAT, 1); } if (isset($context['event.task.action']) && isset($this->taskActionStatusToOutputMap[$context['event.task.action']])) { $actionStatusSection = sprintf('[<event-task-action-%1$s>%2$s</event-task-action-%1$s>]', $context['event.task.action'], $this->taskActionStatusToOutputMap[$context['event.task.action']]); } return $actionStatusSection; }
php
private function getTaskActionStatusSectionFromContext(array $context) { $actionStatusSection = ''; if ($this->output->isDecorated()) { $actionStatusSection = sprintf(self::ANSI_CURSOR_BACKWARD_FORMAT, 1); } if (isset($context['event.task.action']) && isset($this->taskActionStatusToOutputMap[$context['event.task.action']])) { $actionStatusSection = sprintf('[<event-task-action-%1$s>%2$s</event-task-action-%1$s>]', $context['event.task.action'], $this->taskActionStatusToOutputMap[$context['event.task.action']]); } return $actionStatusSection; }
[ "private", "function", "getTaskActionStatusSectionFromContext", "(", "array", "$", "context", ")", "{", "$", "actionStatusSection", "=", "''", ";", "if", "(", "$", "this", "->", "output", "->", "isDecorated", "(", ")", ")", "{", "$", "actionStatusSection", "="...
Returns the task status section based on the context. @param array $context @return string
[ "Returns", "the", "task", "status", "section", "based", "on", "the", "context", "." ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L233-L244
accompli/accompli
src/Console/Logger/ConsoleLogger.php
ConsoleLogger.interpolate
private function interpolate($message, array $context) { $replacements = array(); foreach ($context as $key => $value) { if (is_array($value) === false && (is_object($value) === false || method_exists($value, '__toString'))) { $replacements[sprintf('{%s}', $key)] = $value; } } return strtr($message, $replacements); }
php
private function interpolate($message, array $context) { $replacements = array(); foreach ($context as $key => $value) { if (is_array($value) === false && (is_object($value) === false || method_exists($value, '__toString'))) { $replacements[sprintf('{%s}', $key)] = $value; } } return strtr($message, $replacements); }
[ "private", "function", "interpolate", "(", "$", "message", ",", "array", "$", "context", ")", "{", "$", "replacements", "=", "array", "(", ")", ";", "foreach", "(", "$", "context", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array"...
Interpolates context values into the message placeholders. @author PHP Framework Interoperability Group @param string $message @param array $context @return string
[ "Interpolates", "context", "values", "into", "the", "message", "placeholders", "." ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L256-L266
accompli/accompli
src/Console/Logger/ConsoleLogger.php
ConsoleLogger.getMessageLineCount
private function getMessageLineCount($message) { $messageLength = FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $message); return ceil($messageLength / $this->getTerminalWidth()); }
php
private function getMessageLineCount($message) { $messageLength = FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $message); return ceil($messageLength / $this->getTerminalWidth()); }
[ "private", "function", "getMessageLineCount", "(", "$", "message", ")", "{", "$", "messageLength", "=", "FormatterHelper", "::", "strlenWithoutDecoration", "(", "$", "this", "->", "output", "->", "getFormatter", "(", ")", ",", "$", "message", ")", ";", "return...
Returns the line count of the message based on the terminal width. @param string $message @return int
[ "Returns", "the", "line", "count", "of", "the", "message", "based", "on", "the", "terminal", "width", "." ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L275-L280
silverstripe/silverstripe-versionfeed
src/VersionFeed.php
VersionFeed.getDiffList
public function getDiffList($highestVersion = null, $limit = 100) { // This can leak secured content if it was protected via inherited setting. // For now the users will need to be aware about this shortcoming. $offset = $highestVersion ? "AND \"SiteTree_Versions\".\"Version\"<='".(int)$highestVersion."'" : ''; // Get just enough elements for diffing. We need one more than desired to have something to compare to. $qLimit = (int)$limit + 1; $versions = $this->owner->allVersions( "\"WasPublished\"='1' AND \"CanViewType\" IN ('Anyone', 'Inherit') $offset", "\"SiteTree\".\"LastEdited\" DESC, \"SiteTree\".\"ID\" DESC", $qLimit ); // Process the list to add the comparisons. $changeList = new ArrayList(); $previous = null; $count = 0; foreach ($versions as $version) { $changed = false; // Check if we have something to compare with. if (isset($previous)) { // Produce the diff fields for use in the template. if ($version->Title != $previous->Title) { $diffTitle = Diff::compareHTML($version->Title, $previous->Title); $version->DiffTitle = DBField::create_field('HTMLText', null); $version->DiffTitle->setValue( sprintf( '<div><em>%s</em> ' . $diffTitle . '</div>', _t(__CLASS__ . '.TITLECHANGED', 'Title has changed:') ) ); $changed = true; } if ($version->Content != $previous->Content) { $diffContent = Diff::compareHTML($version->Content, $previous->Content); $version->DiffContent = DBField::create_field('HTMLText', null); $version->DiffContent->setValue('<div>'.$diffContent.'</div>'); $changed = true; } // Copy the link so it can be cached. $oldPage = $version->getField('object'); if (!$oldPage instanceof SiteTree) { // We only need enough info to generate the link... $oldPage = SiteTree::create([ 'ID' => $oldPage->ID, 'URLSegment' => $oldPage->URLSegment, 'ParentID' => $oldPage->ParentID ]); } $version->GeneratedLink = $oldPage->AbsoluteLink(); } // Omit the versions that haven't been visibly changed (only takes the above fields into consideration). if ($changed) { $changeList->push($version); $count++; } // Store the last version for comparison. $previous = $version; } // Make sure enough diff items have been generated to satisfy the $limit. If we ran out, add the final, // non-diffed item (the initial version). This will also work for a single-diff request: if we are requesting // a diff on the initial version we will just get that version, verbatim. if ($previous && $versions->count()<$qLimit) { $first = clone($previous); $first->DiffContent = DBField::create_field('HTMLText', null); $first->DiffContent->setValue('<div>' . $first->Content . '</div>'); // Copy the link so it can be cached. $first->GeneratedLink = $first->AbsoluteLink(); $changeList->push($first); } return $changeList; }
php
public function getDiffList($highestVersion = null, $limit = 100) { // This can leak secured content if it was protected via inherited setting. // For now the users will need to be aware about this shortcoming. $offset = $highestVersion ? "AND \"SiteTree_Versions\".\"Version\"<='".(int)$highestVersion."'" : ''; // Get just enough elements for diffing. We need one more than desired to have something to compare to. $qLimit = (int)$limit + 1; $versions = $this->owner->allVersions( "\"WasPublished\"='1' AND \"CanViewType\" IN ('Anyone', 'Inherit') $offset", "\"SiteTree\".\"LastEdited\" DESC, \"SiteTree\".\"ID\" DESC", $qLimit ); // Process the list to add the comparisons. $changeList = new ArrayList(); $previous = null; $count = 0; foreach ($versions as $version) { $changed = false; // Check if we have something to compare with. if (isset($previous)) { // Produce the diff fields for use in the template. if ($version->Title != $previous->Title) { $diffTitle = Diff::compareHTML($version->Title, $previous->Title); $version->DiffTitle = DBField::create_field('HTMLText', null); $version->DiffTitle->setValue( sprintf( '<div><em>%s</em> ' . $diffTitle . '</div>', _t(__CLASS__ . '.TITLECHANGED', 'Title has changed:') ) ); $changed = true; } if ($version->Content != $previous->Content) { $diffContent = Diff::compareHTML($version->Content, $previous->Content); $version->DiffContent = DBField::create_field('HTMLText', null); $version->DiffContent->setValue('<div>'.$diffContent.'</div>'); $changed = true; } // Copy the link so it can be cached. $oldPage = $version->getField('object'); if (!$oldPage instanceof SiteTree) { // We only need enough info to generate the link... $oldPage = SiteTree::create([ 'ID' => $oldPage->ID, 'URLSegment' => $oldPage->URLSegment, 'ParentID' => $oldPage->ParentID ]); } $version->GeneratedLink = $oldPage->AbsoluteLink(); } // Omit the versions that haven't been visibly changed (only takes the above fields into consideration). if ($changed) { $changeList->push($version); $count++; } // Store the last version for comparison. $previous = $version; } // Make sure enough diff items have been generated to satisfy the $limit. If we ran out, add the final, // non-diffed item (the initial version). This will also work for a single-diff request: if we are requesting // a diff on the initial version we will just get that version, verbatim. if ($previous && $versions->count()<$qLimit) { $first = clone($previous); $first->DiffContent = DBField::create_field('HTMLText', null); $first->DiffContent->setValue('<div>' . $first->Content . '</div>'); // Copy the link so it can be cached. $first->GeneratedLink = $first->AbsoluteLink(); $changeList->push($first); } return $changeList; }
[ "public", "function", "getDiffList", "(", "$", "highestVersion", "=", "null", ",", "$", "limit", "=", "100", ")", "{", "// This can leak secured content if it was protected via inherited setting.", "// For now the users will need to be aware about this shortcoming.", "$", "offset...
Compile a list of changes to the current page, excluding non-published and explicitly secured versions. @param int $highestVersion Top version number to consider. @param int $limit Limit to the amount of items returned. @returns ArrayList List of cleaned records.
[ "Compile", "a", "list", "of", "changes", "to", "the", "current", "page", "excluding", "non", "-", "published", "and", "explicitly", "secured", "versions", "." ]
train
https://github.com/silverstripe/silverstripe-versionfeed/blob/831f03a2b85602c7a7fba110e0ef51c36ad4f204/src/VersionFeed.php#L73-L153
silverstripe/silverstripe-versionfeed
src/VersionFeed.php
VersionFeed.getDiff
public function getDiff() { $changes = $this->getDiffList($this->owner->Version, 1); if ($changes && $changes->Count()) { return $changes->First(); } return null; }
php
public function getDiff() { $changes = $this->getDiffList($this->owner->Version, 1); if ($changes && $changes->Count()) { return $changes->First(); } return null; }
[ "public", "function", "getDiff", "(", ")", "{", "$", "changes", "=", "$", "this", "->", "getDiffList", "(", "$", "this", "->", "owner", "->", "Version", ",", "1", ")", ";", "if", "(", "$", "changes", "&&", "$", "changes", "->", "Count", "(", ")", ...
Return a single diff representing this version. Returns the initial version if there is nothing to compare to. @return DataObject|null Object with relevant fields diffed.
[ "Return", "a", "single", "diff", "representing", "this", "version", ".", "Returns", "the", "initial", "version", "if", "there", "is", "nothing", "to", "compare", "to", "." ]
train
https://github.com/silverstripe/silverstripe-versionfeed/blob/831f03a2b85602c7a7fba110e0ef51c36ad4f204/src/VersionFeed.php#L161-L169
silverstripe/silverstripe-versionfeed
src/VersionFeed.php
VersionFeed.getDiffedChanges
public function getDiffedChanges($highestVersion = null, $fullHistory = true, $limit = 100) { return $this->getDiffList( $highestVersion, $fullHistory ? $limit : 1 ); }
php
public function getDiffedChanges($highestVersion = null, $fullHistory = true, $limit = 100) { return $this->getDiffList( $highestVersion, $fullHistory ? $limit : 1 ); }
[ "public", "function", "getDiffedChanges", "(", "$", "highestVersion", "=", "null", ",", "$", "fullHistory", "=", "true", ",", "$", "limit", "=", "100", ")", "{", "return", "$", "this", "->", "getDiffList", "(", "$", "highestVersion", ",", "$", "fullHistory...
Compile a list of changes to the current page, excluding non-published and explicitly secured versions. @deprecated 2.0.0 Use VersionFeed::getDiffList instead @param int $highestVersion Top version number to consider. @param boolean $fullHistory Set to true to get the full change history, set to false for a single diff. @param int $limit Limit to the amount of items returned. @returns ArrayList List of cleaned records.
[ "Compile", "a", "list", "of", "changes", "to", "the", "current", "page", "excluding", "non", "-", "published", "and", "explicitly", "secured", "versions", "." ]
train
https://github.com/silverstripe/silverstripe-versionfeed/blob/831f03a2b85602c7a7fba110e0ef51c36ad4f204/src/VersionFeed.php#L182-L188
despark/ignicms
app/Http/Controllers/Admin/SeoPagesController.php
SeoPagesController.store
public function store(SeoPagesRequest $request) { $input = $request->all(); $record = $this->model->create($input); $this->notify([ 'type' => 'success', 'title' => 'Successful create!', 'description' => 'SeoPage is created successfully!', ]); return redirect(route('seo_page.edit', ['id' => $record->id])); }
php
public function store(SeoPagesRequest $request) { $input = $request->all(); $record = $this->model->create($input); $this->notify([ 'type' => 'success', 'title' => 'Successful create!', 'description' => 'SeoPage is created successfully!', ]); return redirect(route('seo_page.edit', ['id' => $record->id])); }
[ "public", "function", "store", "(", "SeoPagesRequest", "$", "request", ")", "{", "$", "input", "=", "$", "request", "->", "all", "(", ")", ";", "$", "record", "=", "$", "this", "->", "model", "->", "create", "(", "$", "input", ")", ";", "$", "this"...
Store a newly created resource in storage. @param Request $request @return Response
[ "Store", "a", "newly", "created", "resource", "in", "storage", "." ]
train
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/app/Http/Controllers/Admin/SeoPagesController.php#L48-L61
despark/ignicms
app/Http/Controllers/Admin/SeoPagesController.php
SeoPagesController.update
public function update(SeoPagesRequest $request, $id) { $input = $request->all(); $record = $this->model->findOrFail($id); $record->update($input); $this->notify([ 'type' => 'success', 'title' => 'Successful update!', 'description' => 'SeoPage is updated successfully.', ]); return redirect()->back(); }
php
public function update(SeoPagesRequest $request, $id) { $input = $request->all(); $record = $this->model->findOrFail($id); $record->update($input); $this->notify([ 'type' => 'success', 'title' => 'Successful update!', 'description' => 'SeoPage is updated successfully.', ]); return redirect()->back(); }
[ "public", "function", "update", "(", "SeoPagesRequest", "$", "request", ",", "$", "id", ")", "{", "$", "input", "=", "$", "request", "->", "all", "(", ")", ";", "$", "record", "=", "$", "this", "->", "model", "->", "findOrFail", "(", "$", "id", ")"...
Update the specified resource in storage. @param Request $request @param int $id @return Response
[ "Update", "the", "specified", "resource", "in", "storage", "." ]
train
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/app/Http/Controllers/Admin/SeoPagesController.php#L90-L105
despark/ignicms
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/URI.php
CI_URI._set_uri_string
function _set_uri_string($str) { // Filter out control characters $str = remove_invisible_characters($str, FALSE); // If the URI contains only a slash we'll kill it $this->uri_string = ($str == '/') ? '' : $str; }
php
function _set_uri_string($str) { // Filter out control characters $str = remove_invisible_characters($str, FALSE); // If the URI contains only a slash we'll kill it $this->uri_string = ($str == '/') ? '' : $str; }
[ "function", "_set_uri_string", "(", "$", "str", ")", "{", "// Filter out control characters", "$", "str", "=", "remove_invisible_characters", "(", "$", "str", ",", "FALSE", ")", ";", "// If the URI contains only a slash we'll kill it", "$", "this", "->", "uri_string", ...
Set the URI String @access public @param string @return string
[ "Set", "the", "URI", "String" ]
train
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/URI.php#L158-L165
despark/ignicms
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/URI.php
CI_URI._filter_uri
function _filter_uri($str) { if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) { // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str)) { show_error('The URI you submitted has disallowed characters.', 400); } } // Convert programatic characters to entities $bad = array('$', '(', ')', '%28', '%29'); $good = array('&#36;', '&#40;', '&#41;', '&#40;', '&#41;'); return str_replace($bad, $good, $str); }
php
function _filter_uri($str) { if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) { // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str)) { show_error('The URI you submitted has disallowed characters.', 400); } } // Convert programatic characters to entities $bad = array('$', '(', ')', '%28', '%29'); $good = array('&#36;', '&#40;', '&#41;', '&#40;', '&#41;'); return str_replace($bad, $good, $str); }
[ "function", "_filter_uri", "(", "$", "str", ")", "{", "if", "(", "$", "str", "!=", "''", "&&", "$", "this", "->", "config", "->", "item", "(", "'permitted_uri_chars'", ")", "!=", "''", "&&", "$", "this", "->", "config", "->", "item", "(", "'enable_qu...
Filter segments for malicious characters @access private @param string @return string
[ "Filter", "segments", "for", "malicious", "characters" ]
train
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/URI.php#L251-L268
despark/ignicms
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/URI.php
CI_URI._remove_url_suffix
function _remove_url_suffix() { if ($this->config->item('url_suffix') != "") { $this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string); } }
php
function _remove_url_suffix() { if ($this->config->item('url_suffix') != "") { $this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string); } }
[ "function", "_remove_url_suffix", "(", ")", "{", "if", "(", "$", "this", "->", "config", "->", "item", "(", "'url_suffix'", ")", "!=", "\"\"", ")", "{", "$", "this", "->", "uri_string", "=", "preg_replace", "(", "\"|\"", ".", "preg_quote", "(", "$", "t...
Remove the suffix from the URL if needed @access private @return void
[ "Remove", "the", "suffix", "from", "the", "URL", "if", "needed" ]
train
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/URI.php#L278-L284
qloog/yaf-library
src/Http/Response.php
Response.getHeaders
public function getHeaders() { if ($this->headers) { return $this->headers; } $this->headers = [ 'STATUS' => $this->code(), ]; $originHeaders = explode("\r\n\r\n", $this->originHeaders); $originHeader = array_pop($originHeaders); foreach (explode("\r\n", $originHeader) as $i => $header) { if ($i == 0 || !$header) { continue; } $header = explode(':', $header, 2); $header[0] = strtoupper($header[0]); if ($header[0] == 'SET-COOKIE') { $this->headers[$header[0]][] = isset($header[1]) ? trim($header[1]) : ''; } else { $this->headers[$header[0]] = isset($header[1]) ? trim($header[1]) : ''; } } return $this->headers; }
php
public function getHeaders() { if ($this->headers) { return $this->headers; } $this->headers = [ 'STATUS' => $this->code(), ]; $originHeaders = explode("\r\n\r\n", $this->originHeaders); $originHeader = array_pop($originHeaders); foreach (explode("\r\n", $originHeader) as $i => $header) { if ($i == 0 || !$header) { continue; } $header = explode(':', $header, 2); $header[0] = strtoupper($header[0]); if ($header[0] == 'SET-COOKIE') { $this->headers[$header[0]][] = isset($header[1]) ? trim($header[1]) : ''; } else { $this->headers[$header[0]] = isset($header[1]) ? trim($header[1]) : ''; } } return $this->headers; }
[ "public", "function", "getHeaders", "(", ")", "{", "if", "(", "$", "this", "->", "headers", ")", "{", "return", "$", "this", "->", "headers", ";", "}", "$", "this", "->", "headers", "=", "[", "'STATUS'", "=>", "$", "this", "->", "code", "(", ")", ...
获取所有响应头 @return array
[ "获取所有响应头" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Response.php#L92-L119
makinacorpus/drupal-ucms
ucms_user/src/Action/UserActionProvider.php
UserActionProvider.getActions
public function getActions($item, $primaryOnly = false, array $groups = []) { $actions = []; $userId = $this->getUserIdFrom($item); if ($this->isGranted(Permission::VIEW, $item)) { $actions[] = new Action($this->t("View"), 'admin/dashboard/user/' . $userId, null, 'eye', 1, true, true); } if ($this->isGranted(Permission::LOCK, $item)) { if (!$this->getStatusFrom($item)) { $action_title = $this->t("Enable"); $action_path = 'admin/dashboard/user/' . $userId . '/enable'; $action_icon = 'check-circle'; } else { $action_title = $this->t("Disable"); $action_path = 'admin/dashboard/user/' . $userId . '/disable'; $action_icon = 'ban'; } $action_disabled = ($userId === $this->currentUser->id()); $actions[] = new Action($action_title, $action_path, 'dialog', $action_icon, 2, false, true, $action_disabled); } if ($this->isGranted(Permission::UPDATE, $item)) { $actions[] = new Action($this->t("Edit"), 'admin/dashboard/user/' . $userId . '/edit', null, 'pencil', 3, false, true); $actions[] = new Action($this->t("Change email"), 'admin/dashboard/user/' . $userId . '/change-email', 'dialog', 'pencil', 4, false, true); $actions[] = new Action($this->t("Reset password"), 'admin/dashboard/user/' . $userId . '/reset-password', 'dialog', 'refresh', 5, false, true); } if ($this->isGranted(Permission::DELETE, $item)) { $actions[] = new Action($this->t("Delete"), 'admin/dashboard/user/' . $userId . '/delete', 'dialog', 'trash', 6, false, true); } return $actions; }
php
public function getActions($item, $primaryOnly = false, array $groups = []) { $actions = []; $userId = $this->getUserIdFrom($item); if ($this->isGranted(Permission::VIEW, $item)) { $actions[] = new Action($this->t("View"), 'admin/dashboard/user/' . $userId, null, 'eye', 1, true, true); } if ($this->isGranted(Permission::LOCK, $item)) { if (!$this->getStatusFrom($item)) { $action_title = $this->t("Enable"); $action_path = 'admin/dashboard/user/' . $userId . '/enable'; $action_icon = 'check-circle'; } else { $action_title = $this->t("Disable"); $action_path = 'admin/dashboard/user/' . $userId . '/disable'; $action_icon = 'ban'; } $action_disabled = ($userId === $this->currentUser->id()); $actions[] = new Action($action_title, $action_path, 'dialog', $action_icon, 2, false, true, $action_disabled); } if ($this->isGranted(Permission::UPDATE, $item)) { $actions[] = new Action($this->t("Edit"), 'admin/dashboard/user/' . $userId . '/edit', null, 'pencil', 3, false, true); $actions[] = new Action($this->t("Change email"), 'admin/dashboard/user/' . $userId . '/change-email', 'dialog', 'pencil', 4, false, true); $actions[] = new Action($this->t("Reset password"), 'admin/dashboard/user/' . $userId . '/reset-password', 'dialog', 'refresh', 5, false, true); } if ($this->isGranted(Permission::DELETE, $item)) { $actions[] = new Action($this->t("Delete"), 'admin/dashboard/user/' . $userId . '/delete', 'dialog', 'trash', 6, false, true); } return $actions; }
[ "public", "function", "getActions", "(", "$", "item", ",", "$", "primaryOnly", "=", "false", ",", "array", "$", "groups", "=", "[", "]", ")", "{", "$", "actions", "=", "[", "]", ";", "$", "userId", "=", "$", "this", "->", "getUserIdFrom", "(", "$",...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/Action/UserActionProvider.php#L56-L91
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php
Standard.uploadFile
public function uploadFile( \stdClass $params ) { $this->checkParams( $params, array( 'site' ) ); $this->setLocale( $params->site ); $clientFilename = ''; $context = $this->getContext(); $request = $context->getView()->request(); $dest = $this->storeFile( $request, $clientFilename ); $result = (object) array( 'site' => $params->site, 'items' => array( (object) array( 'job.label' => 'Product text import: ' . $clientFilename, 'job.method' => 'Product_Import_Text.importFile', 'job.parameter' => array( 'site' => $params->site, 'items' => $dest, ), 'job.status' => 1, ), ), ); $jobController = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'admin/job' ); $jobController->saveItems( $result ); return array( 'items' => $dest, 'success' => true, ); }
php
public function uploadFile( \stdClass $params ) { $this->checkParams( $params, array( 'site' ) ); $this->setLocale( $params->site ); $clientFilename = ''; $context = $this->getContext(); $request = $context->getView()->request(); $dest = $this->storeFile( $request, $clientFilename ); $result = (object) array( 'site' => $params->site, 'items' => array( (object) array( 'job.label' => 'Product text import: ' . $clientFilename, 'job.method' => 'Product_Import_Text.importFile', 'job.parameter' => array( 'site' => $params->site, 'items' => $dest, ), 'job.status' => 1, ), ), ); $jobController = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'admin/job' ); $jobController->saveItems( $result ); return array( 'items' => $dest, 'success' => true, ); }
[ "public", "function", "uploadFile", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'site'", ")", ")", ";", "$", "this", "->", "setLocale", "(", "$", "params", "->", "site", ")...
Uploads a CSV file with all product texts. @param \stdClass $params Object containing the properties
[ "Uploads", "a", "CSV", "file", "with", "all", "product", "texts", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php#L42-L75
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php
Standard.importFile
public function importFile( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'items' ) ); $this->setLocale( $params->site ); $fs = $this->getContext()->getFilesystemManager()->get( 'fs-admin' ); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $path ) { $tmpfile = $fs->readf( $path ); /** controller/extjs/product/import/text/standard/container/type * Container file type storing all language files of the texts to import * * When exporting texts, one file or content object is created per * language. All those files or content objects are put into one container * file so editors don't have to download one file for each language. * * The container file types that are supported by default are: * * Zip * * Extensions implement other container types like spread sheets, XMLs or * more advanced ways of handling the exported data. * * @param string Container file type * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/format */ /** controller/extjs/product/import/text/standard/container/format * Format of the language files for the texts to import * * The exported texts are stored in one file or content object per * language. The format of that file or content object can be configured * with this option but most formats are bound to a specific container * type. * * The formats that are supported by default are: * * CSV (requires container type "Zip") * * Extensions implement other container types like spread sheets, XMLs or * more advanced ways of handling the exported data. * * @param string Content file type * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/type * @see controller/extjs/product/import/text/standard/container/options */ /** controller/extjs/product/import/text/standard/container/options * Options changing the expected format for the texts to import * * Each content format may support some configuration options to change * the output for that content type. * * The options for the CSV content format are: * * csv-separator, default ',' * * csv-enclosure, default '"' * * csv-escape, default '"' * * csv-lineend, default '\n' * * For format options provided by other container types implemented by * extensions, please have a look into the extension documentation. * * @param array Associative list of options with the name as key and its value * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/format */ $container = $this->createContainer( $tmpfile, 'controller/extjs/product/import/text/standard/container' ); $textTypeMap = []; foreach( $this->getTextTypes( 'product' ) as $item ) { $textTypeMap[$item->getCode()] = $item->getId(); } foreach( $container as $content ) { $this->importTextsFromContent( $content, $textTypeMap, 'product' ); } unlink( $tmpfile ); $fs->rm( $path ); } return array( 'success' => true, ); }
php
public function importFile( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'items' ) ); $this->setLocale( $params->site ); $fs = $this->getContext()->getFilesystemManager()->get( 'fs-admin' ); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $path ) { $tmpfile = $fs->readf( $path ); /** controller/extjs/product/import/text/standard/container/type * Container file type storing all language files of the texts to import * * When exporting texts, one file or content object is created per * language. All those files or content objects are put into one container * file so editors don't have to download one file for each language. * * The container file types that are supported by default are: * * Zip * * Extensions implement other container types like spread sheets, XMLs or * more advanced ways of handling the exported data. * * @param string Container file type * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/format */ /** controller/extjs/product/import/text/standard/container/format * Format of the language files for the texts to import * * The exported texts are stored in one file or content object per * language. The format of that file or content object can be configured * with this option but most formats are bound to a specific container * type. * * The formats that are supported by default are: * * CSV (requires container type "Zip") * * Extensions implement other container types like spread sheets, XMLs or * more advanced ways of handling the exported data. * * @param string Content file type * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/type * @see controller/extjs/product/import/text/standard/container/options */ /** controller/extjs/product/import/text/standard/container/options * Options changing the expected format for the texts to import * * Each content format may support some configuration options to change * the output for that content type. * * The options for the CSV content format are: * * csv-separator, default ',' * * csv-enclosure, default '"' * * csv-escape, default '"' * * csv-lineend, default '\n' * * For format options provided by other container types implemented by * extensions, please have a look into the extension documentation. * * @param array Associative list of options with the name as key and its value * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/format */ $container = $this->createContainer( $tmpfile, 'controller/extjs/product/import/text/standard/container' ); $textTypeMap = []; foreach( $this->getTextTypes( 'product' ) as $item ) { $textTypeMap[$item->getCode()] = $item->getId(); } foreach( $container as $content ) { $this->importTextsFromContent( $content, $textTypeMap, 'product' ); } unlink( $tmpfile ); $fs->rm( $path ); } return array( 'success' => true, ); }
[ "public", "function", "importFile", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'site'", ",", "'items'", ")", ")", ";", "$", "this", "->", "setLocale", "(", "$", "params", ...
Imports a CSV file with all product texts. @param \stdClass $params Object containing the properties
[ "Imports", "a", "CSV", "file", "with", "all", "product", "texts", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php#L83-L176
makinacorpus/drupal-ucms
ucms_cart/src/Action/NodeActionProvider.php
NodeActionProvider.getActions
public function getActions($item, $primaryOnly = false, array $groups = []) { $ret = []; if ($this->isGranted('use favorites')) { // @todo constant or helper ? $inCart = $this->cart->has($this->account->id(), $item->id()); $ret[] = Action::create([ 'title' => $inCart ? $this->t("Remove from cart") : $this->t("Add to cart"), 'uri' => 'admin/cart/' . $item->id() . ($inCart ? '/remove' : '/add') . '/nojs', // 'options' => 'ajax', 'icon' => 'shopping-cart', 'primary' => false, 'priority' => -25, 'redirect' => true, 'group' => 'mark', ]); } return $ret; }
php
public function getActions($item, $primaryOnly = false, array $groups = []) { $ret = []; if ($this->isGranted('use favorites')) { // @todo constant or helper ? $inCart = $this->cart->has($this->account->id(), $item->id()); $ret[] = Action::create([ 'title' => $inCart ? $this->t("Remove from cart") : $this->t("Add to cart"), 'uri' => 'admin/cart/' . $item->id() . ($inCart ? '/remove' : '/add') . '/nojs', // 'options' => 'ajax', 'icon' => 'shopping-cart', 'primary' => false, 'priority' => -25, 'redirect' => true, 'group' => 'mark', ]); } return $ret; }
[ "public", "function", "getActions", "(", "$", "item", ",", "$", "primaryOnly", "=", "false", ",", "array", "$", "groups", "=", "[", "]", ")", "{", "$", "ret", "=", "[", "]", ";", "if", "(", "$", "this", "->", "isGranted", "(", "'use favorites'", ")...
{inheritdoc}
[ "{", "inheritdoc", "}" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_cart/src/Action/NodeActionProvider.php#L32-L51
artkonekt/gears
src/Backend/Drivers/CachedDatabase.php
CachedDatabase.pkey
protected function pkey(string $key, $userId): string { return sprintf('%s(%s).%s', self::PREFERENCES_KEY_PREFIX, $userId, $key); }
php
protected function pkey(string $key, $userId): string { return sprintf('%s(%s).%s', self::PREFERENCES_KEY_PREFIX, $userId, $key); }
[ "protected", "function", "pkey", "(", "string", "$", "key", ",", "$", "userId", ")", ":", "string", "{", "return", "sprintf", "(", "'%s(%s).%s'", ",", "self", "::", "PREFERENCES_KEY_PREFIX", ",", "$", "userId", ",", "$", "key", ")", ";", "}" ]
Returns the cache key for a preference for user @param string $key @param int $userId @return string
[ "Returns", "the", "cache", "key", "for", "a", "preference", "for", "user" ]
train
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L168-L171
artkonekt/gears
src/Backend/Drivers/CachedDatabase.php
CachedDatabase.sforget
protected function sforget($key) { $keys = is_array($key) ? $key : [$key]; foreach ($keys as $key) { $this->cache->forget($this->skey($key)); } $this->cache->forget($this->skey('*')); }
php
protected function sforget($key) { $keys = is_array($key) ? $key : [$key]; foreach ($keys as $key) { $this->cache->forget($this->skey($key)); } $this->cache->forget($this->skey('*')); }
[ "protected", "function", "sforget", "(", "$", "key", ")", "{", "$", "keys", "=", "is_array", "(", "$", "key", ")", "?", "$", "key", ":", "[", "$", "key", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "this", "->", "c...
Removes a setting from the cache by its key @param string|array $key One or more keys
[ "Removes", "a", "setting", "from", "the", "cache", "by", "its", "key" ]
train
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L178-L187
artkonekt/gears
src/Backend/Drivers/CachedDatabase.php
CachedDatabase.pforget
protected function pforget($key, $userId) { $keys = is_array($key) ? $key : [$key]; foreach ($keys as $key) { $this->cache->forget($this->pkey($key, $userId)); } $this->cache->forget($this->pkey('*', $userId)); }
php
protected function pforget($key, $userId) { $keys = is_array($key) ? $key : [$key]; foreach ($keys as $key) { $this->cache->forget($this->pkey($key, $userId)); } $this->cache->forget($this->pkey('*', $userId)); }
[ "protected", "function", "pforget", "(", "$", "key", ",", "$", "userId", ")", "{", "$", "keys", "=", "is_array", "(", "$", "key", ")", "?", "$", "key", ":", "[", "$", "key", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "...
Removes a preference from the cache by key and user @param string|array $key One or more keys @param int $userId
[ "Removes", "a", "preference", "from", "the", "cache", "by", "key", "and", "user" ]
train
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L195-L204
makinacorpus/drupal-ucms
ucms_site/src/Action/NodeActionProvider.php
NodeActionProvider.getActions
public function getActions($item, $primaryOnly = false, array $groups = []) { $ret = []; /* @var $item NodeInterface */ $account = $this->currentUser; // Check if current content is a reference within the current context if ($this->siteManager->hasContext()) { $site = $this->siteManager->getContext(); if ($this->nodeAccess->userCanDereference($account, $item, $site)) { $ret[] = new Action($this->t("Remove from the current site"), 'node/' . $item->nid . '/dereference-from/' . $site->getId(), 'dialog', 'remove', 2, true, true, false, 'site'); } if ($this->nodeAccess->userCanReference($account, $item)) { $ret[] = new Action($this->t("Use on another site"), 'node/' . $item->nid . '/reference', 'dialog', 'link', 2, true, true, false, 'site'); } if (!$site->hasHome() && $item->site_id == $site->getId() && $this->isGranted(Permission::UPDATE, $item)) { $ret[] = new Action($this->t("Set as home page"), 'node/' . $item->nid . '/set-home', 'dialog', 'home', 2, false, true, false, 'site'); } } else if ($this->nodeAccess->userCanReference($account, $item)) { // We are not on a site, just display "normal" action $ret[] = new Action($this->t("Use on my site"), 'node/' . $item->nid . '/reference', 'dialog', 'link', 2, true, true, false, 'site'); } if ($this->isGranted(Permission::LOCK, $item)) { if ($item->is_clonable) { $ret[] = new Action($this->t("Lock"), 'node/' . $item->id() . '/lock', 'dialog', 'lock', 2, false, true, false, 'edit'); } else { $ret[] = new Action($this->t("Unlock"), 'node/' . $item->id() . '/unlock', 'dialog', 'lock', 2, false, true, false, 'edit'); } } $ret[] = new Action($this->t("View in site"), 'node/' . $item->id() . '/site-list', 'dialog', 'search', 100, false, true, false, 'view'); return $ret; }
php
public function getActions($item, $primaryOnly = false, array $groups = []) { $ret = []; /* @var $item NodeInterface */ $account = $this->currentUser; // Check if current content is a reference within the current context if ($this->siteManager->hasContext()) { $site = $this->siteManager->getContext(); if ($this->nodeAccess->userCanDereference($account, $item, $site)) { $ret[] = new Action($this->t("Remove from the current site"), 'node/' . $item->nid . '/dereference-from/' . $site->getId(), 'dialog', 'remove', 2, true, true, false, 'site'); } if ($this->nodeAccess->userCanReference($account, $item)) { $ret[] = new Action($this->t("Use on another site"), 'node/' . $item->nid . '/reference', 'dialog', 'link', 2, true, true, false, 'site'); } if (!$site->hasHome() && $item->site_id == $site->getId() && $this->isGranted(Permission::UPDATE, $item)) { $ret[] = new Action($this->t("Set as home page"), 'node/' . $item->nid . '/set-home', 'dialog', 'home', 2, false, true, false, 'site'); } } else if ($this->nodeAccess->userCanReference($account, $item)) { // We are not on a site, just display "normal" action $ret[] = new Action($this->t("Use on my site"), 'node/' . $item->nid . '/reference', 'dialog', 'link', 2, true, true, false, 'site'); } if ($this->isGranted(Permission::LOCK, $item)) { if ($item->is_clonable) { $ret[] = new Action($this->t("Lock"), 'node/' . $item->id() . '/lock', 'dialog', 'lock', 2, false, true, false, 'edit'); } else { $ret[] = new Action($this->t("Unlock"), 'node/' . $item->id() . '/unlock', 'dialog', 'lock', 2, false, true, false, 'edit'); } } $ret[] = new Action($this->t("View in site"), 'node/' . $item->id() . '/site-list', 'dialog', 'search', 100, false, true, false, 'view'); return $ret; }
[ "public", "function", "getActions", "(", "$", "item", ",", "$", "primaryOnly", "=", "false", ",", "array", "$", "groups", "=", "[", "]", ")", "{", "$", "ret", "=", "[", "]", ";", "/* @var $item NodeInterface */", "$", "account", "=", "$", "this", "->",...
{inheritdoc}
[ "{", "inheritdoc", "}" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Action/NodeActionProvider.php#L39-L77
makinacorpus/drupal-ucms
ucms_contrib/src/Filter/MediaFilter.php
MediaFilter.create
public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { return new static( $configuration, $pluginId, $pluginDefinition, $container->get('entity.manager'), $container->get('ucms_site.manager'), $container->get('ucms_site.node_manager'), $container->get('logger.channel.default'), $container->getParameter('ucms_contrib.filter.view_mode.markup') ); }
php
public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { return new static( $configuration, $pluginId, $pluginDefinition, $container->get('entity.manager'), $container->get('ucms_site.manager'), $container->get('ucms_site.node_manager'), $container->get('logger.channel.default'), $container->getParameter('ucms_contrib.filter.view_mode.markup') ); }
[ "public", "static", "function", "create", "(", "ContainerInterface", "$", "container", ",", "array", "$", "configuration", ",", "$", "pluginId", ",", "$", "pluginDefinition", ")", "{", "return", "new", "static", "(", "$", "configuration", ",", "$", "pluginId",...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/Filter/MediaFilter.php#L22-L34
zbateson/mail-mime-parser
src/Message/Helper/MultipartHelper.php
MultipartHelper.setContentPartForMimeType
public function setContentPartForMimeType(Message $message, $mimeType, $stringOrHandle, $charset) { $part = ($mimeType === 'text/html') ? $message->getHtmlPart() : $message->getTextPart(); if ($part === null) { $part = $this->createContentPartForMimeType($message, $mimeType, $charset); } else { $contentType = $part->getContentType(); $part->setRawHeader('Content-Type', "$contentType;\r\n\tcharset=\"$charset\""); } $part->setContent($stringOrHandle); }
php
public function setContentPartForMimeType(Message $message, $mimeType, $stringOrHandle, $charset) { $part = ($mimeType === 'text/html') ? $message->getHtmlPart() : $message->getTextPart(); if ($part === null) { $part = $this->createContentPartForMimeType($message, $mimeType, $charset); } else { $contentType = $part->getContentType(); $part->setRawHeader('Content-Type', "$contentType;\r\n\tcharset=\"$charset\""); } $part->setContent($stringOrHandle); }
[ "public", "function", "setContentPartForMimeType", "(", "Message", "$", "message", ",", "$", "mimeType", ",", "$", "stringOrHandle", ",", "$", "charset", ")", "{", "$", "part", "=", "(", "$", "mimeType", "===", "'text/html'", ")", "?", "$", "message", "->"...
Either creates a mime part or sets the existing mime part with the passed mimeType to $strongOrHandle. @param Message $message @param string $mimeType @param string|resource $stringOrHandle @param string $charset
[ "Either", "creates", "a", "mime", "part", "or", "sets", "the", "existing", "mime", "part", "with", "the", "passed", "mimeType", "to", "$strongOrHandle", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Helper/MultipartHelper.php#L429-L439
zbateson/mail-mime-parser
src/Header/Part/HeaderPart.php
HeaderPart.convertEncoding
protected function convertEncoding($str, $from = 'ISO-8859-1', $force = false) { if ($from !== 'UTF-8') { // mime header part decoding will force it. This is necessary for // UTF-7 because mb_check_encoding will return true if ($force || !($this->charsetConverter->checkEncoding($str, 'UTF-8'))) { return $this->charsetConverter->convert($str, $from, 'UTF-8'); } } return $str; }
php
protected function convertEncoding($str, $from = 'ISO-8859-1', $force = false) { if ($from !== 'UTF-8') { // mime header part decoding will force it. This is necessary for // UTF-7 because mb_check_encoding will return true if ($force || !($this->charsetConverter->checkEncoding($str, 'UTF-8'))) { return $this->charsetConverter->convert($str, $from, 'UTF-8'); } } return $str; }
[ "protected", "function", "convertEncoding", "(", "$", "str", ",", "$", "from", "=", "'ISO-8859-1'", ",", "$", "force", "=", "false", ")", "{", "if", "(", "$", "from", "!==", "'UTF-8'", ")", "{", "// mime header part decoding will force it. This is necessary for",...
Ensures the encoding of the passed string is set to UTF-8. The method does nothing if the passed $from charset is UTF-8 already, or if $force is set to false and mb_check_encoding for $str returns true for 'UTF-8'. @param string $str @param string $from @param boolean $force @return string utf-8 string
[ "Ensures", "the", "encoding", "of", "the", "passed", "string", "is", "set", "to", "UTF", "-", "8", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Part/HeaderPart.php#L95-L105
zbateson/mail-mime-parser
src/Stream/MessagePartStream.php
MessagePartStream.getCharsetDecoratorForStream
private function getCharsetDecoratorForStream(StreamInterface $stream) { $charset = $this->part->getCharset(); if (!empty($charset)) { $stream = $this->streamFactory->newCharsetStream( $stream, $charset, MailMimeParser::DEFAULT_CHARSET ); } return $stream; }
php
private function getCharsetDecoratorForStream(StreamInterface $stream) { $charset = $this->part->getCharset(); if (!empty($charset)) { $stream = $this->streamFactory->newCharsetStream( $stream, $charset, MailMimeParser::DEFAULT_CHARSET ); } return $stream; }
[ "private", "function", "getCharsetDecoratorForStream", "(", "StreamInterface", "$", "stream", ")", "{", "$", "charset", "=", "$", "this", "->", "part", "->", "getCharset", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "charset", ")", ")", "{", "$", ...
Attaches and returns a CharsetStream decorator to the passed $stream. If the current attached MessagePart doesn't specify a charset, $stream is returned as-is. @param StreamInterface $stream @return StreamInterface
[ "Attaches", "and", "returns", "a", "CharsetStream", "decorator", "to", "the", "passed", "$stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Stream/MessagePartStream.php#L58-L69
zbateson/mail-mime-parser
src/Stream/MessagePartStream.php
MessagePartStream.getTransferEncodingDecoratorForStream
private function getTransferEncodingDecoratorForStream(StreamInterface $stream) { $encoding = $this->part->getContentTransferEncoding(); $decorator = null; switch ($encoding) { case 'quoted-printable': $decorator = $this->streamFactory->newQuotedPrintableStream($stream); break; case 'base64': $decorator = $this->streamFactory->newBase64Stream( $this->streamFactory->newChunkSplitStream($stream)); break; case 'x-uuencode': $decorator = $this->streamFactory->newUUStream($stream); $decorator->setFilename($this->part->getFilename()); break; default: return $stream; } return $decorator; }
php
private function getTransferEncodingDecoratorForStream(StreamInterface $stream) { $encoding = $this->part->getContentTransferEncoding(); $decorator = null; switch ($encoding) { case 'quoted-printable': $decorator = $this->streamFactory->newQuotedPrintableStream($stream); break; case 'base64': $decorator = $this->streamFactory->newBase64Stream( $this->streamFactory->newChunkSplitStream($stream)); break; case 'x-uuencode': $decorator = $this->streamFactory->newUUStream($stream); $decorator->setFilename($this->part->getFilename()); break; default: return $stream; } return $decorator; }
[ "private", "function", "getTransferEncodingDecoratorForStream", "(", "StreamInterface", "$", "stream", ")", "{", "$", "encoding", "=", "$", "this", "->", "part", "->", "getContentTransferEncoding", "(", ")", ";", "$", "decorator", "=", "null", ";", "switch", "("...
Attaches and returns a transfer encoding stream decorator to the passed $stream. The attached stream decorator is based on the attached part's returned value from MessagePart::getContentTransferEncoding, using one of the following stream decorators as appropriate: o QuotedPrintableStream o Base64Stream o UUStream @param StreamInterface $stream @return StreamInterface
[ "Attaches", "and", "returns", "a", "transfer", "encoding", "stream", "decorator", "to", "the", "passed", "$stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Stream/MessagePartStream.php#L86-L106
zbateson/mail-mime-parser
src/Stream/MessagePartStream.php
MessagePartStream.writePartContentTo
private function writePartContentTo(StreamInterface $stream) { $contentStream = $this->part->getContentStream(); if ($contentStream !== null) { $copyStream = $this->streamFactory->newNonClosingStream($stream); $es = $this->getTransferEncodingDecoratorForStream($copyStream); $cs = $this->getCharsetDecoratorForStream($es); Psr7\copy_to_stream($contentStream, $cs); $cs->close(); } }
php
private function writePartContentTo(StreamInterface $stream) { $contentStream = $this->part->getContentStream(); if ($contentStream !== null) { $copyStream = $this->streamFactory->newNonClosingStream($stream); $es = $this->getTransferEncodingDecoratorForStream($copyStream); $cs = $this->getCharsetDecoratorForStream($es); Psr7\copy_to_stream($contentStream, $cs); $cs->close(); } }
[ "private", "function", "writePartContentTo", "(", "StreamInterface", "$", "stream", ")", "{", "$", "contentStream", "=", "$", "this", "->", "part", "->", "getContentStream", "(", ")", ";", "if", "(", "$", "contentStream", "!==", "null", ")", "{", "$", "cop...
Writes out the content portion of the attached mime part to the passed $stream. @param StreamInterface $stream
[ "Writes", "out", "the", "content", "portion", "of", "the", "attached", "mime", "part", "to", "the", "passed", "$stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Stream/MessagePartStream.php#L114-L124
zbateson/mail-mime-parser
src/Stream/MessagePartStream.php
MessagePartStream.getBoundaryAndChildStreams
protected function getBoundaryAndChildStreams(ParentHeaderPart $part) { $boundary = $part->getHeaderParameter('Content-Type', 'boundary'); if ($boundary === null) { return array_map( function ($child) { return $child->getStream(); }, $part->getChildParts() ); } $streams = []; foreach ($part->getChildParts() as $i => $child) { if ($i !== 0 || $part->hasContent()) { $streams[] = Psr7\stream_for("\r\n"); } $streams[] = Psr7\stream_for("--$boundary\r\n"); $streams[] = $child->getStream(); } $streams[] = Psr7\stream_for("\r\n--$boundary--\r\n"); return $streams; }
php
protected function getBoundaryAndChildStreams(ParentHeaderPart $part) { $boundary = $part->getHeaderParameter('Content-Type', 'boundary'); if ($boundary === null) { return array_map( function ($child) { return $child->getStream(); }, $part->getChildParts() ); } $streams = []; foreach ($part->getChildParts() as $i => $child) { if ($i !== 0 || $part->hasContent()) { $streams[] = Psr7\stream_for("\r\n"); } $streams[] = Psr7\stream_for("--$boundary\r\n"); $streams[] = $child->getStream(); } $streams[] = Psr7\stream_for("\r\n--$boundary--\r\n"); return $streams; }
[ "protected", "function", "getBoundaryAndChildStreams", "(", "ParentHeaderPart", "$", "part", ")", "{", "$", "boundary", "=", "$", "part", "->", "getHeaderParameter", "(", "'Content-Type'", ",", "'boundary'", ")", ";", "if", "(", "$", "boundary", "===", "null", ...
Creates an array of streams based on the attached part's mime boundary and child streams. @param ParentHeaderPart $part passed in because $this->part is declared as MessagePart @return StreamInterface[]
[ "Creates", "an", "array", "of", "streams", "based", "on", "the", "attached", "part", "s", "mime", "boundary", "and", "child", "streams", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Stream/MessagePartStream.php#L134-L156
zbateson/mail-mime-parser
src/Stream/MessagePartStream.php
MessagePartStream.getStreamsArray
protected function getStreamsArray() { $content = Psr7\stream_for(); $this->writePartContentTo($content); $content->rewind(); $streams = [ $this->streamFactory->newHeaderStream($this->part), $content ]; /** * @var ParentHeaderPart */ $part = $this->part; if ($part instanceof ParentHeaderPart && $part->getChildCount()) { $streams = array_merge($streams, $this->getBoundaryAndChildStreams($part)); } return $streams; }
php
protected function getStreamsArray() { $content = Psr7\stream_for(); $this->writePartContentTo($content); $content->rewind(); $streams = [ $this->streamFactory->newHeaderStream($this->part), $content ]; /** * @var ParentHeaderPart */ $part = $this->part; if ($part instanceof ParentHeaderPart && $part->getChildCount()) { $streams = array_merge($streams, $this->getBoundaryAndChildStreams($part)); } return $streams; }
[ "protected", "function", "getStreamsArray", "(", ")", "{", "$", "content", "=", "Psr7", "\\", "stream_for", "(", ")", ";", "$", "this", "->", "writePartContentTo", "(", "$", "content", ")", ";", "$", "content", "->", "rewind", "(", ")", ";", "$", "stre...
Returns an array of Psr7 Streams representing the attached part and it's direct children. @return StreamInterface[]
[ "Returns", "an", "array", "of", "Psr7", "Streams", "representing", "the", "attached", "part", "and", "it", "s", "direct", "children", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Stream/MessagePartStream.php#L164-L180
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.getStream
public function getStream() { if ($this->stream === null) { return $this->streamFactory->newMessagePartStream($this); } $this->stream->rewind(); return $this->stream; }
php
public function getStream() { if ($this->stream === null) { return $this->streamFactory->newMessagePartStream($this); } $this->stream->rewind(); return $this->stream; }
[ "public", "function", "getStream", "(", ")", "{", "if", "(", "$", "this", "->", "stream", "===", "null", ")", "{", "return", "$", "this", "->", "streamFactory", "->", "newMessagePartStream", "(", "$", "this", ")", ";", "}", "$", "this", "->", "stream",...
Returns a Psr7 StreamInterface containing this part, including any headers for a MimePart, its content, and all its children. @return StreamInterface the resource handle
[ "Returns", "a", "Psr7", "StreamInterface", "containing", "this", "part", "including", "any", "headers", "for", "a", "MimePart", "its", "content", "and", "all", "its", "children", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L226-L233
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.setCharsetOverride
public function setCharsetOverride($charsetOverride, $onlyIfNoCharset = false) { if (!$onlyIfNoCharset || $this->getCharset() === null) { $this->charsetOverride = $charsetOverride; } }
php
public function setCharsetOverride($charsetOverride, $onlyIfNoCharset = false) { if (!$onlyIfNoCharset || $this->getCharset() === null) { $this->charsetOverride = $charsetOverride; } }
[ "public", "function", "setCharsetOverride", "(", "$", "charsetOverride", ",", "$", "onlyIfNoCharset", "=", "false", ")", "{", "if", "(", "!", "$", "onlyIfNoCharset", "||", "$", "this", "->", "getCharset", "(", ")", "===", "null", ")", "{", "$", "this", "...
Overrides the default character set used for reading content from content streams in cases where a user knows the source charset is not what is specified. If set, the returned value from MessagePart::getCharset is ignored. Note that setting an override on a Message and calling getTextStream, getTextContent, getHtmlStream or getHtmlContent will not be applied to those sub-parts, unless the text/html part is the Message itself. Instead, Message:getTextPart() should be called, and setCharsetOverride called on the returned MessagePart. @param string $charsetOverride @param boolean $onlyIfNoCharset if true, $charsetOverride is used only if getCharset returns null.
[ "Overrides", "the", "default", "character", "set", "used", "for", "reading", "content", "from", "content", "streams", "in", "cases", "where", "a", "user", "knows", "the", "source", "charset", "is", "not", "what", "is", "specified", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L252-L257
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.getContentResourceHandle
public function getContentResourceHandle($charset = MailMimeParser::DEFAULT_CHARSET) { $stream = $this->getContentStream($charset); if ($stream !== null) { return StreamWrapper::getResource($stream); } return null; }
php
public function getContentResourceHandle($charset = MailMimeParser::DEFAULT_CHARSET) { $stream = $this->getContentStream($charset); if ($stream !== null) { return StreamWrapper::getResource($stream); } return null; }
[ "public", "function", "getContentResourceHandle", "(", "$", "charset", "=", "MailMimeParser", "::", "DEFAULT_CHARSET", ")", "{", "$", "stream", "=", "$", "this", "->", "getContentStream", "(", "$", "charset", ")", ";", "if", "(", "$", "stream", "!==", "null"...
Returns a resource handle for the content's stream, or null if the part doesn't have a content stream. The method wraps a call to {@see MessagePart::getContentStream()} and returns a resource handle for the returned Stream. @param string $charset @return resource|null
[ "Returns", "a", "resource", "handle", "for", "the", "content", "s", "stream", "or", "null", "if", "the", "part", "doesn", "t", "have", "a", "content", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L269-L276
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.getContentStream
public function getContentStream($charset = MailMimeParser::DEFAULT_CHARSET) { if ($this->hasContent()) { $tr = ($this->ignoreTransferEncoding) ? '' : $this->getContentTransferEncoding(); $ch = ($this->charsetOverride !== null) ? $this->charsetOverride : $this->getCharset(); return $this->partStreamFilterManager->getContentStream( $tr, $ch, $charset ); } return null; }
php
public function getContentStream($charset = MailMimeParser::DEFAULT_CHARSET) { if ($this->hasContent()) { $tr = ($this->ignoreTransferEncoding) ? '' : $this->getContentTransferEncoding(); $ch = ($this->charsetOverride !== null) ? $this->charsetOverride : $this->getCharset(); return $this->partStreamFilterManager->getContentStream( $tr, $ch, $charset ); } return null; }
[ "public", "function", "getContentStream", "(", "$", "charset", "=", "MailMimeParser", "::", "DEFAULT_CHARSET", ")", "{", "if", "(", "$", "this", "->", "hasContent", "(", ")", ")", "{", "$", "tr", "=", "(", "$", "this", "->", "ignoreTransferEncoding", ")", ...
Returns the StreamInterface for the part's content or null if the part doesn't have a content section. The library automatically handles decoding and charset conversion (to the target passed $charset) based on the part's transfer encoding as returned by {@see MessagePart::getContentTransferEncoding()} and the part's charset as returned by {@see MessagePart::getCharset()}. The returned stream is ready to be read from directly. Note that the returned Stream is a shared object. If called multiple time with the same $charset, and the value of the part's Content-Transfer-Encoding header not having changed, the stream will be rewound. This would affect other existing variables referencing the stream, for example: ``` // assuming $part is a part containing the following // string for its content: '12345678' $stream = $part->getContentStream(); $someChars = $part->read(4); $stream2 = $part->getContentStream(); $moreChars = $part->read(4); echo ($someChars === $moreChars); //1 ``` In this case the Stream was rewound, and $stream's second call to read 4 bytes reads the same first 4. @param string $charset @return StreamInterface
[ "Returns", "the", "StreamInterface", "for", "the", "part", "s", "content", "or", "null", "if", "the", "part", "doesn", "t", "have", "a", "content", "section", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L311-L323
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.getBinaryContentStream
public function getBinaryContentStream() { if ($this->hasContent()) { $tr = ($this->ignoreTransferEncoding) ? '' : $this->getContentTransferEncoding(); return $this->partStreamFilterManager->getBinaryStream($tr); } return null; }
php
public function getBinaryContentStream() { if ($this->hasContent()) { $tr = ($this->ignoreTransferEncoding) ? '' : $this->getContentTransferEncoding(); return $this->partStreamFilterManager->getBinaryStream($tr); } return null; }
[ "public", "function", "getBinaryContentStream", "(", ")", "{", "if", "(", "$", "this", "->", "hasContent", "(", ")", ")", "{", "$", "tr", "=", "(", "$", "this", "->", "ignoreTransferEncoding", ")", "?", "''", ":", "$", "this", "->", "getContentTransferEn...
Returns the raw data stream for the current part, if it exists, or null if there's no content associated with the stream. This is basically the same as calling {@see MessagePart::getContentStream()}, except no automatic charset conversion is done. Note that for non-text streams, this doesn't have an effect, as charset conversion is not performed in that case, and is useful only when: - The charset defined is not correct, and the conversion produces errors; or - You'd like to read the raw contents without conversion, for instance to save it to file or allow a user to download it as-is (in a download link for example). @param string $charset @return StreamInterface
[ "Returns", "the", "raw", "data", "stream", "for", "the", "current", "part", "if", "it", "exists", "or", "null", "if", "there", "s", "no", "content", "associated", "with", "the", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L344-L351
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.getBinaryContentResourceHandle
public function getBinaryContentResourceHandle() { $stream = $this->getBinaryContentStream(); if ($stream !== null) { return StreamWrapper::getResource($stream); } return null; }
php
public function getBinaryContentResourceHandle() { $stream = $this->getBinaryContentStream(); if ($stream !== null) { return StreamWrapper::getResource($stream); } return null; }
[ "public", "function", "getBinaryContentResourceHandle", "(", ")", "{", "$", "stream", "=", "$", "this", "->", "getBinaryContentStream", "(", ")", ";", "if", "(", "$", "stream", "!==", "null", ")", "{", "return", "StreamWrapper", "::", "getResource", "(", "$"...
Returns a resource handle for the content's raw data stream, or null if the part doesn't have a content stream. The method wraps a call to {@see MessagePart::getBinaryContentStream()} and returns a resource handle for the returned Stream. @return resource|null
[ "Returns", "a", "resource", "handle", "for", "the", "content", "s", "raw", "data", "stream", "or", "null", "if", "the", "part", "doesn", "t", "have", "a", "content", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L362-L369
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.saveContent
public function saveContent($filenameResourceOrStream) { $resourceOrStream = $filenameResourceOrStream; if (is_string($filenameResourceOrStream)) { $resourceOrStream = fopen($filenameResourceOrStream, 'w+'); } $stream = Psr7\stream_for($resourceOrStream); Psr7\copy_to_stream($this->getBinaryContentStream(), $stream); if (!is_string($filenameResourceOrStream) && !($filenameResourceOrStream instanceof StreamInterface)) { // only detach if it wasn't a string or StreamInterface, so the // fopen call can be properly closed if it was $stream->detach(); } }
php
public function saveContent($filenameResourceOrStream) { $resourceOrStream = $filenameResourceOrStream; if (is_string($filenameResourceOrStream)) { $resourceOrStream = fopen($filenameResourceOrStream, 'w+'); } $stream = Psr7\stream_for($resourceOrStream); Psr7\copy_to_stream($this->getBinaryContentStream(), $stream); if (!is_string($filenameResourceOrStream) && !($filenameResourceOrStream instanceof StreamInterface)) { // only detach if it wasn't a string or StreamInterface, so the // fopen call can be properly closed if it was $stream->detach(); } }
[ "public", "function", "saveContent", "(", "$", "filenameResourceOrStream", ")", "{", "$", "resourceOrStream", "=", "$", "filenameResourceOrStream", ";", "if", "(", "is_string", "(", "$", "filenameResourceOrStream", ")", ")", "{", "$", "resourceOrStream", "=", "fop...
Saves the binary content of the stream to the passed file, resource or stream. Note that charset conversion is not performed in this case, and the contents of the part are saved in their binary format as transmitted (but after any content-transfer decoding is performed). {@see MessagePart::getBinaryContentStream()} for a more detailed description of the stream. If the passed parameter is a string, it's assumed to be a filename to write to. The file is opened in 'w+' mode, and closed before returning. When passing a resource or Psr7 Stream, the resource is not closed, nor rewound. @param string|resource|Stream $filenameResourceOrStream
[ "Saves", "the", "binary", "content", "of", "the", "stream", "to", "the", "passed", "file", "resource", "or", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L389-L405
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.getContent
public function getContent($charset = MailMimeParser::DEFAULT_CHARSET) { $stream = $this->getContentStream($charset); if ($stream !== null) { return $stream->getContents(); } return null; }
php
public function getContent($charset = MailMimeParser::DEFAULT_CHARSET) { $stream = $this->getContentStream($charset); if ($stream !== null) { return $stream->getContents(); } return null; }
[ "public", "function", "getContent", "(", "$", "charset", "=", "MailMimeParser", "::", "DEFAULT_CHARSET", ")", "{", "$", "stream", "=", "$", "this", "->", "getContentStream", "(", "$", "charset", ")", ";", "if", "(", "$", "stream", "!==", "null", ")", "{"...
Shortcut to reading stream content and assigning it to a string. Returns null if the part doesn't have a content stream. The returned string is encoded to the passed $charset character encoding, defaulting to UTF-8. @see MessagePart::getContentStream() @param string $charset @return string
[ "Shortcut", "to", "reading", "stream", "content", "and", "assigning", "it", "to", "a", "string", ".", "Returns", "null", "if", "the", "part", "doesn", "t", "have", "a", "content", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L418-L425
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.attachContentStream
public function attachContentStream(StreamInterface $stream, $streamCharset = MailMimeParser::DEFAULT_CHARSET) { if ($this->contentStream !== null && $this->contentStream !== $stream) { $this->contentStream->close(); } $this->contentStream = $stream; $ch = ($this->charsetOverride !== null) ? $this->charsetOverride : $this->getCharset(); if ($ch !== null && $streamCharset !== $ch) { $this->charsetOverride = $streamCharset; } $this->ignoreTransferEncoding = true; $this->partStreamFilterManager->setStream($stream); $this->onChange(); }
php
public function attachContentStream(StreamInterface $stream, $streamCharset = MailMimeParser::DEFAULT_CHARSET) { if ($this->contentStream !== null && $this->contentStream !== $stream) { $this->contentStream->close(); } $this->contentStream = $stream; $ch = ($this->charsetOverride !== null) ? $this->charsetOverride : $this->getCharset(); if ($ch !== null && $streamCharset !== $ch) { $this->charsetOverride = $streamCharset; } $this->ignoreTransferEncoding = true; $this->partStreamFilterManager->setStream($stream); $this->onChange(); }
[ "public", "function", "attachContentStream", "(", "StreamInterface", "$", "stream", ",", "$", "streamCharset", "=", "MailMimeParser", "::", "DEFAULT_CHARSET", ")", "{", "if", "(", "$", "this", "->", "contentStream", "!==", "null", "&&", "$", "this", "->", "con...
Attaches the stream or resource handle for the part's content. The stream is closed when another stream is attached, or the MimePart is destroyed. @param StreamInterface $stream @param string $streamCharset
[ "Attaches", "the", "stream", "or", "resource", "handle", "for", "the", "part", "s", "content", ".", "The", "stream", "is", "closed", "when", "another", "stream", "is", "attached", "or", "the", "MimePart", "is", "destroyed", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L445-L458
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.detachContentStream
public function detachContentStream() { $this->contentStream = null; $this->partStreamFilterManager->setStream(null); $this->onChange(); }
php
public function detachContentStream() { $this->contentStream = null; $this->partStreamFilterManager->setStream(null); $this->onChange(); }
[ "public", "function", "detachContentStream", "(", ")", "{", "$", "this", "->", "contentStream", "=", "null", ";", "$", "this", "->", "partStreamFilterManager", "->", "setStream", "(", "null", ")", ";", "$", "this", "->", "onChange", "(", ")", ";", "}" ]
Detaches and closes the content stream.
[ "Detaches", "and", "closes", "the", "content", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L463-L468
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.setContent
public function setContent($resource, $charset = MailMimeParser::DEFAULT_CHARSET) { $stream = Psr7\stream_for($resource); $this->attachContentStream($stream, $charset); // this->onChange called in attachContentStream }
php
public function setContent($resource, $charset = MailMimeParser::DEFAULT_CHARSET) { $stream = Psr7\stream_for($resource); $this->attachContentStream($stream, $charset); // this->onChange called in attachContentStream }
[ "public", "function", "setContent", "(", "$", "resource", ",", "$", "charset", "=", "MailMimeParser", "::", "DEFAULT_CHARSET", ")", "{", "$", "stream", "=", "Psr7", "\\", "stream_for", "(", "$", "resource", ")", ";", "$", "this", "->", "attachContentStream",...
Sets the content of the part to the passed resource. @param string|resource|StreamInterface $resource @param string $charset
[ "Sets", "the", "content", "of", "the", "part", "to", "the", "passed", "resource", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L476-L481
zbateson/mail-mime-parser
src/Message/Part/MessagePart.php
MessagePart.save
public function save($filenameResourceOrStream) { $resourceOrStream = $filenameResourceOrStream; if (is_string($filenameResourceOrStream)) { $resourceOrStream = fopen($filenameResourceOrStream, 'w+'); } $partStream = $this->getStream(); $partStream->rewind(); $stream = Psr7\stream_for($resourceOrStream); Psr7\copy_to_stream($partStream, $stream); if (!is_string($filenameResourceOrStream) && !($filenameResourceOrStream instanceof StreamInterface)) { // only detach if it wasn't a string or StreamInterface, so the // fopen call can be properly closed if it was $stream->detach(); } }
php
public function save($filenameResourceOrStream) { $resourceOrStream = $filenameResourceOrStream; if (is_string($filenameResourceOrStream)) { $resourceOrStream = fopen($filenameResourceOrStream, 'w+'); } $partStream = $this->getStream(); $partStream->rewind(); $stream = Psr7\stream_for($resourceOrStream); Psr7\copy_to_stream($partStream, $stream); if (!is_string($filenameResourceOrStream) && !($filenameResourceOrStream instanceof StreamInterface)) { // only detach if it wasn't a string or StreamInterface, so the // fopen call can be properly closed if it was $stream->detach(); } }
[ "public", "function", "save", "(", "$", "filenameResourceOrStream", ")", "{", "$", "resourceOrStream", "=", "$", "filenameResourceOrStream", ";", "if", "(", "is_string", "(", "$", "filenameResourceOrStream", ")", ")", "{", "$", "resourceOrStream", "=", "fopen", ...
Saves the message/part to the passed file, resource, or stream. If the passed parameter is a string, it's assumed to be a filename to write to. The file is opened in 'w+' mode, and closed before returning. When passing a resource or Psr7 Stream, the resource is not closed, nor rewound. @param string|resource|StreamInterface $filenameResourceOrStream
[ "Saves", "the", "message", "/", "part", "to", "the", "passed", "file", "resource", "or", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/MessagePart.php#L494-L512
zbateson/mail-mime-parser
src/Header/Consumer/ParameterConsumer.php
ParameterConsumer.getTokenSplitPattern
protected function getTokenSplitPattern() { $sChars = implode('|', $this->getAllTokenSeparators()); $mimePartPattern = MimeLiteralPart::MIME_PART_PATTERN_NO_QUOTES; return '~(' . $mimePartPattern . '|\\\\.|' . $sChars . ')~'; }
php
protected function getTokenSplitPattern() { $sChars = implode('|', $this->getAllTokenSeparators()); $mimePartPattern = MimeLiteralPart::MIME_PART_PATTERN_NO_QUOTES; return '~(' . $mimePartPattern . '|\\\\.|' . $sChars . ')~'; }
[ "protected", "function", "getTokenSplitPattern", "(", ")", "{", "$", "sChars", "=", "implode", "(", "'|'", ",", "$", "this", "->", "getAllTokenSeparators", "(", ")", ")", ";", "$", "mimePartPattern", "=", "MimeLiteralPart", "::", "MIME_PART_PATTERN_NO_QUOTES", "...
Overridden to use a specialized regex for finding mime-encoded parts (RFC 2047). Some implementations seem to place mime-encoded parts within quoted parameters, and split the mime-encoded parts across multiple split parameters. The specialized regex doesn't allow double quotes inside a mime encoded part, so it can be "continued" in another parameter. @return string the regex pattern
[ "Overridden", "to", "use", "a", "specialized", "regex", "for", "finding", "mime", "-", "encoded", "parts", "(", "RFC", "2047", ")", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/ParameterConsumer.php#L49-L54
zbateson/mail-mime-parser
src/Header/Consumer/ParameterConsumer.php
ParameterConsumer.getPartForToken
protected function getPartForToken($token, $isLiteral) { if ($isLiteral) { return $this->partFactory->newLiteralPart($token); } return $this->partFactory->newToken($token); }
php
protected function getPartForToken($token, $isLiteral) { if ($isLiteral) { return $this->partFactory->newLiteralPart($token); } return $this->partFactory->newToken($token); }
[ "protected", "function", "getPartForToken", "(", "$", "token", ",", "$", "isLiteral", ")", "{", "if", "(", "$", "isLiteral", ")", "{", "return", "$", "this", "->", "partFactory", "->", "newLiteralPart", "(", "$", "token", ")", ";", "}", "return", "$", ...
Creates and returns a \ZBateson\MailMimeParser\Header\Part\Token out of the passed string token and returns it, unless the token is an escaped literal, in which case a LiteralPart is returned. @param string $token @param bool $isLiteral @return \ZBateson\MailMimeParser\Header\Part\HeaderPart
[ "Creates", "and", "returns", "a", "\\", "ZBateson", "\\", "MailMimeParser", "\\", "Header", "\\", "Part", "\\", "Token", "out", "of", "the", "passed", "string", "token", "and", "returns", "it", "unless", "the", "token", "is", "an", "escaped", "literal", "i...
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/ParameterConsumer.php#L65-L71
zbateson/mail-mime-parser
src/Header/Consumer/ParameterConsumer.php
ParameterConsumer.addToSplitPart
private function addToSplitPart(ArrayObject $splitParts, $name, $value, $index, $isEncoded) { $ret = null; if (!isset($splitParts[trim($name)])) { $ret = $this->partFactory->newSplitParameterToken($name); $splitParts[$name] = $ret; } $splitParts[$name]->addPart($value, $isEncoded, $index); return $ret; }
php
private function addToSplitPart(ArrayObject $splitParts, $name, $value, $index, $isEncoded) { $ret = null; if (!isset($splitParts[trim($name)])) { $ret = $this->partFactory->newSplitParameterToken($name); $splitParts[$name] = $ret; } $splitParts[$name]->addPart($value, $isEncoded, $index); return $ret; }
[ "private", "function", "addToSplitPart", "(", "ArrayObject", "$", "splitParts", ",", "$", "name", ",", "$", "value", ",", "$", "index", ",", "$", "isEncoded", ")", "{", "$", "ret", "=", "null", ";", "if", "(", "!", "isset", "(", "$", "splitParts", "[...
Adds the passed parameter with the given name and value to a SplitParameterToken, at the passed index. If one with the given name doesn't exist, it is created. @param ArrayObject $splitParts @param string $name @param string $value @param int $index @param boolean $isEncoded
[ "Adds", "the", "passed", "parameter", "with", "the", "given", "name", "and", "value", "to", "a", "SplitParameterToken", "at", "the", "passed", "index", ".", "If", "one", "with", "the", "given", "name", "doesn", "t", "exist", "it", "is", "created", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/ParameterConsumer.php#L84-L93
zbateson/mail-mime-parser
src/Header/Consumer/ParameterConsumer.php
ParameterConsumer.getPartFor
private function getPartFor($strName, $strValue, ArrayObject $splitParts) { if ($strName === '') { return $this->partFactory->newMimeLiteralPart($strValue); } elseif (preg_match('~^\s*([^\*]+)\*(\d*)(\*)?$~', $strName, $matches)) { return $this->addToSplitPart( $splitParts, $matches[1], $strValue, $matches[2], (empty($matches[2]) || !empty($matches[3])) ); } return $this->partFactory->newParameterPart($strName, $strValue); }
php
private function getPartFor($strName, $strValue, ArrayObject $splitParts) { if ($strName === '') { return $this->partFactory->newMimeLiteralPart($strValue); } elseif (preg_match('~^\s*([^\*]+)\*(\d*)(\*)?$~', $strName, $matches)) { return $this->addToSplitPart( $splitParts, $matches[1], $strValue, $matches[2], (empty($matches[2]) || !empty($matches[3])) ); } return $this->partFactory->newParameterPart($strName, $strValue); }
[ "private", "function", "getPartFor", "(", "$", "strName", ",", "$", "strValue", ",", "ArrayObject", "$", "splitParts", ")", "{", "if", "(", "$", "strName", "===", "''", ")", "{", "return", "$", "this", "->", "partFactory", "->", "newMimeLiteralPart", "(", ...
Instantiates and returns either a MimeLiteralPart if $strName is empty, a SplitParameterToken if the parameter is a split parameter and is the first in a series, null if it's a split parameter but is not the first part in its series, or a ParameterPart is returned otherwise. If the part is a SplitParameterToken, it's added to the passed $splitParts as well with its name as a key. @param string $strName @param string $strValue @param ArrayObject $splitParts @return \ZBateson\MailMimeParser\Header\Part\MimeLiteralPart |SplitParameterToken|\ZBateson\MailMimeParser\Header\Part\ParameterPart
[ "Instantiates", "and", "returns", "either", "a", "MimeLiteralPart", "if", "$strName", "is", "empty", "a", "SplitParameterToken", "if", "the", "parameter", "is", "a", "split", "parameter", "and", "is", "the", "first", "in", "a", "series", "null", "if", "it", ...
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/ParameterConsumer.php#L110-L124
zbateson/mail-mime-parser
src/Header/Consumer/ParameterConsumer.php
ParameterConsumer.processTokenPart
private function processTokenPart( $tokenValue, ArrayObject $combined, ArrayObject $splitParts, &$strName, &$strCat ) { if ($tokenValue === ';') { $combined[] = $this->getPartFor($strName, $strCat, $splitParts); $strName = ''; $strCat = ''; return true; } elseif ($tokenValue === '=' && $strCat !== '') { $strName = $strCat; $strCat = ''; return true; } return false; }
php
private function processTokenPart( $tokenValue, ArrayObject $combined, ArrayObject $splitParts, &$strName, &$strCat ) { if ($tokenValue === ';') { $combined[] = $this->getPartFor($strName, $strCat, $splitParts); $strName = ''; $strCat = ''; return true; } elseif ($tokenValue === '=' && $strCat !== '') { $strName = $strCat; $strCat = ''; return true; } return false; }
[ "private", "function", "processTokenPart", "(", "$", "tokenValue", ",", "ArrayObject", "$", "combined", ",", "ArrayObject", "$", "splitParts", ",", "&", "$", "strName", ",", "&", "$", "strCat", ")", "{", "if", "(", "$", "tokenValue", "===", "';'", ")", "...
Handles parameter separator tokens during final processing. If the end token is found, a new HeaderPart is assigned to the passed $combined array. If an '=' character is found, $strCat is assigned to $strName and emptied. Returns true if the token was processed, and false otherwise. @param string $tokenValue @param ArrayObject $combined @param ArrayObject $splitParts @param string $strName @param string $strCat @return boolean
[ "Handles", "parameter", "separator", "tokens", "during", "final", "processing", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/ParameterConsumer.php#L142-L160
zbateson/mail-mime-parser
src/Header/Consumer/ParameterConsumer.php
ParameterConsumer.finalizeParameterParts
private function finalizeParameterParts(ArrayObject $combined) { foreach ($combined as $key => $part) { if ($part instanceof SplitParameterToken) { $combined[$key] = $this->partFactory->newParameterPart( $part->getName(), $part->getValue(), $part->getLanguage() ); } } return $this->filterIgnoredSpaces($combined->getArrayCopy()); }
php
private function finalizeParameterParts(ArrayObject $combined) { foreach ($combined as $key => $part) { if ($part instanceof SplitParameterToken) { $combined[$key] = $this->partFactory->newParameterPart( $part->getName(), $part->getValue(), $part->getLanguage() ); } } return $this->filterIgnoredSpaces($combined->getArrayCopy()); }
[ "private", "function", "finalizeParameterParts", "(", "ArrayObject", "$", "combined", ")", "{", "foreach", "(", "$", "combined", "as", "$", "key", "=>", "$", "part", ")", "{", "if", "(", "$", "part", "instanceof", "SplitParameterToken", ")", "{", "$", "com...
Loops over parts in the passed array, creating ParameterParts out of any parsed SplitParameterTokens, replacing them in the array. The method then calls filterIgnoreSpaces to filter out empty elements in the combined array and returns an array. @param ArrayObject $combined @return HeaderPart[]|array
[ "Loops", "over", "parts", "in", "the", "passed", "array", "creating", "ParameterParts", "out", "of", "any", "parsed", "SplitParameterTokens", "replacing", "them", "in", "the", "array", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/ParameterConsumer.php#L172-L184
zbateson/mail-mime-parser
src/Header/Consumer/ParameterConsumer.php
ParameterConsumer.processParts
protected function processParts(array $parts) { $combined = new ArrayObject(); $splitParts = new ArrayObject(); $strCat = ''; $strName = ''; $parts[] = $this->partFactory->newToken(';'); foreach ($parts as $part) { $pValue = $part->getValue(); if ($part instanceof Token && $this->processTokenPart($pValue, $combined, $splitParts, $strName, $strCat)) { continue; } $strCat .= $pValue; } return $this->finalizeParameterParts($combined); }
php
protected function processParts(array $parts) { $combined = new ArrayObject(); $splitParts = new ArrayObject(); $strCat = ''; $strName = ''; $parts[] = $this->partFactory->newToken(';'); foreach ($parts as $part) { $pValue = $part->getValue(); if ($part instanceof Token && $this->processTokenPart($pValue, $combined, $splitParts, $strName, $strCat)) { continue; } $strCat .= $pValue; } return $this->finalizeParameterParts($combined); }
[ "protected", "function", "processParts", "(", "array", "$", "parts", ")", "{", "$", "combined", "=", "new", "ArrayObject", "(", ")", ";", "$", "splitParts", "=", "new", "ArrayObject", "(", ")", ";", "$", "strCat", "=", "''", ";", "$", "strName", "=", ...
Post processing involves creating Part\LiteralPart or Part\ParameterPart objects out of created Token and LiteralParts. @param HeaderPart[] $parts @return HeaderPart[]|array
[ "Post", "processing", "involves", "creating", "Part", "\\", "LiteralPart", "or", "Part", "\\", "ParameterPart", "objects", "out", "of", "created", "Token", "and", "LiteralParts", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/ParameterConsumer.php#L193-L208
zbateson/mail-mime-parser
src/Message/Part/PartBuilder.php
PartBuilder.addChild
public function addChild(PartBuilder $partBuilder) { $partBuilder->parent = $this; // discard parts added after the end boundary if (!$this->endBoundaryFound) { $this->children[] = $partBuilder; } }
php
public function addChild(PartBuilder $partBuilder) { $partBuilder->parent = $this; // discard parts added after the end boundary if (!$this->endBoundaryFound) { $this->children[] = $partBuilder; } }
[ "public", "function", "addChild", "(", "PartBuilder", "$", "partBuilder", ")", "{", "$", "partBuilder", "->", "parent", "=", "$", "this", ";", "// discard parts added after the end boundary", "if", "(", "!", "$", "this", "->", "endBoundaryFound", ")", "{", "$", ...
Registers the passed PartBuilder as a child of the current PartBuilder. @param \ZBateson\MailMimeParser\Message\PartBuilder $partBuilder
[ "Registers", "the", "passed", "PartBuilder", "as", "a", "child", "of", "the", "current", "PartBuilder", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/PartBuilder.php#L164-L171
zbateson/mail-mime-parser
src/Message/Part/PartBuilder.php
PartBuilder.getMimeBoundary
public function getMimeBoundary() { if ($this->mimeBoundary === false) { $this->mimeBoundary = null; $contentType = $this->getContentType(); if ($contentType !== null) { $this->mimeBoundary = $contentType->getValueFor('boundary'); } } return $this->mimeBoundary; }
php
public function getMimeBoundary() { if ($this->mimeBoundary === false) { $this->mimeBoundary = null; $contentType = $this->getContentType(); if ($contentType !== null) { $this->mimeBoundary = $contentType->getValueFor('boundary'); } } return $this->mimeBoundary; }
[ "public", "function", "getMimeBoundary", "(", ")", "{", "if", "(", "$", "this", "->", "mimeBoundary", "===", "false", ")", "{", "$", "this", "->", "mimeBoundary", "=", "null", ";", "$", "contentType", "=", "$", "this", "->", "getContentType", "(", ")", ...
Returns the parsed boundary parameter of the Content-Type header if set for a multipart message part. @return string
[ "Returns", "the", "parsed", "boundary", "parameter", "of", "the", "Content", "-", "Type", "header", "if", "set", "for", "a", "multipart", "message", "part", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/PartBuilder.php#L222-L232
zbateson/mail-mime-parser
src/Message/Part/PartBuilder.php
PartBuilder.isMultiPart
public function isMultiPart() { $contentType = $this->getContentType(); if ($contentType !== null) { // casting to bool, preg_match returns 1 for true return (bool) (preg_match( '~multipart/\w+~i', $contentType->getValue() )); } return false; }
php
public function isMultiPart() { $contentType = $this->getContentType(); if ($contentType !== null) { // casting to bool, preg_match returns 1 for true return (bool) (preg_match( '~multipart/\w+~i', $contentType->getValue() )); } return false; }
[ "public", "function", "isMultiPart", "(", ")", "{", "$", "contentType", "=", "$", "this", "->", "getContentType", "(", ")", ";", "if", "(", "$", "contentType", "!==", "null", ")", "{", "// casting to bool, preg_match returns 1 for true", "return", "(", "bool", ...
Returns true if this part's content-type is multipart/* @return boolean
[ "Returns", "true", "if", "this", "part", "s", "content", "-", "type", "is", "multipart", "/", "*" ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/PartBuilder.php#L239-L250
zbateson/mail-mime-parser
src/Message/Part/PartBuilder.php
PartBuilder.setEndBoundaryFound
public function setEndBoundaryFound($line) { $boundary = $this->getMimeBoundary(); if ($this->parent !== null && $this->parent->setEndBoundaryFound($line)) { $this->parentBoundaryFound = true; return true; } elseif ($boundary !== null) { if ($line === "--$boundary--") { $this->endBoundaryFound = true; return true; } elseif ($line === "--$boundary") { return true; } } return false; }
php
public function setEndBoundaryFound($line) { $boundary = $this->getMimeBoundary(); if ($this->parent !== null && $this->parent->setEndBoundaryFound($line)) { $this->parentBoundaryFound = true; return true; } elseif ($boundary !== null) { if ($line === "--$boundary--") { $this->endBoundaryFound = true; return true; } elseif ($line === "--$boundary") { return true; } } return false; }
[ "public", "function", "setEndBoundaryFound", "(", "$", "line", ")", "{", "$", "boundary", "=", "$", "this", "->", "getMimeBoundary", "(", ")", ";", "if", "(", "$", "this", "->", "parent", "!==", "null", "&&", "$", "this", "->", "parent", "->", "setEndB...
Returns true if the passed $line of read input matches this PartBuilder's mime boundary, or any of its parent's mime boundaries for a multipart message. If the passed $line is the ending boundary for the current PartBuilder, $this->isEndBoundaryFound will return true after. @param string $line @return boolean
[ "Returns", "true", "if", "the", "passed", "$line", "of", "read", "input", "matches", "this", "PartBuilder", "s", "mime", "boundary", "or", "any", "of", "its", "parent", "s", "mime", "boundaries", "for", "a", "multipart", "message", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/PartBuilder.php#L263-L278
zbateson/mail-mime-parser
src/Message/Part/PartBuilder.php
PartBuilder.setEof
public function setEof() { $this->parentBoundaryFound = true; if ($this->parent !== null) { $this->parent->parentBoundaryFound = true; } }
php
public function setEof() { $this->parentBoundaryFound = true; if ($this->parent !== null) { $this->parent->parentBoundaryFound = true; } }
[ "public", "function", "setEof", "(", ")", "{", "$", "this", "->", "parentBoundaryFound", "=", "true", ";", "if", "(", "$", "this", "->", "parent", "!==", "null", ")", "{", "$", "this", "->", "parent", "->", "parentBoundaryFound", "=", "true", ";", "}",...
Called once EOF is reached while reading content. The method sets the flag used by PartBuilder::isParentBoundaryFound to true on this part and all parent PartBuilders.
[ "Called", "once", "EOF", "is", "reached", "while", "reading", "content", ".", "The", "method", "sets", "the", "flag", "used", "by", "PartBuilder", "::", "isParentBoundaryFound", "to", "true", "on", "this", "part", "and", "all", "parent", "PartBuilders", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/PartBuilder.php#L297-L303
zbateson/mail-mime-parser
src/Message/Part/PartBuilder.php
PartBuilder.getStreamPartStartOffset
public function getStreamPartStartOffset() { if ($this->parent) { return $this->streamPartStartPos - $this->parent->streamPartStartPos; } return $this->streamPartStartPos; }
php
public function getStreamPartStartOffset() { if ($this->parent) { return $this->streamPartStartPos - $this->parent->streamPartStartPos; } return $this->streamPartStartPos; }
[ "public", "function", "getStreamPartStartOffset", "(", ")", "{", "if", "(", "$", "this", "->", "parent", ")", "{", "return", "$", "this", "->", "streamPartStartPos", "-", "$", "this", "->", "parent", "->", "streamPartStartPos", ";", "}", "return", "$", "th...
Returns the offset for this part's stream within its parent stream. @return int
[ "Returns", "the", "offset", "for", "this", "part", "s", "stream", "within", "its", "parent", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/PartBuilder.php#L322-L328
zbateson/mail-mime-parser
src/Message/Part/PartBuilder.php
PartBuilder.getStreamContentStartOffset
public function getStreamContentStartOffset() { if ($this->parent) { return $this->streamContentStartPos - $this->parent->streamPartStartPos; } return $this->streamContentStartPos; }
php
public function getStreamContentStartOffset() { if ($this->parent) { return $this->streamContentStartPos - $this->parent->streamPartStartPos; } return $this->streamContentStartPos; }
[ "public", "function", "getStreamContentStartOffset", "(", ")", "{", "if", "(", "$", "this", "->", "parent", ")", "{", "return", "$", "this", "->", "streamContentStartPos", "-", "$", "this", "->", "parent", "->", "streamPartStartPos", ";", "}", "return", "$",...
Returns the offset for this part's content within its part stream. @return int
[ "Returns", "the", "offset", "for", "this", "part", "s", "content", "within", "its", "part", "stream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/PartBuilder.php#L345-L351
zbateson/mail-mime-parser
src/Message/Part/PartBuilder.php
PartBuilder.setStreamPartEndPos
public function setStreamPartEndPos($streamPartEndPos) { $this->streamPartEndPos = $streamPartEndPos; if ($this->parent !== null) { $this->parent->setStreamPartEndPos($streamPartEndPos); } }
php
public function setStreamPartEndPos($streamPartEndPos) { $this->streamPartEndPos = $streamPartEndPos; if ($this->parent !== null) { $this->parent->setStreamPartEndPos($streamPartEndPos); } }
[ "public", "function", "setStreamPartEndPos", "(", "$", "streamPartEndPos", ")", "{", "$", "this", "->", "streamPartEndPos", "=", "$", "streamPartEndPos", ";", "if", "(", "$", "this", "->", "parent", "!==", "null", ")", "{", "$", "this", "->", "parent", "->...
Sets the end position of the part in the input stream, and also calls parent->setParentStreamPartEndPos to expand to parent parts. @param int $streamPartEndPos
[ "Sets", "the", "end", "position", "of", "the", "part", "in", "the", "input", "stream", "and", "also", "calls", "parent", "-", ">", "setParentStreamPartEndPos", "to", "expand", "to", "parent", "parts", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Message/Part/PartBuilder.php#L379-L385
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.getInstance
public static function getInstance(ConsumerService $consumerService, HeaderPartFactory $partFactory) { static $instances = []; $class = get_called_class(); if (!isset($instances[$class])) { $instances[$class] = new static($consumerService, $partFactory); } return $instances[$class]; }
php
public static function getInstance(ConsumerService $consumerService, HeaderPartFactory $partFactory) { static $instances = []; $class = get_called_class(); if (!isset($instances[$class])) { $instances[$class] = new static($consumerService, $partFactory); } return $instances[$class]; }
[ "public", "static", "function", "getInstance", "(", "ConsumerService", "$", "consumerService", ",", "HeaderPartFactory", "$", "partFactory", ")", "{", "static", "$", "instances", "=", "[", "]", ";", "$", "class", "=", "get_called_class", "(", ")", ";", "if", ...
Returns the singleton instance for the class. @param ConsumerService $consumerService @param HeaderPartFactory $partFactory
[ "Returns", "the", "singleton", "instance", "for", "the", "class", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L56-L64
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.getAllConsumers
protected function getAllConsumers() { $found = [$this]; do { $current = current($found); $subConsumers = $current->getSubConsumers(); foreach ($subConsumers as $consumer) { if (!in_array($consumer, $found)) { $found[] = $consumer; } } } while (next($found) !== false); return $found; }
php
protected function getAllConsumers() { $found = [$this]; do { $current = current($found); $subConsumers = $current->getSubConsumers(); foreach ($subConsumers as $consumer) { if (!in_array($consumer, $found)) { $found[] = $consumer; } } } while (next($found) !== false); return $found; }
[ "protected", "function", "getAllConsumers", "(", ")", "{", "$", "found", "=", "[", "$", "this", "]", ";", "do", "{", "$", "current", "=", "current", "(", "$", "found", ")", ";", "$", "subConsumers", "=", "$", "current", "->", "getSubConsumers", "(", ...
Returns this consumer and all unique sub consumers. Loops into the sub-consumers (and their sub-consumers, etc...) finding all unique consumers, and returns them in an array. @return \ZBateson\MailMimeParser\Header\AbstractConsumer[]
[ "Returns", "this", "consumer", "and", "all", "unique", "sub", "consumers", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L98-L111
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.parseRawValue
private function parseRawValue($value) { $tokens = $this->splitRawValue($value); return $this->parseTokensIntoParts(new NoRewindIterator(SplFixedArray::fromArray($tokens))); }
php
private function parseRawValue($value) { $tokens = $this->splitRawValue($value); return $this->parseTokensIntoParts(new NoRewindIterator(SplFixedArray::fromArray($tokens))); }
[ "private", "function", "parseRawValue", "(", "$", "value", ")", "{", "$", "tokens", "=", "$", "this", "->", "splitRawValue", "(", "$", "value", ")", ";", "return", "$", "this", "->", "parseTokensIntoParts", "(", "new", "NoRewindIterator", "(", "SplFixedArray...
Called by __invoke to parse the raw header value into header parts. Calls splitTokens to split the value into token part strings, then calls parseParts to parse the returned array. @param string $value @return \ZBateson\MailMimeParser\Header\Part\HeaderPart[] the array of parsed parts
[ "Called", "by", "__invoke", "to", "parse", "the", "raw", "header", "value", "into", "header", "parts", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L123-L127
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.getAllTokenSeparators
protected function getAllTokenSeparators() { $markers = $this->getTokenSeparators(); $subConsumers = $this->getAllConsumers(); foreach ($subConsumers as $consumer) { $markers = array_merge($consumer->getTokenSeparators(), $markers); } return array_unique($markers); }
php
protected function getAllTokenSeparators() { $markers = $this->getTokenSeparators(); $subConsumers = $this->getAllConsumers(); foreach ($subConsumers as $consumer) { $markers = array_merge($consumer->getTokenSeparators(), $markers); } return array_unique($markers); }
[ "protected", "function", "getAllTokenSeparators", "(", ")", "{", "$", "markers", "=", "$", "this", "->", "getTokenSeparators", "(", ")", ";", "$", "subConsumers", "=", "$", "this", "->", "getAllConsumers", "(", ")", ";", "foreach", "(", "$", "subConsumers", ...
Returns a list of regular expression markers for this consumer and all sub-consumers by calling 'getTokenSeparators'.. @return string[] an array of regular expression markers
[ "Returns", "a", "list", "of", "regular", "expression", "markers", "for", "this", "consumer", "and", "all", "sub", "-", "consumers", "by", "calling", "getTokenSeparators", ".." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L148-L156
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.getTokenSplitPattern
protected function getTokenSplitPattern() { $sChars = implode('|', $this->getAllTokenSeparators()); $mimePartPattern = MimeLiteralPart::MIME_PART_PATTERN; return '~(' . $mimePartPattern . '|\\\\.|' . $sChars . ')~'; }
php
protected function getTokenSplitPattern() { $sChars = implode('|', $this->getAllTokenSeparators()); $mimePartPattern = MimeLiteralPart::MIME_PART_PATTERN; return '~(' . $mimePartPattern . '|\\\\.|' . $sChars . ')~'; }
[ "protected", "function", "getTokenSplitPattern", "(", ")", "{", "$", "sChars", "=", "implode", "(", "'|'", ",", "$", "this", "->", "getAllTokenSeparators", "(", ")", ")", ";", "$", "mimePartPattern", "=", "MimeLiteralPart", "::", "MIME_PART_PATTERN", ";", "ret...
Returns a regex pattern used to split the input header string. The default implementation calls getAllTokenSeparators and implodes the returned array with the regex OR '|' character as its glue. @return string the regex pattern
[ "Returns", "a", "regex", "pattern", "used", "to", "split", "the", "input", "header", "string", ".", "The", "default", "implementation", "calls", "getAllTokenSeparators", "and", "implodes", "the", "returned", "array", "with", "the", "regex", "OR", "|", "character...
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L165-L170
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.getPartForToken
protected function getPartForToken($token, $isLiteral) { if ($isLiteral) { return $this->partFactory->newLiteralPart($token); } elseif (preg_match('/^\s+$/', $token)) { return $this->partFactory->newToken(' '); } return $this->partFactory->newInstance($token); }
php
protected function getPartForToken($token, $isLiteral) { if ($isLiteral) { return $this->partFactory->newLiteralPart($token); } elseif (preg_match('/^\s+$/', $token)) { return $this->partFactory->newToken(' '); } return $this->partFactory->newInstance($token); }
[ "protected", "function", "getPartForToken", "(", "$", "token", ",", "$", "isLiteral", ")", "{", "if", "(", "$", "isLiteral", ")", "{", "return", "$", "this", "->", "partFactory", "->", "newLiteralPart", "(", "$", "token", ")", ";", "}", "elseif", "(", ...
Constructs and returns a \ZBateson\MailMimeParser\Header\Part\HeaderPart for the passed string token. If the token should be ignored, the function must return null. The default created part uses the instance's partFactory->newInstance method. @param string $token the token @param bool $isLiteral set to true if the token represents a literal - e.g. an escaped token @return \ZBateson\MailMimeParser\Header\Part\HeaderPart|null the constructed header part or null if the token should be ignored
[ "Constructs", "and", "returns", "a", "\\", "ZBateson", "\\", "MailMimeParser", "\\", "Header", "\\", "Part", "\\", "HeaderPart", "for", "the", "passed", "string", "token", ".", "If", "the", "token", "should", "be", "ignored", "the", "function", "must", "retu...
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L223-L231
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.getConsumerTokenParts
protected function getConsumerTokenParts(Iterator $tokens) { $token = $tokens->current(); $subConsumers = $this->getSubConsumers(); foreach ($subConsumers as $consumer) { if ($consumer->isStartToken($token)) { $this->advanceToNextToken($tokens, true); return $consumer->parseTokensIntoParts($tokens); } } return [$this->getPartForToken($token, false)]; }
php
protected function getConsumerTokenParts(Iterator $tokens) { $token = $tokens->current(); $subConsumers = $this->getSubConsumers(); foreach ($subConsumers as $consumer) { if ($consumer->isStartToken($token)) { $this->advanceToNextToken($tokens, true); return $consumer->parseTokensIntoParts($tokens); } } return [$this->getPartForToken($token, false)]; }
[ "protected", "function", "getConsumerTokenParts", "(", "Iterator", "$", "tokens", ")", "{", "$", "token", "=", "$", "tokens", "->", "current", "(", ")", ";", "$", "subConsumers", "=", "$", "this", "->", "getSubConsumers", "(", ")", ";", "foreach", "(", "...
Iterates through this consumer's sub-consumers checking if the current token triggers a sub-consumer's start token and passes control onto that sub-consumer's parseTokenIntoParts. If no sub-consumer is responsible for the current token, calls getPartForToken and returns it in an array. @param Iterator $tokens @return \ZBateson\MailMimeParser\Header\Part\HeaderPart[]|array
[ "Iterates", "through", "this", "consumer", "s", "sub", "-", "consumers", "checking", "if", "the", "current", "token", "triggers", "a", "sub", "-", "consumer", "s", "start", "token", "and", "passes", "control", "onto", "that", "sub", "-", "consumer", "s", "...
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L242-L253
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.getTokenParts
protected function getTokenParts(Iterator $tokens) { $token = $tokens->current(); if (strlen($token) === 2 && $token[0] === '\\') { return [$this->getPartForToken(substr($token, 1), true)]; } return $this->getConsumerTokenParts($tokens); }
php
protected function getTokenParts(Iterator $tokens) { $token = $tokens->current(); if (strlen($token) === 2 && $token[0] === '\\') { return [$this->getPartForToken(substr($token, 1), true)]; } return $this->getConsumerTokenParts($tokens); }
[ "protected", "function", "getTokenParts", "(", "Iterator", "$", "tokens", ")", "{", "$", "token", "=", "$", "tokens", "->", "current", "(", ")", ";", "if", "(", "strlen", "(", "$", "token", ")", "===", "2", "&&", "$", "token", "[", "0", "]", "===",...
Returns an array of \ZBateson\MailMimeParser\Header\Part\HeaderPart for the current token on the iterator. If the current token is a start token from a sub-consumer, the sub- consumer's parseTokensIntoParts method is called. @param Iterator $tokens @return \ZBateson\MailMimeParser\Header\Part\HeaderPart[]|array
[ "Returns", "an", "array", "of", "\\", "ZBateson", "\\", "MailMimeParser", "\\", "Header", "\\", "Part", "\\", "HeaderPart", "for", "the", "current", "token", "on", "the", "iterator", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L265-L272
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.advanceToNextToken
protected function advanceToNextToken(Iterator $tokens, $isStartToken) { if (($isStartToken) || ($tokens->valid() && !$this->isEndToken($tokens->current()))) { $tokens->next(); } }
php
protected function advanceToNextToken(Iterator $tokens, $isStartToken) { if (($isStartToken) || ($tokens->valid() && !$this->isEndToken($tokens->current()))) { $tokens->next(); } }
[ "protected", "function", "advanceToNextToken", "(", "Iterator", "$", "tokens", ",", "$", "isStartToken", ")", "{", "if", "(", "(", "$", "isStartToken", ")", "||", "(", "$", "tokens", "->", "valid", "(", ")", "&&", "!", "$", "this", "->", "isEndToken", ...
Determines if the iterator should be advanced to the next token after reading tokens or finding a start token. The default implementation will advance for a start token, but not advance on the end token of the current consumer, allowing the end token to be passed up to a higher-level consumer. @param Iterator $tokens @param bool $isStartToken
[ "Determines", "if", "the", "iterator", "should", "be", "advanced", "to", "the", "next", "token", "after", "reading", "tokens", "or", "finding", "a", "start", "token", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L285-L290
zbateson/mail-mime-parser
src/Header/Consumer/AbstractConsumer.php
AbstractConsumer.parseTokensIntoParts
protected function parseTokensIntoParts(Iterator $tokens) { $parts = []; while ($tokens->valid() && !$this->isEndToken($tokens->current())) { $parts = array_merge($parts, $this->getTokenParts($tokens)); $this->advanceToNextToken($tokens, false); } return $this->processParts($parts); }
php
protected function parseTokensIntoParts(Iterator $tokens) { $parts = []; while ($tokens->valid() && !$this->isEndToken($tokens->current())) { $parts = array_merge($parts, $this->getTokenParts($tokens)); $this->advanceToNextToken($tokens, false); } return $this->processParts($parts); }
[ "protected", "function", "parseTokensIntoParts", "(", "Iterator", "$", "tokens", ")", "{", "$", "parts", "=", "[", "]", ";", "while", "(", "$", "tokens", "->", "valid", "(", ")", "&&", "!", "$", "this", "->", "isEndToken", "(", "$", "tokens", "->", "...
Iterates over the passed token Iterator and returns an array of parsed \ZBateson\MailMimeParser\Header\Part\HeaderPart objects. The method checks each token to see if the token matches a sub-consumer's start token, or if it matches the current consumer's end token to stop processing. If a sub-consumer's start token is matched, the sub-consumer is invoked and its returned parts are merged to the current consumer's header parts. After all tokens are read and an array of Header\Parts are constructed, the array is passed to AbstractConsumer::processParts for any final processing. @param Iterator $tokens an iterator over a string of tokens @return \ZBateson\MailMimeParser\Header\Part\HeaderPart[] an array of parsed parts
[ "Iterates", "over", "the", "passed", "token", "Iterator", "and", "returns", "an", "array", "of", "parsed", "\\", "ZBateson", "\\", "MailMimeParser", "\\", "Header", "\\", "Part", "\\", "HeaderPart", "objects", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Header/Consumer/AbstractConsumer.php#L311-L319
zbateson/mail-mime-parser
src/Stream/StreamFactory.php
StreamFactory.getLimitedPartStream
public function getLimitedPartStream(StreamInterface $stream, PartBuilder $part) { return $this->newLimitStream( $stream, $part->getStreamPartLength(), $part->getStreamPartStartOffset() ); }
php
public function getLimitedPartStream(StreamInterface $stream, PartBuilder $part) { return $this->newLimitStream( $stream, $part->getStreamPartLength(), $part->getStreamPartStartOffset() ); }
[ "public", "function", "getLimitedPartStream", "(", "StreamInterface", "$", "stream", ",", "PartBuilder", "$", "part", ")", "{", "return", "$", "this", "->", "newLimitStream", "(", "$", "stream", ",", "$", "part", "->", "getStreamPartLength", "(", ")", ",", "...
Returns a SeekingLimitStream using $part->getStreamPartLength() and $part->getStreamPartStartOffset() @param StreamInterface $stream @param PartBuilder $part @return SeekingLimitStream
[ "Returns", "a", "SeekingLimitStream", "using", "$part", "-", ">", "getStreamPartLength", "()", "and", "$part", "-", ">", "getStreamPartStartOffset", "()" ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Stream/StreamFactory.php#L36-L43
zbateson/mail-mime-parser
src/Stream/StreamFactory.php
StreamFactory.getLimitedContentStream
public function getLimitedContentStream(StreamInterface $stream, PartBuilder $part) { $length = $part->getStreamContentLength(); if ($length !== 0) { return $this->newLimitStream( $stream, $part->getStreamContentLength(), $part->getStreamContentStartOffset() ); } return null; }
php
public function getLimitedContentStream(StreamInterface $stream, PartBuilder $part) { $length = $part->getStreamContentLength(); if ($length !== 0) { return $this->newLimitStream( $stream, $part->getStreamContentLength(), $part->getStreamContentStartOffset() ); } return null; }
[ "public", "function", "getLimitedContentStream", "(", "StreamInterface", "$", "stream", ",", "PartBuilder", "$", "part", ")", "{", "$", "length", "=", "$", "part", "->", "getStreamContentLength", "(", ")", ";", "if", "(", "$", "length", "!==", "0", ")", "{...
Returns a SeekingLimitStream using $part->getStreamContentLength() and $part->getStreamContentStartOffset() @param StreamInterface $stream @param PartBuilder $part @return SeekingLimitStream
[ "Returns", "a", "SeekingLimitStream", "using", "$part", "-", ">", "getStreamContentLength", "()", "and", "$part", "-", ">", "getStreamContentStartOffset", "()" ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Stream/StreamFactory.php#L53-L64
zbateson/mail-mime-parser
src/Stream/StreamFactory.php
StreamFactory.newLimitStream
private function newLimitStream(StreamInterface $stream, $length, $start) { return new SeekingLimitStream( $this->newNonClosingStream($stream), $length, $start ); }
php
private function newLimitStream(StreamInterface $stream, $length, $start) { return new SeekingLimitStream( $this->newNonClosingStream($stream), $length, $start ); }
[ "private", "function", "newLimitStream", "(", "StreamInterface", "$", "stream", ",", "$", "length", ",", "$", "start", ")", "{", "return", "new", "SeekingLimitStream", "(", "$", "this", "->", "newNonClosingStream", "(", "$", "stream", ")", ",", "$", "length"...
Creates and returns a SeekingLimitedStream. @param StreamInterface $stream @param int $length @param int $start @return SeekingLimitStream
[ "Creates", "and", "returns", "a", "SeekingLimitedStream", "." ]
train
https://github.com/zbateson/mail-mime-parser/blob/63bedd7d71fb3abff2381174a14637c5a4ddaa36/src/Stream/StreamFactory.php#L74-L81