id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
43,200
checkout/checkout-magento2-plugin
Model/Service/OrderService.php
OrderService.getCheckoutMethod
private function getCheckoutMethod(Quote $quote) { if ($this->customerSession->isLoggedIn()) { return Onepage::METHOD_CUSTOMER; } if (!$quote->getCheckoutMethod()) { if ($this->checkoutHelper->isAllowedGuestCheckout($quote)) { $quote->setCheckoutMethod(Onepage::METHOD_GUEST); } else { $quote->setCheckoutMethod(Onepage::METHOD_REGISTER); } } return $quote->getCheckoutMethod(); }
php
private function getCheckoutMethod(Quote $quote) { if ($this->customerSession->isLoggedIn()) { return Onepage::METHOD_CUSTOMER; } if (!$quote->getCheckoutMethod()) { if ($this->checkoutHelper->isAllowedGuestCheckout($quote)) { $quote->setCheckoutMethod(Onepage::METHOD_GUEST); } else { $quote->setCheckoutMethod(Onepage::METHOD_REGISTER); } } return $quote->getCheckoutMethod(); }
[ "private", "function", "getCheckoutMethod", "(", "Quote", "$", "quote", ")", "{", "if", "(", "$", "this", "->", "customerSession", "->", "isLoggedIn", "(", ")", ")", "{", "return", "Onepage", "::", "METHOD_CUSTOMER", ";", "}", "if", "(", "!", "$", "quote...
Get checkout method. @param Quote $quote @return string
[ "Get", "checkout", "method", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Service/OrderService.php#L297-L311
43,201
checkout/checkout-magento2-plugin
Model/Service/OrderService.php
OrderService.disabledQuoteAddressValidation
protected function disabledQuoteAddressValidation(Quote $quote) { $billingAddress = $quote->getBillingAddress(); $billingAddress->setShouldIgnoreValidation(true); if (!$quote->getIsVirtual()) { $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setShouldIgnoreValidation(true); if (!$billingAddress->getEmail()) { $billingAddress->setSameAsBilling(1); } } }
php
protected function disabledQuoteAddressValidation(Quote $quote) { $billingAddress = $quote->getBillingAddress(); $billingAddress->setShouldIgnoreValidation(true); if (!$quote->getIsVirtual()) { $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setShouldIgnoreValidation(true); if (!$billingAddress->getEmail()) { $billingAddress->setSameAsBilling(1); } } }
[ "protected", "function", "disabledQuoteAddressValidation", "(", "Quote", "$", "quote", ")", "{", "$", "billingAddress", "=", "$", "quote", "->", "getBillingAddress", "(", ")", ";", "$", "billingAddress", "->", "setShouldIgnoreValidation", "(", "true", ")", ";", ...
Disables the address validation for the given quote instance. @param Quote $quote
[ "Disables", "the", "address", "validation", "for", "the", "given", "quote", "instance", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Service/OrderService.php#L318-L330
43,202
checkout/checkout-magento2-plugin
Model/Adapter/CallbackEventAdapter.php
CallbackEventAdapter.getTargetCommandName
public function getTargetCommandName($eventType) { $eventParts = explode('.', $eventType); $command = null; if( array_key_exists(1, $eventParts)) { $command = self::$map[ $eventParts[1] ] ?? null; } return $command; }
php
public function getTargetCommandName($eventType) { $eventParts = explode('.', $eventType); $command = null; if( array_key_exists(1, $eventParts)) { $command = self::$map[ $eventParts[1] ] ?? null; } return $command; }
[ "public", "function", "getTargetCommandName", "(", "$", "eventType", ")", "{", "$", "eventParts", "=", "explode", "(", "'.'", ",", "$", "eventType", ")", ";", "$", "command", "=", "null", ";", "if", "(", "array_key_exists", "(", "1", ",", "$", "eventPart...
Returns the target command name based on received gateway event type. @param string $eventType @return string|null
[ "Returns", "the", "target", "command", "name", "based", "on", "received", "gateway", "event", "type", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/CallbackEventAdapter.php#L31-L40
43,203
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/PaymentCurrency.php
PaymentCurrency.getPaymentCurrencyOptions
public function getPaymentCurrencyOptions() { // Create the base options $options = [ [ 'value' => self::BASE_CURRENCY, 'label' => __('Use Magento default') ], [ 'value' => self::ORDER_CURRENCY, 'label' => __('Order currency') ], [ 'value' => self::CUSTOM_CURRENCY, 'label' => __('Custom currency') ], ]; // Return the options as array return $options; }
php
public function getPaymentCurrencyOptions() { // Create the base options $options = [ [ 'value' => self::BASE_CURRENCY, 'label' => __('Use Magento default') ], [ 'value' => self::ORDER_CURRENCY, 'label' => __('Order currency') ], [ 'value' => self::CUSTOM_CURRENCY, 'label' => __('Custom currency') ], ]; // Return the options as array return $options; }
[ "public", "function", "getPaymentCurrencyOptions", "(", ")", "{", "// Create the base options", "$", "options", "=", "[", "[", "'value'", "=>", "self", "::", "BASE_CURRENCY", ",", "'label'", "=>", "__", "(", "'Use Magento default'", ")", "]", ",", "[", "'value'"...
Get the payment currency options @return array
[ "Get", "the", "payment", "currency", "options" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/PaymentCurrency.php#L35-L55
43,204
kaystrobach/TYPO3.dyncss
Classes/Parser/AbstractParser.php
AbstractParser._postCompile
public function _postCompile($string) { /** * $relativePath seems to be unused? * * @todo missing declaration of inputFilename */ $relativePath = dirname(substr($this->inputFilename, strlen(PATH_site))).'/'; /* * find all matches of url() and adjust uris */ preg_match_all('|url[\s]*\([\s]*(?<url>[^\)]*)[\s]*\)[\s]*|Ui', $string, $matches, PREG_SET_ORDER); if (is_array($matches) && count($matches)) { foreach ($matches as $key => $value) { // Don't modify inline SVGs if (strpos($value['url'], 'data:image') === false) { $url = trim($value[0], '\'"'); $orgPath = trim($value['url'], '\'"'); $newPath = $this->resolveUrlInCss($orgPath); $string = str_replace($url, 'url("' . $newPath . '")', $string); } } } /* * find all matches of src= and adjust uris */ preg_match_all('|src=([\'"])(?<url>[^\'"]*)\1|Ui', $string, $matches, PREG_SET_ORDER); if (is_array($matches) && count($matches)) { foreach ($matches as $key => $value) { $url = trim($value['url'], '\'"'); $newPath = $this->resolveUrlInCss($url); $string = str_replace($url, $newPath, $string); } } return $string; }
php
public function _postCompile($string) { /** * $relativePath seems to be unused? * * @todo missing declaration of inputFilename */ $relativePath = dirname(substr($this->inputFilename, strlen(PATH_site))).'/'; /* * find all matches of url() and adjust uris */ preg_match_all('|url[\s]*\([\s]*(?<url>[^\)]*)[\s]*\)[\s]*|Ui', $string, $matches, PREG_SET_ORDER); if (is_array($matches) && count($matches)) { foreach ($matches as $key => $value) { // Don't modify inline SVGs if (strpos($value['url'], 'data:image') === false) { $url = trim($value[0], '\'"'); $orgPath = trim($value['url'], '\'"'); $newPath = $this->resolveUrlInCss($orgPath); $string = str_replace($url, 'url("' . $newPath . '")', $string); } } } /* * find all matches of src= and adjust uris */ preg_match_all('|src=([\'"])(?<url>[^\'"]*)\1|Ui', $string, $matches, PREG_SET_ORDER); if (is_array($matches) && count($matches)) { foreach ($matches as $key => $value) { $url = trim($value['url'], '\'"'); $newPath = $this->resolveUrlInCss($url); $string = str_replace($url, $newPath, $string); } } return $string; }
[ "public", "function", "_postCompile", "(", "$", "string", ")", "{", "/**\n * $relativePath seems to be unused?\n *\n * @todo missing declaration of inputFilename\n */", "$", "relativePath", "=", "dirname", "(", "substr", "(", "$", "this", "->", "...
Fixes pathes to compliant with original location of the file. @param $string @return mixed @todo add typehinting
[ "Fixes", "pathes", "to", "compliant", "with", "original", "location", "of", "the", "file", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Parser/AbstractParser.php#L145-L185
43,205
kaystrobach/TYPO3.dyncss
Classes/Parser/AbstractParser.php
AbstractParser.resolveUrlInCss
public function resolveUrlInCss($url) { if (substr($url, 0, 2) === '//') { // double slashed indicate a fully fledged url like //typo3.org return $url; } if (strpos($url, '://') !== false) { // http://, ftp:// etc. should not be touched return $url; } if (substr($url, 0, 1) === '/') { if (substr($url, 0, strlen(PATH_site)) === PATH_site) { return '../../'.substr($url, strlen(PATH_site)); } return $url; } if (substr($url, 0, 5) === 'data:') { // data:image/svg+xml;base64,... should not be touched return $url; } // anything inside TYPO3 has to be adjusted return '../../../../'.dirname($this->removePrefixFromString(PATH_site, $this->inputFilename)).'/'.$url; }
php
public function resolveUrlInCss($url) { if (substr($url, 0, 2) === '//') { // double slashed indicate a fully fledged url like //typo3.org return $url; } if (strpos($url, '://') !== false) { // http://, ftp:// etc. should not be touched return $url; } if (substr($url, 0, 1) === '/') { if (substr($url, 0, strlen(PATH_site)) === PATH_site) { return '../../'.substr($url, strlen(PATH_site)); } return $url; } if (substr($url, 0, 5) === 'data:') { // data:image/svg+xml;base64,... should not be touched return $url; } // anything inside TYPO3 has to be adjusted return '../../../../'.dirname($this->removePrefixFromString(PATH_site, $this->inputFilename)).'/'.$url; }
[ "public", "function", "resolveUrlInCss", "(", "$", "url", ")", "{", "if", "(", "substr", "(", "$", "url", ",", "0", ",", "2", ")", "===", "'//'", ")", "{", "// double slashed indicate a fully fledged url like //typo3.org", "return", "$", "url", ";", "}", "if...
fixes URLs for use in CSS files. @param $url @return string @todo add typehinting
[ "fixes", "URLs", "for", "use", "in", "CSS", "files", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Parser/AbstractParser.php#L196-L219
43,206
kaystrobach/TYPO3.dyncss
Classes/Parser/AbstractParser.php
AbstractParser.removePrefixFromString
public function removePrefixFromString($prefix, $string) { if (GeneralUtility::isFirstPartOfStr($string, $prefix)) { return substr($string, strlen($prefix)); } else { return $string; } }
php
public function removePrefixFromString($prefix, $string) { if (GeneralUtility::isFirstPartOfStr($string, $prefix)) { return substr($string, strlen($prefix)); } else { return $string; } }
[ "public", "function", "removePrefixFromString", "(", "$", "prefix", ",", "$", "string", ")", "{", "if", "(", "GeneralUtility", "::", "isFirstPartOfStr", "(", "$", "string", ",", "$", "prefix", ")", ")", "{", "return", "substr", "(", "$", "string", ",", "...
removes a prefix from a string. @param $prefix @param $string @return string @todo add typehinting
[ "removes", "a", "prefix", "from", "a", "string", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Parser/AbstractParser.php#L231-L238
43,207
kaystrobach/TYPO3.dyncss
Classes/Service/DyncssService.php
DyncssService.fixPathForInput
protected static function fixPathForInput($file) { if (empty($file)) { throw new \InvalidArgumentException('fixPathForInput needs a valid $file, the given value was empty'); } if (TYPO3_MODE === 'FE') { return GeneralUtility::getFileAbsFileName($file); } if (TYPO3_MODE === 'BE' && !self::isCliRequest()) { return GeneralUtility::resolveBackPath(PATH_typo3 . $file); } return $file; }
php
protected static function fixPathForInput($file) { if (empty($file)) { throw new \InvalidArgumentException('fixPathForInput needs a valid $file, the given value was empty'); } if (TYPO3_MODE === 'FE') { return GeneralUtility::getFileAbsFileName($file); } if (TYPO3_MODE === 'BE' && !self::isCliRequest()) { return GeneralUtility::resolveBackPath(PATH_typo3 . $file); } return $file; }
[ "protected", "static", "function", "fixPathForInput", "(", "$", "file", ")", "{", "if", "(", "empty", "(", "$", "file", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'fixPathForInput needs a valid $file, the given value was empty'", ")", ";"...
Just makes path absolute. @param $file @return string @todo add typehinting
[ "Just", "makes", "path", "absolute", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Service/DyncssService.php#L43-L55
43,208
kaystrobach/TYPO3.dyncss
Classes/Service/DyncssService.php
DyncssService.fixPathForOutput
protected static function fixPathForOutput($file) { if (TYPO3_MODE === 'FE') { $file = str_replace(PATH_site, '', $file); } elseif (TYPO3_MODE === 'BE') { $file = str_replace(PATH_site, '../', $file); if (array_key_exists('BACK_PATH', $GLOBALS)) { $file = $GLOBALS['BACK_PATH'].$file; } } return $file; }
php
protected static function fixPathForOutput($file) { if (TYPO3_MODE === 'FE') { $file = str_replace(PATH_site, '', $file); } elseif (TYPO3_MODE === 'BE') { $file = str_replace(PATH_site, '../', $file); if (array_key_exists('BACK_PATH', $GLOBALS)) { $file = $GLOBALS['BACK_PATH'].$file; } } return $file; }
[ "protected", "static", "function", "fixPathForOutput", "(", "$", "file", ")", "{", "if", "(", "TYPO3_MODE", "===", "'FE'", ")", "{", "$", "file", "=", "str_replace", "(", "PATH_site", ",", "''", ",", "$", "file", ")", ";", "}", "elseif", "(", "TYPO3_MO...
Fixes the path for fe or be usage. @param $file @return mixed @todo add typehinting
[ "Fixes", "the", "path", "for", "fe", "or", "be", "usage", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Service/DyncssService.php#L74-L86
43,209
kaystrobach/TYPO3.dyncss
Classes/Hooks/T3libPageRendererRenderPreProcessHook.php
T3libPageRendererRenderPreProcessHook.execute
public function execute(&$params, &$pagerenderer) { if (!is_array($params['cssFiles'])) { return; } $cssFilesArray = []; foreach ($params['cssFiles'] as $cssFile => $cssFileSettings) { $compiledFile = \KayStrobach\Dyncss\Service\DyncssService::getCompiledFile($cssFile); if ($compiledFile !== $cssFile) { $cssFileSettings['file'] = $compiledFile; //needed for TYPO3 4.6+ ;) $cssFileSettings['compress'] = 0; $cssFilesArray[$compiledFile] = $cssFileSettings; } else { $cssFilesArray[$cssFile] = $cssFileSettings; } } $params['cssFiles'] = $cssFilesArray; }
php
public function execute(&$params, &$pagerenderer) { if (!is_array($params['cssFiles'])) { return; } $cssFilesArray = []; foreach ($params['cssFiles'] as $cssFile => $cssFileSettings) { $compiledFile = \KayStrobach\Dyncss\Service\DyncssService::getCompiledFile($cssFile); if ($compiledFile !== $cssFile) { $cssFileSettings['file'] = $compiledFile; //needed for TYPO3 4.6+ ;) $cssFileSettings['compress'] = 0; $cssFilesArray[$compiledFile] = $cssFileSettings; } else { $cssFilesArray[$cssFile] = $cssFileSettings; } } $params['cssFiles'] = $cssFilesArray; }
[ "public", "function", "execute", "(", "&", "$", "params", ",", "&", "$", "pagerenderer", ")", "{", "if", "(", "!", "is_array", "(", "$", "params", "[", "'cssFiles'", "]", ")", ")", "{", "return", ";", "}", "$", "cssFilesArray", "=", "[", "]", ";", ...
This function iterates over the arrays and rebuild them to keep the order, as keynames may change. @param array $params @param \TYPO3\CMS\Core\Page\PageRenderer $pagerenderer
[ "This", "function", "iterates", "over", "the", "arrays", "and", "rebuild", "them", "to", "keep", "the", "order", "as", "keynames", "may", "change", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Hooks/T3libPageRendererRenderPreProcessHook.php#L40-L57
43,210
kaystrobach/TYPO3.dyncss
Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php
ClearCacheActionsHook.manipulateCacheActions
public function manipulateCacheActions(&$cacheActions, &$optionValues) { if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->getBackendUser()->isAdmin()) ) { $hrefParams = ['cacheCmd' => 'dyncss', 'ajaxCall' => 1]; /** @var \TYPO3\CMS\Core\Imaging\IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconFactory::class); $translationPrefix = 'LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.'; if (version_compare(TYPO3_version, '8.7', '<')) { $cacheActions[] = [ 'id' => 'dyncss', 'title' => LocalizationUtility::translate($translationPrefix . 'title', 'Dyncss'), 'description' => LocalizationUtility::translate($translationPrefix . 'description', 'Dyncss'), 'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams), 'icon' => $iconFactory->getIcon('actions-system-cache-clear-dyncss', Icon::SIZE_SMALL)->render() ]; } else { $cacheActions[] = [ 'id' => 'dyncss', 'title' => $translationPrefix . 'title', 'description' => $translationPrefix . 'description', 'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams), 'iconIdentifier' => 'actions-system-cache-clear-dyncss' ]; } $optionValues[] = 'dyncss'; } }
php
public function manipulateCacheActions(&$cacheActions, &$optionValues) { if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->getBackendUser()->isAdmin()) ) { $hrefParams = ['cacheCmd' => 'dyncss', 'ajaxCall' => 1]; /** @var \TYPO3\CMS\Core\Imaging\IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconFactory::class); $translationPrefix = 'LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.'; if (version_compare(TYPO3_version, '8.7', '<')) { $cacheActions[] = [ 'id' => 'dyncss', 'title' => LocalizationUtility::translate($translationPrefix . 'title', 'Dyncss'), 'description' => LocalizationUtility::translate($translationPrefix . 'description', 'Dyncss'), 'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams), 'icon' => $iconFactory->getIcon('actions-system-cache-clear-dyncss', Icon::SIZE_SMALL)->render() ]; } else { $cacheActions[] = [ 'id' => 'dyncss', 'title' => $translationPrefix . 'title', 'description' => $translationPrefix . 'description', 'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams), 'iconIdentifier' => 'actions-system-cache-clear-dyncss' ]; } $optionValues[] = 'dyncss'; } }
[ "public", "function", "manipulateCacheActions", "(", "&", "$", "cacheActions", ",", "&", "$", "optionValues", ")", "{", "if", "(", "$", "this", "->", "getBackendUser", "(", ")", "->", "getTSConfigVal", "(", "'options.clearCache.system'", ")", "||", "GeneralUtili...
Modifies CacheMenuItems array @param array $cacheActions Array of CacheMenuItems @param array $optionValues Array of AccessConfigurations-identifiers (typically used by userTS with options.clearCache.identifier) @return void
[ "Modifies", "CacheMenuItems", "array" ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php#L27-L56
43,211
kaystrobach/TYPO3.dyncss
Classes/ExtMgm/Statefield.php
Statefield.main
public function main() { $buffer = ''; $registry = GeneralUtility::makeInstance('KayStrobach\Dyncss\Configuration\BeRegistry'); $handlers = $registry->getAllFileHandler(); if (count($handlers)) { foreach ($handlers as $extension => $class) { /** @var AbstractParser $parser */ $parser = new $class(); $buffer .= '<tr><td>*.'.$extension.'</td>'; $buffer .= '<td>'.$class.'</td>'; $buffer .= '<td><a href="'.$parser->getParserHomepage().'" target="_blank">'.$parser->getParserName().'</a></td>'; $buffer .= '<td>'.$parser->getVersion().'</td>'; $buffer .= '</tr>'; } /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Congrats, you have '.count($handlers).' handlers registered.', '', FlashMessage::OK, true ); $this->addFlashMessage($flashMessage); $buffer = '<table class="t3-table table"><thead><tr><th>extension</th><th>class</th><th>name</th><th>version</th></tr></thead>'.$buffer.'</table>'; } else { /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Please install one of the dyncss_* extensions', 'No handler registered! - No dynamic css is handled at all ;/', FlashMessage::WARNING, true ); $this->addFlashMessage($flashMessage); return $this->renderFlashMessage(); } $renderedFlashMessages = $this->renderFlashMessage(); return $renderedFlashMessages . $buffer; }
php
public function main() { $buffer = ''; $registry = GeneralUtility::makeInstance('KayStrobach\Dyncss\Configuration\BeRegistry'); $handlers = $registry->getAllFileHandler(); if (count($handlers)) { foreach ($handlers as $extension => $class) { /** @var AbstractParser $parser */ $parser = new $class(); $buffer .= '<tr><td>*.'.$extension.'</td>'; $buffer .= '<td>'.$class.'</td>'; $buffer .= '<td><a href="'.$parser->getParserHomepage().'" target="_blank">'.$parser->getParserName().'</a></td>'; $buffer .= '<td>'.$parser->getVersion().'</td>'; $buffer .= '</tr>'; } /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Congrats, you have '.count($handlers).' handlers registered.', '', FlashMessage::OK, true ); $this->addFlashMessage($flashMessage); $buffer = '<table class="t3-table table"><thead><tr><th>extension</th><th>class</th><th>name</th><th>version</th></tr></thead>'.$buffer.'</table>'; } else { /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Please install one of the dyncss_* extensions', 'No handler registered! - No dynamic css is handled at all ;/', FlashMessage::WARNING, true ); $this->addFlashMessage($flashMessage); return $this->renderFlashMessage(); } $renderedFlashMessages = $this->renderFlashMessage(); return $renderedFlashMessages . $buffer; }
[ "public", "function", "main", "(", ")", "{", "$", "buffer", "=", "''", ";", "$", "registry", "=", "GeneralUtility", "::", "makeInstance", "(", "'KayStrobach\\Dyncss\\Configuration\\BeRegistry'", ")", ";", "$", "handlers", "=", "$", "registry", "->", "getAllFileH...
Render state field
[ "Render", "state", "field" ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/ExtMgm/Statefield.php#L25-L64
43,212
kaystrobach/TYPO3.dyncss
Classes/ExtMgm/Statefield.php
Statefield.addFlashMessage
protected function addFlashMessage(FlashMessage $flashMessage) { if (!($this->flashMessageService instanceof FlashMessageService)) { $this->flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); } /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); }
php
protected function addFlashMessage(FlashMessage $flashMessage) { if (!($this->flashMessageService instanceof FlashMessageService)) { $this->flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); } /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); }
[ "protected", "function", "addFlashMessage", "(", "FlashMessage", "$", "flashMessage", ")", "{", "if", "(", "!", "(", "$", "this", "->", "flashMessageService", "instanceof", "FlashMessageService", ")", ")", "{", "$", "this", "->", "flashMessageService", "=", "Gen...
Add flash message to message queue @param FlashMessage $flashMessage @return void
[ "Add", "flash", "message", "to", "message", "queue" ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/ExtMgm/Statefield.php#L72-L80
43,213
phly/http
src/Server.php
Server.listen
public function listen(callable $finalHandler = null) { $callback = $this->callback; ob_start(); $bufferLevel = ob_get_level(); $response = $callback($this->request, $this->response, $finalHandler); if (! $response instanceof ResponseInterface) { $response = $this->response; } $this->getEmitter()->emit($response, $bufferLevel); }
php
public function listen(callable $finalHandler = null) { $callback = $this->callback; ob_start(); $bufferLevel = ob_get_level(); $response = $callback($this->request, $this->response, $finalHandler); if (! $response instanceof ResponseInterface) { $response = $this->response; } $this->getEmitter()->emit($response, $bufferLevel); }
[ "public", "function", "listen", "(", "callable", "$", "finalHandler", "=", "null", ")", "{", "$", "callback", "=", "$", "this", "->", "callback", ";", "ob_start", "(", ")", ";", "$", "bufferLevel", "=", "ob_get_level", "(", ")", ";", "$", "response", "...
"Listen" to an incoming request If provided a $finalHandler, that callable will be used for incomplete requests. Output buffering is enabled prior to invoking the attached callback; any output buffered will be sent prior to any response body content. @param null|callable $finalHandler
[ "Listen", "to", "an", "incoming", "request" ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Server.php#L151-L163
43,214
phly/http
src/RequestTrait.php
RequestTrait.initialize
private function initialize($uri = null, $method = null, $body = 'php://memory', array $headers = []) { if (! $uri instanceof UriInterface && ! is_string($uri) && null !== $uri) { throw new InvalidArgumentException( 'Invalid URI provided; must be null, a string, or a Psr\Http\Message\UriInterface instance' ); } $this->validateMethod($method); if (! is_string($body) && ! is_resource($body) && ! $body instanceof StreamInterface) { throw new InvalidArgumentException( 'Body must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\Http\Message\StreamInterface implementation' ); } if (is_string($uri)) { $uri = new Uri($uri); } $this->method = $method; $this->uri = $uri; $this->stream = ($body instanceof StreamInterface) ? $body : new Stream($body, 'r'); list($this->headerNames, $headers) = $this->filterHeaders($headers); $this->assertHeaders($headers); $this->headers = $headers; }
php
private function initialize($uri = null, $method = null, $body = 'php://memory', array $headers = []) { if (! $uri instanceof UriInterface && ! is_string($uri) && null !== $uri) { throw new InvalidArgumentException( 'Invalid URI provided; must be null, a string, or a Psr\Http\Message\UriInterface instance' ); } $this->validateMethod($method); if (! is_string($body) && ! is_resource($body) && ! $body instanceof StreamInterface) { throw new InvalidArgumentException( 'Body must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\Http\Message\StreamInterface implementation' ); } if (is_string($uri)) { $uri = new Uri($uri); } $this->method = $method; $this->uri = $uri; $this->stream = ($body instanceof StreamInterface) ? $body : new Stream($body, 'r'); list($this->headerNames, $headers) = $this->filterHeaders($headers); $this->assertHeaders($headers); $this->headers = $headers; }
[ "private", "function", "initialize", "(", "$", "uri", "=", "null", ",", "$", "method", "=", "null", ",", "$", "body", "=", "'php://memory'", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "!", "$", "uri", "instanceof", "UriInterfac...
Initialize request state. Used by constructors. @param null|string $uri URI for the request, if any. @param null|string $method HTTP method for the request, if any. @param string|resource|StreamInterface $body Message body, if any. @param array $headers Headers for the message, if any. @throws InvalidArgumentException for any invalid value.
[ "Initialize", "request", "state", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/RequestTrait.php#L66-L95
43,215
phly/http
src/RequestTrait.php
RequestTrait.assertHeaders
private function assertHeaders(array $headers) { foreach ($headers as $name => $headerValues) { HeaderSecurity::assertValidName($name); array_walk($headerValues, __NAMESPACE__ . '\HeaderSecurity::assertValid'); } }
php
private function assertHeaders(array $headers) { foreach ($headers as $name => $headerValues) { HeaderSecurity::assertValidName($name); array_walk($headerValues, __NAMESPACE__ . '\HeaderSecurity::assertValid'); } }
[ "private", "function", "assertHeaders", "(", "array", "$", "headers", ")", "{", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "headerValues", ")", "{", "HeaderSecurity", "::", "assertValidName", "(", "$", "name", ")", ";", "array_walk", "("...
Ensure header names and values are valid. @param array $headers @throws InvalidArgumentException
[ "Ensure", "header", "names", "and", "values", "are", "valid", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/RequestTrait.php#L309-L315
43,216
phly/http
src/AbstractSerializer.php
AbstractSerializer.getLine
protected static function getLine(StreamInterface $stream) { $line = ''; $crFound = false; while (! $stream->eof()) { $char = $stream->read(1); if ($crFound && $char === self::LF) { $crFound = false; break; } // CR NOT followed by LF if ($crFound && $char !== self::LF) { throw new UnexpectedValueException('Unexpected carriage return detected'); } // LF in isolation if (! $crFound && $char === self::LF) { throw new UnexpectedValueException('Unexpected line feed detected'); } // CR found; do not append if ($char === self::CR) { $crFound = true; continue; } // Any other character: append $line .= $char; } // CR found at end of stream if ($crFound) { throw new UnexpectedValueException("Unexpected end of headers"); } return $line; }
php
protected static function getLine(StreamInterface $stream) { $line = ''; $crFound = false; while (! $stream->eof()) { $char = $stream->read(1); if ($crFound && $char === self::LF) { $crFound = false; break; } // CR NOT followed by LF if ($crFound && $char !== self::LF) { throw new UnexpectedValueException('Unexpected carriage return detected'); } // LF in isolation if (! $crFound && $char === self::LF) { throw new UnexpectedValueException('Unexpected line feed detected'); } // CR found; do not append if ($char === self::CR) { $crFound = true; continue; } // Any other character: append $line .= $char; } // CR found at end of stream if ($crFound) { throw new UnexpectedValueException("Unexpected end of headers"); } return $line; }
[ "protected", "static", "function", "getLine", "(", "StreamInterface", "$", "stream", ")", "{", "$", "line", "=", "''", ";", "$", "crFound", "=", "false", ";", "while", "(", "!", "$", "stream", "->", "eof", "(", ")", ")", "{", "$", "char", "=", "$",...
Retrieve a single line from the stream. Retrieves a line from the stream; a line is defined as a sequence of characters ending in a CRLF sequence. @param StreamInterface $stream @return string @throws UnexpectedValueException if the sequence contains a CR or LF in isolation, or ends in a CR.
[ "Retrieve", "a", "single", "line", "from", "the", "stream", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/AbstractSerializer.php#L29-L67
43,217
phly/http
src/AbstractSerializer.php
AbstractSerializer.splitStream
protected static function splitStream(StreamInterface $stream) { $headers = []; $currentHeader = false; while ($line = self::getLine($stream)) { if (preg_match(';^(?P<name>[!#$%&\'*+.^_`\|~0-9a-zA-Z-]+):(?P<value>.*)$;', $line, $matches)) { $currentHeader = $matches['name']; if (! isset($headers[$currentHeader])) { $headers[$currentHeader] = []; } $headers[$currentHeader][] = ltrim($matches['value']); continue; } if (! $currentHeader) { throw new UnexpectedValueException('Invalid header detected'); } if (! preg_match('#^[ \t]#', $line)) { throw new UnexpectedValueException('Invalid header continuation'); } // Append continuation to last header value found $value = array_pop($headers[$currentHeader]); $headers[$currentHeader][] = $value . ltrim($line); } $body = new Stream('php://temp', 'wb+'); if (! $stream->eof()) { while ($data = $stream->read(4096)) { $body->write($data); } $body->rewind(); } return [$headers, $body]; }
php
protected static function splitStream(StreamInterface $stream) { $headers = []; $currentHeader = false; while ($line = self::getLine($stream)) { if (preg_match(';^(?P<name>[!#$%&\'*+.^_`\|~0-9a-zA-Z-]+):(?P<value>.*)$;', $line, $matches)) { $currentHeader = $matches['name']; if (! isset($headers[$currentHeader])) { $headers[$currentHeader] = []; } $headers[$currentHeader][] = ltrim($matches['value']); continue; } if (! $currentHeader) { throw new UnexpectedValueException('Invalid header detected'); } if (! preg_match('#^[ \t]#', $line)) { throw new UnexpectedValueException('Invalid header continuation'); } // Append continuation to last header value found $value = array_pop($headers[$currentHeader]); $headers[$currentHeader][] = $value . ltrim($line); } $body = new Stream('php://temp', 'wb+'); if (! $stream->eof()) { while ($data = $stream->read(4096)) { $body->write($data); } $body->rewind(); } return [$headers, $body]; }
[ "protected", "static", "function", "splitStream", "(", "StreamInterface", "$", "stream", ")", "{", "$", "headers", "=", "[", "]", ";", "$", "currentHeader", "=", "false", ";", "while", "(", "$", "line", "=", "self", "::", "getLine", "(", "$", "stream", ...
Split the stream into headers and body content. Returns an array containing two elements - The first is an array of headers - The second is a StreamInterface containing the body content @param StreamInterface $stream @return array @throws UnexpectedValueException For invalid headers.
[ "Split", "the", "stream", "into", "headers", "and", "body", "content", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/AbstractSerializer.php#L81-L118
43,218
phly/http
src/AbstractSerializer.php
AbstractSerializer.serializeHeaders
protected static function serializeHeaders(array $headers) { $lines = []; foreach ($headers as $header => $values) { $normalized = self::filterHeader($header); foreach ($values as $value) { $lines[] = sprintf('%s: %s', $normalized, $value); } } return implode("\r\n", $lines); }
php
protected static function serializeHeaders(array $headers) { $lines = []; foreach ($headers as $header => $values) { $normalized = self::filterHeader($header); foreach ($values as $value) { $lines[] = sprintf('%s: %s', $normalized, $value); } } return implode("\r\n", $lines); }
[ "protected", "static", "function", "serializeHeaders", "(", "array", "$", "headers", ")", "{", "$", "lines", "=", "[", "]", ";", "foreach", "(", "$", "headers", "as", "$", "header", "=>", "$", "values", ")", "{", "$", "normalized", "=", "self", "::", ...
Serialize headers to string values. @param array $headers @return string
[ "Serialize", "headers", "to", "string", "values", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/AbstractSerializer.php#L126-L137
43,219
phly/http
src/Request/Serializer.php
Serializer.fromString
public static function fromString($message) { $stream = new Stream('php://temp', 'wb+'); $stream->write($message); return self::fromStream($stream); }
php
public static function fromString($message) { $stream = new Stream('php://temp', 'wb+'); $stream->write($message); return self::fromStream($stream); }
[ "public", "static", "function", "fromString", "(", "$", "message", ")", "{", "$", "stream", "=", "new", "Stream", "(", "'php://temp'", ",", "'wb+'", ")", ";", "$", "stream", "->", "write", "(", "$", "message", ")", ";", "return", "self", "::", "fromStr...
Deserialize a request string to a request instance. Internally, casts the message to a stream and invokes fromStream(). @param string $message @return Request @throws UnexpectedValueException when errors occur parsing the message.
[ "Deserialize", "a", "request", "string", "to", "a", "request", "instance", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Request/Serializer.php#L31-L36
43,220
phly/http
src/Request/Serializer.php
Serializer.fromStream
public static function fromStream(StreamInterface $stream) { if (! $stream->isReadable() || ! $stream->isSeekable()) { throw new InvalidArgumentException('Message stream must be both readable and seekable'); } $stream->rewind(); list($method, $requestTarget, $version) = self::getRequestLine($stream); $uri = self::createUriFromRequestTarget($requestTarget); list($headers, $body) = self::splitStream($stream); return (new Request($uri, $method, $body, $headers)) ->withProtocolVersion($version) ->withRequestTarget($requestTarget); }
php
public static function fromStream(StreamInterface $stream) { if (! $stream->isReadable() || ! $stream->isSeekable()) { throw new InvalidArgumentException('Message stream must be both readable and seekable'); } $stream->rewind(); list($method, $requestTarget, $version) = self::getRequestLine($stream); $uri = self::createUriFromRequestTarget($requestTarget); list($headers, $body) = self::splitStream($stream); return (new Request($uri, $method, $body, $headers)) ->withProtocolVersion($version) ->withRequestTarget($requestTarget); }
[ "public", "static", "function", "fromStream", "(", "StreamInterface", "$", "stream", ")", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", "||", "!", "$", "stream", "->", "isSeekable", "(", ")", ")", "{", "throw", "new", "InvalidArgument...
Deserialize a request stream to a request instance. @param StreamInterface $stream @return Request @throws UnexpectedValueException when errors occur parsing the message.
[ "Deserialize", "a", "request", "stream", "to", "a", "request", "instance", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Request/Serializer.php#L45-L61
43,221
phly/http
src/Request/Serializer.php
Serializer.getRequestLine
private static function getRequestLine(StreamInterface $stream) { $requestLine = self::getLine($stream); if (! preg_match( '#^(?P<method>[!\#$%&\'*+.^_`|~a-zA-Z0-9-]+) (?P<target>[^\s]+) HTTP/(?P<version>[1-9]\d*\.\d+)$#', $requestLine, $matches )) { throw new UnexpectedValueException('Invalid request line detected'); } return [$matches['method'], $matches['target'], $matches['version']]; }
php
private static function getRequestLine(StreamInterface $stream) { $requestLine = self::getLine($stream); if (! preg_match( '#^(?P<method>[!\#$%&\'*+.^_`|~a-zA-Z0-9-]+) (?P<target>[^\s]+) HTTP/(?P<version>[1-9]\d*\.\d+)$#', $requestLine, $matches )) { throw new UnexpectedValueException('Invalid request line detected'); } return [$matches['method'], $matches['target'], $matches['version']]; }
[ "private", "static", "function", "getRequestLine", "(", "StreamInterface", "$", "stream", ")", "{", "$", "requestLine", "=", "self", "::", "getLine", "(", "$", "stream", ")", ";", "if", "(", "!", "preg_match", "(", "'#^(?P<method>[!\\#$%&\\'*+.^_`|~a-zA-Z0-9-]+) (...
Retrieve the components of the request line. Retrieves the first line of the stream and parses it, raising an exception if it does not follow specifications; if valid, returns a list with the method, target, and version, in that order. @param StreamInterface $stream @return array
[ "Retrieve", "the", "components", "of", "the", "request", "line", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Request/Serializer.php#L102-L115
43,222
phly/http
src/Request/Serializer.php
Serializer.createUriFromRequestTarget
private static function createUriFromRequestTarget($requestTarget) { if (preg_match('#^https?://#', $requestTarget)) { return new Uri($requestTarget); } if (preg_match('#^(\*|[^/])#', $requestTarget)) { return new Uri(); } return new Uri($requestTarget); }
php
private static function createUriFromRequestTarget($requestTarget) { if (preg_match('#^https?://#', $requestTarget)) { return new Uri($requestTarget); } if (preg_match('#^(\*|[^/])#', $requestTarget)) { return new Uri(); } return new Uri($requestTarget); }
[ "private", "static", "function", "createUriFromRequestTarget", "(", "$", "requestTarget", ")", "{", "if", "(", "preg_match", "(", "'#^https?://#'", ",", "$", "requestTarget", ")", ")", "{", "return", "new", "Uri", "(", "$", "requestTarget", ")", ";", "}", "i...
Create and return a Uri instance based on the provided request target. If the request target is of authority or asterisk form, an empty Uri instance is returned; otherwise, the value is used to create and return a new Uri instance. @param string $requestTarget @return Uri
[ "Create", "and", "return", "a", "Uri", "instance", "based", "on", "the", "provided", "request", "target", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Request/Serializer.php#L127-L138
43,223
phly/http
src/Response/Serializer.php
Serializer.fromStream
public static function fromStream(StreamInterface $stream) { if (! $stream->isReadable() || ! $stream->isSeekable()) { throw new InvalidArgumentException('Message stream must be both readable and seekable'); } $stream->rewind(); list($version, $status, $reasonPhrase) = self::getStatusLine($stream); list($headers, $body) = self::splitStream($stream); return (new Response($body, $status, $headers)) ->withProtocolVersion($version) ->withStatus($status, $reasonPhrase); }
php
public static function fromStream(StreamInterface $stream) { if (! $stream->isReadable() || ! $stream->isSeekable()) { throw new InvalidArgumentException('Message stream must be both readable and seekable'); } $stream->rewind(); list($version, $status, $reasonPhrase) = self::getStatusLine($stream); list($headers, $body) = self::splitStream($stream); return (new Response($body, $status, $headers)) ->withProtocolVersion($version) ->withStatus($status, $reasonPhrase); }
[ "public", "static", "function", "fromStream", "(", "StreamInterface", "$", "stream", ")", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", "||", "!", "$", "stream", "->", "isSeekable", "(", ")", ")", "{", "throw", "new", "InvalidArgument...
Parse a response from a stream. @param StreamInterface $stream @return ResponseInterface @throws InvalidArgumentException when the stream is not readable. @throws UnexpectedValueException when errors occur parsing the message.
[ "Parse", "a", "response", "from", "a", "stream", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Response/Serializer.php#L36-L50
43,224
phly/http
src/Response/Serializer.php
Serializer.getStatusLine
private static function getStatusLine(StreamInterface $stream) { $line = self::getLine($stream); if (! preg_match( '#^HTTP/(?P<version>[1-9]\d*\.\d) (?P<status>[1-5]\d{2})(\s+(?P<reason>.+))?$#', $line, $matches )) { throw new UnexpectedValueException('No status line detected'); } return [$matches['version'], $matches['status'], isset($matches['reason']) ? $matches['reason'] : '']; }
php
private static function getStatusLine(StreamInterface $stream) { $line = self::getLine($stream); if (! preg_match( '#^HTTP/(?P<version>[1-9]\d*\.\d) (?P<status>[1-5]\d{2})(\s+(?P<reason>.+))?$#', $line, $matches )) { throw new UnexpectedValueException('No status line detected'); } return [$matches['version'], $matches['status'], isset($matches['reason']) ? $matches['reason'] : '']; }
[ "private", "static", "function", "getStatusLine", "(", "StreamInterface", "$", "stream", ")", "{", "$", "line", "=", "self", "::", "getLine", "(", "$", "stream", ")", ";", "if", "(", "!", "preg_match", "(", "'#^HTTP/(?P<version>[1-9]\\d*\\.\\d) (?P<status>[1-5]\\d...
Retrieve the status line for the message. @param StreamInterface $stream @return array Array with three elements: 0 => version, 1 => status, 2 => reason @throws UnexpectedValueException if line is malformed
[ "Retrieve", "the", "status", "line", "for", "the", "message", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Response/Serializer.php#L89-L102
43,225
phly/http
src/ServerRequest.php
ServerRequest.getStream
private function getStream($stream) { if ($stream === 'php://input') { return new PhpInputStream(); } if (! is_string($stream) && ! is_resource($stream) && ! $stream instanceof StreamInterface) { throw new InvalidArgumentException( 'Stream must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\Http\Message\StreamInterface implementation' ); } if (! $stream instanceof StreamInterface) { return new Stream($stream, 'r'); } return $stream; }
php
private function getStream($stream) { if ($stream === 'php://input') { return new PhpInputStream(); } if (! is_string($stream) && ! is_resource($stream) && ! $stream instanceof StreamInterface) { throw new InvalidArgumentException( 'Stream must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\Http\Message\StreamInterface implementation' ); } if (! $stream instanceof StreamInterface) { return new Stream($stream, 'r'); } return $stream; }
[ "private", "function", "getStream", "(", "$", "stream", ")", "{", "if", "(", "$", "stream", "===", "'php://input'", ")", "{", "return", "new", "PhpInputStream", "(", ")", ";", "}", "if", "(", "!", "is_string", "(", "$", "stream", ")", "&&", "!", "is_...
Set the body stream @param string|resource|StreamInterface $stream @return void
[ "Set", "the", "body", "stream" ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/ServerRequest.php#L249-L268
43,226
phly/http
src/MessageTrait.php
MessageTrait.getHeaderLine
public function getHeaderLine($header) { $value = $this->getHeader($header); if (empty($value)) { return null; } return implode(',', $value); }
php
public function getHeaderLine($header) { $value = $this->getHeader($header); if (empty($value)) { return null; } return implode(',', $value); }
[ "public", "function", "getHeaderLine", "(", "$", "header", ")", "{", "$", "value", "=", "$", "this", "->", "getHeader", "(", "$", "header", ")", ";", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "null", ";", "}", "return", "implo...
Retrieves the line for a single header, with the header values as a comma-separated string. This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma. NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating. If the header does not appear in the message, this method MUST return a null value. @param string $name Case-insensitive header field name. @return string|null A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return a null value.
[ "Retrieves", "the", "line", "for", "a", "single", "header", "with", "the", "header", "values", "as", "a", "comma", "-", "separated", "string", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/MessageTrait.php#L157-L165
43,227
phly/http
src/MessageTrait.php
MessageTrait.withHeader
public function withHeader($header, $value) { if (is_string($value)) { $value = [ $value ]; } if (! is_array($value) || ! $this->arrayContainsOnlyStrings($value)) { throw new InvalidArgumentException( 'Invalid header value; must be a string or array of strings' ); } HeaderSecurity::assertValidName($header); self::assertValidHeaderValue($value); $normalized = strtolower($header); $new = clone $this; $new->headerNames[$normalized] = $header; $new->headers[$header] = $value; return $new; }
php
public function withHeader($header, $value) { if (is_string($value)) { $value = [ $value ]; } if (! is_array($value) || ! $this->arrayContainsOnlyStrings($value)) { throw new InvalidArgumentException( 'Invalid header value; must be a string or array of strings' ); } HeaderSecurity::assertValidName($header); self::assertValidHeaderValue($value); $normalized = strtolower($header); $new = clone $this; $new->headerNames[$normalized] = $header; $new->headers[$header] = $value; return $new; }
[ "public", "function", "withHeader", "(", "$", "header", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "$", "value", "]", ";", "}", "if", "(", "!", "is_array", "(", "$", "value", "...
Return an instance with the provided header, replacing any existing values of any headers with the same case-insensitive name. While header names are case-insensitive, the casing of the header will be preserved by this function, and returned from getHeaders(). This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new and/or updated header and value. @param string $name Case-insensitive header field name. @param string|string[] $value Header value(s). @return self @throws \InvalidArgumentException for invalid header names or values.
[ "Return", "an", "instance", "with", "the", "provided", "header", "replacing", "any", "existing", "values", "of", "any", "headers", "with", "the", "same", "case", "-", "insensitive", "name", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/MessageTrait.php#L183-L205
43,228
phly/http
src/Response/SapiEmitter.php
SapiEmitter.filterHeader
private function filterHeader($header) { $filtered = str_replace('-', ' ', $header); $filtered = ucwords($filtered); return str_replace(' ', '-', $filtered); }
php
private function filterHeader($header) { $filtered = str_replace('-', ' ', $header); $filtered = ucwords($filtered); return str_replace(' ', '-', $filtered); }
[ "private", "function", "filterHeader", "(", "$", "header", ")", "{", "$", "filtered", "=", "str_replace", "(", "'-'", ",", "' '", ",", "$", "header", ")", ";", "$", "filtered", "=", "ucwords", "(", "$", "filtered", ")", ";", "return", "str_replace", "(...
Filter a header name to wordcase @param string $header @return string
[ "Filter", "a", "header", "name", "to", "wordcase" ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Response/SapiEmitter.php#L101-L106
43,229
WyriHaximus/TwigView
src/Lib/Twig/Extension/Inflector.php
Inflector.getFilters
public function getFilters(): array { return [ new TwigFilter('pluralize', 'Cake\Utility\Inflector::pluralize'), new TwigFilter('singularize', 'Cake\Utility\Inflector::singularize'), new TwigFilter('camelize', 'Cake\Utility\Inflector::camelize'), new TwigFilter('underscore', 'Cake\Utility\Inflector::underscore'), new TwigFilter('humanize', 'Cake\Utility\Inflector::humanize'), new TwigFilter('tableize', 'Cake\Utility\Inflector::tableize'), new TwigFilter('classify', 'Cake\Utility\Inflector::classify'), new TwigFilter('variable', 'Cake\Utility\Inflector::variable'), new TwigFilter('dasherize', 'Cake\Utility\Inflector::dasherize'), new TwigFilter('slug', 'Cake\Utility\Text::slug'), ]; }
php
public function getFilters(): array { return [ new TwigFilter('pluralize', 'Cake\Utility\Inflector::pluralize'), new TwigFilter('singularize', 'Cake\Utility\Inflector::singularize'), new TwigFilter('camelize', 'Cake\Utility\Inflector::camelize'), new TwigFilter('underscore', 'Cake\Utility\Inflector::underscore'), new TwigFilter('humanize', 'Cake\Utility\Inflector::humanize'), new TwigFilter('tableize', 'Cake\Utility\Inflector::tableize'), new TwigFilter('classify', 'Cake\Utility\Inflector::classify'), new TwigFilter('variable', 'Cake\Utility\Inflector::variable'), new TwigFilter('dasherize', 'Cake\Utility\Inflector::dasherize'), new TwigFilter('slug', 'Cake\Utility\Text::slug'), ]; }
[ "public", "function", "getFilters", "(", ")", ":", "array", "{", "return", "[", "new", "TwigFilter", "(", "'pluralize'", ",", "'Cake\\Utility\\Inflector::pluralize'", ")", ",", "new", "TwigFilter", "(", "'singularize'", ",", "'Cake\\Utility\\Inflector::singularize'", ...
Get filters for this extension. @return \Twig\TwigFunction[]
[ "Get", "filters", "for", "this", "extension", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Extension/Inflector.php#L28-L42
43,230
WyriHaximus/TwigView
src/Shell/CompileShell.php
CompileShell.all
public function all() { $this->out('<info>Compiling all templates</info>'); foreach (Scanner::all() as $section => $templates) { $this->out('<info>Compiling ' . $section . '\'s templates</info>'); $this->walkIterator($templates); } }
php
public function all() { $this->out('<info>Compiling all templates</info>'); foreach (Scanner::all() as $section => $templates) { $this->out('<info>Compiling ' . $section . '\'s templates</info>'); $this->walkIterator($templates); } }
[ "public", "function", "all", "(", ")", "{", "$", "this", "->", "out", "(", "'<info>Compiling all templates</info>'", ")", ";", "foreach", "(", "Scanner", "::", "all", "(", ")", "as", "$", "section", "=>", "$", "templates", ")", "{", "$", "this", "->", ...
Compile all templates.
[ "Compile", "all", "templates", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/CompileShell.php#L61-L69
43,231
WyriHaximus/TwigView
src/Shell/CompileShell.php
CompileShell.plugin
public function plugin($plugin) { $this->out('<info>Compiling one ' . $plugin . '\'s templates</info>'); $this->walkIterator(Scanner::plugin($plugin)); }
php
public function plugin($plugin) { $this->out('<info>Compiling one ' . $plugin . '\'s templates</info>'); $this->walkIterator(Scanner::plugin($plugin)); }
[ "public", "function", "plugin", "(", "$", "plugin", ")", "{", "$", "this", "->", "out", "(", "'<info>Compiling one '", ".", "$", "plugin", ".", "'\\'s templates</info>'", ")", ";", "$", "this", "->", "walkIterator", "(", "Scanner", "::", "plugin", "(", "$"...
Compile only this plugin. @param string $plugin Plugin name.
[ "Compile", "only", "this", "plugin", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/CompileShell.php#L77-L81
43,232
WyriHaximus/TwigView
src/Shell/CompileShell.php
CompileShell.getOptionParser
public function getOptionParser(): ConsoleOptionParser { return parent::getOptionParser()->addSubcommand( 'all', [ 'short' => 'a', 'help' => __('Searches and precompiles all twig templates it finds.'), ] )->addSubcommand( 'plugin', [ 'short' => 'p', 'help' => __('Searches and precompiles all twig templates for a specific plugin.'), ] )->addSubcommand( 'file', [ 'short' => 'f', 'help' => __('Precompile a specific file.'), ] )->setDescription(__('TwigView templates precompiler')); }
php
public function getOptionParser(): ConsoleOptionParser { return parent::getOptionParser()->addSubcommand( 'all', [ 'short' => 'a', 'help' => __('Searches and precompiles all twig templates it finds.'), ] )->addSubcommand( 'plugin', [ 'short' => 'p', 'help' => __('Searches and precompiles all twig templates for a specific plugin.'), ] )->addSubcommand( 'file', [ 'short' => 'f', 'help' => __('Precompile a specific file.'), ] )->setDescription(__('TwigView templates precompiler')); }
[ "public", "function", "getOptionParser", "(", ")", ":", "ConsoleOptionParser", "{", "return", "parent", "::", "getOptionParser", "(", ")", "->", "addSubcommand", "(", "'all'", ",", "[", "'short'", "=>", "'a'", ",", "'help'", "=>", "__", "(", "'Searches and pre...
Set options for this console. @return \Cake\Console\ConsoleOptionParser
[ "Set", "options", "for", "this", "console", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/CompileShell.php#L100-L121
43,233
WyriHaximus/TwigView
src/Shell/CompileShell.php
CompileShell.compileTemplate
protected function compileTemplate($fileName) { try { $this-> twigView-> getTwig()-> loadTemplate($fileName); $this->out('<success>' . $fileName . '</success>'); } catch (\Exception $exception) { $this->out('<error>' . $fileName . '</error>'); $this->out('<error>' . $exception->getMessage() . '</error>'); } }
php
protected function compileTemplate($fileName) { try { $this-> twigView-> getTwig()-> loadTemplate($fileName); $this->out('<success>' . $fileName . '</success>'); } catch (\Exception $exception) { $this->out('<error>' . $fileName . '</error>'); $this->out('<error>' . $exception->getMessage() . '</error>'); } }
[ "protected", "function", "compileTemplate", "(", "$", "fileName", ")", "{", "try", "{", "$", "this", "->", "twigView", "->", "getTwig", "(", ")", "->", "loadTemplate", "(", "$", "fileName", ")", ";", "$", "this", "->", "out", "(", "'<success>'", ".", "...
Compile a template. @param string $fileName Template to compile.
[ "Compile", "a", "template", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/CompileShell.php#L142-L154
43,234
WyriHaximus/TwigView
src/Lib/TreeScanner.php
TreeScanner.convertToTree
protected static function convertToTree(array $paths): array { foreach ($paths as $index => $path) { static::convertPathToTree($paths, $index, $path); } return $paths; }
php
protected static function convertToTree(array $paths): array { foreach ($paths as $index => $path) { static::convertPathToTree($paths, $index, $path); } return $paths; }
[ "protected", "static", "function", "convertToTree", "(", "array", "$", "paths", ")", ":", "array", "{", "foreach", "(", "$", "paths", "as", "$", "index", "=>", "$", "path", ")", "{", "static", "::", "convertPathToTree", "(", "$", "paths", ",", "$", "in...
Turn a set of paths into a tree. @param array $paths Paths to turn into a tree. @return array
[ "Turn", "a", "set", "of", "paths", "into", "a", "tree", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/TreeScanner.php#L58-L65
43,235
WyriHaximus/TwigView
src/Lib/TreeScanner.php
TreeScanner.convertPathToTree
protected static function convertPathToTree(array &$paths, $index, $path) { if (strpos($path, DIRECTORY_SEPARATOR) !== false) { $chunks = explode(DIRECTORY_SEPARATOR, $path); $paths = static::branch($paths, $chunks); unset($paths[$index]); } }
php
protected static function convertPathToTree(array &$paths, $index, $path) { if (strpos($path, DIRECTORY_SEPARATOR) !== false) { $chunks = explode(DIRECTORY_SEPARATOR, $path); $paths = static::branch($paths, $chunks); unset($paths[$index]); } }
[ "protected", "static", "function", "convertPathToTree", "(", "array", "&", "$", "paths", ",", "$", "index", ",", "$", "path", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", "!==", "false", ")", "{", "$", "chunks", "="...
Convert a path into a tree when it contains a directory separator. @param array $paths The paths to work on. @param mixed $index Index of $path. @param string $path Path to breakup and turn into a tree.
[ "Convert", "a", "path", "into", "a", "tree", "when", "it", "contains", "a", "directory", "separator", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/TreeScanner.php#L75-L82
43,236
WyriHaximus/TwigView
src/Lib/TreeScanner.php
TreeScanner.branch
protected static function branch(array $paths, array $branches): array { $twig = array_shift($branches); if (count($branches) == 0) { $paths[] = $twig; return $paths; } if (!isset($paths[$twig])) { $paths[$twig] = []; } $paths[$twig] = static::branch($paths[$twig], $branches); return $paths; }
php
protected static function branch(array $paths, array $branches): array { $twig = array_shift($branches); if (count($branches) == 0) { $paths[] = $twig; return $paths; } if (!isset($paths[$twig])) { $paths[$twig] = []; } $paths[$twig] = static::branch($paths[$twig], $branches); return $paths; }
[ "protected", "static", "function", "branch", "(", "array", "$", "paths", ",", "array", "$", "branches", ")", ":", "array", "{", "$", "twig", "=", "array_shift", "(", "$", "branches", ")", ";", "if", "(", "count", "(", "$", "branches", ")", "==", "0",...
Create a branch for the current level and push a twig on it. @param array $paths Paths to append. @param array $branches Branches to use untill only one left. @return array
[ "Create", "a", "branch", "for", "the", "current", "level", "and", "push", "a", "twig", "on", "it", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/TreeScanner.php#L92-L108
43,237
WyriHaximus/TwigView
src/Shell/Task/TwigTemplateTask.php
TwigTemplateTask.bake
public function bake($action, $content = '', $outputFile = null): string { if ($outputFile === null) { $outputFile = $action; } if ($content === true) { $content = $this->getContent($action); } if (empty($content)) { $this->err("<warning>No generated content for '{$action}.php', not generating template.</warning>"); return false; } $this->out("\n" . sprintf('Baking `%s` view twig template file...', $outputFile), 1, Shell::QUIET); $path = $this->getPath(); $filename = $path . Inflector::underscore($outputFile) . '.twig'; $this->createFile($filename, $content); return $content; }
php
public function bake($action, $content = '', $outputFile = null): string { if ($outputFile === null) { $outputFile = $action; } if ($content === true) { $content = $this->getContent($action); } if (empty($content)) { $this->err("<warning>No generated content for '{$action}.php', not generating template.</warning>"); return false; } $this->out("\n" . sprintf('Baking `%s` view twig template file...', $outputFile), 1, Shell::QUIET); $path = $this->getPath(); $filename = $path . Inflector::underscore($outputFile) . '.twig'; $this->createFile($filename, $content); return $content; }
[ "public", "function", "bake", "(", "$", "action", ",", "$", "content", "=", "''", ",", "$", "outputFile", "=", "null", ")", ":", "string", "{", "if", "(", "$", "outputFile", "===", "null", ")", "{", "$", "outputFile", "=", "$", "action", ";", "}", ...
Assembles and writes bakes the twig view file. @param string $action Action to bake. @param string $content Content to write. @param string $outputFile The destination action name. If null, will fallback to $template. @return string Generated file content.
[ "Assembles", "and", "writes", "bakes", "the", "twig", "view", "file", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/Task/TwigTemplateTask.php#L36-L55
43,238
WyriHaximus/TwigView
src/Lib/Cache.php
Cache.fetch
public function fetch($identifier) { [$config, $key] = $this->configSplit($identifier); return CakeCache::read(static::CACHE_PREFIX . $key, $config); }
php
public function fetch($identifier) { [$config, $key] = $this->configSplit($identifier); return CakeCache::read(static::CACHE_PREFIX . $key, $config); }
[ "public", "function", "fetch", "(", "$", "identifier", ")", "{", "[", "$", "config", ",", "$", "key", "]", "=", "$", "this", "->", "configSplit", "(", "$", "identifier", ")", ";", "return", "CakeCache", "::", "read", "(", "static", "::", "CACHE_PREFIX"...
Retrieve data from the cache. @param string $identifier Identifier for this bit of data to read. @return mixed The cached data, or false if the data doesn't exist, has expired, or on error while fetching.
[ "Retrieve", "data", "from", "the", "cache", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Cache.php#L19-L24
43,239
WyriHaximus/TwigView
src/Lib/Twig/Node/Cell.php
Cell.compile
public function compile(Compiler $compiler) { $compiler->addDebugInfo($this); if ($this->assign) { $compiler->raw('$context[\'' . $this->getAttribute('variable') . '\'] = '); } else { $compiler->raw('echo '); } $compiler->raw('$context[\'_view\']->cell('); $compiler->subcompile($this->getNode('name')); $data = $this->getNode('data'); if ($data !== null) { $compiler->raw(','); $compiler->subcompile($data); } $options = $this->getNode('options'); if ($options !== null) { $compiler->raw(','); $compiler->subcompile($options); } $compiler->raw(");\n"); }
php
public function compile(Compiler $compiler) { $compiler->addDebugInfo($this); if ($this->assign) { $compiler->raw('$context[\'' . $this->getAttribute('variable') . '\'] = '); } else { $compiler->raw('echo '); } $compiler->raw('$context[\'_view\']->cell('); $compiler->subcompile($this->getNode('name')); $data = $this->getNode('data'); if ($data !== null) { $compiler->raw(','); $compiler->subcompile($data); } $options = $this->getNode('options'); if ($options !== null) { $compiler->raw(','); $compiler->subcompile($options); } $compiler->raw(");\n"); }
[ "public", "function", "compile", "(", "Compiler", "$", "compiler", ")", "{", "$", "compiler", "->", "addDebugInfo", "(", "$", "this", ")", ";", "if", "(", "$", "this", "->", "assign", ")", "{", "$", "compiler", "->", "raw", "(", "'$context[\\''", ".", ...
Compile tag. @param \Twig\Compiler $compiler Compiler.
[ "Compile", "tag", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Node/Cell.php#L82-L104
43,240
WyriHaximus/TwigView
src/Lib/Scanner.php
Scanner.plugin
public static function plugin($plugin) { $templates = []; foreach (App::path('Template', $plugin) as $path) { $templates = array_merge($templates, static::iteratePath($path)); } return $templates; }
php
public static function plugin($plugin) { $templates = []; foreach (App::path('Template', $plugin) as $path) { $templates = array_merge($templates, static::iteratePath($path)); } return $templates; }
[ "public", "static", "function", "plugin", "(", "$", "plugin", ")", "{", "$", "templates", "=", "[", "]", ";", "foreach", "(", "App", "::", "path", "(", "'Template'", ",", "$", "plugin", ")", "as", "$", "path", ")", "{", "$", "templates", "=", "arra...
Return all templates for a given plugin. @param string $plugin The plugin to find all templates for. @return mixed
[ "Return", "all", "templates", "for", "a", "given", "plugin", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L55-L64
43,241
WyriHaximus/TwigView
src/Lib/Scanner.php
Scanner.clearEmptySections
protected static function clearEmptySections(array $sections): array { array_walk($sections, function ($templates, $index) use (&$sections) { if (count($templates) == 0) { unset($sections[$index]); } }); return $sections; }
php
protected static function clearEmptySections(array $sections): array { array_walk($sections, function ($templates, $index) use (&$sections) { if (count($templates) == 0) { unset($sections[$index]); } }); return $sections; }
[ "protected", "static", "function", "clearEmptySections", "(", "array", "$", "sections", ")", ":", "array", "{", "array_walk", "(", "$", "sections", ",", "function", "(", "$", "templates", ",", "$", "index", ")", "use", "(", "&", "$", "sections", ")", "{"...
Check sections a remove the ones without anything in them. @param array $sections Sections to check. @return array
[ "Check", "sections", "a", "remove", "the", "ones", "without", "anything", "in", "them", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L73-L82
43,242
WyriHaximus/TwigView
src/Lib/Scanner.php
Scanner.pluginsWithTemplates
protected static function pluginsWithTemplates(): array { $plugins = Plugin::loaded(); array_walk($plugins, function ($plugin, $index) use (&$plugins) { $paths = App::path('Template', $plugin); array_walk($paths, function ($path, $index) use (&$paths) { if (!is_dir($path)) { unset($paths[$index]); } }); }); return $plugins; }
php
protected static function pluginsWithTemplates(): array { $plugins = Plugin::loaded(); array_walk($plugins, function ($plugin, $index) use (&$plugins) { $paths = App::path('Template', $plugin); array_walk($paths, function ($path, $index) use (&$paths) { if (!is_dir($path)) { unset($paths[$index]); } }); }); return $plugins; }
[ "protected", "static", "function", "pluginsWithTemplates", "(", ")", ":", "array", "{", "$", "plugins", "=", "Plugin", "::", "loaded", "(", ")", ";", "array_walk", "(", "$", "plugins", ",", "function", "(", "$", "plugin", ",", "$", "index", ")", "use", ...
Finds all plugins with a Template directory. @return array
[ "Finds", "all", "plugins", "with", "a", "Template", "directory", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L89-L104
43,243
WyriHaximus/TwigView
src/Lib/Scanner.php
Scanner.setupIterator
protected static function setupIterator($path): Iterator { return new RegexIterator(new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS ), RecursiveIteratorIterator::CHILD_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD ), '/.*?' . TwigView::EXT . '$/', RegexIterator::GET_MATCH); }
php
protected static function setupIterator($path): Iterator { return new RegexIterator(new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS ), RecursiveIteratorIterator::CHILD_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD ), '/.*?' . TwigView::EXT . '$/', RegexIterator::GET_MATCH); }
[ "protected", "static", "function", "setupIterator", "(", "$", "path", ")", ":", "Iterator", "{", "return", "new", "RegexIterator", "(", "new", "RecursiveIteratorIterator", "(", "new", "RecursiveDirectoryIterator", "(", "$", "path", ",", "FilesystemIterator", "::", ...
Setup iterator for given path. @param string $path Path to setup iterator for. @return \Iterator
[ "Setup", "iterator", "for", "given", "path", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L125-L137
43,244
WyriHaximus/TwigView
src/Lib/Scanner.php
Scanner.walkIterator
protected static function walkIterator(Iterator $iterator): array { $items = []; $array = iterator_to_array($iterator); uasort($array, function ($a, $b) { if ($a == $b) { return 0; } return $a < $b ? -1 : 1; }); foreach ($array as $paths) { foreach ($paths as $path) { $items[] = $path; } } return $items; }
php
protected static function walkIterator(Iterator $iterator): array { $items = []; $array = iterator_to_array($iterator); uasort($array, function ($a, $b) { if ($a == $b) { return 0; } return $a < $b ? -1 : 1; }); foreach ($array as $paths) { foreach ($paths as $path) { $items[] = $path; } } return $items; }
[ "protected", "static", "function", "walkIterator", "(", "Iterator", "$", "iterator", ")", ":", "array", "{", "$", "items", "=", "[", "]", ";", "$", "array", "=", "iterator_to_array", "(", "$", "iterator", ")", ";", "uasort", "(", "$", "array", ",", "fu...
Walk over the iterator and compile all templates. @param \Iterator $iterator Iterator to walk. @return array
[ "Walk", "over", "the", "iterator", "and", "compile", "all", "templates", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L146-L166
43,245
WyriHaximus/TwigView
src/Lib/RelativeScanner.php
RelativeScanner.stripAbsolutePath
protected static function stripAbsolutePath(array $paths, $plugin = null): array { foreach (App::path('Template', $plugin) as $templatesPath) { array_walk($paths, function (&$path) use ($templatesPath) { if (substr($path, 0, strlen($templatesPath)) == $templatesPath) { $path = substr($path, strlen($templatesPath)); } }); } return $paths; }
php
protected static function stripAbsolutePath(array $paths, $plugin = null): array { foreach (App::path('Template', $plugin) as $templatesPath) { array_walk($paths, function (&$path) use ($templatesPath) { if (substr($path, 0, strlen($templatesPath)) == $templatesPath) { $path = substr($path, strlen($templatesPath)); } }); } return $paths; }
[ "protected", "static", "function", "stripAbsolutePath", "(", "array", "$", "paths", ",", "$", "plugin", "=", "null", ")", ":", "array", "{", "foreach", "(", "App", "::", "path", "(", "'Template'", ",", "$", "plugin", ")", "as", "$", "templatesPath", ")",...
Strip the absolute path of template's paths. @param array $paths Paths to strip. @param string|null $plugin Hold plugin name or null for App. @return array
[ "Strip", "the", "absolute", "path", "of", "template", "s", "paths", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/RelativeScanner.php#L61-L72
43,246
WyriHaximus/TwigView
src/View/TwigView.php
TwigView.initialize
public function initialize(): void { $this->twig = new Environment($this->getLoader(), $this->resolveConfig()); $this->getEventManager()->dispatch(ConstructEvent::create($this, $this->twig)); $this->_ext = self::EXT; parent::initialize(); }
php
public function initialize(): void { $this->twig = new Environment($this->getLoader(), $this->resolveConfig()); $this->getEventManager()->dispatch(ConstructEvent::create($this, $this->twig)); $this->_ext = self::EXT; parent::initialize(); }
[ "public", "function", "initialize", "(", ")", ":", "void", "{", "$", "this", "->", "twig", "=", "new", "Environment", "(", "$", "this", "->", "getLoader", "(", ")", ",", "$", "this", "->", "resolveConfig", "(", ")", ")", ";", "$", "this", "->", "ge...
Initialize view.
[ "Initialize", "view", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/View/TwigView.php#L69-L78
43,247
WyriHaximus/TwigView
src/View/TwigView.php
TwigView.getLoader
protected function getLoader(): Loader { $event = LoaderEvent::create(new Loader()); $this->getEventManager()->dispatch($event); return $event->getResultLoader(); }
php
protected function getLoader(): Loader { $event = LoaderEvent::create(new Loader()); $this->getEventManager()->dispatch($event); return $event->getResultLoader(); }
[ "protected", "function", "getLoader", "(", ")", ":", "Loader", "{", "$", "event", "=", "LoaderEvent", "::", "create", "(", "new", "Loader", "(", ")", ")", ";", "$", "this", "->", "getEventManager", "(", ")", "->", "dispatch", "(", "$", "event", ")", ...
Create the template loader. @return \WyriHaximus\TwigView\Lib\Twig\Loader
[ "Create", "the", "template", "loader", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/View/TwigView.php#L156-L162
43,248
WyriHaximus/TwigView
src/Lib/Twig/Loader.php
Loader.isFresh
public function isFresh($name, $time): bool { $name = $this->resolveFileName($name); return filemtime($name) < $time; }
php
public function isFresh($name, $time): bool { $name = $this->resolveFileName($name); return filemtime($name) < $time; }
[ "public", "function", "isFresh", "(", "$", "name", ",", "$", "time", ")", ":", "bool", "{", "$", "name", "=", "$", "this", "->", "resolveFileName", "(", "$", "name", ")", ";", "return", "filemtime", "(", "$", "name", ")", "<", "$", "time", ";", "...
Check if template is still fresh. @param string $name Template. @param int $time Timestamp. @return bool
[ "Check", "if", "template", "is", "still", "fresh", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Loader.php#L80-L85
43,249
WyriHaximus/TwigView
src/Lib/Twig/Loader.php
Loader.resolveFileName
private function resolveFileName($name): string { $filename = $this->getFilename($name); if ($filename === false) { throw new LoaderError(sprintf('Template "%s" is not defined.', $name)); } return $filename; }
php
private function resolveFileName($name): string { $filename = $this->getFilename($name); if ($filename === false) { throw new LoaderError(sprintf('Template "%s" is not defined.', $name)); } return $filename; }
[ "private", "function", "resolveFileName", "(", "$", "name", ")", ":", "string", "{", "$", "filename", "=", "$", "this", "->", "getFilename", "(", "$", "name", ")", ";", "if", "(", "$", "filename", "===", "false", ")", "{", "throw", "new", "LoaderError"...
Resolve template name to filename. @param string $name Template. @throws \Twig\Error\LoaderError Thrown when template file isn't found. @return string
[ "Resolve", "template", "name", "to", "filename", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Loader.php#L113-L121
43,250
WyriHaximus/TwigView
src/Lib/Twig/Loader.php
Loader.getFilename
private function getFilename($name) { if (file_exists($name)) { return $name; } [$plugin, $file] = pluginSplit($name); foreach ([null, $plugin] as $scope) { $paths = $this->getPaths($scope); foreach ($paths as $path) { $filePath = $path . $file; if (is_file($filePath)) { return $filePath; } $filePath = $path . $file . TwigView::EXT; if (is_file($filePath)) { return $filePath; } } } return false; }
php
private function getFilename($name) { if (file_exists($name)) { return $name; } [$plugin, $file] = pluginSplit($name); foreach ([null, $plugin] as $scope) { $paths = $this->getPaths($scope); foreach ($paths as $path) { $filePath = $path . $file; if (is_file($filePath)) { return $filePath; } $filePath = $path . $file . TwigView::EXT; if (is_file($filePath)) { return $filePath; } } } return false; }
[ "private", "function", "getFilename", "(", "$", "name", ")", "{", "if", "(", "file_exists", "(", "$", "name", ")", ")", "{", "return", "$", "name", ";", "}", "[", "$", "plugin", ",", "$", "file", "]", "=", "pluginSplit", "(", "$", "name", ")", ";...
Get template filename. @param string $name Template. @return string|false
[ "Get", "template", "filename", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Loader.php#L131-L154
43,251
TransbankDevelopers/transbank-sdk-php
lib/onepay/OnepayBase.php
OnepayBase.setCurrentIntegrationType
public static function setCurrentIntegrationType($type) { if (!self::integrationTypes()[$type]) { $integrationTypes = array_keys(self::integrationTypes()); $integrationTypesAsString = join($integrationTypes, ", "); throw new \Exception('Invalid integration type, valid values are: ' . $integrationTypesAsString); } self::$integrationType = $type; }
php
public static function setCurrentIntegrationType($type) { if (!self::integrationTypes()[$type]) { $integrationTypes = array_keys(self::integrationTypes()); $integrationTypesAsString = join($integrationTypes, ", "); throw new \Exception('Invalid integration type, valid values are: ' . $integrationTypesAsString); } self::$integrationType = $type; }
[ "public", "static", "function", "setCurrentIntegrationType", "(", "$", "type", ")", "{", "if", "(", "!", "self", "::", "integrationTypes", "(", ")", "[", "$", "type", "]", ")", "{", "$", "integrationTypes", "=", "array_keys", "(", "self", "::", "integratio...
Set the integration type
[ "Set", "the", "integration", "type" ]
d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8
https://github.com/TransbankDevelopers/transbank-sdk-php/blob/d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8/lib/onepay/OnepayBase.php#L192-L200
43,252
TransbankDevelopers/transbank-sdk-php
lib/onepay/Item.php
Item.setQuantity
public function setQuantity($quantity) { if (!is_integer($quantity)) { throw new \Exception ("quantity must be an Integer"); } if ($quantity < 0) { throw new \Exception ("quantity cannot be less than zero"); } $this->quantity = $quantity; }
php
public function setQuantity($quantity) { if (!is_integer($quantity)) { throw new \Exception ("quantity must be an Integer"); } if ($quantity < 0) { throw new \Exception ("quantity cannot be less than zero"); } $this->quantity = $quantity; }
[ "public", "function", "setQuantity", "(", "$", "quantity", ")", "{", "if", "(", "!", "is_integer", "(", "$", "quantity", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"quantity must be an Integer\"", ")", ";", "}", "if", "(", "$", "quantity", ...
Set the quantity for an instance of Item
[ "Set", "the", "quantity", "for", "an", "instance", "of", "Item" ]
d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8
https://github.com/TransbankDevelopers/transbank-sdk-php/blob/d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8/lib/onepay/Item.php#L53-L61
43,253
TransbankDevelopers/transbank-sdk-php
lib/onepay/Item.php
Item.setAdditionalData
public function setAdditionalData($additionalData) { if (is_null($additionalData)) { $additionalData = ""; } if (!is_string($additionalData)) { throw new \Exception ("Additional Data must be a String"); } $this->additionalData = $additionalData; }
php
public function setAdditionalData($additionalData) { if (is_null($additionalData)) { $additionalData = ""; } if (!is_string($additionalData)) { throw new \Exception ("Additional Data must be a String"); } $this->additionalData = $additionalData; }
[ "public", "function", "setAdditionalData", "(", "$", "additionalData", ")", "{", "if", "(", "is_null", "(", "$", "additionalData", ")", ")", "{", "$", "additionalData", "=", "\"\"", ";", "}", "if", "(", "!", "is_string", "(", "$", "additionalData", ")", ...
Set the additional data for an instance of Item
[ "Set", "the", "additional", "data", "for", "an", "instance", "of", "Item" ]
d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8
https://github.com/TransbankDevelopers/transbank-sdk-php/blob/d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8/lib/onepay/Item.php#L87-L95
43,254
yangqi/Htmldom
src/Yangqi/Htmldom/Htmldom.php
Htmldom.load_file
public function load_file() { $args = func_get_args(); $this->load(call_user_func_array('file_get_contents', $args), true); // Throw an error if we can't properly load the dom. if (($error=error_get_last())!==null) { $this->clear(); return false; } }
php
public function load_file() { $args = func_get_args(); $this->load(call_user_func_array('file_get_contents', $args), true); // Throw an error if we can't properly load the dom. if (($error=error_get_last())!==null) { $this->clear(); return false; } }
[ "public", "function", "load_file", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "this", "->", "load", "(", "call_user_func_array", "(", "'file_get_contents'", ",", "$", "args", ")", ",", "true", ")", ";", "// Throw an error if we can...
load html from file
[ "load", "html", "from", "file" ]
e6c0c6eb3c5c5855708ae155569fab7f7fba95c2
https://github.com/yangqi/Htmldom/blob/e6c0c6eb3c5c5855708ae155569fab7f7fba95c2/src/Yangqi/Htmldom/Htmldom.php#L178-L187
43,255
yangqi/Htmldom
src/Yangqi/Htmldom/Htmldom.php
Htmldom.find
public function find($selector, $idx=null, $lowercase=false) { return $this->root->find($selector, $idx, $lowercase); }
php
public function find($selector, $idx=null, $lowercase=false) { return $this->root->find($selector, $idx, $lowercase); }
[ "public", "function", "find", "(", "$", "selector", ",", "$", "idx", "=", "null", ",", "$", "lowercase", "=", "false", ")", "{", "return", "$", "this", "->", "root", "->", "find", "(", "$", "selector", ",", "$", "idx", ",", "$", "lowercase", ")", ...
Paperg - allow us to specify that we want case insensitive testing of the value of the selector.
[ "Paperg", "-", "allow", "us", "to", "specify", "that", "we", "want", "case", "insensitive", "testing", "of", "the", "value", "of", "the", "selector", "." ]
e6c0c6eb3c5c5855708ae155569fab7f7fba95c2
https://github.com/yangqi/Htmldom/blob/e6c0c6eb3c5c5855708ae155569fab7f7fba95c2/src/Yangqi/Htmldom/Htmldom.php#L273-L276
43,256
yangqi/Htmldom
src/Yangqi/Htmldom/Htmldom.php
Htmldom.as_text_node
protected function as_text_node($tag) { $node = new Htmldomnode($this); ++$this->cursor; $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>'; $this->link_nodes($node, false); $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next return true; }
php
protected function as_text_node($tag) { $node = new Htmldomnode($this); ++$this->cursor; $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>'; $this->link_nodes($node, false); $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next return true; }
[ "protected", "function", "as_text_node", "(", "$", "tag", ")", "{", "$", "node", "=", "new", "Htmldomnode", "(", "$", "this", ")", ";", "++", "$", "this", "->", "cursor", ";", "$", "node", "->", "_", "[", "HDOM_INFO_TEXT", "]", "=", "'</'", ".", "$...
as a text node
[ "as", "a", "text", "node" ]
e6c0c6eb3c5c5855708ae155569fab7f7fba95c2
https://github.com/yangqi/Htmldom/blob/e6c0c6eb3c5c5855708ae155569fab7f7fba95c2/src/Yangqi/Htmldom/Htmldom.php#L698-L706
43,257
craftcms/commerce-stripe
src/services/Invoices.php
Invoices.getSubscriptionInvoices
public function getSubscriptionInvoices(int $subscriptionId): array { $results = $this->_createInvoiceQuery() ->where(['subscriptionId' => $subscriptionId]) ->orderBy(['dateCreated' => SORT_DESC]) ->all(); $invoices = []; foreach ($results as $result) { $result['invoiceData'] = Json::decodeIfJson($result['invoiceData']); $invoices[] = new Invoice($result); } return $invoices; }
php
public function getSubscriptionInvoices(int $subscriptionId): array { $results = $this->_createInvoiceQuery() ->where(['subscriptionId' => $subscriptionId]) ->orderBy(['dateCreated' => SORT_DESC]) ->all(); $invoices = []; foreach ($results as $result) { $result['invoiceData'] = Json::decodeIfJson($result['invoiceData']); $invoices[] = new Invoice($result); } return $invoices; }
[ "public", "function", "getSubscriptionInvoices", "(", "int", "$", "subscriptionId", ")", ":", "array", "{", "$", "results", "=", "$", "this", "->", "_createInvoiceQuery", "(", ")", "->", "where", "(", "[", "'subscriptionId'", "=>", "$", "subscriptionId", "]", ...
Returns a customer by gateway and user id. @param int $subscriptionId The subscription id. @return Invoice[]
[ "Returns", "a", "customer", "by", "gateway", "and", "user", "id", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/services/Invoices.php#L76-L91
43,258
craftcms/commerce-stripe
src/services/Invoices.php
Invoices.getInvoiceByReference
public function getInvoiceByReference(string $reference) { $invoiceRow = $this->_createInvoiceQuery() ->where(['reference' => $reference]) ->one(); if ($invoiceRow) { return new Invoice($invoiceRow); } return null; }
php
public function getInvoiceByReference(string $reference) { $invoiceRow = $this->_createInvoiceQuery() ->where(['reference' => $reference]) ->one(); if ($invoiceRow) { return new Invoice($invoiceRow); } return null; }
[ "public", "function", "getInvoiceByReference", "(", "string", "$", "reference", ")", "{", "$", "invoiceRow", "=", "$", "this", "->", "_createInvoiceQuery", "(", ")", "->", "where", "(", "[", "'reference'", "=>", "$", "reference", "]", ")", "->", "one", "("...
Get an invoice from the database by the invoice reference number. Returns null if not found. @param string $reference @return Invoice|null
[ "Get", "an", "invoice", "from", "the", "database", "by", "the", "invoice", "reference", "number", ".", "Returns", "null", "if", "not", "found", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/services/Invoices.php#L99-L110
43,259
craftcms/commerce-stripe
src/services/Customers.php
Customers.getCustomer
public function getCustomer(int $gatewayId, User $user): Customer { $result = $this->_createCustomerQuery() ->where(['userId' => $user->id, 'gatewayId' => $gatewayId]) ->one(); if ($result !== null) { return new Customer($result); } Stripe::setApiKey(Craft::parseEnv(Commerce::getInstance()->getGateways()->getGatewayById($gatewayId)->apiKey)); Stripe::setAppInfo(StripePlugin::getInstance()->name, StripePlugin::getInstance()->version, StripePlugin::getInstance()->documentationUrl); Stripe::setApiVersion(Gateway::STRIPE_API_VERSION); /** @var StripeCustomer $stripeCustomer */ $stripeCustomer = StripeCustomer::create([ 'description' => Craft::t('commerce-stripe', 'Customer for Craft user with ID {id}', ['id' => $user->id]), 'email' => $user->email ]); $customer = new Customer([ 'userId' => $user->id, 'gatewayId' => $gatewayId, 'reference' => $stripeCustomer->id, 'response' => $stripeCustomer->jsonSerialize() ]); if (!$this->saveCustomer($customer)) { throw new CustomerException('Could not save customer: ' . implode(', ', $customer->getErrorSummary(true))); } return $customer; }
php
public function getCustomer(int $gatewayId, User $user): Customer { $result = $this->_createCustomerQuery() ->where(['userId' => $user->id, 'gatewayId' => $gatewayId]) ->one(); if ($result !== null) { return new Customer($result); } Stripe::setApiKey(Craft::parseEnv(Commerce::getInstance()->getGateways()->getGatewayById($gatewayId)->apiKey)); Stripe::setAppInfo(StripePlugin::getInstance()->name, StripePlugin::getInstance()->version, StripePlugin::getInstance()->documentationUrl); Stripe::setApiVersion(Gateway::STRIPE_API_VERSION); /** @var StripeCustomer $stripeCustomer */ $stripeCustomer = StripeCustomer::create([ 'description' => Craft::t('commerce-stripe', 'Customer for Craft user with ID {id}', ['id' => $user->id]), 'email' => $user->email ]); $customer = new Customer([ 'userId' => $user->id, 'gatewayId' => $gatewayId, 'reference' => $stripeCustomer->id, 'response' => $stripeCustomer->jsonSerialize() ]); if (!$this->saveCustomer($customer)) { throw new CustomerException('Could not save customer: ' . implode(', ', $customer->getErrorSummary(true))); } return $customer; }
[ "public", "function", "getCustomer", "(", "int", "$", "gatewayId", ",", "User", "$", "user", ")", ":", "Customer", "{", "$", "result", "=", "$", "this", "->", "_createCustomerQuery", "(", ")", "->", "where", "(", "[", "'userId'", "=>", "$", "user", "->...
Returns a customer by gateway and user @param int $gatewayId The stripe gateway @param User $user The user @return Customer @throws CustomerException
[ "Returns", "a", "customer", "by", "gateway", "and", "user" ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/services/Customers.php#L44-L76
43,260
craftcms/commerce-stripe
src/services/Customers.php
Customers.deleteCustomerById
public function deleteCustomerById($id): bool { $record = CustomerRecord::findOne($id); if ($record) { return (bool)$record->delete(); } return false; }
php
public function deleteCustomerById($id): bool { $record = CustomerRecord::findOne($id); if ($record) { return (bool)$record->delete(); } return false; }
[ "public", "function", "deleteCustomerById", "(", "$", "id", ")", ":", "bool", "{", "$", "record", "=", "CustomerRecord", "::", "findOne", "(", "$", "id", ")", ";", "if", "(", "$", "record", ")", "{", "return", "(", "bool", ")", "$", "record", "->", ...
Delete a customer by it's id. @param int $id The id @return bool @throws \Throwable in case something went wrong when deleting.
[ "Delete", "a", "customer", "by", "it", "s", "id", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/services/Customers.php#L126-L135
43,261
craftcms/commerce-stripe
src/models/Plan.php
Plan.isOnSamePaymentCycleAs
public function isOnSamePaymentCycleAs(Plan $plan): bool { $thisPlanData = Json::decode($this->planData); $otherPlanData = Json::decode($plan->planData); return $thisPlanData['plan']['interval'] === $otherPlanData['plan']['interval'] && $thisPlanData['plan']['interval_count'] === $otherPlanData['plan']['interval_count']; }
php
public function isOnSamePaymentCycleAs(Plan $plan): bool { $thisPlanData = Json::decode($this->planData); $otherPlanData = Json::decode($plan->planData); return $thisPlanData['plan']['interval'] === $otherPlanData['plan']['interval'] && $thisPlanData['plan']['interval_count'] === $otherPlanData['plan']['interval_count']; }
[ "public", "function", "isOnSamePaymentCycleAs", "(", "Plan", "$", "plan", ")", ":", "bool", "{", "$", "thisPlanData", "=", "Json", "::", "decode", "(", "$", "this", "->", "planData", ")", ";", "$", "otherPlanData", "=", "Json", "::", "decode", "(", "$", ...
Returns true if this plan is on the same payment cycle as another plan. @param Plan $plan @return bool
[ "Returns", "true", "if", "this", "plan", "is", "on", "the", "same", "payment", "cycle", "as", "another", "plan", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/models/Plan.php#L37-L43
43,262
craftcms/commerce-stripe
src/migrations/Install.php
Install._convertGateways
private function _convertGateways() { $gateways = (new Query()) ->select(['id', 'settings']) ->where(['type' => 'craft\\commerce\\gateways\\Stripe']) ->from(['{{%commerce_gateways}}']) ->all(); $dbConnection = Craft::$app->getDb(); foreach ($gateways as $gateway) { $settings = Json::decodeIfJson($gateway['settings']); if ($settings && isset($settings['includeReceiptEmailInRequests'])) { $settings['sendReceiptEmail'] = $settings['includeReceiptEmailInRequests']; unset($settings['includeReceiptEmailInRequests']); } else { $settings = []; } $settings = Json::encode($settings); $values = [ 'type' => Gateway::class, 'settings' => $settings ]; $dbConnection->createCommand() ->update('{{%commerce_gateways}}', $values, ['id' => $gateway['id']]) ->execute(); } }
php
private function _convertGateways() { $gateways = (new Query()) ->select(['id', 'settings']) ->where(['type' => 'craft\\commerce\\gateways\\Stripe']) ->from(['{{%commerce_gateways}}']) ->all(); $dbConnection = Craft::$app->getDb(); foreach ($gateways as $gateway) { $settings = Json::decodeIfJson($gateway['settings']); if ($settings && isset($settings['includeReceiptEmailInRequests'])) { $settings['sendReceiptEmail'] = $settings['includeReceiptEmailInRequests']; unset($settings['includeReceiptEmailInRequests']); } else { $settings = []; } $settings = Json::encode($settings); $values = [ 'type' => Gateway::class, 'settings' => $settings ]; $dbConnection->createCommand() ->update('{{%commerce_gateways}}', $values, ['id' => $gateway['id']]) ->execute(); } }
[ "private", "function", "_convertGateways", "(", ")", "{", "$", "gateways", "=", "(", "new", "Query", "(", ")", ")", "->", "select", "(", "[", "'id'", ",", "'settings'", "]", ")", "->", "where", "(", "[", "'type'", "=>", "'craft\\\\commerce\\\\gateways\\\\S...
Converts any old school Stripe gateways to this one
[ "Converts", "any", "old", "school", "Stripe", "gateways", "to", "this", "one" ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/migrations/Install.php#L90-L122
43,263
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._buildRequestPaymentSource
private function _buildRequestPaymentSource(Transaction $transaction, Payment $paymentForm, array $request): Source { // For 3D secure, make sure to set the redirect URL and the metadata flag, so we can catch it later. if ($paymentForm->threeDSecure) { unset($request['description'], $request['receipt_email']); $request['type'] = 'three_d_secure'; $request['three_d_secure'] = [ 'card' => $paymentForm->token ]; $request['redirect'] = [ 'return_url' => UrlHelper::actionUrl('commerce/payments/complete-payment', ['commerceTransactionId' => $transaction->id, 'commerceTransactionHash' => $transaction->hash]) ]; $request['metadata']['three_d_secure_flow'] = true; return Source::create($request); } if ($paymentForm->token) { $paymentForm->token = $this->_normalizePaymentToken((string)$paymentForm->token); /** @var Source $source */ $source = Source::retrieve($paymentForm->token); // If this required 3D secure, let's set the flag for it and repeat if (!empty($source->card->three_d_secure) && $source->card->three_d_secure == 'required') { $paymentForm->threeDSecure = true; return $this->_buildRequestPaymentSource($transaction, $paymentForm, $request); } return $source; } throw new PaymentException(Craft::t('commerce-stripe', 'Cannot process the payment at this time')); }
php
private function _buildRequestPaymentSource(Transaction $transaction, Payment $paymentForm, array $request): Source { // For 3D secure, make sure to set the redirect URL and the metadata flag, so we can catch it later. if ($paymentForm->threeDSecure) { unset($request['description'], $request['receipt_email']); $request['type'] = 'three_d_secure'; $request['three_d_secure'] = [ 'card' => $paymentForm->token ]; $request['redirect'] = [ 'return_url' => UrlHelper::actionUrl('commerce/payments/complete-payment', ['commerceTransactionId' => $transaction->id, 'commerceTransactionHash' => $transaction->hash]) ]; $request['metadata']['three_d_secure_flow'] = true; return Source::create($request); } if ($paymentForm->token) { $paymentForm->token = $this->_normalizePaymentToken((string)$paymentForm->token); /** @var Source $source */ $source = Source::retrieve($paymentForm->token); // If this required 3D secure, let's set the flag for it and repeat if (!empty($source->card->three_d_secure) && $source->card->three_d_secure == 'required') { $paymentForm->threeDSecure = true; return $this->_buildRequestPaymentSource($transaction, $paymentForm, $request); } return $source; } throw new PaymentException(Craft::t('commerce-stripe', 'Cannot process the payment at this time')); }
[ "private", "function", "_buildRequestPaymentSource", "(", "Transaction", "$", "transaction", ",", "Payment", "$", "paymentForm", ",", "array", "$", "request", ")", ":", "Source", "{", "// For 3D secure, make sure to set the redirect URL and the metadata flag, so we can catch it...
Build a payment source for request. @param Transaction $transaction the transaction to be used as base @param Payment $paymentForm the payment form @param array $request the request data @return Source @throws PaymentException if unexpected payment information encountered
[ "Build", "a", "payment", "source", "for", "request", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1001-L1039
43,264
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._createPaymentResponseFromError
private function _createPaymentResponseFromError(\Exception $exception): PaymentResponse { if ($exception instanceof CardError) { $body = $exception->getJsonBody(); $data = $body; $data['code'] = $body['error']['code']; $data['message'] = $body['error']['message']; $data['id'] = $body['error']['charge']; } else if ($exception instanceof Base) { // So it's not a card being declined but something else. ¯\_(ツ)_/¯ $body = $exception->getJsonBody(); $data = $body; $data['id'] = null; $data['message'] = $body['error']['message'] ?? $exception->getMessage(); $data['code'] = $body['error']['code'] ?? $body['error']['type'] ?? $exception->getStripeCode(); } else { throw $exception; } return new PaymentResponse($data); }
php
private function _createPaymentResponseFromError(\Exception $exception): PaymentResponse { if ($exception instanceof CardError) { $body = $exception->getJsonBody(); $data = $body; $data['code'] = $body['error']['code']; $data['message'] = $body['error']['message']; $data['id'] = $body['error']['charge']; } else if ($exception instanceof Base) { // So it's not a card being declined but something else. ¯\_(ツ)_/¯ $body = $exception->getJsonBody(); $data = $body; $data['id'] = null; $data['message'] = $body['error']['message'] ?? $exception->getMessage(); $data['code'] = $body['error']['code'] ?? $body['error']['type'] ?? $exception->getStripeCode(); } else { throw $exception; } return new PaymentResponse($data); }
[ "private", "function", "_createPaymentResponseFromError", "(", "\\", "Exception", "$", "exception", ")", ":", "PaymentResponse", "{", "if", "(", "$", "exception", "instanceof", "CardError", ")", "{", "$", "body", "=", "$", "exception", "->", "getJsonBody", "(", ...
Create a Response object from an Exception. @param \Exception $exception @return PaymentResponse @throws \Exception if not a Stripe exception
[ "Create", "a", "Response", "object", "from", "an", "Exception", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1063-L1083
43,265
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._createSubscriptionPayment
private function _createSubscriptionPayment(array $data, Currency $currency): SubscriptionPayment { $payment = new SubscriptionPayment([ 'paymentAmount' => $data['amount_due'] / (10 ** $currency->minorUnit), 'paymentCurrency' => $currency, 'paymentDate' => $data['date'], 'paymentReference' => $data['charge'], 'paid' => $data['paid'], 'response' => Json::encode($data) ]); return $payment; }
php
private function _createSubscriptionPayment(array $data, Currency $currency): SubscriptionPayment { $payment = new SubscriptionPayment([ 'paymentAmount' => $data['amount_due'] / (10 ** $currency->minorUnit), 'paymentCurrency' => $currency, 'paymentDate' => $data['date'], 'paymentReference' => $data['charge'], 'paid' => $data['paid'], 'response' => Json::encode($data) ]); return $payment; }
[ "private", "function", "_createSubscriptionPayment", "(", "array", "$", "data", ",", "Currency", "$", "currency", ")", ":", "SubscriptionPayment", "{", "$", "payment", "=", "new", "SubscriptionPayment", "(", "[", "'paymentAmount'", "=>", "$", "data", "[", "'amou...
Create a subscription payment model from invoice. @param array $data @param Currency $currency the currency used for payment @return SubscriptionPayment
[ "Create", "a", "subscription", "payment", "model", "from", "invoice", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1093-L1105
43,266
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._handleInvoiceCreated
private function _handleInvoiceCreated(array $data) { $stripeInvoice = $data['data']['object']; if ($this->hasEventHandlers(self::EVENT_CREATE_INVOICE)) { $this->trigger(self::EVENT_CREATE_INVOICE, new CreateInvoiceEvent([ 'invoiceData' => $stripeInvoice ])); } $canBePaid = empty($stripeInvoice['paid']) && $stripeInvoice['billing'] === 'charge_automatically'; if (StripePlugin::getInstance()->getSettings()->chargeInvoicesImmediately && $canBePaid) { /** @var StripeInvoice $invoice */ $invoice = StripeInvoice::retrieve($stripeInvoice['id']); $invoice->pay(); } }
php
private function _handleInvoiceCreated(array $data) { $stripeInvoice = $data['data']['object']; if ($this->hasEventHandlers(self::EVENT_CREATE_INVOICE)) { $this->trigger(self::EVENT_CREATE_INVOICE, new CreateInvoiceEvent([ 'invoiceData' => $stripeInvoice ])); } $canBePaid = empty($stripeInvoice['paid']) && $stripeInvoice['billing'] === 'charge_automatically'; if (StripePlugin::getInstance()->getSettings()->chargeInvoicesImmediately && $canBePaid) { /** @var StripeInvoice $invoice */ $invoice = StripeInvoice::retrieve($stripeInvoice['id']); $invoice->pay(); } }
[ "private", "function", "_handleInvoiceCreated", "(", "array", "$", "data", ")", "{", "$", "stripeInvoice", "=", "$", "data", "[", "'data'", "]", "[", "'object'", "]", ";", "if", "(", "$", "this", "->", "hasEventHandlers", "(", "self", "::", "EVENT_CREATE_I...
Handle a created invoice. @param array $data
[ "Handle", "a", "created", "invoice", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1210-L1227
43,267
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._handlePlanEvent
private function _handlePlanEvent(array $data) { $planService = Commerce::getInstance()->getPlans(); if ($data['type'] == 'plan.deleted') { $plan = $planService->getPlanByReference($data['data']['object']['id']); if ($plan) { $planService->archivePlanById($plan->id); Craft::warning($plan->name . ' was archived because the corresponding plan was deleted on Stripe. (event "' . $data['id'] . '")', 'stripe'); } } }
php
private function _handlePlanEvent(array $data) { $planService = Commerce::getInstance()->getPlans(); if ($data['type'] == 'plan.deleted') { $plan = $planService->getPlanByReference($data['data']['object']['id']); if ($plan) { $planService->archivePlanById($plan->id); Craft::warning($plan->name . ' was archived because the corresponding plan was deleted on Stripe. (event "' . $data['id'] . '")', 'stripe'); } } }
[ "private", "function", "_handlePlanEvent", "(", "array", "$", "data", ")", "{", "$", "planService", "=", "Commerce", "::", "getInstance", "(", ")", "->", "getPlans", "(", ")", ";", "if", "(", "$", "data", "[", "'type'", "]", "==", "'plan.deleted'", ")", ...
Handle Plan events @param array $data @throws \yii\base\InvalidConfigException If plan not
[ "Handle", "Plan", "events" ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1276-L1288
43,268
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._getStripeCustomer
private function _getStripeCustomer(int $userId): Customer { try { $user = Craft::$app->getUsers()->getUserById($userId); $customers = StripePlugin::getInstance()->getCustomers(); $customer = $customers->getCustomer($this->id, $user); return Customer::retrieve($customer->reference); } catch (\Exception $exception) { throw new CustomerException('Could not fetch Stripe customer: ' . $exception->getMessage()); } }
php
private function _getStripeCustomer(int $userId): Customer { try { $user = Craft::$app->getUsers()->getUserById($userId); $customers = StripePlugin::getInstance()->getCustomers(); $customer = $customers->getCustomer($this->id, $user); return Customer::retrieve($customer->reference); } catch (\Exception $exception) { throw new CustomerException('Could not fetch Stripe customer: ' . $exception->getMessage()); } }
[ "private", "function", "_getStripeCustomer", "(", "int", "$", "userId", ")", ":", "Customer", "{", "try", "{", "$", "user", "=", "Craft", "::", "$", "app", "->", "getUsers", "(", ")", "->", "getUserById", "(", "$", "userId", ")", ";", "$", "customers",...
Get the Stripe customer for a User. @param int $userId @return Customer @throws CustomerException if wasn't able to create or retrieve Stripe Customer.
[ "Get", "the", "Stripe", "customer", "for", "a", "User", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1360-L1370
43,269
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._normalizePaymentToken
private function _normalizePaymentToken(string $token = ''): string { if (StringHelper::substr($token, 0, 4) === 'tok_') { try { /** @var Source $tokenSource */ $tokenSource = Source::create([ 'type' => 'card', 'token' => $token ]); return $tokenSource->id; } catch (\Exception $exception) { Craft::error('Unable to normalize payment token: ' . $token . ', because ' . $exception->getMessage()); } } return $token; }
php
private function _normalizePaymentToken(string $token = ''): string { if (StringHelper::substr($token, 0, 4) === 'tok_') { try { /** @var Source $tokenSource */ $tokenSource = Source::create([ 'type' => 'card', 'token' => $token ]); return $tokenSource->id; } catch (\Exception $exception) { Craft::error('Unable to normalize payment token: ' . $token . ', because ' . $exception->getMessage()); } } return $token; }
[ "private", "function", "_normalizePaymentToken", "(", "string", "$", "token", "=", "''", ")", ":", "string", "{", "if", "(", "StringHelper", "::", "substr", "(", "$", "token", ",", "0", ",", "4", ")", "===", "'tok_'", ")", "{", "try", "{", "/** @var So...
Normalize one-time payment token to a source token, that may or may not be multi-use. @param string $token @return string
[ "Normalize", "one", "-", "time", "payment", "token", "to", "a", "source", "token", "that", "may", "or", "may", "not", "be", "multi", "-", "use", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1378-L1395
43,270
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._authorizeOrPurchase
private function _authorizeOrPurchase(Transaction $transaction, BasePaymentForm $form, bool $capture = true): RequestResponseInterface { /** @var Payment $form */ $requestData = $this->_buildRequestData($transaction); $paymentSource = $this->_buildRequestPaymentSource($transaction, $form, $requestData); if ($paymentSource instanceof Source && $paymentSource->status === 'pending' && $paymentSource->flow === 'redirect') { // This should only happen for 3D secure payments. $response = $this->_createPaymentResponseFromApiResource($paymentSource); $response->setRedirectUrl($paymentSource->redirect->url); return $response; } $requestData['source'] = $paymentSource; if ($form->customer) { $requestData['customer'] = $form->customer; } $requestData['capture'] = $capture; try { $charge = Charge::create($requestData, ['idempotency_key' => $transaction->hash]); return $this->_createPaymentResponseFromApiResource($charge); } catch (\Exception $exception) { return $this->_createPaymentResponseFromError($exception); } }
php
private function _authorizeOrPurchase(Transaction $transaction, BasePaymentForm $form, bool $capture = true): RequestResponseInterface { /** @var Payment $form */ $requestData = $this->_buildRequestData($transaction); $paymentSource = $this->_buildRequestPaymentSource($transaction, $form, $requestData); if ($paymentSource instanceof Source && $paymentSource->status === 'pending' && $paymentSource->flow === 'redirect') { // This should only happen for 3D secure payments. $response = $this->_createPaymentResponseFromApiResource($paymentSource); $response->setRedirectUrl($paymentSource->redirect->url); return $response; } $requestData['source'] = $paymentSource; if ($form->customer) { $requestData['customer'] = $form->customer; } $requestData['capture'] = $capture; try { $charge = Charge::create($requestData, ['idempotency_key' => $transaction->hash]); return $this->_createPaymentResponseFromApiResource($charge); } catch (\Exception $exception) { return $this->_createPaymentResponseFromError($exception); } }
[ "private", "function", "_authorizeOrPurchase", "(", "Transaction", "$", "transaction", ",", "BasePaymentForm", "$", "form", ",", "bool", "$", "capture", "=", "true", ")", ":", "RequestResponseInterface", "{", "/** @var Payment $form */", "$", "requestData", "=", "$"...
Make an authorize or purchase request to Stripe @param Transaction $transaction the transaction on which this request is based @param BasePaymentForm $form payment form parameters @param bool $capture whether funds should be captured immediately, defaults to true. @return RequestResponseInterface @throws NotSupportedException if unrecognized currency specified for transaction @throws PaymentException if unexpected payment information provided. @throws \Exception if reasons
[ "Make", "an", "authorize", "or", "purchase", "request", "to", "Stripe" ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1409-L1438
43,271
craftcms/commerce-stripe
src/gateways/Gateway.php
Gateway._saveSubscriptionInvoice
private function _saveSubscriptionInvoice(array $stripeInvoice, Subscription $subscription): Invoice { $invoiceService = StripePlugin::getInstance()->getInvoices(); $invoice = $invoiceService->getInvoiceByReference($stripeInvoice['id']) ?: new Invoice(); $invoice->subscriptionId = $subscription->id; $invoice->reference = $stripeInvoice['id']; $invoice->invoiceData = $stripeInvoice; $invoiceService->saveInvoice($invoice); return $invoice; }
php
private function _saveSubscriptionInvoice(array $stripeInvoice, Subscription $subscription): Invoice { $invoiceService = StripePlugin::getInstance()->getInvoices(); $invoice = $invoiceService->getInvoiceByReference($stripeInvoice['id']) ?: new Invoice(); $invoice->subscriptionId = $subscription->id; $invoice->reference = $stripeInvoice['id']; $invoice->invoiceData = $stripeInvoice; $invoiceService->saveInvoice($invoice); return $invoice; }
[ "private", "function", "_saveSubscriptionInvoice", "(", "array", "$", "stripeInvoice", ",", "Subscription", "$", "subscription", ")", ":", "Invoice", "{", "$", "invoiceService", "=", "StripePlugin", "::", "getInstance", "(", ")", "->", "getInvoices", "(", ")", "...
Save a subscription invoice. @param $stripeInvoice @param $subscription @return Invoice
[ "Save", "a", "subscription", "invoice", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1447-L1457
43,272
craftcms/commerce-stripe
src/models/Customer.php
Customer.getGateway
public function getGateway() { if (null === $this->_gateway) { $this->_gateway = Commerce::getInstance()->getGateways()->getGatewayById($this->gatewayId); } return $this->_gateway; }
php
public function getGateway() { if (null === $this->_gateway) { $this->_gateway = Commerce::getInstance()->getGateways()->getGatewayById($this->gatewayId); } return $this->_gateway; }
[ "public", "function", "getGateway", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_gateway", ")", "{", "$", "this", "->", "_gateway", "=", "Commerce", "::", "getInstance", "(", ")", "->", "getGateways", "(", ")", "->", "getGatewayById", ...
Returns the gateway associated with this customer. @return GatewayInterface|null
[ "Returns", "the", "gateway", "associated", "with", "this", "customer", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/models/Customer.php#L98-L105
43,273
craftcms/commerce-stripe
src/controllers/DefaultController.php
DefaultController.actionFetchPlans
public function actionFetchPlans() { try { $this->requirePostRequest(); $this->requireAcceptsJson(); $request = Craft::$app->getRequest(); $gatewayId = $request->getRequiredBodyParam('gatewayId'); $gateway = Commerce::getInstance()->getGateways()->getGatewayById($gatewayId); if (!$gateway || !$gateway instanceof Gateway) { throw new BadRequestHttpException('That is not a valid gateway id.'); } return $this->asJson($gateway->getSubscriptionPlans()); } catch (\Throwable $e) { return $this->asErrorJson($e->getMessage()); } }
php
public function actionFetchPlans() { try { $this->requirePostRequest(); $this->requireAcceptsJson(); $request = Craft::$app->getRequest(); $gatewayId = $request->getRequiredBodyParam('gatewayId'); $gateway = Commerce::getInstance()->getGateways()->getGatewayById($gatewayId); if (!$gateway || !$gateway instanceof Gateway) { throw new BadRequestHttpException('That is not a valid gateway id.'); } return $this->asJson($gateway->getSubscriptionPlans()); } catch (\Throwable $e) { return $this->asErrorJson($e->getMessage()); } }
[ "public", "function", "actionFetchPlans", "(", ")", "{", "try", "{", "$", "this", "->", "requirePostRequest", "(", ")", ";", "$", "this", "->", "requireAcceptsJson", "(", ")", ";", "$", "request", "=", "Craft", "::", "$", "app", "->", "getRequest", "(", ...
Load Stripe Subscription plans for a gateway. @return Response
[ "Load", "Stripe", "Subscription", "plans", "for", "a", "gateway", "." ]
95795f5997cd4d57e3652ca12bfc3c15f182fb02
https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/controllers/DefaultController.php#L39-L57
43,274
rips/php-connector
src/Requests/BaseRequest.php
BaseRequest.handleResponse
protected function handleResponse(ResponseInterface $response) { $responseWrapper = new Response($response); $statusCode = (int) floor($response->getStatusCode() / 100); if ($statusCode === 4) { throw new ClientException($responseWrapper); } elseif ($statusCode === 5) { throw new ServerException($responseWrapper); } return $responseWrapper; }
php
protected function handleResponse(ResponseInterface $response) { $responseWrapper = new Response($response); $statusCode = (int) floor($response->getStatusCode() / 100); if ($statusCode === 4) { throw new ClientException($responseWrapper); } elseif ($statusCode === 5) { throw new ServerException($responseWrapper); } return $responseWrapper; }
[ "protected", "function", "handleResponse", "(", "ResponseInterface", "$", "response", ")", "{", "$", "responseWrapper", "=", "new", "Response", "(", "$", "response", ")", ";", "$", "statusCode", "=", "(", "int", ")", "floor", "(", "$", "response", "->", "g...
Handle response returned by Guzzle @param ResponseInterface $response @return Response @throws ClientException if status code starts with 4 @throws ServerException if status code starts with 5
[ "Handle", "response", "returned", "by", "Guzzle" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/BaseRequest.php#L34-L46
43,275
rips/php-connector
src/Requests/MaintenanceRequests.php
MaintenanceRequests.deleteCode
public function deleteCode(array $queryParams = []) { $response = $this->client->delete('/maintenance/code', [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
php
public function deleteCode(array $queryParams = []) { $response = $this->client->delete('/maintenance/code', [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
[ "public", "function", "deleteCode", "(", "array", "$", "queryParams", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "delete", "(", "'/maintenance/code'", ",", "[", "'query'", "=>", "$", "queryParams", ",", "]", ")", ...
Remove old and unused code from cloud. @param array $queryParams @return Response
[ "Remove", "old", "and", "unused", "code", "from", "cloud", "." ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/MaintenanceRequests.php#L15-L22
43,276
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.deleteById
public function deleteById($appId, $scanId, array $queryParams = []) { if (is_null($appId) || is_null($scanId)) { throw new LibException('appId or scanId is null'); } $response = $this->client->delete("{$this->uri($appId)}/{$scanId}", [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
php
public function deleteById($appId, $scanId, array $queryParams = []) { if (is_null($appId) || is_null($scanId)) { throw new LibException('appId or scanId is null'); } $response = $this->client->delete("{$this->uri($appId)}/{$scanId}", [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
[ "public", "function", "deleteById", "(", "$", "appId", ",", "$", "scanId", ",", "array", "$", "queryParams", "=", "[", "]", ")", "{", "if", "(", "is_null", "(", "$", "appId", ")", "||", "is_null", "(", "$", "scanId", ")", ")", "{", "throw", "new", ...
Delete a scan by id @param int $appId @param int $scanId @param array $queryParams @return Response
[ "Delete", "a", "scan", "by", "id" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L223-L234
43,277
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.blockUntilDone
public function blockUntilDone( $appId, $scanId, $waitTime = 0, $sleepTime = 5, array $queryParams = [] ) { for ($iteration = 0;; $iteration++) { $scanResponse = $this->getById($appId, $scanId, $queryParams); $scan = $scanResponse->getDecodedData(); if ((int) $scan->phase === 0 && (int) $scan->percent === 100) { return $scanResponse; } else if ($waitTime > 0 && $iteration > ($waitTime / $sleepTime)) { throw new \Exception('Scan did not finish before the defined wait time.'); } sleep($sleepTime); } throw new \Exception('blockUntilDone unexpected state'); }
php
public function blockUntilDone( $appId, $scanId, $waitTime = 0, $sleepTime = 5, array $queryParams = [] ) { for ($iteration = 0;; $iteration++) { $scanResponse = $this->getById($appId, $scanId, $queryParams); $scan = $scanResponse->getDecodedData(); if ((int) $scan->phase === 0 && (int) $scan->percent === 100) { return $scanResponse; } else if ($waitTime > 0 && $iteration > ($waitTime / $sleepTime)) { throw new \Exception('Scan did not finish before the defined wait time.'); } sleep($sleepTime); } throw new \Exception('blockUntilDone unexpected state'); }
[ "public", "function", "blockUntilDone", "(", "$", "appId", ",", "$", "scanId", ",", "$", "waitTime", "=", "0", ",", "$", "sleepTime", "=", "5", ",", "array", "$", "queryParams", "=", "[", "]", ")", "{", "for", "(", "$", "iteration", "=", "0", ";", ...
Block until scan is finished @param int $appId @param int $scanId @param int $waitTime - Optional time to wait, will wait indefinitely if 0 (default: 0) @param int $sleepTime - Time to wait between scan completion checks (default: 5) @param array $queryParams @return Response @throws \Exception if scan does not finish in time
[ "Block", "until", "scan", "is", "finished" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L247-L268
43,278
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.classes
public function classes() { if (is_null($this->classRequests)) { $this->classRequests = new ClassRequests($this->client); } return $this->classRequests; }
php
public function classes() { if (is_null($this->classRequests)) { $this->classRequests = new ClassRequests($this->client); } return $this->classRequests; }
[ "public", "function", "classes", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "classRequests", ")", ")", "{", "$", "this", "->", "classRequests", "=", "new", "ClassRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return", ...
Class requests accessor @return ClassRequests
[ "Class", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L275-L282
43,279
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.comparisons
public function comparisons() { if (is_null($this->comparisonRequests)) { $this->comparisonRequests = new ComparisonRequests($this->client); } return $this->comparisonRequests; }
php
public function comparisons() { if (is_null($this->comparisonRequests)) { $this->comparisonRequests = new ComparisonRequests($this->client); } return $this->comparisonRequests; }
[ "public", "function", "comparisons", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "comparisonRequests", ")", ")", "{", "$", "this", "->", "comparisonRequests", "=", "new", "ComparisonRequests", "(", "$", "this", "->", "client", ")", ";", ...
Comparison requests accessor @return ComparisonRequests
[ "Comparison", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L289-L296
43,280
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.concats
public function concats() { if (is_null($this->concatRequests)) { $this->concatRequests = new ConcatRequests($this->client); } return $this->concatRequests; }
php
public function concats() { if (is_null($this->concatRequests)) { $this->concatRequests = new ConcatRequests($this->client); } return $this->concatRequests; }
[ "public", "function", "concats", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "concatRequests", ")", ")", "{", "$", "this", "->", "concatRequests", "=", "new", "ConcatRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return",...
Concat requests accessor @return ConcatRequests
[ "Concat", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L303-L310
43,281
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.exports
public function exports() { if (is_null($this->exportRequests)) { $this->exportRequests = new ExportRequests($this->client); } return $this->exportRequests; }
php
public function exports() { if (is_null($this->exportRequests)) { $this->exportRequests = new ExportRequests($this->client); } return $this->exportRequests; }
[ "public", "function", "exports", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "exportRequests", ")", ")", "{", "$", "this", "->", "exportRequests", "=", "new", "ExportRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return",...
Export requests accessor @return ExportRequests
[ "Export", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L317-L324
43,282
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.files
public function files() { if (is_null($this->fileRequests)) { $this->fileRequests = new FileRequests($this->client); } return $this->fileRequests; }
php
public function files() { if (is_null($this->fileRequests)) { $this->fileRequests = new FileRequests($this->client); } return $this->fileRequests; }
[ "public", "function", "files", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "fileRequests", ")", ")", "{", "$", "this", "->", "fileRequests", "=", "new", "FileRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return", "$", ...
File requests accessor @return FileRequests
[ "File", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L331-L338
43,283
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.functions
public function functions() { if (is_null($this->functionRequests)) { $this->functionRequests = new FunctionRequests($this->client); } return $this->functionRequests; }
php
public function functions() { if (is_null($this->functionRequests)) { $this->functionRequests = new FunctionRequests($this->client); } return $this->functionRequests; }
[ "public", "function", "functions", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "functionRequests", ")", ")", "{", "$", "this", "->", "functionRequests", "=", "new", "FunctionRequests", "(", "$", "this", "->", "client", ")", ";", "}", "...
Function requests accessor @return FunctionRequests
[ "Function", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L345-L352
43,284
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.issues
public function issues() { if (is_null($this->issueRequests)) { $this->issueRequests = new IssueRequests($this->client); } return $this->issueRequests; }
php
public function issues() { if (is_null($this->issueRequests)) { $this->issueRequests = new IssueRequests($this->client); } return $this->issueRequests; }
[ "public", "function", "issues", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "issueRequests", ")", ")", "{", "$", "this", "->", "issueRequests", "=", "new", "IssueRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return", "...
Issue requests accessor @return IssueRequests
[ "Issue", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L359-L366
43,285
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.processes
public function processes() { if (is_null($this->processRequests)) { $this->processRequests = new ProcessRequests($this->client); } return $this->processRequests; }
php
public function processes() { if (is_null($this->processRequests)) { $this->processRequests = new ProcessRequests($this->client); } return $this->processRequests; }
[ "public", "function", "processes", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "processRequests", ")", ")", "{", "$", "this", "->", "processRequests", "=", "new", "ProcessRequests", "(", "$", "this", "->", "client", ")", ";", "}", "ret...
Process requests accessor @return ProcessRequests
[ "Process", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L373-L380
43,286
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.sinks
public function sinks() { if (is_null($this->sinkRequests)) { $this->sinkRequests = new SinkRequests($this->client); } return $this->sinkRequests; }
php
public function sinks() { if (is_null($this->sinkRequests)) { $this->sinkRequests = new SinkRequests($this->client); } return $this->sinkRequests; }
[ "public", "function", "sinks", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "sinkRequests", ")", ")", "{", "$", "this", "->", "sinkRequests", "=", "new", "SinkRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return", "$", ...
Sink requests accessor @return SinkRequests
[ "Sink", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L387-L394
43,287
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.sources
public function sources() { if (is_null($this->sourceRequests)) { $this->sourceRequests = new SourceRequests($this->client); } return $this->sourceRequests; }
php
public function sources() { if (is_null($this->sourceRequests)) { $this->sourceRequests = new SourceRequests($this->client); } return $this->sourceRequests; }
[ "public", "function", "sources", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "sourceRequests", ")", ")", "{", "$", "this", "->", "sourceRequests", "=", "new", "SourceRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return",...
Source requests accessor @return SourceRequests
[ "Source", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L401-L408
43,288
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.entrypoints
public function entrypoints() { if (is_null($this->entrypointRequests)) { $this->entrypointRequests = new EntrypointRequests($this->client); } return $this->entrypointRequests; }
php
public function entrypoints() { if (is_null($this->entrypointRequests)) { $this->entrypointRequests = new EntrypointRequests($this->client); } return $this->entrypointRequests; }
[ "public", "function", "entrypoints", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "entrypointRequests", ")", ")", "{", "$", "this", "->", "entrypointRequests", "=", "new", "EntrypointRequests", "(", "$", "this", "->", "client", ")", ";", ...
Entrypoint requests accessor @return EntrypointRequests
[ "Entrypoint", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L415-L422
43,289
rips/php-connector
src/Requests/Application/ScanRequests.php
ScanRequests.libraries
public function libraries() { if (is_null($this->libraryRequests)) { $this->libraryRequests = new LibraryRequests($this->client); } return $this->libraryRequests; }
php
public function libraries() { if (is_null($this->libraryRequests)) { $this->libraryRequests = new LibraryRequests($this->client); } return $this->libraryRequests; }
[ "public", "function", "libraries", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "libraryRequests", ")", ")", "{", "$", "this", "->", "libraryRequests", "=", "new", "LibraryRequests", "(", "$", "this", "->", "client", ")", ";", "}", "ret...
Libraries requests accessor @return LibraryRequests
[ "Libraries", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L429-L436
43,290
rips/php-connector
src/Requests/StatusRequests.php
StatusRequests.getStatus
public function getStatus(array $queryParams = []) { $response = $this->client->get($this->uri(), [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
php
public function getStatus(array $queryParams = []) { $response = $this->client->get($this->uri(), [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
[ "public", "function", "getStatus", "(", "array", "$", "queryParams", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "uri", "(", ")", ",", "[", "'query'", "=>", "$", "queryParams", ",...
Get status info for the current session and API env. @param array $queryParams @return Response
[ "Get", "status", "info", "for", "the", "current", "session", "and", "API", "env", "." ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/StatusRequests.php#L26-L33
43,291
rips/php-connector
src/Requests/StatusRequests.php
StatusRequests.isLoggedIn
public function isLoggedIn() { $response = $this->client->get($this->uri()); try { $body = $this->handleResponse($response)->getDecodedData(); } catch (ClientException $exception) { return false; } return property_exists( $body, 'user' ); }
php
public function isLoggedIn() { $response = $this->client->get($this->uri()); try { $body = $this->handleResponse($response)->getDecodedData(); } catch (ClientException $exception) { return false; } return property_exists( $body, 'user' ); }
[ "public", "function", "isLoggedIn", "(", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "uri", "(", ")", ")", ";", "try", "{", "$", "body", "=", "$", "this", "->", "handleResponse", "(", "$", "re...
Checks if the user is logged with the given credentials @return boolean
[ "Checks", "if", "the", "user", "is", "logged", "with", "the", "given", "credentials" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/StatusRequests.php#L40-L54
43,292
rips/php-connector
src/Requests/Application/Scan/Issue/ReviewRequests.php
ReviewRequests.uri
protected function uri($appId, $scanId, $issueId = null, $reviewId = null) { if (is_null($issueId)) { return "/applications/{$appId}/scans/{$scanId}/issues/reviews/batches"; } return is_null($reviewId) ? "/applications/{$appId}/scans/{$scanId}/issues/{$issueId}/reviews" : "/applications/{$appId}/scans/{$scanId}/issues/{$issueId}/reviews/{$reviewId}"; }
php
protected function uri($appId, $scanId, $issueId = null, $reviewId = null) { if (is_null($issueId)) { return "/applications/{$appId}/scans/{$scanId}/issues/reviews/batches"; } return is_null($reviewId) ? "/applications/{$appId}/scans/{$scanId}/issues/{$issueId}/reviews" : "/applications/{$appId}/scans/{$scanId}/issues/{$issueId}/reviews/{$reviewId}"; }
[ "protected", "function", "uri", "(", "$", "appId", ",", "$", "scanId", ",", "$", "issueId", "=", "null", ",", "$", "reviewId", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "issueId", ")", ")", "{", "return", "\"/applications/{$appId}/scans/{$sc...
Build a uri for the request @param int $appId @param int $scanId @param int $issueId @param int $reviewId @return string
[ "Build", "a", "uri", "for", "the", "request" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/Issue/ReviewRequests.php#L26-L35
43,293
rips/php-connector
src/Requests/Application/Scan/Issue/ReviewRequests.php
ReviewRequests.types
public function types() { if (is_null($this->typeRequests)) { $this->typeRequests = new TypeRequests($this->client); } return $this->typeRequests; }
php
public function types() { if (is_null($this->typeRequests)) { $this->typeRequests = new TypeRequests($this->client); } return $this->typeRequests; }
[ "public", "function", "types", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "typeRequests", ")", ")", "{", "$", "this", "->", "typeRequests", "=", "new", "TypeRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return", "$", ...
Type requests accessor @return TypeRequests
[ "Type", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/Issue/ReviewRequests.php#L118-L125
43,294
rips/php-connector
src/Requests/Application/Scan/ExportRequests.php
ExportRequests.queuePdf
public function queuePdf($appId, $scanId, array $queryParams = []) { $response = $this->client->post($this->uri($appId, $scanId, 'pdfs') . '/queues', [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
php
public function queuePdf($appId, $scanId, array $queryParams = []) { $response = $this->client->post($this->uri($appId, $scanId, 'pdfs') . '/queues', [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
[ "public", "function", "queuePdf", "(", "$", "appId", ",", "$", "scanId", ",", "array", "$", "queryParams", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "uri", "(", "$", "appId", ...
Create a new pdf export on the queue @param int $appId @param int $scanId @param array $queryParams @return Response
[ "Create", "a", "new", "pdf", "export", "on", "the", "queue" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/ExportRequests.php#L69-L76
43,295
rips/php-connector
src/Requests/Application/Scan/ExportRequests.php
ExportRequests.getQueuedPdf
public function getQueuedPdf($appId, $scanId, $queueId, array $queryParams = []) { $response = $this->client->get($this->uri($appId, $scanId, 'pdfs') . '/queues/' . $queueId, [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
php
public function getQueuedPdf($appId, $scanId, $queueId, array $queryParams = []) { $response = $this->client->get($this->uri($appId, $scanId, 'pdfs') . '/queues/' . $queueId, [ 'query' => $queryParams, ]); return $this->handleResponse($response); }
[ "public", "function", "getQueuedPdf", "(", "$", "appId", ",", "$", "scanId", ",", "$", "queueId", ",", "array", "$", "queryParams", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "ur...
Get information about pdf export on queue @param $appId @param $scanId @param $queueId @param array $queryParams @return Response
[ "Get", "information", "about", "pdf", "export", "on", "queue" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/ExportRequests.php#L87-L94
43,296
rips/php-connector
src/Requests/Application/Scan/ExportRequests.php
ExportRequests.downloadQueuedPdf
public function downloadQueuedPdf($appId, $scanId, $queueId, $outFile, array $queryParams = []) { $response = $this->client->get($this->uri($appId, $scanId, 'pdfs') . '/queues/' . $queueId . '/downloads', [ 'sink' => $outFile, 'query' => $queryParams, ]); return $this->handleResponse($response); }
php
public function downloadQueuedPdf($appId, $scanId, $queueId, $outFile, array $queryParams = []) { $response = $this->client->get($this->uri($appId, $scanId, 'pdfs') . '/queues/' . $queueId . '/downloads', [ 'sink' => $outFile, 'query' => $queryParams, ]); return $this->handleResponse($response); }
[ "public", "function", "downloadQueuedPdf", "(", "$", "appId", ",", "$", "scanId", ",", "$", "queueId", ",", "$", "outFile", ",", "array", "$", "queryParams", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "("...
Download pdf export from queue @param $appId @param $scanId @param $queueId @param $outFile @param array $queryParams @return Response
[ "Download", "pdf", "export", "from", "queue" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/ExportRequests.php#L106-L114
43,297
rips/php-connector
src/Requests/ApplicationRequests.php
ApplicationRequests.acls
public function acls() { if (is_null($this->aclRequests)) { $this->aclRequests = new AclRequests($this->client); } return $this->aclRequests; }
php
public function acls() { if (is_null($this->aclRequests)) { $this->aclRequests = new AclRequests($this->client); } return $this->aclRequests; }
[ "public", "function", "acls", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "aclRequests", ")", ")", "{", "$", "this", "->", "aclRequests", "=", "new", "AclRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return", "$", "t...
ACL requests accessor @return Application\AclRequests
[ "ACL", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/ApplicationRequests.php#L152-L159
43,298
rips/php-connector
src/Requests/ApplicationRequests.php
ApplicationRequests.profiles
public function profiles() { if (is_null($this->profileRequests)) { $this->profileRequests = new ProfileRequests($this->client); } return $this->profileRequests; }
php
public function profiles() { if (is_null($this->profileRequests)) { $this->profileRequests = new ProfileRequests($this->client); } return $this->profileRequests; }
[ "public", "function", "profiles", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "profileRequests", ")", ")", "{", "$", "this", "->", "profileRequests", "=", "new", "ProfileRequests", "(", "$", "this", "->", "client", ")", ";", "}", "retu...
Profile requests accessor @return ProfileRequests
[ "Profile", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/ApplicationRequests.php#L166-L173
43,299
rips/php-connector
src/Requests/ApplicationRequests.php
ApplicationRequests.scans
public function scans() { if (is_null($this->scanRequests)) { $this->scanRequests = new ScanRequests($this->client); } return $this->scanRequests; }
php
public function scans() { if (is_null($this->scanRequests)) { $this->scanRequests = new ScanRequests($this->client); } return $this->scanRequests; }
[ "public", "function", "scans", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "scanRequests", ")", ")", "{", "$", "this", "->", "scanRequests", "=", "new", "ScanRequests", "(", "$", "this", "->", "client", ")", ";", "}", "return", "$", ...
Scan requests accessor @return ScanRequests
[ "Scan", "requests", "accessor" ]
8a6cbd600ca164f4f65248dad8d6af7a579cc2d9
https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/ApplicationRequests.php#L180-L187