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
14,800
JoffreyPoreeCoding/MongoDB-ODM
src/Iterator/GridFSDocumentIterator.php
GridFSDocumentIterator.next
public function next() { $this->position++; $this->generator->next(); $this->currentData = $this->generator->current(); }
php
public function next() { $this->position++; $this->generator->next(); $this->currentData = $this->generator->current(); }
[ "public", "function", "next", "(", ")", "{", "$", "this", "->", "position", "++", ";", "$", "this", "->", "generator", "->", "next", "(", ")", ";", "$", "this", "->", "currentData", "=", "$", "this", "->", "generator", "->", "current", "(", ")", ";", "}" ]
Moves forward to next element. @return void
[ "Moves", "forward", "to", "next", "element", "." ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Iterator/GridFSDocumentIterator.php#L30-L35
14,801
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php
ItemManager.removeStatus
public function removeStatus(ApiItemInterface $item, $status, $flush = false) { // BITMASK $currentBitmaskStatus = $item->getBitmaskStatus(); // if status is in bitmask, remove it if ($currentBitmaskStatus && $currentBitmaskStatus & $status) { $item->setBitmaskStatus($currentBitmaskStatus & ~$status); } if ($flush === true) { $this->em->flush(); } }
php
public function removeStatus(ApiItemInterface $item, $status, $flush = false) { // BITMASK $currentBitmaskStatus = $item->getBitmaskStatus(); // if status is in bitmask, remove it if ($currentBitmaskStatus && $currentBitmaskStatus & $status) { $item->setBitmaskStatus($currentBitmaskStatus & ~$status); } if ($flush === true) { $this->em->flush(); } }
[ "public", "function", "removeStatus", "(", "ApiItemInterface", "$", "item", ",", "$", "status", ",", "$", "flush", "=", "false", ")", "{", "// BITMASK", "$", "currentBitmaskStatus", "=", "$", "item", "->", "getBitmaskStatus", "(", ")", ";", "// if status is in bitmask, remove it", "if", "(", "$", "currentBitmaskStatus", "&&", "$", "currentBitmaskStatus", "&", "$", "status", ")", "{", "$", "item", "->", "setBitmaskStatus", "(", "$", "currentBitmaskStatus", "&", "~", "$", "status", ")", ";", "}", "if", "(", "$", "flush", "===", "true", ")", "{", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}", "}" ]
Converts status of an item @param ApiItemInterface $item @param int $status @param bool $flush
[ "Converts", "status", "of", "an", "item" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php#L271-L283
14,802
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php
ItemManager.findByIdAndLocale
public function findByIdAndLocale($id, $locale) { $item = $this->itemRepository->findByIdAndLocale($id, $locale); if ($item) { return $this->itemFactory->createApiEntity($item, $locale); } else { return null; } }
php
public function findByIdAndLocale($id, $locale) { $item = $this->itemRepository->findByIdAndLocale($id, $locale); if ($item) { return $this->itemFactory->createApiEntity($item, $locale); } else { return null; } }
[ "public", "function", "findByIdAndLocale", "(", "$", "id", ",", "$", "locale", ")", "{", "$", "item", "=", "$", "this", "->", "itemRepository", "->", "findByIdAndLocale", "(", "$", "id", ",", "$", "locale", ")", ";", "if", "(", "$", "item", ")", "{", "return", "$", "this", "->", "itemFactory", "->", "createApiEntity", "(", "$", "item", ",", "$", "locale", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Finds an item by id and locale @param int $id @param string $locale @return null|ApiItemInterface
[ "Finds", "an", "item", "by", "id", "and", "locale" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php#L312-L321
14,803
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php
ItemManager.setItemByProductData
protected function setItemByProductData($productData, ApiItemInterface $item, $locale) { $productId = $this->getProductId($productData); /** @var Product $product */ $product = $this->productRepository->find($productId); if (!$product) { throw new ProductNotFoundException(self::$productEntityName, $productId); } $item->setProduct($product); $translation = $product->getTranslation($locale); // when the product is not available in the current language choose the first translation you find // FIXME: should be changed when products have a language fallback // https://github.com/massiveart/POOL-ALPIN/issues/611 if (is_null($translation)) { if (count($product->getTranslations()) > 0) { $translation = $product->getTranslations()[0]; } else { throw new ProductException('Product ' . $product->getId() . ' has no translations!'); } } $this->setItemSupplier($item, $product); $item->setName($translation->getName()); $item->setDescription($translation->getLongDescription()); $item->setNumber($product->getNumber()); // set order unit if ($product->getOrderUnit()) { $item->setQuantityUnit($product->getOrderUnit()->getTranslation($locale)->getName()); } // TODO: get tax from product https://github.com/massiveart/POOL-ALPIN/issues/1224 $item->setTax(0); return $product; }
php
protected function setItemByProductData($productData, ApiItemInterface $item, $locale) { $productId = $this->getProductId($productData); /** @var Product $product */ $product = $this->productRepository->find($productId); if (!$product) { throw new ProductNotFoundException(self::$productEntityName, $productId); } $item->setProduct($product); $translation = $product->getTranslation($locale); // when the product is not available in the current language choose the first translation you find // FIXME: should be changed when products have a language fallback // https://github.com/massiveart/POOL-ALPIN/issues/611 if (is_null($translation)) { if (count($product->getTranslations()) > 0) { $translation = $product->getTranslations()[0]; } else { throw new ProductException('Product ' . $product->getId() . ' has no translations!'); } } $this->setItemSupplier($item, $product); $item->setName($translation->getName()); $item->setDescription($translation->getLongDescription()); $item->setNumber($product->getNumber()); // set order unit if ($product->getOrderUnit()) { $item->setQuantityUnit($product->getOrderUnit()->getTranslation($locale)->getName()); } // TODO: get tax from product https://github.com/massiveart/POOL-ALPIN/issues/1224 $item->setTax(0); return $product; }
[ "protected", "function", "setItemByProductData", "(", "$", "productData", ",", "ApiItemInterface", "$", "item", ",", "$", "locale", ")", "{", "$", "productId", "=", "$", "this", "->", "getProductId", "(", "$", "productData", ")", ";", "/** @var Product $product */", "$", "product", "=", "$", "this", "->", "productRepository", "->", "find", "(", "$", "productId", ")", ";", "if", "(", "!", "$", "product", ")", "{", "throw", "new", "ProductNotFoundException", "(", "self", "::", "$", "productEntityName", ",", "$", "productId", ")", ";", "}", "$", "item", "->", "setProduct", "(", "$", "product", ")", ";", "$", "translation", "=", "$", "product", "->", "getTranslation", "(", "$", "locale", ")", ";", "// when the product is not available in the current language choose the first translation you find", "// FIXME: should be changed when products have a language fallback", "// https://github.com/massiveart/POOL-ALPIN/issues/611", "if", "(", "is_null", "(", "$", "translation", ")", ")", "{", "if", "(", "count", "(", "$", "product", "->", "getTranslations", "(", ")", ")", ">", "0", ")", "{", "$", "translation", "=", "$", "product", "->", "getTranslations", "(", ")", "[", "0", "]", ";", "}", "else", "{", "throw", "new", "ProductException", "(", "'Product '", ".", "$", "product", "->", "getId", "(", ")", ".", "' has no translations!'", ")", ";", "}", "}", "$", "this", "->", "setItemSupplier", "(", "$", "item", ",", "$", "product", ")", ";", "$", "item", "->", "setName", "(", "$", "translation", "->", "getName", "(", ")", ")", ";", "$", "item", "->", "setDescription", "(", "$", "translation", "->", "getLongDescription", "(", ")", ")", ";", "$", "item", "->", "setNumber", "(", "$", "product", "->", "getNumber", "(", ")", ")", ";", "// set order unit", "if", "(", "$", "product", "->", "getOrderUnit", "(", ")", ")", "{", "$", "item", "->", "setQuantityUnit", "(", "$", "product", "->", "getOrderUnit", "(", ")", "->", "getTranslation", "(", "$", "locale", ")", "->", "getName", "(", ")", ")", ";", "}", "// TODO: get tax from product https://github.com/massiveart/POOL-ALPIN/issues/1224", "$", "item", "->", "setTax", "(", "0", ")", ";", "return", "$", "product", ";", "}" ]
Sets item based on given product data @param array $productData @param ApiItemInterface $item @param string $locale @throws MissingItemAttributeException @throws ProductException @throws ProductNotFoundException @return ProductInterface
[ "Sets", "item", "based", "on", "given", "product", "data" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php#L510-L548
14,804
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php
ItemManager.setItemSupplier
protected function setItemSupplier($item, $product) { // get products supplier if ($product->getSupplier()) { $item->setSupplier($product->getSupplier()); $item->setSupplierName($product->getSupplier()->getName()); } else { $item->setSupplier(null); $item->setSupplierName(''); } }
php
protected function setItemSupplier($item, $product) { // get products supplier if ($product->getSupplier()) { $item->setSupplier($product->getSupplier()); $item->setSupplierName($product->getSupplier()->getName()); } else { $item->setSupplier(null); $item->setSupplierName(''); } }
[ "protected", "function", "setItemSupplier", "(", "$", "item", ",", "$", "product", ")", "{", "// get products supplier", "if", "(", "$", "product", "->", "getSupplier", "(", ")", ")", "{", "$", "item", "->", "setSupplier", "(", "$", "product", "->", "getSupplier", "(", ")", ")", ";", "$", "item", "->", "setSupplierName", "(", "$", "product", "->", "getSupplier", "(", ")", "->", "getName", "(", ")", ")", ";", "}", "else", "{", "$", "item", "->", "setSupplier", "(", "null", ")", ";", "$", "item", "->", "setSupplierName", "(", "''", ")", ";", "}", "}" ]
Set supplier of an item @param $item @param $product
[ "Set", "supplier", "of", "an", "item" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php#L556-L566
14,805
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php
ItemManager.updatePrices
private function updatePrices(ApiItemInterface $item, $data) { //TODO: currency $currency = null; // set products price by data if ($item->getUseProductsPrice() === false) { $item->setPrice($this->getProperty($data, 'price', $item->getPrice())); } // set items total net price $price = $this->itemPriceCalculator->calculate($item, $currency, $item->getUseProductsPrice()); $item->setTotalNetPrice($price); // set items price $itemPrice = $this->itemPriceCalculator->getItemPrice($item, $currency, $item->getUseProductsPrice()); $item->setPrice($itemPrice); }
php
private function updatePrices(ApiItemInterface $item, $data) { //TODO: currency $currency = null; // set products price by data if ($item->getUseProductsPrice() === false) { $item->setPrice($this->getProperty($data, 'price', $item->getPrice())); } // set items total net price $price = $this->itemPriceCalculator->calculate($item, $currency, $item->getUseProductsPrice()); $item->setTotalNetPrice($price); // set items price $itemPrice = $this->itemPriceCalculator->getItemPrice($item, $currency, $item->getUseProductsPrice()); $item->setPrice($itemPrice); }
[ "private", "function", "updatePrices", "(", "ApiItemInterface", "$", "item", ",", "$", "data", ")", "{", "//TODO: currency", "$", "currency", "=", "null", ";", "// set products price by data", "if", "(", "$", "item", "->", "getUseProductsPrice", "(", ")", "===", "false", ")", "{", "$", "item", "->", "setPrice", "(", "$", "this", "->", "getProperty", "(", "$", "data", ",", "'price'", ",", "$", "item", "->", "getPrice", "(", ")", ")", ")", ";", "}", "// set items total net price", "$", "price", "=", "$", "this", "->", "itemPriceCalculator", "->", "calculate", "(", "$", "item", ",", "$", "currency", ",", "$", "item", "->", "getUseProductsPrice", "(", ")", ")", ";", "$", "item", "->", "setTotalNetPrice", "(", "$", "price", ")", ";", "// set items price", "$", "itemPrice", "=", "$", "this", "->", "itemPriceCalculator", "->", "getItemPrice", "(", "$", "item", ",", "$", "currency", ",", "$", "item", "->", "getUseProductsPrice", "(", ")", ")", ";", "$", "item", "->", "setPrice", "(", "$", "itemPrice", ")", ";", "}" ]
Function updates item prices its product data @param ApiItemInterface $item @param array $data
[ "Function", "updates", "item", "prices", "its", "product", "data" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Item/ItemManager.php#L574-L591
14,806
kiwiz/ecl
src/Statement/CommandList.php
CommandList.process
public function process(\ECL\SymbolTable $table) { $results = []; // Loop over every Command and process it. for($i = 0; $i < count($this->commands); ++$i) { $command = $this->commands[$i]; $curr_result = $command->process($table); $table[\ECL\SymbolTable::DEFAULT_SYMBOL] = $curr_result; // If the last Command is not a store, allow returning the result. if($i + 1 >= count($this->commands) && !($command instanceof \ECL\Command\Store)) { $results[] = $curr_result; } } // Results from the last Command are only available within this CommandList. unset($table[\ECL\SymbolTable::DEFAULT_SYMBOL]); return $results; }
php
public function process(\ECL\SymbolTable $table) { $results = []; // Loop over every Command and process it. for($i = 0; $i < count($this->commands); ++$i) { $command = $this->commands[$i]; $curr_result = $command->process($table); $table[\ECL\SymbolTable::DEFAULT_SYMBOL] = $curr_result; // If the last Command is not a store, allow returning the result. if($i + 1 >= count($this->commands) && !($command instanceof \ECL\Command\Store)) { $results[] = $curr_result; } } // Results from the last Command are only available within this CommandList. unset($table[\ECL\SymbolTable::DEFAULT_SYMBOL]); return $results; }
[ "public", "function", "process", "(", "\\", "ECL", "\\", "SymbolTable", "$", "table", ")", "{", "$", "results", "=", "[", "]", ";", "// Loop over every Command and process it.", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "commands", ")", ";", "++", "$", "i", ")", "{", "$", "command", "=", "$", "this", "->", "commands", "[", "$", "i", "]", ";", "$", "curr_result", "=", "$", "command", "->", "process", "(", "$", "table", ")", ";", "$", "table", "[", "\\", "ECL", "\\", "SymbolTable", "::", "DEFAULT_SYMBOL", "]", "=", "$", "curr_result", ";", "// If the last Command is not a store, allow returning the result.", "if", "(", "$", "i", "+", "1", ">=", "count", "(", "$", "this", "->", "commands", ")", "&&", "!", "(", "$", "command", "instanceof", "\\", "ECL", "\\", "Command", "\\", "Store", ")", ")", "{", "$", "results", "[", "]", "=", "$", "curr_result", ";", "}", "}", "// Results from the last Command are only available within this CommandList.", "unset", "(", "$", "table", "[", "\\", "ECL", "\\", "SymbolTable", "::", "DEFAULT_SYMBOL", "]", ")", ";", "return", "$", "results", ";", "}" ]
Process the list of Commands. @param \ECL\SymbolTable $table The global SymbolTable. @return \ECL\ResultSet[] The result from the last Command or an empty array.
[ "Process", "the", "list", "of", "Commands", "." ]
6536dd2a4c1905a08cf718bdbef56a22f0e9b488
https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/Statement/CommandList.php#L25-L44
14,807
WellCommerce/CoreBundle
Provider/RouteProvider.php
RouteProvider.getRouteCollectionForRequest
public function getRouteCollectionForRequest(Request $request) { $collection = new RouteCollection(); $path = $this->getNormalizedPath($request); $resource = $this->repository->findOneBy(['path' => $path]); if ($resource) { $route = $this->createRoute($resource); $collection->add( self::DYNAMIC_PREFIX . $resource->getId(), $route ); } return $collection; }
php
public function getRouteCollectionForRequest(Request $request) { $collection = new RouteCollection(); $path = $this->getNormalizedPath($request); $resource = $this->repository->findOneBy(['path' => $path]); if ($resource) { $route = $this->createRoute($resource); $collection->add( self::DYNAMIC_PREFIX . $resource->getId(), $route ); } return $collection; }
[ "public", "function", "getRouteCollectionForRequest", "(", "Request", "$", "request", ")", "{", "$", "collection", "=", "new", "RouteCollection", "(", ")", ";", "$", "path", "=", "$", "this", "->", "getNormalizedPath", "(", "$", "request", ")", ";", "$", "resource", "=", "$", "this", "->", "repository", "->", "findOneBy", "(", "[", "'path'", "=>", "$", "path", "]", ")", ";", "if", "(", "$", "resource", ")", "{", "$", "route", "=", "$", "this", "->", "createRoute", "(", "$", "resource", ")", ";", "$", "collection", "->", "add", "(", "self", "::", "DYNAMIC_PREFIX", ".", "$", "resource", "->", "getId", "(", ")", ",", "$", "route", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Returns route collection for current request @param Request $request @return RouteCollection
[ "Returns", "route", "collection", "for", "current", "request" ]
984fbd544d4b10cf11e54e0f3c304d100deb6842
https://github.com/WellCommerce/CoreBundle/blob/984fbd544d4b10cf11e54e0f3c304d100deb6842/Provider/RouteProvider.php#L63-L78
14,808
WellCommerce/CoreBundle
Provider/RouteProvider.php
RouteProvider.getRouteByName
public function getRouteByName($identifier) { $id = str_replace(self::DYNAMIC_PREFIX, '', $identifier); $resource = $this->repository->find($id); if ($resource instanceof Route) { return $this->createRoute($resource); } return null; }
php
public function getRouteByName($identifier) { $id = str_replace(self::DYNAMIC_PREFIX, '', $identifier); $resource = $this->repository->find($id); if ($resource instanceof Route) { return $this->createRoute($resource); } return null; }
[ "public", "function", "getRouteByName", "(", "$", "identifier", ")", "{", "$", "id", "=", "str_replace", "(", "self", "::", "DYNAMIC_PREFIX", ",", "''", ",", "$", "identifier", ")", ";", "$", "resource", "=", "$", "this", "->", "repository", "->", "find", "(", "$", "id", ")", ";", "if", "(", "$", "resource", "instanceof", "Route", ")", "{", "return", "$", "this", "->", "createRoute", "(", "$", "resource", ")", ";", "}", "return", "null", ";", "}" ]
Returns route by its identifier @param string $identifier @return SymfonyRoute
[ "Returns", "route", "by", "its", "identifier" ]
984fbd544d4b10cf11e54e0f3c304d100deb6842
https://github.com/WellCommerce/CoreBundle/blob/984fbd544d4b10cf11e54e0f3c304d100deb6842/Provider/RouteProvider.php#L87-L97
14,809
WellCommerce/CoreBundle
Provider/RouteProvider.php
RouteProvider.getNormalizedPath
private function getNormalizedPath(Request $request) { $path = ltrim($request->getPathInfo(), '/'); $paths = explode(self::PATH_PARAMS_SEPARATOR, $path); return current($paths); }
php
private function getNormalizedPath(Request $request) { $path = ltrim($request->getPathInfo(), '/'); $paths = explode(self::PATH_PARAMS_SEPARATOR, $path); return current($paths); }
[ "private", "function", "getNormalizedPath", "(", "Request", "$", "request", ")", "{", "$", "path", "=", "ltrim", "(", "$", "request", "->", "getPathInfo", "(", ")", ",", "'/'", ")", ";", "$", "paths", "=", "explode", "(", "self", "::", "PATH_PARAMS_SEPARATOR", ",", "$", "path", ")", ";", "return", "current", "(", "$", "paths", ")", ";", "}" ]
Returns normalized path used in resource query @param Request $request @return mixed
[ "Returns", "normalized", "path", "used", "in", "resource", "query" ]
984fbd544d4b10cf11e54e0f3c304d100deb6842
https://github.com/WellCommerce/CoreBundle/blob/984fbd544d4b10cf11e54e0f3c304d100deb6842/Provider/RouteProvider.php#L111-L117
14,810
youthweb/urllinker
src/UrlLinker.php
UrlLinker.linkUrlsAndEscapeHtml
public function linkUrlsAndEscapeHtml($text) { // We can abort if there is no . in $text if ( strpos($text, '.') === false ) { return $this->escapeHtml($text); } $html = ''; $position = 0; $match = array(); while (preg_match($this->buildRegex(), $text, $match, PREG_OFFSET_CAPTURE, $position)) { list($url, $urlPosition) = $match[0]; // Add the text leading up to the URL. $html .= $this->escapeHtml(substr($text, $position, $urlPosition - $position)); $scheme = $match[1][0]; $username = $match[2][0]; $password = $match[3][0]; $domain = $match[4][0]; $afterDomain = $match[5][0]; // everything following the domain $port = $match[6][0]; $path = $match[7][0]; // Check that the TLD is valid or that $domain is an IP address. $tld = strtolower(strrchr($domain, '.')); $validTlds = $this->validTlds; if (preg_match('{^\.[0-9]{1,3}$}', $tld) || isset($validTlds[$tld])) { // Do not permit implicit scheme if a password is specified, as // this causes too many errors (e.g. "my email:[email protected]"). if ( ! $scheme && $password ) { $html .= $this->escapeHtml($username); // Continue text parsing at the ':' following the "username". $position = $urlPosition + strlen($username); continue; } if ( ! $scheme && $username && ! $password && ! $afterDomain ) { // Looks like an email address. $emailLinkCreator = $this->emailLinkCreator; // Add the hyperlink. $html .= $emailLinkCreator($url, $url); } else { // Prepend http:// if no scheme is specified $completeUrl = $scheme ? $url : "http://$url"; $linkText = "$domain$port$path"; $htmlLinkCreator = $this->htmlLinkCreator; // Add the hyperlink. $html .= $htmlLinkCreator($completeUrl, $linkText); } } else { // Not a valid URL. $html .= $this->escapeHtml($url); } // Continue text parsing from after the URL. $position = $urlPosition + strlen($url); } // Add the remainder of the text. $html .= $this->escapeHtml(substr($text, $position)); return $html; }
php
public function linkUrlsAndEscapeHtml($text) { // We can abort if there is no . in $text if ( strpos($text, '.') === false ) { return $this->escapeHtml($text); } $html = ''; $position = 0; $match = array(); while (preg_match($this->buildRegex(), $text, $match, PREG_OFFSET_CAPTURE, $position)) { list($url, $urlPosition) = $match[0]; // Add the text leading up to the URL. $html .= $this->escapeHtml(substr($text, $position, $urlPosition - $position)); $scheme = $match[1][0]; $username = $match[2][0]; $password = $match[3][0]; $domain = $match[4][0]; $afterDomain = $match[5][0]; // everything following the domain $port = $match[6][0]; $path = $match[7][0]; // Check that the TLD is valid or that $domain is an IP address. $tld = strtolower(strrchr($domain, '.')); $validTlds = $this->validTlds; if (preg_match('{^\.[0-9]{1,3}$}', $tld) || isset($validTlds[$tld])) { // Do not permit implicit scheme if a password is specified, as // this causes too many errors (e.g. "my email:[email protected]"). if ( ! $scheme && $password ) { $html .= $this->escapeHtml($username); // Continue text parsing at the ':' following the "username". $position = $urlPosition + strlen($username); continue; } if ( ! $scheme && $username && ! $password && ! $afterDomain ) { // Looks like an email address. $emailLinkCreator = $this->emailLinkCreator; // Add the hyperlink. $html .= $emailLinkCreator($url, $url); } else { // Prepend http:// if no scheme is specified $completeUrl = $scheme ? $url : "http://$url"; $linkText = "$domain$port$path"; $htmlLinkCreator = $this->htmlLinkCreator; // Add the hyperlink. $html .= $htmlLinkCreator($completeUrl, $linkText); } } else { // Not a valid URL. $html .= $this->escapeHtml($url); } // Continue text parsing from after the URL. $position = $urlPosition + strlen($url); } // Add the remainder of the text. $html .= $this->escapeHtml(substr($text, $position)); return $html; }
[ "public", "function", "linkUrlsAndEscapeHtml", "(", "$", "text", ")", "{", "// We can abort if there is no . in $text", "if", "(", "strpos", "(", "$", "text", ",", "'.'", ")", "===", "false", ")", "{", "return", "$", "this", "->", "escapeHtml", "(", "$", "text", ")", ";", "}", "$", "html", "=", "''", ";", "$", "position", "=", "0", ";", "$", "match", "=", "array", "(", ")", ";", "while", "(", "preg_match", "(", "$", "this", "->", "buildRegex", "(", ")", ",", "$", "text", ",", "$", "match", ",", "PREG_OFFSET_CAPTURE", ",", "$", "position", ")", ")", "{", "list", "(", "$", "url", ",", "$", "urlPosition", ")", "=", "$", "match", "[", "0", "]", ";", "// Add the text leading up to the URL.", "$", "html", ".=", "$", "this", "->", "escapeHtml", "(", "substr", "(", "$", "text", ",", "$", "position", ",", "$", "urlPosition", "-", "$", "position", ")", ")", ";", "$", "scheme", "=", "$", "match", "[", "1", "]", "[", "0", "]", ";", "$", "username", "=", "$", "match", "[", "2", "]", "[", "0", "]", ";", "$", "password", "=", "$", "match", "[", "3", "]", "[", "0", "]", ";", "$", "domain", "=", "$", "match", "[", "4", "]", "[", "0", "]", ";", "$", "afterDomain", "=", "$", "match", "[", "5", "]", "[", "0", "]", ";", "// everything following the domain", "$", "port", "=", "$", "match", "[", "6", "]", "[", "0", "]", ";", "$", "path", "=", "$", "match", "[", "7", "]", "[", "0", "]", ";", "// Check that the TLD is valid or that $domain is an IP address.", "$", "tld", "=", "strtolower", "(", "strrchr", "(", "$", "domain", ",", "'.'", ")", ")", ";", "$", "validTlds", "=", "$", "this", "->", "validTlds", ";", "if", "(", "preg_match", "(", "'{^\\.[0-9]{1,3}$}'", ",", "$", "tld", ")", "||", "isset", "(", "$", "validTlds", "[", "$", "tld", "]", ")", ")", "{", "// Do not permit implicit scheme if a password is specified, as", "// this causes too many errors (e.g. \"my email:[email protected]\").", "if", "(", "!", "$", "scheme", "&&", "$", "password", ")", "{", "$", "html", ".=", "$", "this", "->", "escapeHtml", "(", "$", "username", ")", ";", "// Continue text parsing at the ':' following the \"username\".", "$", "position", "=", "$", "urlPosition", "+", "strlen", "(", "$", "username", ")", ";", "continue", ";", "}", "if", "(", "!", "$", "scheme", "&&", "$", "username", "&&", "!", "$", "password", "&&", "!", "$", "afterDomain", ")", "{", "// Looks like an email address.", "$", "emailLinkCreator", "=", "$", "this", "->", "emailLinkCreator", ";", "// Add the hyperlink.", "$", "html", ".=", "$", "emailLinkCreator", "(", "$", "url", ",", "$", "url", ")", ";", "}", "else", "{", "// Prepend http:// if no scheme is specified", "$", "completeUrl", "=", "$", "scheme", "?", "$", "url", ":", "\"http://$url\"", ";", "$", "linkText", "=", "\"$domain$port$path\"", ";", "$", "htmlLinkCreator", "=", "$", "this", "->", "htmlLinkCreator", ";", "// Add the hyperlink.", "$", "html", ".=", "$", "htmlLinkCreator", "(", "$", "completeUrl", ",", "$", "linkText", ")", ";", "}", "}", "else", "{", "// Not a valid URL.", "$", "html", ".=", "$", "this", "->", "escapeHtml", "(", "$", "url", ")", ";", "}", "// Continue text parsing from after the URL.", "$", "position", "=", "$", "urlPosition", "+", "strlen", "(", "$", "url", ")", ";", "}", "// Add the remainder of the text.", "$", "html", ".=", "$", "this", "->", "escapeHtml", "(", "substr", "(", "$", "text", ",", "$", "position", ")", ")", ";", "return", "$", "html", ";", "}" ]
Transforms plain text into valid HTML, escaping special characters and turning URLs into links. @param string $text @return string
[ "Transforms", "plain", "text", "into", "valid", "HTML", "escaping", "special", "characters", "and", "turning", "URLs", "into", "links", "." ]
dbc377ea253b9fc6c137b85b342699b9f5db272a
https://github.com/youthweb/urllinker/blob/dbc377ea253b9fc6c137b85b342699b9f5db272a/src/UrlLinker.php#L232-L314
14,811
bestit/commercetools-order-export-bundle
src/Exporter.php
Exporter.exportOrder
private function exportOrder(Order $order, int $foundOrder) { $logger = $this->getLogger(); try { $eventDispatcher = $this->getEventDispatcher(); $filesystem = $this->getFilesystem(); $event = $eventDispatcher->dispatch( EventStore::PRE_ORDER_EXPORT, new PrepareOrderExportEvent($filesystem, $order) ); $logger->debug( 'Try to write the order export.', [ 'file' => $file = $this->getOrderNameGenerator()->getOrderName($order), 'number' => $foundOrder ] + ($exportData = $event->getExportData()) ); $written = ($isStopped = $event->isPropagationStopped()) ? false : $filesystem->put($file, $this->getView()->render($this->getFileTemplate(), $exportData)); if (!$written) { $logger->error( 'Failed to write order export file.', ['file' => $file, 'number' => $foundOrder, 'isStopped' => $isStopped] + $exportData ); $eventDispatcher->dispatch( EventStore::POST_ORDER_EXPORT_FAIL, new FailedOrderExportEvent($filesystem, $order) ); } else { $logger->info( 'Wrote order export file.', ['file' => $file, 'number' => $foundOrder] + $exportData ); $eventDispatcher->dispatch( EventStore::POST_ORDER_EXPORT, new FinishOrderExportEvent($file, $filesystem, $order) ); } } catch (SkippableException $exc) { $logger->warning( 'Exception while writing the order export file.', ['exception' => $exc, 'order' => $order] ); $eventDispatcher->dispatch( EventStore::POST_ORDER_EXPORT_FAIL, (new FailedOrderExportEvent($filesystem, $order))->setException($exc) ); } }
php
private function exportOrder(Order $order, int $foundOrder) { $logger = $this->getLogger(); try { $eventDispatcher = $this->getEventDispatcher(); $filesystem = $this->getFilesystem(); $event = $eventDispatcher->dispatch( EventStore::PRE_ORDER_EXPORT, new PrepareOrderExportEvent($filesystem, $order) ); $logger->debug( 'Try to write the order export.', [ 'file' => $file = $this->getOrderNameGenerator()->getOrderName($order), 'number' => $foundOrder ] + ($exportData = $event->getExportData()) ); $written = ($isStopped = $event->isPropagationStopped()) ? false : $filesystem->put($file, $this->getView()->render($this->getFileTemplate(), $exportData)); if (!$written) { $logger->error( 'Failed to write order export file.', ['file' => $file, 'number' => $foundOrder, 'isStopped' => $isStopped] + $exportData ); $eventDispatcher->dispatch( EventStore::POST_ORDER_EXPORT_FAIL, new FailedOrderExportEvent($filesystem, $order) ); } else { $logger->info( 'Wrote order export file.', ['file' => $file, 'number' => $foundOrder] + $exportData ); $eventDispatcher->dispatch( EventStore::POST_ORDER_EXPORT, new FinishOrderExportEvent($file, $filesystem, $order) ); } } catch (SkippableException $exc) { $logger->warning( 'Exception while writing the order export file.', ['exception' => $exc, 'order' => $order] ); $eventDispatcher->dispatch( EventStore::POST_ORDER_EXPORT_FAIL, (new FailedOrderExportEvent($filesystem, $order))->setException($exc) ); } }
[ "private", "function", "exportOrder", "(", "Order", "$", "order", ",", "int", "$", "foundOrder", ")", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "try", "{", "$", "eventDispatcher", "=", "$", "this", "->", "getEventDispatcher", "(", ")", ";", "$", "filesystem", "=", "$", "this", "->", "getFilesystem", "(", ")", ";", "$", "event", "=", "$", "eventDispatcher", "->", "dispatch", "(", "EventStore", "::", "PRE_ORDER_EXPORT", ",", "new", "PrepareOrderExportEvent", "(", "$", "filesystem", ",", "$", "order", ")", ")", ";", "$", "logger", "->", "debug", "(", "'Try to write the order export.'", ",", "[", "'file'", "=>", "$", "file", "=", "$", "this", "->", "getOrderNameGenerator", "(", ")", "->", "getOrderName", "(", "$", "order", ")", ",", "'number'", "=>", "$", "foundOrder", "]", "+", "(", "$", "exportData", "=", "$", "event", "->", "getExportData", "(", ")", ")", ")", ";", "$", "written", "=", "(", "$", "isStopped", "=", "$", "event", "->", "isPropagationStopped", "(", ")", ")", "?", "false", ":", "$", "filesystem", "->", "put", "(", "$", "file", ",", "$", "this", "->", "getView", "(", ")", "->", "render", "(", "$", "this", "->", "getFileTemplate", "(", ")", ",", "$", "exportData", ")", ")", ";", "if", "(", "!", "$", "written", ")", "{", "$", "logger", "->", "error", "(", "'Failed to write order export file.'", ",", "[", "'file'", "=>", "$", "file", ",", "'number'", "=>", "$", "foundOrder", ",", "'isStopped'", "=>", "$", "isStopped", "]", "+", "$", "exportData", ")", ";", "$", "eventDispatcher", "->", "dispatch", "(", "EventStore", "::", "POST_ORDER_EXPORT_FAIL", ",", "new", "FailedOrderExportEvent", "(", "$", "filesystem", ",", "$", "order", ")", ")", ";", "}", "else", "{", "$", "logger", "->", "info", "(", "'Wrote order export file.'", ",", "[", "'file'", "=>", "$", "file", ",", "'number'", "=>", "$", "foundOrder", "]", "+", "$", "exportData", ")", ";", "$", "eventDispatcher", "->", "dispatch", "(", "EventStore", "::", "POST_ORDER_EXPORT", ",", "new", "FinishOrderExportEvent", "(", "$", "file", ",", "$", "filesystem", ",", "$", "order", ")", ")", ";", "}", "}", "catch", "(", "SkippableException", "$", "exc", ")", "{", "$", "logger", "->", "warning", "(", "'Exception while writing the order export file.'", ",", "[", "'exception'", "=>", "$", "exc", ",", "'order'", "=>", "$", "order", "]", ")", ";", "$", "eventDispatcher", "->", "dispatch", "(", "EventStore", "::", "POST_ORDER_EXPORT_FAIL", ",", "(", "new", "FailedOrderExportEvent", "(", "$", "filesystem", ",", "$", "order", ")", ")", "->", "setException", "(", "$", "exc", ")", ")", ";", "}", "}" ]
Exports the given order. @param Order $order @param int $foundOrder
[ "Exports", "the", "given", "order", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/Exporter.php#L89-L146
14,812
bestit/commercetools-order-export-bundle
src/Exporter.php
Exporter.exportOrders
public function exportOrders(OrderVisitor $orderVisitor, ProgressBar $bar): bool { $logger = $this->getLogger(); $bar->start($count = count($orderVisitor)); $logger->debug('Started the order export.', ['count' => $count]); foreach ($orderVisitor() as $num => $order) { set_time_limit(0); $this->exportOrder($order, $num); $bar->advance(); } $logger->debug('Finished the order export.', ['count' => $count]); $bar->finish(); return true; }
php
public function exportOrders(OrderVisitor $orderVisitor, ProgressBar $bar): bool { $logger = $this->getLogger(); $bar->start($count = count($orderVisitor)); $logger->debug('Started the order export.', ['count' => $count]); foreach ($orderVisitor() as $num => $order) { set_time_limit(0); $this->exportOrder($order, $num); $bar->advance(); } $logger->debug('Finished the order export.', ['count' => $count]); $bar->finish(); return true; }
[ "public", "function", "exportOrders", "(", "OrderVisitor", "$", "orderVisitor", ",", "ProgressBar", "$", "bar", ")", ":", "bool", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "$", "bar", "->", "start", "(", "$", "count", "=", "count", "(", "$", "orderVisitor", ")", ")", ";", "$", "logger", "->", "debug", "(", "'Started the order export.'", ",", "[", "'count'", "=>", "$", "count", "]", ")", ";", "foreach", "(", "$", "orderVisitor", "(", ")", "as", "$", "num", "=>", "$", "order", ")", "{", "set_time_limit", "(", "0", ")", ";", "$", "this", "->", "exportOrder", "(", "$", "order", ",", "$", "num", ")", ";", "$", "bar", "->", "advance", "(", ")", ";", "}", "$", "logger", "->", "debug", "(", "'Finished the order export.'", ",", "[", "'count'", "=>", "$", "count", "]", ")", ";", "$", "bar", "->", "finish", "(", ")", ";", "return", "true", ";", "}" ]
Exports the given orders. @param OrderVisitor $orderVisitor @param ProgressBar $bar @return bool @todo Add ErrorManagement
[ "Exports", "the", "given", "orders", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/Exporter.php#L155-L176
14,813
WellCommerce/CoreBundle
Form/DataTransformer/DataTransformerFactory.php
DataTransformerFactory.createRepositoryTransformer
public function createRepositoryTransformer(string $alias) : DataTransformerInterface { if (!$this->collection->has($alias)) { throw new MissingFormDataTransformerException($alias); } $serviceId = $this->collection->get($alias); return $this->get($serviceId); }
php
public function createRepositoryTransformer(string $alias) : DataTransformerInterface { if (!$this->collection->has($alias)) { throw new MissingFormDataTransformerException($alias); } $serviceId = $this->collection->get($alias); return $this->get($serviceId); }
[ "public", "function", "createRepositoryTransformer", "(", "string", "$", "alias", ")", ":", "DataTransformerInterface", "{", "if", "(", "!", "$", "this", "->", "collection", "->", "has", "(", "$", "alias", ")", ")", "{", "throw", "new", "MissingFormDataTransformerException", "(", "$", "alias", ")", ";", "}", "$", "serviceId", "=", "$", "this", "->", "collection", "->", "get", "(", "$", "alias", ")", ";", "return", "$", "this", "->", "get", "(", "$", "serviceId", ")", ";", "}" ]
Creates and returns a new instance of form data transformer @param string $alias @return DataTransformerInterface
[ "Creates", "and", "returns", "a", "new", "instance", "of", "form", "data", "transformer" ]
984fbd544d4b10cf11e54e0f3c304d100deb6842
https://github.com/WellCommerce/CoreBundle/blob/984fbd544d4b10cf11e54e0f3c304d100deb6842/Form/DataTransformer/DataTransformerFactory.php#L47-L56
14,814
jamband/ripple
src/Ripple.php
Ripple.embed
public function embed(?string $url = null, ?string $id = null): ?string { $hasMultiple = function (string $url, string $pattern): bool { return false !== strpos($url, $pattern); }; if (isset($url, $id)) { $ripple = new static($url); if (null !== $ripple->provider) { $class = static::PROVIDERS[$provider = $ripple->provider]; $embed = $class::embed($id, $hasMultiple($url, $class::MULTIPLE_PATTERN)); } } if ('' !== $this->content) { $class = static::PROVIDERS[$provider = $this->provider]; $embed = $class::embed($class::id($this->content), $hasMultiple($this->url, $class::MULTIPLE_PATTERN)); } if (!isset($embed, $provider)) { return null; } if (isset($this->embedParams[$provider])) { return $embed.$this->embedParams[$provider]; } return $embed; }
php
public function embed(?string $url = null, ?string $id = null): ?string { $hasMultiple = function (string $url, string $pattern): bool { return false !== strpos($url, $pattern); }; if (isset($url, $id)) { $ripple = new static($url); if (null !== $ripple->provider) { $class = static::PROVIDERS[$provider = $ripple->provider]; $embed = $class::embed($id, $hasMultiple($url, $class::MULTIPLE_PATTERN)); } } if ('' !== $this->content) { $class = static::PROVIDERS[$provider = $this->provider]; $embed = $class::embed($class::id($this->content), $hasMultiple($this->url, $class::MULTIPLE_PATTERN)); } if (!isset($embed, $provider)) { return null; } if (isset($this->embedParams[$provider])) { return $embed.$this->embedParams[$provider]; } return $embed; }
[ "public", "function", "embed", "(", "?", "string", "$", "url", "=", "null", ",", "?", "string", "$", "id", "=", "null", ")", ":", "?", "string", "{", "$", "hasMultiple", "=", "function", "(", "string", "$", "url", ",", "string", "$", "pattern", ")", ":", "bool", "{", "return", "false", "!==", "strpos", "(", "$", "url", ",", "$", "pattern", ")", ";", "}", ";", "if", "(", "isset", "(", "$", "url", ",", "$", "id", ")", ")", "{", "$", "ripple", "=", "new", "static", "(", "$", "url", ")", ";", "if", "(", "null", "!==", "$", "ripple", "->", "provider", ")", "{", "$", "class", "=", "static", "::", "PROVIDERS", "[", "$", "provider", "=", "$", "ripple", "->", "provider", "]", ";", "$", "embed", "=", "$", "class", "::", "embed", "(", "$", "id", ",", "$", "hasMultiple", "(", "$", "url", ",", "$", "class", "::", "MULTIPLE_PATTERN", ")", ")", ";", "}", "}", "if", "(", "''", "!==", "$", "this", "->", "content", ")", "{", "$", "class", "=", "static", "::", "PROVIDERS", "[", "$", "provider", "=", "$", "this", "->", "provider", "]", ";", "$", "embed", "=", "$", "class", "::", "embed", "(", "$", "class", "::", "id", "(", "$", "this", "->", "content", ")", ",", "$", "hasMultiple", "(", "$", "this", "->", "url", ",", "$", "class", "::", "MULTIPLE_PATTERN", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "embed", ",", "$", "provider", ")", ")", "{", "return", "null", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "embedParams", "[", "$", "provider", "]", ")", ")", "{", "return", "$", "embed", ".", "$", "this", "->", "embedParams", "[", "$", "provider", "]", ";", "}", "return", "$", "embed", ";", "}" ]
Returns HTML embed of the track. @param null|string $url @param null|string $id @return null|string
[ "Returns", "HTML", "embed", "of", "the", "track", "." ]
91443f8016af76cacf749e05633abc1bdaf4675f
https://github.com/jamband/ripple/blob/91443f8016af76cacf749e05633abc1bdaf4675f/src/Ripple.php#L117-L146
14,815
flownative/flow-doubleoptin
Classes/Helper.php
Helper.validateTokenHash
public function validateTokenHash($tokenHash) { $tokenData = $this->tokenCache->get($tokenHash); if ($tokenData === false) { $this->logger->log(sprintf('Validation of token hash %s failed', $tokenHash), LOG_INFO); return null; } $preset = $this->getPreset($tokenData['presetName']); if (!(isset($preset['preserveToken']) && $preset['preserveToken'])) { $this->tokenCache->remove($tokenHash); } $this->logger->log(sprintf('Validated token hash %s for identifier %s', $tokenHash, $tokenData['identifier']), LOG_INFO); return new Token($tokenHash, $tokenData['identifier'], $this->getPreset($tokenData['presetName']), $tokenData['meta']); }
php
public function validateTokenHash($tokenHash) { $tokenData = $this->tokenCache->get($tokenHash); if ($tokenData === false) { $this->logger->log(sprintf('Validation of token hash %s failed', $tokenHash), LOG_INFO); return null; } $preset = $this->getPreset($tokenData['presetName']); if (!(isset($preset['preserveToken']) && $preset['preserveToken'])) { $this->tokenCache->remove($tokenHash); } $this->logger->log(sprintf('Validated token hash %s for identifier %s', $tokenHash, $tokenData['identifier']), LOG_INFO); return new Token($tokenHash, $tokenData['identifier'], $this->getPreset($tokenData['presetName']), $tokenData['meta']); }
[ "public", "function", "validateTokenHash", "(", "$", "tokenHash", ")", "{", "$", "tokenData", "=", "$", "this", "->", "tokenCache", "->", "get", "(", "$", "tokenHash", ")", ";", "if", "(", "$", "tokenData", "===", "false", ")", "{", "$", "this", "->", "logger", "->", "log", "(", "sprintf", "(", "'Validation of token hash %s failed'", ",", "$", "tokenHash", ")", ",", "LOG_INFO", ")", ";", "return", "null", ";", "}", "$", "preset", "=", "$", "this", "->", "getPreset", "(", "$", "tokenData", "[", "'presetName'", "]", ")", ";", "if", "(", "!", "(", "isset", "(", "$", "preset", "[", "'preserveToken'", "]", ")", "&&", "$", "preset", "[", "'preserveToken'", "]", ")", ")", "{", "$", "this", "->", "tokenCache", "->", "remove", "(", "$", "tokenHash", ")", ";", "}", "$", "this", "->", "logger", "->", "log", "(", "sprintf", "(", "'Validated token hash %s for identifier %s'", ",", "$", "tokenHash", ",", "$", "tokenData", "[", "'identifier'", "]", ")", ",", "LOG_INFO", ")", ";", "return", "new", "Token", "(", "$", "tokenHash", ",", "$", "tokenData", "[", "'identifier'", "]", ",", "$", "this", "->", "getPreset", "(", "$", "tokenData", "[", "'presetName'", "]", ")", ",", "$", "tokenData", "[", "'meta'", "]", ")", ";", "}" ]
This checks if a given hash is known and still valid before returning the associated Token. If no valid Token is found for the hash, NULL is returned. @param $tokenHash @return Token @throws UnknownPresetException
[ "This", "checks", "if", "a", "given", "hash", "is", "known", "and", "still", "valid", "before", "returning", "the", "associated", "Token", "." ]
18ae7e9b326118d5592816896b46ad840c67491c
https://github.com/flownative/flow-doubleoptin/blob/18ae7e9b326118d5592816896b46ad840c67491c/Classes/Helper.php#L116-L134
14,816
flownative/flow-doubleoptin
Classes/Helper.php
Helper.invalidateToken
public function invalidateToken(Token $token) { $this->tokenCache->remove($token->getHash()); $this->logger->log(sprintf('Deleted token %s.', $token->getIdentifier()), LOG_INFO); }
php
public function invalidateToken(Token $token) { $this->tokenCache->remove($token->getHash()); $this->logger->log(sprintf('Deleted token %s.', $token->getIdentifier()), LOG_INFO); }
[ "public", "function", "invalidateToken", "(", "Token", "$", "token", ")", "{", "$", "this", "->", "tokenCache", "->", "remove", "(", "$", "token", "->", "getHash", "(", ")", ")", ";", "$", "this", "->", "logger", "->", "log", "(", "sprintf", "(", "'Deleted token %s.'", ",", "$", "token", "->", "getIdentifier", "(", ")", ")", ",", "LOG_INFO", ")", ";", "}" ]
Removes the given token from the token cache. This is only necessary if the 'preserveToken' parameter of the token's preset is true. Otherwise tokens are deleted automatically. @param Token $token @return void
[ "Removes", "the", "given", "token", "from", "the", "token", "cache", "." ]
18ae7e9b326118d5592816896b46ad840c67491c
https://github.com/flownative/flow-doubleoptin/blob/18ae7e9b326118d5592816896b46ad840c67491c/Classes/Helper.php#L145-L150
14,817
discophp/framework
core/classes/Console.class.php
Console.devMode
public function devMode($args){ if(empty($args[0])){ $mode = \Disco\manage\Manager::devMode(); echo 'DEV_MODE : ' . (($mode) ? 'true' : 'false') . PHP_EOL; exit; }//if else if($args[0] != 'true' && $args[0] != 'false'){ echo 'Mode takes one of two values: true | false' . PHP_EOL . 'Please supply a correct value' . PHP_EOL; exit; }//if \Disco\manage\Manager::devMode(($args[0] == 'true') ? true : false); echo 'DEV_MODE now set to: ' . $args[0] . PHP_EOL; }
php
public function devMode($args){ if(empty($args[0])){ $mode = \Disco\manage\Manager::devMode(); echo 'DEV_MODE : ' . (($mode) ? 'true' : 'false') . PHP_EOL; exit; }//if else if($args[0] != 'true' && $args[0] != 'false'){ echo 'Mode takes one of two values: true | false' . PHP_EOL . 'Please supply a correct value' . PHP_EOL; exit; }//if \Disco\manage\Manager::devMode(($args[0] == 'true') ? true : false); echo 'DEV_MODE now set to: ' . $args[0] . PHP_EOL; }
[ "public", "function", "devMode", "(", "$", "args", ")", "{", "if", "(", "empty", "(", "$", "args", "[", "0", "]", ")", ")", "{", "$", "mode", "=", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "devMode", "(", ")", ";", "echo", "'DEV_MODE : '", ".", "(", "(", "$", "mode", ")", "?", "'true'", ":", "'false'", ")", ".", "PHP_EOL", ";", "exit", ";", "}", "//if", "else", "if", "(", "$", "args", "[", "0", "]", "!=", "'true'", "&&", "$", "args", "[", "0", "]", "!=", "'false'", ")", "{", "echo", "'Mode takes one of two values: true | false'", ".", "PHP_EOL", ".", "'Please supply a correct value'", ".", "PHP_EOL", ";", "exit", ";", "}", "//if", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "devMode", "(", "(", "$", "args", "[", "0", "]", "==", "'true'", ")", "?", "true", ":", "false", ")", ";", "echo", "'DEV_MODE now set to: '", ".", "$", "args", "[", "0", "]", ".", "PHP_EOL", ";", "}" ]
Get the current dev mode, optionally setting it. eg: `dev-mode` eg: `dev-mode true` eg: `dev-mode false` @param array $args The arguements.
[ "Get", "the", "current", "dev", "mode", "optionally", "setting", "it", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Console.class.php#L219-L234
14,818
discophp/framework
core/classes/Console.class.php
Console.dbRestore
public function dbRestore($args){ $path = '/app/db/'; if(isset($args[0])){ $path = $args[0]; }//if $path = \App::path() . '/' . trim($path,'/') . '/'; $fileName = \App::config('DB_DB'); if(isset($args[1])){ $fileName = $args[1]; }//if $fileName = $path . $fileName . '.sql'; if(!is_file($fileName)){ echo "Backup `{$fileName}` does not exist, exiting." . PHP_EOL; exit; }//if $e = "mysql -u %1\$s -p'%2\$s' -h %3\$s %4\$s < %5\$s;"; $e = sprintf($e, \App::config('DB_USER'), \App::config('DB_PASSWORD'), \App::config('DB_HOST'), \App::config('DB_DB'), $fileName ); $error = exec($e); if(!$error){ echo 'DB `' . \App::config('DB_DB') . "` successfully restored from `{$fileName}`"; } else { echo 'Unable to restore! : ' . $error; }//el echo PHP_EOL; }
php
public function dbRestore($args){ $path = '/app/db/'; if(isset($args[0])){ $path = $args[0]; }//if $path = \App::path() . '/' . trim($path,'/') . '/'; $fileName = \App::config('DB_DB'); if(isset($args[1])){ $fileName = $args[1]; }//if $fileName = $path . $fileName . '.sql'; if(!is_file($fileName)){ echo "Backup `{$fileName}` does not exist, exiting." . PHP_EOL; exit; }//if $e = "mysql -u %1\$s -p'%2\$s' -h %3\$s %4\$s < %5\$s;"; $e = sprintf($e, \App::config('DB_USER'), \App::config('DB_PASSWORD'), \App::config('DB_HOST'), \App::config('DB_DB'), $fileName ); $error = exec($e); if(!$error){ echo 'DB `' . \App::config('DB_DB') . "` successfully restored from `{$fileName}`"; } else { echo 'Unable to restore! : ' . $error; }//el echo PHP_EOL; }
[ "public", "function", "dbRestore", "(", "$", "args", ")", "{", "$", "path", "=", "'/app/db/'", ";", "if", "(", "isset", "(", "$", "args", "[", "0", "]", ")", ")", "{", "$", "path", "=", "$", "args", "[", "0", "]", ";", "}", "//if", "$", "path", "=", "\\", "App", "::", "path", "(", ")", ".", "'/'", ".", "trim", "(", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "$", "fileName", "=", "\\", "App", "::", "config", "(", "'DB_DB'", ")", ";", "if", "(", "isset", "(", "$", "args", "[", "1", "]", ")", ")", "{", "$", "fileName", "=", "$", "args", "[", "1", "]", ";", "}", "//if", "$", "fileName", "=", "$", "path", ".", "$", "fileName", ".", "'.sql'", ";", "if", "(", "!", "is_file", "(", "$", "fileName", ")", ")", "{", "echo", "\"Backup `{$fileName}` does not exist, exiting.\"", ".", "PHP_EOL", ";", "exit", ";", "}", "//if", "$", "e", "=", "\"mysql -u %1\\$s -p'%2\\$s' -h %3\\$s %4\\$s < %5\\$s;\"", ";", "$", "e", "=", "sprintf", "(", "$", "e", ",", "\\", "App", "::", "config", "(", "'DB_USER'", ")", ",", "\\", "App", "::", "config", "(", "'DB_PASSWORD'", ")", ",", "\\", "App", "::", "config", "(", "'DB_HOST'", ")", ",", "\\", "App", "::", "config", "(", "'DB_DB'", ")", ",", "$", "fileName", ")", ";", "$", "error", "=", "exec", "(", "$", "e", ")", ";", "if", "(", "!", "$", "error", ")", "{", "echo", "'DB `'", ".", "\\", "App", "::", "config", "(", "'DB_DB'", ")", ".", "\"` successfully restored from `{$fileName}`\"", ";", "}", "else", "{", "echo", "'Unable to restore! : '", ".", "$", "error", ";", "}", "//el", "echo", "PHP_EOL", ";", "}" ]
Restore the DB from a backup. eg: `db-restore` eg: `db-restore /app/db/` eg `db-restore /app/db/ BACKUP.sql` @param array $args The arguements.
[ "Restore", "the", "DB", "from", "a", "backup", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Console.class.php#L377-L417
14,819
discophp/framework
core/classes/Console.class.php
Console.create
public function create($args){ if($args[0] == 'model'){ if(!isset($args[1])){ echo 'You must specify a table to build the model from' . PHP_EOL; exit; }//if $table = $args[1]; $templatePath = isset($args[2]) ? $args[2] : 'app/config/model.format'; $outputPath = isset($args[3]) ? $args[3] : 'app/model'; if($table=='all'){ $result = $this->getDBSchema(); while($row = $result->fetch()){ $model = \Disco\manage\Manager::buildModel($row['table_name']); \Disco\manage\Manager::writeModel($row['table_name'],$model,$templatePath,$outputPath); }//while }//if else { $model = \Disco\manage\Manager::buildModel($table); \Disco\manage\Manager::writeModel($table,$model,$templatePath,$outputPath); }//el }//if else if($args[0] == 'record'){ if(!isset($args[1])){ echo 'You must specify a table to build the record from' . PHP_EOL; exit; }//if $table = $args[1]; $templatePath = isset($args[2]) ? $args[2] : 'app/config/record.format'; $outputPath = isset($args[3]) ? $args[3] : 'app/record'; if($table=='all'){ $result = $this->getDBSchema(); while($row = $result->fetch()){ $record = \Disco\manage\Manager::buildRecord($row['table_name']); \Disco\manage\Manager::writeRecord($row['table_name'],$record,$templatePath,$outputPath); }//while }//if else { $record = \Disco\manage\Manager::buildRecord($table); \Disco\manage\Manager::writeRecord($table,$record,$templatePath,$outputPath); }//el }//elif }
php
public function create($args){ if($args[0] == 'model'){ if(!isset($args[1])){ echo 'You must specify a table to build the model from' . PHP_EOL; exit; }//if $table = $args[1]; $templatePath = isset($args[2]) ? $args[2] : 'app/config/model.format'; $outputPath = isset($args[3]) ? $args[3] : 'app/model'; if($table=='all'){ $result = $this->getDBSchema(); while($row = $result->fetch()){ $model = \Disco\manage\Manager::buildModel($row['table_name']); \Disco\manage\Manager::writeModel($row['table_name'],$model,$templatePath,$outputPath); }//while }//if else { $model = \Disco\manage\Manager::buildModel($table); \Disco\manage\Manager::writeModel($table,$model,$templatePath,$outputPath); }//el }//if else if($args[0] == 'record'){ if(!isset($args[1])){ echo 'You must specify a table to build the record from' . PHP_EOL; exit; }//if $table = $args[1]; $templatePath = isset($args[2]) ? $args[2] : 'app/config/record.format'; $outputPath = isset($args[3]) ? $args[3] : 'app/record'; if($table=='all'){ $result = $this->getDBSchema(); while($row = $result->fetch()){ $record = \Disco\manage\Manager::buildRecord($row['table_name']); \Disco\manage\Manager::writeRecord($row['table_name'],$record,$templatePath,$outputPath); }//while }//if else { $record = \Disco\manage\Manager::buildRecord($table); \Disco\manage\Manager::writeRecord($table,$record,$templatePath,$outputPath); }//el }//elif }
[ "public", "function", "create", "(", "$", "args", ")", "{", "if", "(", "$", "args", "[", "0", "]", "==", "'model'", ")", "{", "if", "(", "!", "isset", "(", "$", "args", "[", "1", "]", ")", ")", "{", "echo", "'You must specify a table to build the model from'", ".", "PHP_EOL", ";", "exit", ";", "}", "//if", "$", "table", "=", "$", "args", "[", "1", "]", ";", "$", "templatePath", "=", "isset", "(", "$", "args", "[", "2", "]", ")", "?", "$", "args", "[", "2", "]", ":", "'app/config/model.format'", ";", "$", "outputPath", "=", "isset", "(", "$", "args", "[", "3", "]", ")", "?", "$", "args", "[", "3", "]", ":", "'app/model'", ";", "if", "(", "$", "table", "==", "'all'", ")", "{", "$", "result", "=", "$", "this", "->", "getDBSchema", "(", ")", ";", "while", "(", "$", "row", "=", "$", "result", "->", "fetch", "(", ")", ")", "{", "$", "model", "=", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "buildModel", "(", "$", "row", "[", "'table_name'", "]", ")", ";", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "writeModel", "(", "$", "row", "[", "'table_name'", "]", ",", "$", "model", ",", "$", "templatePath", ",", "$", "outputPath", ")", ";", "}", "//while", "}", "//if", "else", "{", "$", "model", "=", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "buildModel", "(", "$", "table", ")", ";", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "writeModel", "(", "$", "table", ",", "$", "model", ",", "$", "templatePath", ",", "$", "outputPath", ")", ";", "}", "//el", "}", "//if", "else", "if", "(", "$", "args", "[", "0", "]", "==", "'record'", ")", "{", "if", "(", "!", "isset", "(", "$", "args", "[", "1", "]", ")", ")", "{", "echo", "'You must specify a table to build the record from'", ".", "PHP_EOL", ";", "exit", ";", "}", "//if", "$", "table", "=", "$", "args", "[", "1", "]", ";", "$", "templatePath", "=", "isset", "(", "$", "args", "[", "2", "]", ")", "?", "$", "args", "[", "2", "]", ":", "'app/config/record.format'", ";", "$", "outputPath", "=", "isset", "(", "$", "args", "[", "3", "]", ")", "?", "$", "args", "[", "3", "]", ":", "'app/record'", ";", "if", "(", "$", "table", "==", "'all'", ")", "{", "$", "result", "=", "$", "this", "->", "getDBSchema", "(", ")", ";", "while", "(", "$", "row", "=", "$", "result", "->", "fetch", "(", ")", ")", "{", "$", "record", "=", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "buildRecord", "(", "$", "row", "[", "'table_name'", "]", ")", ";", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "writeRecord", "(", "$", "row", "[", "'table_name'", "]", ",", "$", "record", ",", "$", "templatePath", ",", "$", "outputPath", ")", ";", "}", "//while", "}", "//if", "else", "{", "$", "record", "=", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "buildRecord", "(", "$", "table", ")", ";", "\\", "Disco", "\\", "manage", "\\", "Manager", "::", "writeRecord", "(", "$", "table", ",", "$", "record", ",", "$", "templatePath", ",", "$", "outputPath", ")", ";", "}", "//el", "}", "//elif", "}" ]
Create a model or a record. Use the special keyword `all` in place of a table name to generate records or models for all tables. eg: `create model user` eg: `create model user /app/config/model.format /app/model/` eg: `create record user` eg: `create record user /app/config/record.format /app/record/` @param array $args The arguements.
[ "Create", "a", "model", "or", "a", "record", ".", "Use", "the", "special", "keyword", "all", "in", "place", "of", "a", "table", "name", "to", "generate", "records", "or", "models", "for", "all", "tables", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Console.class.php#L433-L486
14,820
discophp/framework
core/classes/Console.class.php
Console.consoleQuestion
public static function consoleQuestion($question,$options){ @ob_flush(); $orgQuestion = $question; $opts = ''; foreach($options as $value => $statement){ $opts .= "'{$value}') echo '{$value}'; break;;"; $question .= PHP_EOL . "($value) - {$statement}"; }//foreach $question .= PHP_EOL . 'Your answer? : '; exec(" while true; do read -p '{$question}' answer case \$answer in {$opts} *) echo ''; break;; esac done ", $answer ); if(!array_key_exists($answer[0],$options)){ echo PHP_EOL . 'Please enter a valid option and try again!' . PHP_EOL . PHP_EOL; return self::consoleQuestion($orgQuestion,$options); }//if return $answer[0]; }
php
public static function consoleQuestion($question,$options){ @ob_flush(); $orgQuestion = $question; $opts = ''; foreach($options as $value => $statement){ $opts .= "'{$value}') echo '{$value}'; break;;"; $question .= PHP_EOL . "($value) - {$statement}"; }//foreach $question .= PHP_EOL . 'Your answer? : '; exec(" while true; do read -p '{$question}' answer case \$answer in {$opts} *) echo ''; break;; esac done ", $answer ); if(!array_key_exists($answer[0],$options)){ echo PHP_EOL . 'Please enter a valid option and try again!' . PHP_EOL . PHP_EOL; return self::consoleQuestion($orgQuestion,$options); }//if return $answer[0]; }
[ "public", "static", "function", "consoleQuestion", "(", "$", "question", ",", "$", "options", ")", "{", "@", "ob_flush", "(", ")", ";", "$", "orgQuestion", "=", "$", "question", ";", "$", "opts", "=", "''", ";", "foreach", "(", "$", "options", "as", "$", "value", "=>", "$", "statement", ")", "{", "$", "opts", ".=", "\"'{$value}') echo '{$value}'; break;;\"", ";", "$", "question", ".=", "PHP_EOL", ".", "\"($value) - {$statement}\"", ";", "}", "//foreach", "$", "question", ".=", "PHP_EOL", ".", "'Your answer? : '", ";", "exec", "(", "\"\n while true; do\n read -p '{$question}' answer \n case \\$answer in\n {$opts}\n *) echo ''; break;;\n esac\n done\n \"", ",", "$", "answer", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "answer", "[", "0", "]", ",", "$", "options", ")", ")", "{", "echo", "PHP_EOL", ".", "'Please enter a valid option and try again!'", ".", "PHP_EOL", ".", "PHP_EOL", ";", "return", "self", "::", "consoleQuestion", "(", "$", "orgQuestion", ",", "$", "options", ")", ";", "}", "//if", "return", "$", "answer", "[", "0", "]", ";", "}" ]
Prompt the user at the console with a question and the valid options that serve as an answer to that question. @param string $question The question being asked. @param array $options The possible answers to the question being asked, where the keys are the anwsers and the values are the description of the answer. @return mixed The selected key from $options param.
[ "Prompt", "the", "user", "at", "the", "console", "with", "a", "question", "and", "the", "valid", "options", "that", "serve", "as", "an", "answer", "to", "that", "question", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Console.class.php#L550-L584
14,821
discophp/framework
core/classes/Console.class.php
Console.consolePrompt
public function consolePrompt($question,$cannotBeBlank = false){ @ob_flush(); exec("read -p '{$question} ' answer; echo \$answer;",$answer); if(!$answer[0] && $cannotBeBlank === true){ echo PHP_EOL . 'Answer cannot be blank! Try again...' . PHP_EOL . PHP_EOL; return self::consolePrompt($question,$cannotBeBlank); }//if return $answer[0]; }
php
public function consolePrompt($question,$cannotBeBlank = false){ @ob_flush(); exec("read -p '{$question} ' answer; echo \$answer;",$answer); if(!$answer[0] && $cannotBeBlank === true){ echo PHP_EOL . 'Answer cannot be blank! Try again...' . PHP_EOL . PHP_EOL; return self::consolePrompt($question,$cannotBeBlank); }//if return $answer[0]; }
[ "public", "function", "consolePrompt", "(", "$", "question", ",", "$", "cannotBeBlank", "=", "false", ")", "{", "@", "ob_flush", "(", ")", ";", "exec", "(", "\"read -p '{$question} ' answer; echo \\$answer;\"", ",", "$", "answer", ")", ";", "if", "(", "!", "$", "answer", "[", "0", "]", "&&", "$", "cannotBeBlank", "===", "true", ")", "{", "echo", "PHP_EOL", ".", "'Answer cannot be blank! Try again...'", ".", "PHP_EOL", ".", "PHP_EOL", ";", "return", "self", "::", "consolePrompt", "(", "$", "question", ",", "$", "cannotBeBlank", ")", ";", "}", "//if", "return", "$", "answer", "[", "0", "]", ";", "}" ]
Prompt the user at the console to enter a free form text response to a question. @param string $question The question that needs a response. @param boolean $cannotBeBlank The response to the question cannot be blank. @return string The response to the question.
[ "Prompt", "the", "user", "at", "the", "console", "to", "enter", "a", "free", "form", "text", "response", "to", "a", "question", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Console.class.php#L596-L609
14,822
datasift/datasift-php
lib/DataSift/Push/Definition.php
DataSift_Push_Definition.getOutputParam
public function getOutputParam($key) { if (isset($this->_output_params[$key])) { return $this->_output_params[$key]; } return null; }
php
public function getOutputParam($key) { if (isset($this->_output_params[$key])) { return $this->_output_params[$key]; } return null; }
[ "public", "function", "getOutputParam", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_output_params", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "_output_params", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
Get an output parameter. @param string $key The parameter to get. @return string
[ "Get", "an", "output", "parameter", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Definition.php#L132-L138
14,823
datasift/datasift-php
lib/DataSift/Push/Definition.php
DataSift_Push_Definition.validate
public function validate() { $retval = false; $params = array('output_type' => $this->_output_type); foreach ($this->_output_params as $key => $val) { $params[self::OUTPUT_PARAMS_PREFIX . $key] = $val; } try { $retval = $this->_user->post('push/validate', $params); } catch (DataSift_Exception_APIError $e) { throw new DataSift_Exception_InvalidData($e->getMessage()); } }
php
public function validate() { $retval = false; $params = array('output_type' => $this->_output_type); foreach ($this->_output_params as $key => $val) { $params[self::OUTPUT_PARAMS_PREFIX . $key] = $val; } try { $retval = $this->_user->post('push/validate', $params); } catch (DataSift_Exception_APIError $e) { throw new DataSift_Exception_InvalidData($e->getMessage()); } }
[ "public", "function", "validate", "(", ")", "{", "$", "retval", "=", "false", ";", "$", "params", "=", "array", "(", "'output_type'", "=>", "$", "this", "->", "_output_type", ")", ";", "foreach", "(", "$", "this", "->", "_output_params", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "params", "[", "self", "::", "OUTPUT_PARAMS_PREFIX", ".", "$", "key", "]", "=", "$", "val", ";", "}", "try", "{", "$", "retval", "=", "$", "this", "->", "_user", "->", "post", "(", "'push/validate'", ",", "$", "params", ")", ";", "}", "catch", "(", "DataSift_Exception_APIError", "$", "e", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Validate the output type and parameters with the DataSift API. @throws DataSift_Exception_AccessDenied @throws DataSift_Exception_InvalidData
[ "Validate", "the", "output", "type", "and", "parameters", "with", "the", "DataSift", "API", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Definition.php#L156-L170
14,824
datasift/datasift-php
lib/DataSift/Push/Definition.php
DataSift_Push_Definition.subscribe
protected function subscribe($hash_type, $hash, $name) { $retval = false; // API call parameters $params = array( 'name' => $name, $hash_type => $hash, 'output_type' => $this->_output_type, ); // Prefix the output parameters foreach ($this->_output_params as $key => $val) { $params[self::OUTPUT_PARAMS_PREFIX . $key] = $val; } // Add the initial status if it's not empty if (strlen($this->getInitialStatus()) > 0) { $params['initial_status'] = getInitialStatus(); } // Call the API and create a new PushSubscription from the returned // object return new DataSift_Push_Subscription($this->_user, $this->_user->post('push/create', $params)); }
php
protected function subscribe($hash_type, $hash, $name) { $retval = false; // API call parameters $params = array( 'name' => $name, $hash_type => $hash, 'output_type' => $this->_output_type, ); // Prefix the output parameters foreach ($this->_output_params as $key => $val) { $params[self::OUTPUT_PARAMS_PREFIX . $key] = $val; } // Add the initial status if it's not empty if (strlen($this->getInitialStatus()) > 0) { $params['initial_status'] = getInitialStatus(); } // Call the API and create a new PushSubscription from the returned // object return new DataSift_Push_Subscription($this->_user, $this->_user->post('push/create', $params)); }
[ "protected", "function", "subscribe", "(", "$", "hash_type", ",", "$", "hash", ",", "$", "name", ")", "{", "$", "retval", "=", "false", ";", "// API call parameters", "$", "params", "=", "array", "(", "'name'", "=>", "$", "name", ",", "$", "hash_type", "=>", "$", "hash", ",", "'output_type'", "=>", "$", "this", "->", "_output_type", ",", ")", ";", "// Prefix the output parameters", "foreach", "(", "$", "this", "->", "_output_params", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "params", "[", "self", "::", "OUTPUT_PARAMS_PREFIX", ".", "$", "key", "]", "=", "$", "val", ";", "}", "// Add the initial status if it's not empty", "if", "(", "strlen", "(", "$", "this", "->", "getInitialStatus", "(", ")", ")", ">", "0", ")", "{", "$", "params", "[", "'initial_status'", "]", "=", "getInitialStatus", "(", ")", ";", "}", "// Call the API and create a new PushSubscription from the returned", "// object", "return", "new", "DataSift_Push_Subscription", "(", "$", "this", "->", "_user", ",", "$", "this", "->", "_user", "->", "post", "(", "'push/create'", ",", "$", "params", ")", ")", ";", "}" ]
Subscribe this endpoint to a stream hash or historic playback ID. Note that this will activate the subscription if the initial status is set to active. @param string $hash_type "hash" or "playback_id" @param string $hash The hash or playback ID. @param string $name A name for this subscription. @return DataSift_PushSubscription The new subscription. @throws DataSift_Exception_InvalidData @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Subscribe", "this", "endpoint", "to", "a", "stream", "hash", "or", "historic", "playback", "ID", ".", "Note", "that", "this", "will", "activate", "the", "subscription", "if", "the", "initial", "status", "is", "set", "to", "active", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Definition.php#L250-L272
14,825
etki/opencart-core-installer
src/Plugin.php
Plugin.activate
public function activate(Composer $composer, IOInterface $ioc) { $installer = new Installer($ioc, $composer); /** @type InstallationManager $manager */ $manager = $composer->getInstallationManager(); $manager->addInstaller($installer); }
php
public function activate(Composer $composer, IOInterface $ioc) { $installer = new Installer($ioc, $composer); /** @type InstallationManager $manager */ $manager = $composer->getInstallationManager(); $manager->addInstaller($installer); }
[ "public", "function", "activate", "(", "Composer", "$", "composer", ",", "IOInterface", "$", "ioc", ")", "{", "$", "installer", "=", "new", "Installer", "(", "$", "ioc", ",", "$", "composer", ")", ";", "/** @type InstallationManager $manager */", "$", "manager", "=", "$", "composer", "->", "getInstallationManager", "(", ")", ";", "$", "manager", "->", "addInstaller", "(", "$", "installer", ")", ";", "}" ]
Activates plugin and registers installer. @param Composer $composer Composer instance. @param IOInterface $ioc I/O controller @return void @since 0.1.0
[ "Activates", "plugin", "and", "registers", "installer", "." ]
e651c94982afe966cd36977bbdc2ff4f7e785475
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/Plugin.php#L28-L34
14,826
Laralum/Roles
src/Traits/HasRolesAndPermissions.php
HasRolesAndPermissions.hasPermission
public function hasPermission($permission) { $permission = !is_string($permission) ?: Permission::where(['slug' => $permission])->first(); if (config('laralum.superadmin_bypass_haspermission')) { return true; } if ($permission) { foreach ($this->roles as $role) { if ($role->hasPermission($permission)) { return true; } } } return false; }
php
public function hasPermission($permission) { $permission = !is_string($permission) ?: Permission::where(['slug' => $permission])->first(); if (config('laralum.superadmin_bypass_haspermission')) { return true; } if ($permission) { foreach ($this->roles as $role) { if ($role->hasPermission($permission)) { return true; } } } return false; }
[ "public", "function", "hasPermission", "(", "$", "permission", ")", "{", "$", "permission", "=", "!", "is_string", "(", "$", "permission", ")", "?", ":", "Permission", "::", "where", "(", "[", "'slug'", "=>", "$", "permission", "]", ")", "->", "first", "(", ")", ";", "if", "(", "config", "(", "'laralum.superadmin_bypass_haspermission'", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "permission", ")", "{", "foreach", "(", "$", "this", "->", "roles", "as", "$", "role", ")", "{", "if", "(", "$", "role", "->", "hasPermission", "(", "$", "permission", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns true if the role has a permission. @param mixed $role @return bool
[ "Returns", "true", "if", "the", "role", "has", "a", "permission", "." ]
f934967a5dcebebf81915dd50fccdbcb7e23c113
https://github.com/Laralum/Roles/blob/f934967a5dcebebf81915dd50fccdbcb7e23c113/src/Traits/HasRolesAndPermissions.php#L18-L35
14,827
stubbles/stubbles-webapp-core
src/main/php/interceptor/AddAccessControlAllowOriginHeader.php
AddAccessControlAllowOriginHeader.postProcess
public function postProcess(Request $request, Response $response) { if (empty($this->allowedOriginHosts) || !$request->hasHeader('HTTP_ORIGIN')) { return; } $originHost = $request->readHeader('HTTP_ORIGIN')->unsecure(); foreach ($this->allowedOriginHosts as $allowedOriginHost) { if (preg_match('~' . $allowedOriginHost . '~', $originHost) === 1) { $response->addHeader('Access-Control-Allow-Origin', $originHost); } } }
php
public function postProcess(Request $request, Response $response) { if (empty($this->allowedOriginHosts) || !$request->hasHeader('HTTP_ORIGIN')) { return; } $originHost = $request->readHeader('HTTP_ORIGIN')->unsecure(); foreach ($this->allowedOriginHosts as $allowedOriginHost) { if (preg_match('~' . $allowedOriginHost . '~', $originHost) === 1) { $response->addHeader('Access-Control-Allow-Origin', $originHost); } } }
[ "public", "function", "postProcess", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "allowedOriginHosts", ")", "||", "!", "$", "request", "->", "hasHeader", "(", "'HTTP_ORIGIN'", ")", ")", "{", "return", ";", "}", "$", "originHost", "=", "$", "request", "->", "readHeader", "(", "'HTTP_ORIGIN'", ")", "->", "unsecure", "(", ")", ";", "foreach", "(", "$", "this", "->", "allowedOriginHosts", "as", "$", "allowedOriginHost", ")", "{", "if", "(", "preg_match", "(", "'~'", ".", "$", "allowedOriginHost", ".", "'~'", ",", "$", "originHost", ")", "===", "1", ")", "{", "$", "response", "->", "addHeader", "(", "'Access-Control-Allow-Origin'", ",", "$", "originHost", ")", ";", "}", "}", "}" ]
does the postprocessing stuff @param \stubbles\webapp\Request $request current request @param \stubbles\webapp\Response $response response to send
[ "does", "the", "postprocessing", "stuff" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/interceptor/AddAccessControlAllowOriginHeader.php#L64-L76
14,828
crossjoin/Css
src/Crossjoin/Css/Format/Rule/DeclarationAbstract.php
DeclarationAbstract.checkProperty
public function checkProperty(&$property) { if (is_string($property)) { $property = Placeholder::replaceStringsAndComments($property); $property = Placeholder::removeCommentPlaceholders($property, true); $property = Placeholder::replaceStringPlaceholders($property, true); return true; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($property). "' for argument 'property' given." ); } }
php
public function checkProperty(&$property) { if (is_string($property)) { $property = Placeholder::replaceStringsAndComments($property); $property = Placeholder::removeCommentPlaceholders($property, true); $property = Placeholder::replaceStringPlaceholders($property, true); return true; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($property). "' for argument 'property' given." ); } }
[ "public", "function", "checkProperty", "(", "&", "$", "property", ")", "{", "if", "(", "is_string", "(", "$", "property", ")", ")", "{", "$", "property", "=", "Placeholder", "::", "replaceStringsAndComments", "(", "$", "property", ")", ";", "$", "property", "=", "Placeholder", "::", "removeCommentPlaceholders", "(", "$", "property", ",", "true", ")", ";", "$", "property", "=", "Placeholder", "::", "replaceStringPlaceholders", "(", "$", "property", ",", "true", ")", ";", "return", "true", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "property", ")", ".", "\"' for argument 'property' given.\"", ")", ";", "}", "}" ]
Sets the declaration property. @param string $property @return bool
[ "Sets", "the", "declaration", "property", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/DeclarationAbstract.php#L56-L69
14,829
crossjoin/Css
src/Crossjoin/Css/Format/Rule/DeclarationAbstract.php
DeclarationAbstract.checkValue
public function checkValue(&$value) { if (is_string($value)) { $value = Placeholder::replaceStringsAndComments($value); $value = Placeholder::removeCommentPlaceholders($value, true); $value = Placeholder::replaceStringPlaceholders($value, true); $value = trim($value); if ($value !== '') { return true; } else { $this->setIsValid(false); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value). "' for argument 'value' given." ); } }
php
public function checkValue(&$value) { if (is_string($value)) { $value = Placeholder::replaceStringsAndComments($value); $value = Placeholder::removeCommentPlaceholders($value, true); $value = Placeholder::replaceStringPlaceholders($value, true); $value = trim($value); if ($value !== '') { return true; } else { $this->setIsValid(false); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value). "' for argument 'value' given." ); } }
[ "public", "function", "checkValue", "(", "&", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "Placeholder", "::", "replaceStringsAndComments", "(", "$", "value", ")", ";", "$", "value", "=", "Placeholder", "::", "removeCommentPlaceholders", "(", "$", "value", ",", "true", ")", ";", "$", "value", "=", "Placeholder", "::", "replaceStringPlaceholders", "(", "$", "value", ",", "true", ")", ";", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "if", "(", "$", "value", "!==", "''", ")", "{", "return", "true", ";", "}", "else", "{", "$", "this", "->", "setIsValid", "(", "false", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for argument 'value' given.\"", ")", ";", "}", "}" ]
Checks the declaration value. @param string $value @return bool
[ "Checks", "the", "declaration", "value", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/DeclarationAbstract.php#L99-L117
14,830
gbprod/elastica-provider-bundle
src/ElasticaProviderBundle/Provider/Handler.php
Handler.handle
public function handle(Client $client, $index, $type, $alias = null) { $alias = $alias ?: $index; $entries = $this->registry->get($alias, $type); $this->dispatchHandlingStartedEvent($entries); foreach ($entries as $entry) { $this->dispatchProvidingStartedEvent($entry); $entry->getProvider()->run( $client, $index, $entry->getType(), $this->dispatcher ); $this->dispatchProvidingFinishedEvent($entry); } }
php
public function handle(Client $client, $index, $type, $alias = null) { $alias = $alias ?: $index; $entries = $this->registry->get($alias, $type); $this->dispatchHandlingStartedEvent($entries); foreach ($entries as $entry) { $this->dispatchProvidingStartedEvent($entry); $entry->getProvider()->run( $client, $index, $entry->getType(), $this->dispatcher ); $this->dispatchProvidingFinishedEvent($entry); } }
[ "public", "function", "handle", "(", "Client", "$", "client", ",", "$", "index", ",", "$", "type", ",", "$", "alias", "=", "null", ")", "{", "$", "alias", "=", "$", "alias", "?", ":", "$", "index", ";", "$", "entries", "=", "$", "this", "->", "registry", "->", "get", "(", "$", "alias", ",", "$", "type", ")", ";", "$", "this", "->", "dispatchHandlingStartedEvent", "(", "$", "entries", ")", ";", "foreach", "(", "$", "entries", "as", "$", "entry", ")", "{", "$", "this", "->", "dispatchProvidingStartedEvent", "(", "$", "entry", ")", ";", "$", "entry", "->", "getProvider", "(", ")", "->", "run", "(", "$", "client", ",", "$", "index", ",", "$", "entry", "->", "getType", "(", ")", ",", "$", "this", "->", "dispatcher", ")", ";", "$", "this", "->", "dispatchProvidingFinishedEvent", "(", "$", "entry", ")", ";", "}", "}" ]
Handle provide command
[ "Handle", "provide", "command" ]
ee1e2ca78651d570b7400049bf81d8405fc744fc
https://github.com/gbprod/elastica-provider-bundle/blob/ee1e2ca78651d570b7400049bf81d8405fc744fc/src/ElasticaProviderBundle/Provider/Handler.php#L41-L61
14,831
antarctica/laravel-token-auth
src/Antarctica/LaravelTokenAuth/Filter/AuthFilter.php
AuthFilter.isUserTokenAuthenticated
private function isUserTokenAuthenticated() { try { $token = $this->TokenUser->getTokenInterface()->get(); $this->TokenUser->validate($token); } catch (Exception $exception) { // We will re-throw this error later if no other authentication types give a successful result return $exception; } return true; }
php
private function isUserTokenAuthenticated() { try { $token = $this->TokenUser->getTokenInterface()->get(); $this->TokenUser->validate($token); } catch (Exception $exception) { // We will re-throw this error later if no other authentication types give a successful result return $exception; } return true; }
[ "private", "function", "isUserTokenAuthenticated", "(", ")", "{", "try", "{", "$", "token", "=", "$", "this", "->", "TokenUser", "->", "getTokenInterface", "(", ")", "->", "get", "(", ")", ";", "$", "this", "->", "TokenUser", "->", "validate", "(", "$", "token", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "// We will re-throw this error later if no other authentication types give a successful result", "return", "$", "exception", ";", "}", "return", "true", ";", "}" ]
Validates an authentication token if provided, otherwise returns an exception that can be re-thrown later. @return bool|Exception
[ "Validates", "an", "authentication", "token", "if", "provided", "otherwise", "returns", "an", "exception", "that", "can", "be", "re", "-", "thrown", "later", "." ]
58a0cb29197d78294363df2be61eca4419ce755a
https://github.com/antarctica/laravel-token-auth/blob/58a0cb29197d78294363df2be61eca4419ce755a/src/Antarctica/LaravelTokenAuth/Filter/AuthFilter.php#L91-L105
14,832
activecollab/databasestructure
src/Field/Composite/ForeignKeyField.php
ForeignKeyField.getFields
public function getFields() { return [(new IntegerField($this->getName()))->unsigned(true)->size($this->getSize())->required($this->isRequired())]; }
php
public function getFields() { return [(new IntegerField($this->getName()))->unsigned(true)->size($this->getSize())->required($this->isRequired())]; }
[ "public", "function", "getFields", "(", ")", "{", "return", "[", "(", "new", "IntegerField", "(", "$", "this", "->", "getName", "(", ")", ")", ")", "->", "unsigned", "(", "true", ")", "->", "size", "(", "$", "this", "->", "getSize", "(", ")", ")", "->", "required", "(", "$", "this", "->", "isRequired", "(", ")", ")", "]", ";", "}" ]
Return fields that this field is composed of. @return FieldInterface[]
[ "Return", "fields", "that", "this", "field", "is", "composed", "of", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/ForeignKeyField.php#L63-L66
14,833
elkuku/crowdin-api
src/Languageproject.php
Languageproject.toQuery
public function toQuery() : array { $array = []; foreach (get_object_vars($this) as $name => $value) { if (null === $value) { continue; } if (is_array($value)) { if (count($value)) { foreach ($value as $v) { $array[] = [ 'name' => $name . '[]', 'contents' => $v ]; } } } else { $array[] = [ 'name' => $name, 'contents' => $value ]; } } return $array; }
php
public function toQuery() : array { $array = []; foreach (get_object_vars($this) as $name => $value) { if (null === $value) { continue; } if (is_array($value)) { if (count($value)) { foreach ($value as $v) { $array[] = [ 'name' => $name . '[]', 'contents' => $v ]; } } } else { $array[] = [ 'name' => $name, 'contents' => $value ]; } } return $array; }
[ "public", "function", "toQuery", "(", ")", ":", "array", "{", "$", "array", "=", "[", "]", ";", "foreach", "(", "get_object_vars", "(", "$", "this", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "continue", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "count", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "v", ")", "{", "$", "array", "[", "]", "=", "[", "'name'", "=>", "$", "name", ".", "'[]'", ",", "'contents'", "=>", "$", "v", "]", ";", "}", "}", "}", "else", "{", "$", "array", "[", "]", "=", "[", "'name'", "=>", "$", "name", ",", "'contents'", "=>", "$", "value", "]", ";", "}", "}", "return", "$", "array", ";", "}" ]
Convert tye object to query string. @return array
[ "Convert", "tye", "object", "to", "query", "string", "." ]
690f00eed8f91a875b3f288d319750d6d8ae0453
https://github.com/elkuku/crowdin-api/blob/690f00eed8f91a875b3f288d319750d6d8ae0453/src/Languageproject.php#L162-L196
14,834
FrenchFrogs/framework
src/Business/Business.php
Business.getId
public function getId($format = 'bytes') { return static::isUuid() && $format != false ? uuid($format, $this->id) : $this->id; }
php
public function getId($format = 'bytes') { return static::isUuid() && $format != false ? uuid($format, $this->id) : $this->id; }
[ "public", "function", "getId", "(", "$", "format", "=", "'bytes'", ")", "{", "return", "static", "::", "isUuid", "(", ")", "&&", "$", "format", "!=", "false", "?", "uuid", "(", "$", "format", ",", "$", "this", "->", "id", ")", ":", "$", "this", "->", "id", ";", "}" ]
Getter for ID @return mixed
[ "Getter", "for", "ID" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Business/Business.php#L70-L73
14,835
FrenchFrogs/framework
src/Business/Business.php
Business.getModel
public function getModel($reload = false) { if (!isset($this->model) || $reload) { $class = static::$modelClass; $this->model = $class::findOrFail($this->getId()); } return $this->model; }
php
public function getModel($reload = false) { if (!isset($this->model) || $reload) { $class = static::$modelClass; $this->model = $class::findOrFail($this->getId()); } return $this->model; }
[ "public", "function", "getModel", "(", "$", "reload", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "model", ")", "||", "$", "reload", ")", "{", "$", "class", "=", "static", "::", "$", "modelClass", ";", "$", "this", "->", "model", "=", "$", "class", "::", "findOrFail", "(", "$", "this", "->", "getId", "(", ")", ")", ";", "}", "return", "$", "this", "->", "model", ";", "}" ]
return the main model @param bool|false $reload @return \Illuminate\Database\Eloquent\Model
[ "return", "the", "main", "model" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Business/Business.php#L91-L99
14,836
FrenchFrogs/framework
src/Business/Business.php
Business.exists
static public function exists($id) { try { $class = static::$modelClass; $class::findOrFail(static::isUuid() ? uuid('bytes', $id) : $id); return true; } catch(\Exception $e) { return false; } }
php
static public function exists($id) { try { $class = static::$modelClass; $class::findOrFail(static::isUuid() ? uuid('bytes', $id) : $id); return true; } catch(\Exception $e) { return false; } }
[ "static", "public", "function", "exists", "(", "$", "id", ")", "{", "try", "{", "$", "class", "=", "static", "::", "$", "modelClass", ";", "$", "class", "::", "findOrFail", "(", "static", "::", "isUuid", "(", ")", "?", "uuid", "(", "'bytes'", ",", "$", "id", ")", ":", "$", "id", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
return true id user exist @param $id @return bool
[ "return", "true", "id", "user", "exist" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Business/Business.php#L157-L166
14,837
gbv/orcid-jskos
src/ORCIDService.php
ORCIDService.getOAuthToken
protected function getOAuthToken() { # TODO: use session to store the token if ($this->client_id and $this->client_secret) { $response = $this->httpQuery( 'POST', 'https://orcid.org/oauth/token', [ 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded' ], http_build_query([ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'scope' => '/read-public', 'grant_type' => 'client_credentials', ]) ); if ($response) { return $response->{'access_token'}; } } }
php
protected function getOAuthToken() { # TODO: use session to store the token if ($this->client_id and $this->client_secret) { $response = $this->httpQuery( 'POST', 'https://orcid.org/oauth/token', [ 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded' ], http_build_query([ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'scope' => '/read-public', 'grant_type' => 'client_credentials', ]) ); if ($response) { return $response->{'access_token'}; } } }
[ "protected", "function", "getOAuthToken", "(", ")", "{", "# TODO: use session to store the token", "if", "(", "$", "this", "->", "client_id", "and", "$", "this", "->", "client_secret", ")", "{", "$", "response", "=", "$", "this", "->", "httpQuery", "(", "'POST'", ",", "'https://orcid.org/oauth/token'", ",", "[", "'Accept'", "=>", "'application/json'", ",", "'Content-Type'", "=>", "'application/x-www-form-urlencoded'", "]", ",", "http_build_query", "(", "[", "'client_id'", "=>", "$", "this", "->", "client_id", ",", "'client_secret'", "=>", "$", "this", "->", "client_secret", ",", "'scope'", "=>", "'/read-public'", ",", "'grant_type'", "=>", "'client_credentials'", ",", "]", ")", ")", ";", "if", "(", "$", "response", ")", "{", "return", "$", "response", "->", "{", "'access_token'", "}", ";", "}", "}", "}" ]
Get an OAuth access token
[ "Get", "an", "OAuth", "access", "token" ]
1b7db5d11e8f8fde47e2d068f32770b33fa427a5
https://github.com/gbv/orcid-jskos/blob/1b7db5d11e8f8fde47e2d068f32770b33fa427a5/src/ORCIDService.php#L54-L75
14,838
gbv/orcid-jskos
src/ORCIDService.php
ORCIDService.getProfile
protected function getProfile( $id ) { $token = $this->getOAuthToken(); if (!$token) return; $response = $this->httpQuery( 'GET', "https://pub.orcid.org/v1.2/$id/orcid-bio/", [ 'Authorization' => "Bearer $token", 'Accept' => 'application/json', ] ); if ($response) { return $response->{'orcid-profile'}; } }
php
protected function getProfile( $id ) { $token = $this->getOAuthToken(); if (!$token) return; $response = $this->httpQuery( 'GET', "https://pub.orcid.org/v1.2/$id/orcid-bio/", [ 'Authorization' => "Bearer $token", 'Accept' => 'application/json', ] ); if ($response) { return $response->{'orcid-profile'}; } }
[ "protected", "function", "getProfile", "(", "$", "id", ")", "{", "$", "token", "=", "$", "this", "->", "getOAuthToken", "(", ")", ";", "if", "(", "!", "$", "token", ")", "return", ";", "$", "response", "=", "$", "this", "->", "httpQuery", "(", "'GET'", ",", "\"https://pub.orcid.org/v1.2/$id/orcid-bio/\"", ",", "[", "'Authorization'", "=>", "\"Bearer $token\"", ",", "'Accept'", "=>", "'application/json'", ",", "]", ")", ";", "if", "(", "$", "response", ")", "{", "return", "$", "response", "->", "{", "'orcid-profile'", "}", ";", "}", "}" ]
get an indentified profile by ORCID ID
[ "get", "an", "indentified", "profile", "by", "ORCID", "ID" ]
1b7db5d11e8f8fde47e2d068f32770b33fa427a5
https://github.com/gbv/orcid-jskos/blob/1b7db5d11e8f8fde47e2d068f32770b33fa427a5/src/ORCIDService.php#L116-L133
14,839
gbv/orcid-jskos
src/ORCIDService.php
ORCIDService.searchProfiles
protected function searchProfiles( $query ) { $token = $this->getOAuthToken(); if (!$token) return; $response = Unirest\Request::get( "https://pub.orcid.org/v1.2/search/orcid-bio/", [ 'Authorization' => "Bearer $token", 'Content-Type' => 'application/orcid+json' ], # TODO: search in names only and use boosting [ 'q' => luceneQuery('text',$query) ] ); if ($response->code == 200) { return $response->body->{'orcid-search-results'}; } }
php
protected function searchProfiles( $query ) { $token = $this->getOAuthToken(); if (!$token) return; $response = Unirest\Request::get( "https://pub.orcid.org/v1.2/search/orcid-bio/", [ 'Authorization' => "Bearer $token", 'Content-Type' => 'application/orcid+json' ], # TODO: search in names only and use boosting [ 'q' => luceneQuery('text',$query) ] ); if ($response->code == 200) { return $response->body->{'orcid-search-results'}; } }
[ "protected", "function", "searchProfiles", "(", "$", "query", ")", "{", "$", "token", "=", "$", "this", "->", "getOAuthToken", "(", ")", ";", "if", "(", "!", "$", "token", ")", "return", ";", "$", "response", "=", "Unirest", "\\", "Request", "::", "get", "(", "\"https://pub.orcid.org/v1.2/search/orcid-bio/\"", ",", "[", "'Authorization'", "=>", "\"Bearer $token\"", ",", "'Content-Type'", "=>", "'application/orcid+json'", "]", ",", "# TODO: search in names only and use boosting", "[", "'q'", "=>", "luceneQuery", "(", "'text'", ",", "$", "query", ")", "]", ")", ";", "if", "(", "$", "response", "->", "code", "==", "200", ")", "{", "return", "$", "response", "->", "body", "->", "{", "'orcid-search-results'", "}", ";", "}", "}" ]
search for an ORCID profile
[ "search", "for", "an", "ORCID", "profile" ]
1b7db5d11e8f8fde47e2d068f32770b33fa427a5
https://github.com/gbv/orcid-jskos/blob/1b7db5d11e8f8fde47e2d068f32770b33fa427a5/src/ORCIDService.php#L136-L154
14,840
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/ListsGateway.php
ListsGateway.getList
public function getList(array $options = array()) { $uri = $this->buildListResourceUri($this->listId); $response = $this->makeApiRequest($uri, $options); return $response->list; }
php
public function getList(array $options = array()) { $uri = $this->buildListResourceUri($this->listId); $response = $this->makeApiRequest($uri, $options); return $response->list; }
[ "public", "function", "getList", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "uri", "=", "$", "this", "->", "buildListResourceUri", "(", "$", "this", "->", "listId", ")", ";", "$", "response", "=", "$", "this", "->", "makeApiRequest", "(", "$", "uri", ",", "$", "options", ")", ";", "return", "$", "response", "->", "list", ";", "}" ]
Get a List. @see https://developer.foursquare.com/docs/lists/lists @param array $options
[ "Get", "a", "List", "." ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/ListsGateway.php#L26-L31
14,841
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.resolve
function resolve( $url = '', Array $query_string_vars = [ ] ) { if ( $this->done && empty( $this->error ) ) { return $this->query_vars; } $this->parseUrl( $url, $query_string_vars ); $rewrite = (array) $this->resolver->getRewrite(); if ( ! empty( $rewrite ) ) { list( $matches, $query ) = $this->parseRewriteRules( $rewrite ); $this->setMatchedQuery( $matches, $query ); $this->maybeAdmin(); } return $this->resolveVars(); }
php
function resolve( $url = '', Array $query_string_vars = [ ] ) { if ( $this->done && empty( $this->error ) ) { return $this->query_vars; } $this->parseUrl( $url, $query_string_vars ); $rewrite = (array) $this->resolver->getRewrite(); if ( ! empty( $rewrite ) ) { list( $matches, $query ) = $this->parseRewriteRules( $rewrite ); $this->setMatchedQuery( $matches, $query ); $this->maybeAdmin(); } return $this->resolveVars(); }
[ "function", "resolve", "(", "$", "url", "=", "''", ",", "Array", "$", "query_string_vars", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "done", "&&", "empty", "(", "$", "this", "->", "error", ")", ")", "{", "return", "$", "this", "->", "query_vars", ";", "}", "$", "this", "->", "parseUrl", "(", "$", "url", ",", "$", "query_string_vars", ")", ";", "$", "rewrite", "=", "(", "array", ")", "$", "this", "->", "resolver", "->", "getRewrite", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "rewrite", ")", ")", "{", "list", "(", "$", "matches", ",", "$", "query", ")", "=", "$", "this", "->", "parseRewriteRules", "(", "$", "rewrite", ")", ";", "$", "this", "->", "setMatchedQuery", "(", "$", "matches", ",", "$", "query", ")", ";", "$", "this", "->", "maybeAdmin", "(", ")", ";", "}", "return", "$", "this", "->", "resolveVars", "(", ")", ";", "}" ]
Resolve an url to an array of WP_Query arguments for main query. @param string $url Url to resolve @param type $query_string_vars Query variables to be added to the url @return array|\WP_Error Resolved query or WP_Error is something goes wrong
[ "Resolve", "an", "url", "to", "an", "array", "of", "WP_Query", "arguments", "for", "main", "query", "." ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L80-L92
14,842
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.parseUrl
private function parseUrl( $url = '', Array $query_string_vars = [ ] ) { parse_str( parse_url( $url, PHP_URL_QUERY ), $this->query_string ); $request_uri = trim( parse_url( $url, PHP_URL_PATH ), '/' ); $this->request = trim( preg_replace( '#^/*index\.php#', '', $request_uri ), '/' ); if ( ! empty( $query_string_vars ) ) { $this->query_string = array_merge( $this->query_string, $query_string_vars ); } }
php
private function parseUrl( $url = '', Array $query_string_vars = [ ] ) { parse_str( parse_url( $url, PHP_URL_QUERY ), $this->query_string ); $request_uri = trim( parse_url( $url, PHP_URL_PATH ), '/' ); $this->request = trim( preg_replace( '#^/*index\.php#', '', $request_uri ), '/' ); if ( ! empty( $query_string_vars ) ) { $this->query_string = array_merge( $this->query_string, $query_string_vars ); } }
[ "private", "function", "parseUrl", "(", "$", "url", "=", "''", ",", "Array", "$", "query_string_vars", "=", "[", "]", ")", "{", "parse_str", "(", "parse_url", "(", "$", "url", ",", "PHP_URL_QUERY", ")", ",", "$", "this", "->", "query_string", ")", ";", "$", "request_uri", "=", "trim", "(", "parse_url", "(", "$", "url", ",", "PHP_URL_PATH", ")", ",", "'/'", ")", ";", "$", "this", "->", "request", "=", "trim", "(", "preg_replace", "(", "'#^/*index\\.php#'", ",", "''", ",", "$", "request_uri", ")", ",", "'/'", ")", ";", "if", "(", "!", "empty", "(", "$", "query_string_vars", ")", ")", "{", "$", "this", "->", "query_string", "=", "array_merge", "(", "$", "this", "->", "query_string", ",", "$", "query_string_vars", ")", ";", "}", "}" ]
Parse the url to be resolved taking only relative part and stripping out query vars. @param type string @param array $query_string_vars
[ "Parse", "the", "url", "to", "be", "resolved", "taking", "only", "relative", "part", "and", "stripping", "out", "query", "vars", "." ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L161-L168
14,843
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.parseRewriteRules
private function parseRewriteRules( Array $rewrite ) { $this->error = '404'; $request_match = $this->request; if ( empty( $request_match ) && isset( $rewrite['$'] ) ) { $this->matched_rule = '$'; $matches = [ '' ]; $query = $rewrite['$']; } else { foreach ( (array) $rewrite as $match => $query ) { $matches = $this->parseRewriteRule( $match, $query ); if ( ! is_null( $this->matched_rule ) ) { return [ $matches, $query ]; } } } return [ $matches, $query ]; }
php
private function parseRewriteRules( Array $rewrite ) { $this->error = '404'; $request_match = $this->request; if ( empty( $request_match ) && isset( $rewrite['$'] ) ) { $this->matched_rule = '$'; $matches = [ '' ]; $query = $rewrite['$']; } else { foreach ( (array) $rewrite as $match => $query ) { $matches = $this->parseRewriteRule( $match, $query ); if ( ! is_null( $this->matched_rule ) ) { return [ $matches, $query ]; } } } return [ $matches, $query ]; }
[ "private", "function", "parseRewriteRules", "(", "Array", "$", "rewrite", ")", "{", "$", "this", "->", "error", "=", "'404'", ";", "$", "request_match", "=", "$", "this", "->", "request", ";", "if", "(", "empty", "(", "$", "request_match", ")", "&&", "isset", "(", "$", "rewrite", "[", "'$'", "]", ")", ")", "{", "$", "this", "->", "matched_rule", "=", "'$'", ";", "$", "matches", "=", "[", "''", "]", ";", "$", "query", "=", "$", "rewrite", "[", "'$'", "]", ";", "}", "else", "{", "foreach", "(", "(", "array", ")", "$", "rewrite", "as", "$", "match", "=>", "$", "query", ")", "{", "$", "matches", "=", "$", "this", "->", "parseRewriteRule", "(", "$", "match", ",", "$", "query", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "matched_rule", ")", ")", "{", "return", "[", "$", "matches", ",", "$", "query", "]", ";", "}", "}", "}", "return", "[", "$", "matches", ",", "$", "query", "]", ";", "}" ]
Loop throught registered rewrite rule and check them against the url to resolve. @param array $rewrite @return array @uses \GM\UrlToQueryItem::parseRewriteRule()
[ "Loop", "throught", "registered", "rewrite", "rule", "and", "check", "them", "against", "the", "url", "to", "resolve", "." ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L177-L193
14,844
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.setMatchedQuery
private function setMatchedQuery( $matches = [ ], $query = '' ) { if ( ! is_null( $this->matched_rule ) ) { $mathed = \WP_MatchesMapRegex::apply( preg_replace( "!^.+\?!", '', $query ), $matches ); $this->matched_query = addslashes( $mathed ); parse_str( $this->matched_query, $this->perma_q_vars ); if ( '404' === $this->error ) $this->error = NULL; } }
php
private function setMatchedQuery( $matches = [ ], $query = '' ) { if ( ! is_null( $this->matched_rule ) ) { $mathed = \WP_MatchesMapRegex::apply( preg_replace( "!^.+\?!", '', $query ), $matches ); $this->matched_query = addslashes( $mathed ); parse_str( $this->matched_query, $this->perma_q_vars ); if ( '404' === $this->error ) $this->error = NULL; } }
[ "private", "function", "setMatchedQuery", "(", "$", "matches", "=", "[", "]", ",", "$", "query", "=", "''", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "matched_rule", ")", ")", "{", "$", "mathed", "=", "\\", "WP_MatchesMapRegex", "::", "apply", "(", "preg_replace", "(", "\"!^.+\\?!\"", ",", "''", ",", "$", "query", ")", ",", "$", "matches", ")", ";", "$", "this", "->", "matched_query", "=", "addslashes", "(", "$", "mathed", ")", ";", "parse_str", "(", "$", "this", "->", "matched_query", ",", "$", "this", "->", "perma_q_vars", ")", ";", "if", "(", "'404'", "===", "$", "this", "->", "error", ")", "$", "this", "->", "error", "=", "NULL", ";", "}", "}" ]
When a rute matches, save matched query string and matched query array. @param array $matches Matches coming from regex compare matched rule to url @param string $query Query part of the matched rule
[ "When", "a", "rute", "matches", "save", "matched", "query", "string", "and", "matched", "query", "array", "." ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L231-L238
14,845
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.maybeAdmin
private function maybeAdmin() { if ( empty( $this->request ) || strpos( $this->request, 'wp-admin/' ) !== FALSE ) { $this->error = NULL; if ( ! is_null( $this->perma_q_vars ) && strpos( $this->request, 'wp-admin/' ) !== FALSE ) { $this->perma_q_vars = NULL; } } }
php
private function maybeAdmin() { if ( empty( $this->request ) || strpos( $this->request, 'wp-admin/' ) !== FALSE ) { $this->error = NULL; if ( ! is_null( $this->perma_q_vars ) && strpos( $this->request, 'wp-admin/' ) !== FALSE ) { $this->perma_q_vars = NULL; } } }
[ "private", "function", "maybeAdmin", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "request", ")", "||", "strpos", "(", "$", "this", "->", "request", ",", "'wp-admin/'", ")", "!==", "FALSE", ")", "{", "$", "this", "->", "error", "=", "NULL", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "perma_q_vars", ")", "&&", "strpos", "(", "$", "this", "->", "request", ",", "'wp-admin/'", ")", "!==", "FALSE", ")", "{", "$", "this", "->", "perma_q_vars", "=", "NULL", ";", "}", "}", "}" ]
Check if the url is for admin, in that case unset all the frontend query variables
[ "Check", "if", "the", "url", "is", "for", "admin", "in", "that", "case", "unset", "all", "the", "frontend", "query", "variables" ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L243-L253
14,846
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.resolveVars
private function resolveVars() { $this->setCptQueryVars(); $wp = $this->resolver->getWp(); $public_query_vars = (array) apply_filters( 'query_vars', $wp->public_query_vars ); $extra_query_vars = (array) $this->resolver->getExtraQueryVars(); $this->parseQueryVars( $public_query_vars, $extra_query_vars ); $this->parseTaxQueryVars(); $this->parseCptQueryVars(); $this->parsePrivateQueryVars( $extra_query_vars, $wp->private_query_vars ); if ( ! is_null( $this->error ) ) { return $this->getError(); } $this->query_vars = apply_filters( 'request', $this->query_vars ); $this->done = TRUE; return $this->query_vars; }
php
private function resolveVars() { $this->setCptQueryVars(); $wp = $this->resolver->getWp(); $public_query_vars = (array) apply_filters( 'query_vars', $wp->public_query_vars ); $extra_query_vars = (array) $this->resolver->getExtraQueryVars(); $this->parseQueryVars( $public_query_vars, $extra_query_vars ); $this->parseTaxQueryVars(); $this->parseCptQueryVars(); $this->parsePrivateQueryVars( $extra_query_vars, $wp->private_query_vars ); if ( ! is_null( $this->error ) ) { return $this->getError(); } $this->query_vars = apply_filters( 'request', $this->query_vars ); $this->done = TRUE; return $this->query_vars; }
[ "private", "function", "resolveVars", "(", ")", "{", "$", "this", "->", "setCptQueryVars", "(", ")", ";", "$", "wp", "=", "$", "this", "->", "resolver", "->", "getWp", "(", ")", ";", "$", "public_query_vars", "=", "(", "array", ")", "apply_filters", "(", "'query_vars'", ",", "$", "wp", "->", "public_query_vars", ")", ";", "$", "extra_query_vars", "=", "(", "array", ")", "$", "this", "->", "resolver", "->", "getExtraQueryVars", "(", ")", ";", "$", "this", "->", "parseQueryVars", "(", "$", "public_query_vars", ",", "$", "extra_query_vars", ")", ";", "$", "this", "->", "parseTaxQueryVars", "(", ")", ";", "$", "this", "->", "parseCptQueryVars", "(", ")", ";", "$", "this", "->", "parsePrivateQueryVars", "(", "$", "extra_query_vars", ",", "$", "wp", "->", "private_query_vars", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "error", ")", ")", "{", "return", "$", "this", "->", "getError", "(", ")", ";", "}", "$", "this", "->", "query_vars", "=", "apply_filters", "(", "'request'", ",", "$", "this", "->", "query_vars", ")", ";", "$", "this", "->", "done", "=", "TRUE", ";", "return", "$", "this", "->", "query_vars", ";", "}" ]
Setup the query variables if a rewrite rule matched or if some variables are passed as query string. Strips out not registered query variables and perform the 'request' filter before saving and return found query vars. @return array @uses \GM\UrlToQueryItem::parseQueryVars() @uses \GM\UrlToQueryItem::parseTaxQueryVars() @uses \GM\UrlToQueryItem::parseCptQueryVars() @uses \GM\UrlToQueryItem::parsePrivateQueryVars()
[ "Setup", "the", "query", "variables", "if", "a", "rewrite", "rule", "matched", "or", "if", "some", "variables", "are", "passed", "as", "query", "string", ".", "Strips", "out", "not", "registered", "query", "variables", "and", "perform", "the", "request", "filter", "before", "saving", "and", "return", "found", "query", "vars", "." ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L266-L281
14,847
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.setCptQueryVars
private function setCptQueryVars() { foreach ( get_post_types( [ ], 'objects' ) as $post_type => $t ) { if ( $t->query_var ) $this->post_type_query_vars[$t->query_var] = $post_type; } }
php
private function setCptQueryVars() { foreach ( get_post_types( [ ], 'objects' ) as $post_type => $t ) { if ( $t->query_var ) $this->post_type_query_vars[$t->query_var] = $post_type; } }
[ "private", "function", "setCptQueryVars", "(", ")", "{", "foreach", "(", "get_post_types", "(", "[", "]", ",", "'objects'", ")", "as", "$", "post_type", "=>", "$", "t", ")", "{", "if", "(", "$", "t", "->", "query_var", ")", "$", "this", "->", "post_type_query_vars", "[", "$", "t", "->", "query_var", "]", "=", "$", "post_type", ";", "}", "}" ]
Store all the query rewrite slugs for all registered post types
[ "Store", "all", "the", "query", "rewrite", "slugs", "for", "all", "registered", "post", "types" ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L286-L290
14,848
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.parseQueryVar
private function parseQueryVar( $wpvar = '' ) { if ( ! is_array( $this->query_vars[$wpvar] ) ) { $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; } else { foreach ( $this->query_vars[$wpvar] as $vkey => $v ) { if ( ! is_object( $v ) ) { $this->query_vars[$wpvar][$vkey] = (string) $v; } } } if ( isset( $this->post_type_query_vars[$wpvar] ) ) { $this->query_vars['post_type'] = $this->post_type_query_vars[$wpvar]; $this->query_vars['name'] = $this->query_vars[$wpvar]; } }
php
private function parseQueryVar( $wpvar = '' ) { if ( ! is_array( $this->query_vars[$wpvar] ) ) { $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; } else { foreach ( $this->query_vars[$wpvar] as $vkey => $v ) { if ( ! is_object( $v ) ) { $this->query_vars[$wpvar][$vkey] = (string) $v; } } } if ( isset( $this->post_type_query_vars[$wpvar] ) ) { $this->query_vars['post_type'] = $this->post_type_query_vars[$wpvar]; $this->query_vars['name'] = $this->query_vars[$wpvar]; } }
[ "private", "function", "parseQueryVar", "(", "$", "wpvar", "=", "''", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "query_vars", "[", "$", "wpvar", "]", ")", ")", "{", "$", "this", "->", "query_vars", "[", "$", "wpvar", "]", "=", "(", "string", ")", "$", "this", "->", "query_vars", "[", "$", "wpvar", "]", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "query_vars", "[", "$", "wpvar", "]", "as", "$", "vkey", "=>", "$", "v", ")", "{", "if", "(", "!", "is_object", "(", "$", "v", ")", ")", "{", "$", "this", "->", "query_vars", "[", "$", "wpvar", "]", "[", "$", "vkey", "]", "=", "(", "string", ")", "$", "v", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "post_type_query_vars", "[", "$", "wpvar", "]", ")", ")", "{", "$", "this", "->", "query_vars", "[", "'post_type'", "]", "=", "$", "this", "->", "post_type_query_vars", "[", "$", "wpvar", "]", ";", "$", "this", "->", "query_vars", "[", "'name'", "]", "=", "$", "this", "->", "query_vars", "[", "$", "wpvar", "]", ";", "}", "}" ]
Parse a query variable, "flattening" it if is an array or an object, also set 'post_type' and 'name' query var, if a slug of a registered post type is present among query vars @param string $wpvar
[ "Parse", "a", "query", "variable", "flattening", "it", "if", "is", "an", "array", "or", "an", "object", "also", "set", "post_type", "and", "name", "query", "var", "if", "a", "slug", "of", "a", "registered", "post", "type", "is", "present", "among", "query", "vars" ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L321-L335
14,849
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.parseTaxQueryVars
private function parseTaxQueryVars() { foreach ( get_taxonomies( [ ], 'objects' ) as $t ) { if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) { $encoded = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); $this->query_vars[$t->query_var] = $encoded; } } }
php
private function parseTaxQueryVars() { foreach ( get_taxonomies( [ ], 'objects' ) as $t ) { if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) { $encoded = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); $this->query_vars[$t->query_var] = $encoded; } } }
[ "private", "function", "parseTaxQueryVars", "(", ")", "{", "foreach", "(", "get_taxonomies", "(", "[", "]", ",", "'objects'", ")", "as", "$", "t", ")", "{", "if", "(", "$", "t", "->", "query_var", "&&", "isset", "(", "$", "this", "->", "query_vars", "[", "$", "t", "->", "query_var", "]", ")", ")", "{", "$", "encoded", "=", "str_replace", "(", "' '", ",", "'+'", ",", "$", "this", "->", "query_vars", "[", "$", "t", "->", "query_var", "]", ")", ";", "$", "this", "->", "query_vars", "[", "$", "t", "->", "query_var", "]", "=", "$", "encoded", ";", "}", "}", "}" ]
Convert spacet to '+' in the query variables for custom taxonomies
[ "Convert", "spacet", "to", "+", "in", "the", "query", "variables", "for", "custom", "taxonomies" ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L340-L347
14,850
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.parseCptQueryVars
private function parseCptQueryVars() { if ( isset( $this->query_vars['post_type'] ) ) { $queryable = get_post_types( [ 'publicly_queryable' => TRUE ] ); if ( ! is_array( $this->query_vars['post_type'] ) && ! in_array( $this->query_vars['post_type'], $queryable, TRUE ) ) { unset( $this->query_vars['post_type'] ); } elseif ( is_array( $this->query_vars['post_type'] ) ) { $allowed = array_intersect( $this->query_vars['post_type'], $queryable ); $this->query_vars['post_type'] = $allowed; } } }
php
private function parseCptQueryVars() { if ( isset( $this->query_vars['post_type'] ) ) { $queryable = get_post_types( [ 'publicly_queryable' => TRUE ] ); if ( ! is_array( $this->query_vars['post_type'] ) && ! in_array( $this->query_vars['post_type'], $queryable, TRUE ) ) { unset( $this->query_vars['post_type'] ); } elseif ( is_array( $this->query_vars['post_type'] ) ) { $allowed = array_intersect( $this->query_vars['post_type'], $queryable ); $this->query_vars['post_type'] = $allowed; } } }
[ "private", "function", "parseCptQueryVars", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "query_vars", "[", "'post_type'", "]", ")", ")", "{", "$", "queryable", "=", "get_post_types", "(", "[", "'publicly_queryable'", "=>", "TRUE", "]", ")", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "query_vars", "[", "'post_type'", "]", ")", "&&", "!", "in_array", "(", "$", "this", "->", "query_vars", "[", "'post_type'", "]", ",", "$", "queryable", ",", "TRUE", ")", ")", "{", "unset", "(", "$", "this", "->", "query_vars", "[", "'post_type'", "]", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "this", "->", "query_vars", "[", "'post_type'", "]", ")", ")", "{", "$", "allowed", "=", "array_intersect", "(", "$", "this", "->", "query_vars", "[", "'post_type'", "]", ",", "$", "queryable", ")", ";", "$", "this", "->", "query_vars", "[", "'post_type'", "]", "=", "$", "allowed", ";", "}", "}", "}" ]
Remove from query variables any non publicly queriable post type rewrite slug
[ "Remove", "from", "query", "variables", "any", "non", "publicly", "queriable", "post", "type", "rewrite", "slug" ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L352-L365
14,851
gmazzap/Url_To_Query
UrlToQueryItem.php
UrlToQueryItem.parsePrivateQueryVars
private function parsePrivateQueryVars( Array $extra = [ ], Array $private = [ ] ) { if ( ! empty( $extra ) ) { foreach ( $private as $var ) { if ( isset( $extra[$var] ) ) { $this->query_vars[$var] = $extra[$var]; } } } }
php
private function parsePrivateQueryVars( Array $extra = [ ], Array $private = [ ] ) { if ( ! empty( $extra ) ) { foreach ( $private as $var ) { if ( isset( $extra[$var] ) ) { $this->query_vars[$var] = $extra[$var]; } } } }
[ "private", "function", "parsePrivateQueryVars", "(", "Array", "$", "extra", "=", "[", "]", ",", "Array", "$", "private", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "extra", ")", ")", "{", "foreach", "(", "$", "private", "as", "$", "var", ")", "{", "if", "(", "isset", "(", "$", "extra", "[", "$", "var", "]", ")", ")", "{", "$", "this", "->", "query_vars", "[", "$", "var", "]", "=", "$", "extra", "[", "$", "var", "]", ";", "}", "}", "}", "}" ]
Look in extra query variables passed to resolver and compare to WP object private variables if some variables are found they are added to query variables to be returned @param array $extra @param array $private
[ "Look", "in", "extra", "query", "variables", "passed", "to", "resolver", "and", "compare", "to", "WP", "object", "private", "variables", "if", "some", "variables", "are", "found", "they", "are", "added", "to", "query", "variables", "to", "be", "returned" ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQueryItem.php#L374-L382
14,852
drunomics/service-utils
src/Core/File/FileSystemTrait.php
FileSystemTrait.getFileSystem
public function getFileSystem() { if (empty($this->fileSystem)) { $this->fileSystem = \Drupal::service('file_system'); } return $this->fileSystem; }
php
public function getFileSystem() { if (empty($this->fileSystem)) { $this->fileSystem = \Drupal::service('file_system'); } return $this->fileSystem; }
[ "public", "function", "getFileSystem", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "fileSystem", ")", ")", "{", "$", "this", "->", "fileSystem", "=", "\\", "Drupal", "::", "service", "(", "'file_system'", ")", ";", "}", "return", "$", "this", "->", "fileSystem", ";", "}" ]
Gets the file system. @return \Drupal\Core\File\FileSystemInterface The file system.
[ "Gets", "the", "file", "system", "." ]
56761750043132365ef4ae5d9e0cf4263459328f
https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/Core/File/FileSystemTrait.php#L38-L43
14,853
gregorybesson/PlaygroundCore
src/Service/Recaptcha.php
Recaptcha.recaptcha
public function recaptcha($response, $ipClient = null) { if ($this->getOptions()->getGRecaptchaKey()) { $client = new \Zend\Http\Client($this->getOptions()->getGRecaptchaUrl()); $client->setParameterPost(array( 'secret' => $this->getOptions()->getGRecaptchaKey(), 'response' => $response, 'remoteip' => $ipClient, )); $client->setMethod(\Zend\Http\Request::METHOD_POST); $result = $client->send(); if ($result) { $jsonResult = \Zend\Json\Json::decode($result->getBody()); if ($jsonResult->success) { return true; } } } return false; }
php
public function recaptcha($response, $ipClient = null) { if ($this->getOptions()->getGRecaptchaKey()) { $client = new \Zend\Http\Client($this->getOptions()->getGRecaptchaUrl()); $client->setParameterPost(array( 'secret' => $this->getOptions()->getGRecaptchaKey(), 'response' => $response, 'remoteip' => $ipClient, )); $client->setMethod(\Zend\Http\Request::METHOD_POST); $result = $client->send(); if ($result) { $jsonResult = \Zend\Json\Json::decode($result->getBody()); if ($jsonResult->success) { return true; } } } return false; }
[ "public", "function", "recaptcha", "(", "$", "response", ",", "$", "ipClient", "=", "null", ")", "{", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getGRecaptchaKey", "(", ")", ")", "{", "$", "client", "=", "new", "\\", "Zend", "\\", "Http", "\\", "Client", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getGRecaptchaUrl", "(", ")", ")", ";", "$", "client", "->", "setParameterPost", "(", "array", "(", "'secret'", "=>", "$", "this", "->", "getOptions", "(", ")", "->", "getGRecaptchaKey", "(", ")", ",", "'response'", "=>", "$", "response", ",", "'remoteip'", "=>", "$", "ipClient", ",", ")", ")", ";", "$", "client", "->", "setMethod", "(", "\\", "Zend", "\\", "Http", "\\", "Request", "::", "METHOD_POST", ")", ";", "$", "result", "=", "$", "client", "->", "send", "(", ")", ";", "if", "(", "$", "result", ")", "{", "$", "jsonResult", "=", "\\", "Zend", "\\", "Json", "\\", "Json", "::", "decode", "(", "$", "result", "->", "getBody", "(", ")", ")", ";", "if", "(", "$", "jsonResult", "->", "success", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
This method calls Google ReCaptcha. @param unknown_type $url @return unknown
[ "This", "method", "calls", "Google", "ReCaptcha", "." ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Service/Recaptcha.php#L36-L57
14,854
BugBuster1701/banner
classes/BannerHelper.php
BannerHelper.checkSetUserFrontendLogin
protected function checkSetUserFrontendLogin() { if (FE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); if ( $this->arrCategoryValues['banner_protected'] == 1 && $this->arrCategoryValues['banner_group'] > 0 ) { if ( $this->User->isMemberOf($this->arrCategoryValues['banner_group']) === false ) { $this->statusBannerFrontendGroupView = false; return false; } } } return true; }
php
protected function checkSetUserFrontendLogin() { if (FE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); if ( $this->arrCategoryValues['banner_protected'] == 1 && $this->arrCategoryValues['banner_group'] > 0 ) { if ( $this->User->isMemberOf($this->arrCategoryValues['banner_group']) === false ) { $this->statusBannerFrontendGroupView = false; return false; } } } return true; }
[ "protected", "function", "checkSetUserFrontendLogin", "(", ")", "{", "if", "(", "FE_USER_LOGGED_IN", ")", "{", "$", "this", "->", "import", "(", "'FrontendUser'", ",", "'User'", ")", ";", "if", "(", "$", "this", "->", "arrCategoryValues", "[", "'banner_protected'", "]", "==", "1", "&&", "$", "this", "->", "arrCategoryValues", "[", "'banner_group'", "]", ">", "0", ")", "{", "if", "(", "$", "this", "->", "User", "->", "isMemberOf", "(", "$", "this", "->", "arrCategoryValues", "[", "'banner_group'", "]", ")", "===", "false", ")", "{", "$", "this", "->", "statusBannerFrontendGroupView", "=", "false", ";", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Check if FE User loggen in and banner category is protected @return boolean true = View allowed | false = View not allowed
[ "Check", "if", "FE", "User", "loggen", "in", "and", "banner", "category", "is", "protected" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerHelper.php#L213-L230
14,855
BugBuster1701/banner
classes/BannerHelper.php
BannerHelper.setRandomBlockerId
protected function setRandomBlockerId($BannerID=0) { if ($BannerID==0) { return; }// kein Banner, nichts zu tun $this->statusRandomBlocker = true; $this->setSession('RandomBlocker'.$this->module_id , array( $BannerID => time() )); return ; }
php
protected function setRandomBlockerId($BannerID=0) { if ($BannerID==0) { return; }// kein Banner, nichts zu tun $this->statusRandomBlocker = true; $this->setSession('RandomBlocker'.$this->module_id , array( $BannerID => time() )); return ; }
[ "protected", "function", "setRandomBlockerId", "(", "$", "BannerID", "=", "0", ")", "{", "if", "(", "$", "BannerID", "==", "0", ")", "{", "return", ";", "}", "// kein Banner, nichts zu tun", "$", "this", "->", "statusRandomBlocker", "=", "true", ";", "$", "this", "->", "setSession", "(", "'RandomBlocker'", ".", "$", "this", "->", "module_id", ",", "array", "(", "$", "BannerID", "=>", "time", "(", ")", ")", ")", ";", "return", ";", "}" ]
Random Blocker, Set Banner-ID @param integer $BannerID
[ "Random", "Blocker", "Set", "Banner", "-", "ID" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerHelper.php#L508-L515
14,856
BugBuster1701/banner
classes/BannerHelper.php
BannerHelper.getRandomBlockerId
protected function getRandomBlockerId() { $this->getSession('RandomBlocker'.$this->module_id); if ( count($this->_session) ) { $key = key($this->_session); $value = current($this->_session); unset($value); reset($this->_session); //DEBUG log_message('getRandomBlockerId BannerID:'.$key,'Banner.log'); return $key; } return 0; }
php
protected function getRandomBlockerId() { $this->getSession('RandomBlocker'.$this->module_id); if ( count($this->_session) ) { $key = key($this->_session); $value = current($this->_session); unset($value); reset($this->_session); //DEBUG log_message('getRandomBlockerId BannerID:'.$key,'Banner.log'); return $key; } return 0; }
[ "protected", "function", "getRandomBlockerId", "(", ")", "{", "$", "this", "->", "getSession", "(", "'RandomBlocker'", ".", "$", "this", "->", "module_id", ")", ";", "if", "(", "count", "(", "$", "this", "->", "_session", ")", ")", "{", "$", "key", "=", "key", "(", "$", "this", "->", "_session", ")", ";", "$", "value", "=", "current", "(", "$", "this", "->", "_session", ")", ";", "unset", "(", "$", "value", ")", ";", "reset", "(", "$", "this", "->", "_session", ")", ";", "//DEBUG log_message('getRandomBlockerId BannerID:'.$key,'Banner.log');", "return", "$", "key", ";", "}", "return", "0", ";", "}" ]
Random Blocker, Get Banner-ID @return integer Banner-ID
[ "Random", "Blocker", "Get", "Banner", "-", "ID" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerHelper.php#L522-L535
14,857
BugBuster1701/banner
classes/BannerHelper.php
BannerHelper.setFirstViewBlockerId
protected function setFirstViewBlockerId($banner_categorie=0) { if ($banner_categorie==0) { return; }// keine Banner Kategorie, nichts zu tun $this->statusFirstViewBlocker = true; $this->setSession('FirstViewBlocker'.$this->module_id, array( $banner_categorie => time() )); return ; }
php
protected function setFirstViewBlockerId($banner_categorie=0) { if ($banner_categorie==0) { return; }// keine Banner Kategorie, nichts zu tun $this->statusFirstViewBlocker = true; $this->setSession('FirstViewBlocker'.$this->module_id, array( $banner_categorie => time() )); return ; }
[ "protected", "function", "setFirstViewBlockerId", "(", "$", "banner_categorie", "=", "0", ")", "{", "if", "(", "$", "banner_categorie", "==", "0", ")", "{", "return", ";", "}", "// keine Banner Kategorie, nichts zu tun", "$", "this", "->", "statusFirstViewBlocker", "=", "true", ";", "$", "this", "->", "setSession", "(", "'FirstViewBlocker'", ".", "$", "this", "->", "module_id", ",", "array", "(", "$", "banner_categorie", "=>", "time", "(", ")", ")", ")", ";", "return", ";", "}" ]
First View Blocker, Set Banner Categorie-ID and timestamp @param integer $banner_categorie
[ "First", "View", "Blocker", "Set", "Banner", "Categorie", "-", "ID", "and", "timestamp" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerHelper.php#L542-L549
14,858
BugBuster1701/banner
classes/BannerHelper.php
BannerHelper.removeOldFirstViewBlockerId
protected function removeOldFirstViewBlockerId($key, $tstmap) { // 5 Minuten Blockierung, älter >= 5 Minuten wird gelöscht $FirstViewBlockTime = time() - 60*5; if ( $tstmap > $FirstViewBlockTime ) { return true; } else { \Session::getInstance()->remove($key); } return false; }
php
protected function removeOldFirstViewBlockerId($key, $tstmap) { // 5 Minuten Blockierung, älter >= 5 Minuten wird gelöscht $FirstViewBlockTime = time() - 60*5; if ( $tstmap > $FirstViewBlockTime ) { return true; } else { \Session::getInstance()->remove($key); } return false; }
[ "protected", "function", "removeOldFirstViewBlockerId", "(", "$", "key", ",", "$", "tstmap", ")", "{", "// 5 Minuten Blockierung, älter >= 5 Minuten wird gelöscht", "$", "FirstViewBlockTime", "=", "time", "(", ")", "-", "60", "*", "5", ";", "if", "(", "$", "tstmap", ">", "$", "FirstViewBlockTime", ")", "{", "return", "true", ";", "}", "else", "{", "\\", "Session", "::", "getInstance", "(", ")", "->", "remove", "(", "$", "key", ")", ";", "}", "return", "false", ";", "}" ]
First View Blocker, Remove old Banner Categorie-ID @param integer $banner_categorie @return boolean true = Key is valid, it must be blocked | false = key is invalid
[ "First", "View", "Blocker", "Remove", "old", "Banner", "Categorie", "-", "ID" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerHelper.php#L580-L594
14,859
BugBuster1701/banner
classes/BannerHelper.php
BannerHelper.getSetFirstView
protected function getSetFirstView() { //return true; // for Test only //FirstViewBanner gewünscht? if ($this->banner_firstview !=1) { return false; } $this->BannerReferrer = new \Banner\BannerReferrer(); $this->BannerReferrer->checkReferrer(); $ReferrerDNS = $this->BannerReferrer->getReferrerDNS(); // o own , w wrong if ($ReferrerDNS === 'o') { // eigener Referrer, Begrenzung auf First View nicht nötig. $this->statusBannerFirstView = false; return false; } if ( $this->getFirstViewBlockerId() === false ) { // nichts geblockt, also blocken fürs den nächsten Aufruf $this->setFirstViewBlockerId($this->banner_categories); // kein firstview block gefunden, Anzeigen erlaubt $this->statusBannerFirstView = true; return true; } else { $this->statusBannerFirstView = false; return false; } }
php
protected function getSetFirstView() { //return true; // for Test only //FirstViewBanner gewünscht? if ($this->banner_firstview !=1) { return false; } $this->BannerReferrer = new \Banner\BannerReferrer(); $this->BannerReferrer->checkReferrer(); $ReferrerDNS = $this->BannerReferrer->getReferrerDNS(); // o own , w wrong if ($ReferrerDNS === 'o') { // eigener Referrer, Begrenzung auf First View nicht nötig. $this->statusBannerFirstView = false; return false; } if ( $this->getFirstViewBlockerId() === false ) { // nichts geblockt, also blocken fürs den nächsten Aufruf $this->setFirstViewBlockerId($this->banner_categories); // kein firstview block gefunden, Anzeigen erlaubt $this->statusBannerFirstView = true; return true; } else { $this->statusBannerFirstView = false; return false; } }
[ "protected", "function", "getSetFirstView", "(", ")", "{", "//return true; // for Test only", "//FirstViewBanner gewünscht?", "if", "(", "$", "this", "->", "banner_firstview", "!=", "1", ")", "{", "return", "false", ";", "}", "$", "this", "->", "BannerReferrer", "=", "new", "\\", "Banner", "\\", "BannerReferrer", "(", ")", ";", "$", "this", "->", "BannerReferrer", "->", "checkReferrer", "(", ")", ";", "$", "ReferrerDNS", "=", "$", "this", "->", "BannerReferrer", "->", "getReferrerDNS", "(", ")", ";", "// o own , w wrong", "if", "(", "$", "ReferrerDNS", "===", "'o'", ")", "{", "// eigener Referrer, Begrenzung auf First View nicht nötig.", "$", "this", "->", "statusBannerFirstView", "=", "false", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "getFirstViewBlockerId", "(", ")", "===", "false", ")", "{", "// nichts geblockt, also blocken fürs den nächsten Aufruf", "$", "this", "->", "setFirstViewBlockerId", "(", "$", "this", "->", "banner_categories", ")", ";", "// kein firstview block gefunden, Anzeigen erlaubt", "$", "this", "->", "statusBannerFirstView", "=", "true", ";", "return", "true", ";", "}", "else", "{", "$", "this", "->", "statusBannerFirstView", "=", "false", ";", "return", "false", ";", "}", "}" ]
Get FirstViewBanner status and set cat id as blocker @return boolean true = if requested and not blocked | false = if requested but blocked
[ "Get", "FirstViewBanner", "status", "and", "set", "cat", "id", "as", "blocker" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerHelper.php#L602-L634
14,860
BugBuster1701/banner
classes/BannerHelper.php
BannerHelper.setStatViewUpdateBlockerId
protected function setStatViewUpdateBlockerId($banner_id=0) { if ($banner_id==0) { return; }// keine Banner ID, nichts zu tun //das können mehrere sein!, mergen! $this->setSession('StatViewUpdateBlocker'.$this->module_id, array( $banner_id => time() ), true ); return ; }
php
protected function setStatViewUpdateBlockerId($banner_id=0) { if ($banner_id==0) { return; }// keine Banner ID, nichts zu tun //das können mehrere sein!, mergen! $this->setSession('StatViewUpdateBlocker'.$this->module_id, array( $banner_id => time() ), true ); return ; }
[ "protected", "function", "setStatViewUpdateBlockerId", "(", "$", "banner_id", "=", "0", ")", "{", "if", "(", "$", "banner_id", "==", "0", ")", "{", "return", ";", "}", "// keine Banner ID, nichts zu tun", "//das können mehrere sein!, mergen!", "$", "this", "->", "setSession", "(", "'StatViewUpdateBlocker'", ".", "$", "this", "->", "module_id", ",", "array", "(", "$", "banner_id", "=>", "time", "(", ")", ")", ",", "true", ")", ";", "return", ";", "}" ]
StatViewUpdate Blocker, Set Banner ID and timestamp @param integer $banner_id
[ "StatViewUpdate", "Blocker", "Set", "Banner", "ID", "and", "timestamp" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerHelper.php#L1914-L1920
14,861
BugBuster1701/banner
classes/BannerHelper.php
BannerHelper.removeStatViewUpdateBlockerId
protected function removeStatViewUpdateBlockerId($banner_id, $tstmap) { $BannerBlockTime = time() - 60*5; // 5 Minuten, 0-5 min wird geblockt if ( isset($GLOBALS['TL_CONFIG']['mod_banner_block_time'] ) && intval($GLOBALS['TL_CONFIG']['mod_banner_block_time'])>0 ) { $BannerBlockTime = time() - 60*1*intval($GLOBALS['TL_CONFIG']['mod_banner_block_time']); } if ( $tstmap > $BannerBlockTime ) { return true; } else { //wenn mehrere dann nur den Teil, nicht die ganze Session unset($this->_session[$banner_id]); //wenn Anzahl Banner in Session nun 0 dann Session loeschen if ( count($this->_session) == 0 ) { //komplett löschen \Session::getInstance()->remove('StatViewUpdateBlocker'.$this->module_id); } else //sonst neu setzen { //gekuerzte Session neu setzen $this->setSession('StatViewUpdateBlocker'.$this->module_id, $this->_session , false ); } } return false; }
php
protected function removeStatViewUpdateBlockerId($banner_id, $tstmap) { $BannerBlockTime = time() - 60*5; // 5 Minuten, 0-5 min wird geblockt if ( isset($GLOBALS['TL_CONFIG']['mod_banner_block_time'] ) && intval($GLOBALS['TL_CONFIG']['mod_banner_block_time'])>0 ) { $BannerBlockTime = time() - 60*1*intval($GLOBALS['TL_CONFIG']['mod_banner_block_time']); } if ( $tstmap > $BannerBlockTime ) { return true; } else { //wenn mehrere dann nur den Teil, nicht die ganze Session unset($this->_session[$banner_id]); //wenn Anzahl Banner in Session nun 0 dann Session loeschen if ( count($this->_session) == 0 ) { //komplett löschen \Session::getInstance()->remove('StatViewUpdateBlocker'.$this->module_id); } else //sonst neu setzen { //gekuerzte Session neu setzen $this->setSession('StatViewUpdateBlocker'.$this->module_id, $this->_session , false ); } } return false; }
[ "protected", "function", "removeStatViewUpdateBlockerId", "(", "$", "banner_id", ",", "$", "tstmap", ")", "{", "$", "BannerBlockTime", "=", "time", "(", ")", "-", "60", "*", "5", ";", "// 5 Minuten, 0-5 min wird geblockt", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'TL_CONFIG'", "]", "[", "'mod_banner_block_time'", "]", ")", "&&", "intval", "(", "$", "GLOBALS", "[", "'TL_CONFIG'", "]", "[", "'mod_banner_block_time'", "]", ")", ">", "0", ")", "{", "$", "BannerBlockTime", "=", "time", "(", ")", "-", "60", "*", "1", "*", "intval", "(", "$", "GLOBALS", "[", "'TL_CONFIG'", "]", "[", "'mod_banner_block_time'", "]", ")", ";", "}", "if", "(", "$", "tstmap", ">", "$", "BannerBlockTime", ")", "{", "return", "true", ";", "}", "else", "{", "//wenn mehrere dann nur den Teil, nicht die ganze Session", "unset", "(", "$", "this", "->", "_session", "[", "$", "banner_id", "]", ")", ";", "//wenn Anzahl Banner in Session nun 0 dann Session loeschen", "if", "(", "count", "(", "$", "this", "->", "_session", ")", "==", "0", ")", "{", "//komplett löschen", "\\", "Session", "::", "getInstance", "(", ")", "->", "remove", "(", "'StatViewUpdateBlocker'", ".", "$", "this", "->", "module_id", ")", ";", "}", "else", "//sonst neu setzen", "{", "//gekuerzte Session neu setzen", "$", "this", "->", "setSession", "(", "'StatViewUpdateBlocker'", ".", "$", "this", "->", "module_id", ",", "$", "this", "->", "_session", ",", "false", ")", ";", "}", "}", "return", "false", ";", "}" ]
StatViewUpdate Blocker, Remove old Banner ID @param integer $banner_id @return boolean true = Key is valid, it must be blocked | false = key is invalid
[ "StatViewUpdate", "Blocker", "Remove", "old", "Banner", "ID" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerHelper.php#L1953-L1984
14,862
heyday/heystack
src/DependencyInjection/SilverStripe/HeystackSilverStripeContainer.php
HeystackSilverStripeContainer.get
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) { if ($this->isSilverStripeServiceRequest($id)) { return $this->getSilverStripeService($id); } else { return parent::get($id, $invalidBehavior); } }
php
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) { if ($this->isSilverStripeServiceRequest($id)) { return $this->getSilverStripeService($id); } else { return parent::get($id, $invalidBehavior); } }
[ "public", "function", "get", "(", "$", "id", ",", "$", "invalidBehavior", "=", "self", "::", "EXCEPTION_ON_INVALID_REFERENCE", ")", "{", "if", "(", "$", "this", "->", "isSilverStripeServiceRequest", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "getSilverStripeService", "(", "$", "id", ")", ";", "}", "else", "{", "return", "parent", "::", "get", "(", "$", "id", ",", "$", "invalidBehavior", ")", ";", "}", "}" ]
Use SilverStripe's Dependency Injection system if the service is namespaced silverstripe @param string $id @param int|void $invalidBehavior @return object
[ "Use", "SilverStripe", "s", "Dependency", "Injection", "system", "if", "the", "service", "is", "namespaced", "silverstripe" ]
2c051933f8c532d0a9a23be6ee1ff5c619e47dfe
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/DependencyInjection/SilverStripe/HeystackSilverStripeContainer.php#L45-L52
14,863
larakit/lk-staticfiles
src/StaticFiles/Css.php
Css.add
function add($css_file, $media = null, $condition = null, $no_build = false) { if(!$css_file) { return $this; } $host = config('larakit.lk-staticfiles.host'); if(mb_strpos($css_file, '/') === 0 && mb_strpos($css_file, '/', 1) !== 1) { $css_file = $host . $css_file; } $this->css_external[$css_file] = [ 'condition' => $condition, 'media' => $media, 'no_build' => $no_build, ]; return $this; }
php
function add($css_file, $media = null, $condition = null, $no_build = false) { if(!$css_file) { return $this; } $host = config('larakit.lk-staticfiles.host'); if(mb_strpos($css_file, '/') === 0 && mb_strpos($css_file, '/', 1) !== 1) { $css_file = $host . $css_file; } $this->css_external[$css_file] = [ 'condition' => $condition, 'media' => $media, 'no_build' => $no_build, ]; return $this; }
[ "function", "add", "(", "$", "css_file", ",", "$", "media", "=", "null", ",", "$", "condition", "=", "null", ",", "$", "no_build", "=", "false", ")", "{", "if", "(", "!", "$", "css_file", ")", "{", "return", "$", "this", ";", "}", "$", "host", "=", "config", "(", "'larakit.lk-staticfiles.host'", ")", ";", "if", "(", "mb_strpos", "(", "$", "css_file", ",", "'/'", ")", "===", "0", "&&", "mb_strpos", "(", "$", "css_file", ",", "'/'", ",", "1", ")", "!==", "1", ")", "{", "$", "css_file", "=", "$", "host", ".", "$", "css_file", ";", "}", "$", "this", "->", "css_external", "[", "$", "css_file", "]", "=", "[", "'condition'", "=>", "$", "condition", ",", "'media'", "=>", "$", "media", ",", "'no_build'", "=>", "$", "no_build", ",", "]", ";", "return", "$", "this", ";", "}" ]
Add external css file @param $css_file @param null $media - condition of use @param null $condition - condition including script, example [if IE 6] @param bool $no_build - flag exclude on build @return $this <!--[if IE 6]><link rel="stylesheet" href="http://habrahabr.ru/css/1302697277/ie6.css" media="all" /><![endif]-->
[ "Add", "external", "css", "file" ]
1ee718b1f3a00c29c46b06c2f501413599b0335a
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Css.php#L42-L57
14,864
mremi/Dolist
src/Mremi/Dolist/Contact/Contact.php
Contact.removeField
public function removeField(Field $field) { if ($this->hasField($field)) { unset($this->fields[$field->getName()]); return true; } return false; }
php
public function removeField(Field $field) { if ($this->hasField($field)) { unset($this->fields[$field->getName()]); return true; } return false; }
[ "public", "function", "removeField", "(", "Field", "$", "field", ")", "{", "if", "(", "$", "this", "->", "hasField", "(", "$", "field", ")", ")", "{", "unset", "(", "$", "this", "->", "fields", "[", "$", "field", "->", "getName", "(", ")", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Removes the given field from the fields collection @param Field $field @return boolean
[ "Removes", "the", "given", "field", "from", "the", "fields", "collection" ]
452c863aba12ef2965bafdb619c0278f8fc732d0
https://github.com/mremi/Dolist/blob/452c863aba12ef2965bafdb619c0278f8fc732d0/src/Mremi/Dolist/Contact/Contact.php#L88-L97
14,865
jasny/router
src/Router/Routes/Glob.php
Glob.createRoute
protected function createRoute($value) { if ($value instanceof Route) { return $value; } if (is_array($value)) { $value = (object)$value; } if (is_object($value) && is_callable($value)) { $value = (object)['fn' => $value]; } if (!$value instanceof \stdClass) { throw new \InvalidArgumentException("Unable to create a Route from value " . var_export($value, true)); } return new Route($value); }
php
protected function createRoute($value) { if ($value instanceof Route) { return $value; } if (is_array($value)) { $value = (object)$value; } if (is_object($value) && is_callable($value)) { $value = (object)['fn' => $value]; } if (!$value instanceof \stdClass) { throw new \InvalidArgumentException("Unable to create a Route from value " . var_export($value, true)); } return new Route($value); }
[ "protected", "function", "createRoute", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "Route", ")", "{", "return", "$", "value", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "(", "object", ")", "$", "value", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", "&&", "is_callable", "(", "$", "value", ")", ")", "{", "$", "value", "=", "(", "object", ")", "[", "'fn'", "=>", "$", "value", "]", ";", "}", "if", "(", "!", "$", "value", "instanceof", "\\", "stdClass", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Unable to create a Route from value \"", ".", "var_export", "(", "$", "value", ",", "true", ")", ")", ";", "}", "return", "new", "Route", "(", "$", "value", ")", ";", "}" ]
Create a route from an assisiative array or stdClass object @param Route|\stdClass|array $value @return Route
[ "Create", "a", "route", "from", "an", "assisiative", "array", "or", "stdClass", "object" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/Glob.php#L39-L58
14,866
jasny/router
src/Router/Routes/Glob.php
Glob.createRoutes
protected function createRoutes($input) { if ($input instanceof \Traversable) { $input = iterator_to_array($input, true); } elseif ($input instanceof \stdClass) { $input = get_object_vars($input); } return array_map([$this, 'createRoute'], $input); }
php
protected function createRoutes($input) { if ($input instanceof \Traversable) { $input = iterator_to_array($input, true); } elseif ($input instanceof \stdClass) { $input = get_object_vars($input); } return array_map([$this, 'createRoute'], $input); }
[ "protected", "function", "createRoutes", "(", "$", "input", ")", "{", "if", "(", "$", "input", "instanceof", "\\", "Traversable", ")", "{", "$", "input", "=", "iterator_to_array", "(", "$", "input", ",", "true", ")", ";", "}", "elseif", "(", "$", "input", "instanceof", "\\", "stdClass", ")", "{", "$", "input", "=", "get_object_vars", "(", "$", "input", ")", ";", "}", "return", "array_map", "(", "[", "$", "this", ",", "'createRoute'", "]", ",", "$", "input", ")", ";", "}" ]
Create routes from input @param Route[]|array|stdClass|\Traversable $input @return type
[ "Create", "routes", "from", "input" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/Glob.php#L66-L75
14,867
jasny/router
src/Router/Routes/Glob.php
Glob.fnmatch
public function fnmatch($pattern, $url) { $quoted = preg_quote($pattern, '~'); $step1 = strtr($quoted, ['\?' => '[^/]', '\*' => '[^/]*', '/\*\*' => '(?:/.*)?', '#' => '\d+', '\[' => '[', '\]' => ']', '\-' => '-', '\{' => '{', '\}' => '}']); $step2 = preg_replace_callback('~{[^}]+}~', function ($part) { return '(?:' . substr(strtr($part[0], ',', '|'), 1, -1) . ')'; }, $step1); $regex = rawurldecode($step2); return (boolean)preg_match("~^{$regex}$~i", $url); }
php
public function fnmatch($pattern, $url) { $quoted = preg_quote($pattern, '~'); $step1 = strtr($quoted, ['\?' => '[^/]', '\*' => '[^/]*', '/\*\*' => '(?:/.*)?', '#' => '\d+', '\[' => '[', '\]' => ']', '\-' => '-', '\{' => '{', '\}' => '}']); $step2 = preg_replace_callback('~{[^}]+}~', function ($part) { return '(?:' . substr(strtr($part[0], ',', '|'), 1, -1) . ')'; }, $step1); $regex = rawurldecode($step2); return (boolean)preg_match("~^{$regex}$~i", $url); }
[ "public", "function", "fnmatch", "(", "$", "pattern", ",", "$", "url", ")", "{", "$", "quoted", "=", "preg_quote", "(", "$", "pattern", ",", "'~'", ")", ";", "$", "step1", "=", "strtr", "(", "$", "quoted", ",", "[", "'\\?'", "=>", "'[^/]'", ",", "'\\*'", "=>", "'[^/]*'", ",", "'/\\*\\*'", "=>", "'(?:/.*)?'", ",", "'#'", "=>", "'\\d+'", ",", "'\\['", "=>", "'['", ",", "'\\]'", "=>", "']'", ",", "'\\-'", "=>", "'-'", ",", "'\\{'", "=>", "'{'", ",", "'\\}'", "=>", "'}'", "]", ")", ";", "$", "step2", "=", "preg_replace_callback", "(", "'~{[^}]+}~'", ",", "function", "(", "$", "part", ")", "{", "return", "'(?:'", ".", "substr", "(", "strtr", "(", "$", "part", "[", "0", "]", ",", "','", ",", "'|'", ")", ",", "1", ",", "-", "1", ")", ".", "')'", ";", "}", ",", "$", "step1", ")", ";", "$", "regex", "=", "rawurldecode", "(", "$", "step2", ")", ";", "return", "(", "boolean", ")", "preg_match", "(", "\"~^{$regex}$~i\"", ",", "$", "url", ")", ";", "}" ]
Match url against wildcard pattern. @param string $pattern @param string $url @return boolean
[ "Match", "url", "against", "wildcard", "pattern", "." ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/Glob.php#L121-L134
14,868
jasny/router
src/Router/Routes/Glob.php
Glob.splitRoutePattern
protected function splitRoutePattern($pattern) { if (strpos($pattern, ' ') !== false && preg_match_all('/\s+\+(\w+)\b|\s+\-(\w+)\b/', $pattern, $matches)) { list($path) = preg_split('/\s+/', $pattern, 2); $inc = isset($matches[1]) ? array_filter($matches[1]) : []; $excl = isset($matches[2]) ? array_filter($matches[2]) : []; } else { $path = $pattern; $inc = []; $excl = []; } return [$path, $inc, $excl]; }
php
protected function splitRoutePattern($pattern) { if (strpos($pattern, ' ') !== false && preg_match_all('/\s+\+(\w+)\b|\s+\-(\w+)\b/', $pattern, $matches)) { list($path) = preg_split('/\s+/', $pattern, 2); $inc = isset($matches[1]) ? array_filter($matches[1]) : []; $excl = isset($matches[2]) ? array_filter($matches[2]) : []; } else { $path = $pattern; $inc = []; $excl = []; } return [$path, $inc, $excl]; }
[ "protected", "function", "splitRoutePattern", "(", "$", "pattern", ")", "{", "if", "(", "strpos", "(", "$", "pattern", ",", "' '", ")", "!==", "false", "&&", "preg_match_all", "(", "'/\\s+\\+(\\w+)\\b|\\s+\\-(\\w+)\\b/'", ",", "$", "pattern", ",", "$", "matches", ")", ")", "{", "list", "(", "$", "path", ")", "=", "preg_split", "(", "'/\\s+/'", ",", "$", "pattern", ",", "2", ")", ";", "$", "inc", "=", "isset", "(", "$", "matches", "[", "1", "]", ")", "?", "array_filter", "(", "$", "matches", "[", "1", "]", ")", ":", "[", "]", ";", "$", "excl", "=", "isset", "(", "$", "matches", "[", "2", "]", ")", "?", "array_filter", "(", "$", "matches", "[", "2", "]", ")", ":", "[", "]", ";", "}", "else", "{", "$", "path", "=", "$", "pattern", ";", "$", "inc", "=", "[", "]", ";", "$", "excl", "=", "[", "]", ";", "}", "return", "[", "$", "path", ",", "$", "inc", ",", "$", "excl", "]", ";", "}" ]
Split the route pattern in a path + inclusive and exclusive methods @param string $pattern @return array [path, inc, excl]
[ "Split", "the", "route", "pattern", "in", "a", "path", "+", "inclusive", "and", "exclusive", "methods" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/Glob.php#L142-L155
14,869
jasny/router
src/Router/Routes/Glob.php
Glob.findRoute
protected function findRoute(UriInterface $url, $method = null) { $urlPath = $this->cleanUrl($url->getPath()); $ret = null; foreach ($this as $pattern => $route) { list($path, $inc, $excl) = $this->splitRoutePattern($pattern); if ($path !== '/') $path = rtrim($path, '/'); if ($this->fnmatch($path, $urlPath)) { if (!$method || ((empty($inc) || in_array($method, $inc)) && !in_array($method, $excl))) { $ret = $route; break; } } } return $ret; }
php
protected function findRoute(UriInterface $url, $method = null) { $urlPath = $this->cleanUrl($url->getPath()); $ret = null; foreach ($this as $pattern => $route) { list($path, $inc, $excl) = $this->splitRoutePattern($pattern); if ($path !== '/') $path = rtrim($path, '/'); if ($this->fnmatch($path, $urlPath)) { if (!$method || ((empty($inc) || in_array($method, $inc)) && !in_array($method, $excl))) { $ret = $route; break; } } } return $ret; }
[ "protected", "function", "findRoute", "(", "UriInterface", "$", "url", ",", "$", "method", "=", "null", ")", "{", "$", "urlPath", "=", "$", "this", "->", "cleanUrl", "(", "$", "url", "->", "getPath", "(", ")", ")", ";", "$", "ret", "=", "null", ";", "foreach", "(", "$", "this", "as", "$", "pattern", "=>", "$", "route", ")", "{", "list", "(", "$", "path", ",", "$", "inc", ",", "$", "excl", ")", "=", "$", "this", "->", "splitRoutePattern", "(", "$", "pattern", ")", ";", "if", "(", "$", "path", "!==", "'/'", ")", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "if", "(", "$", "this", "->", "fnmatch", "(", "$", "path", ",", "$", "urlPath", ")", ")", "{", "if", "(", "!", "$", "method", "||", "(", "(", "empty", "(", "$", "inc", ")", "||", "in_array", "(", "$", "method", ",", "$", "inc", ")", ")", "&&", "!", "in_array", "(", "$", "method", ",", "$", "excl", ")", ")", ")", "{", "$", "ret", "=", "$", "route", ";", "break", ";", "}", "}", "}", "return", "$", "ret", ";", "}" ]
Find a matching route @param UriInterface $url @param string $method @return string
[ "Find", "a", "matching", "route" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/Glob.php#L164-L182
14,870
jasny/router
src/Router/Routes/Glob.php
Glob.hasRoute
public function hasRoute(ServerRequestInterface $request, $withMethod = true) { $route = $this->findRoute($request->getUri(), $withMethod ? $request->getMethod() : null); return isset($route); }
php
public function hasRoute(ServerRequestInterface $request, $withMethod = true) { $route = $this->findRoute($request->getUri(), $withMethod ? $request->getMethod() : null); return isset($route); }
[ "public", "function", "hasRoute", "(", "ServerRequestInterface", "$", "request", ",", "$", "withMethod", "=", "true", ")", "{", "$", "route", "=", "$", "this", "->", "findRoute", "(", "$", "request", "->", "getUri", "(", ")", ",", "$", "withMethod", "?", "$", "request", "->", "getMethod", "(", ")", ":", "null", ")", ";", "return", "isset", "(", "$", "route", ")", ";", "}" ]
Check if a route for the URL exists @param ServerRequestInterface $request @return boolean
[ "Check", "if", "a", "route", "for", "the", "URL", "exists" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/Glob.php#L191-L195
14,871
jasny/router
src/Router/Routes/Glob.php
Glob.getRoute
public function getRoute(ServerRequestInterface $request) { $url = $request->getUri(); $route = $this->findRoute($url, $request->getMethod()); if ($route) { $route = $this->bind($route, $request, $this->splitUrl($url->getPath())); } return $route; }
php
public function getRoute(ServerRequestInterface $request) { $url = $request->getUri(); $route = $this->findRoute($url, $request->getMethod()); if ($route) { $route = $this->bind($route, $request, $this->splitUrl($url->getPath())); } return $route; }
[ "public", "function", "getRoute", "(", "ServerRequestInterface", "$", "request", ")", "{", "$", "url", "=", "$", "request", "->", "getUri", "(", ")", ";", "$", "route", "=", "$", "this", "->", "findRoute", "(", "$", "url", ",", "$", "request", "->", "getMethod", "(", ")", ")", ";", "if", "(", "$", "route", ")", "{", "$", "route", "=", "$", "this", "->", "bind", "(", "$", "route", ",", "$", "request", ",", "$", "this", "->", "splitUrl", "(", "$", "url", "->", "getPath", "(", ")", ")", ")", ";", "}", "return", "$", "route", ";", "}" ]
Get route for the request @param ServerRequestInterface $request @return Route
[ "Get", "route", "for", "the", "request" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/Glob.php#L203-L213
14,872
FrenchFrogs/framework
src/Container/Container.php
Container.getInstance
static function getInstance($namespace = null) { $namespace = is_null($namespace) ? static::NAMESPACE_DEFAULT : $namespace; if (!array_key_exists($namespace, static::$instances)) { self::$instances[$namespace] = new static(); } return self::$instances[$namespace]; }
php
static function getInstance($namespace = null) { $namespace = is_null($namespace) ? static::NAMESPACE_DEFAULT : $namespace; if (!array_key_exists($namespace, static::$instances)) { self::$instances[$namespace] = new static(); } return self::$instances[$namespace]; }
[ "static", "function", "getInstance", "(", "$", "namespace", "=", "null", ")", "{", "$", "namespace", "=", "is_null", "(", "$", "namespace", ")", "?", "static", "::", "NAMESPACE_DEFAULT", ":", "$", "namespace", ";", "if", "(", "!", "array_key_exists", "(", "$", "namespace", ",", "static", "::", "$", "instances", ")", ")", "{", "self", "::", "$", "instances", "[", "$", "namespace", "]", "=", "new", "static", "(", ")", ";", "}", "return", "self", "::", "$", "instances", "[", "$", "namespace", "]", ";", "}" ]
constructor du singleton @return Container
[ "constructor", "du", "singleton" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Container/Container.php#L44-L53
14,873
aindong/pluggables
src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php
PluggableMakeHandler.generate
public function generate(Command $console) { $this->generateFolders(); $this->generateGitkeep(); $this->generateFiles(); $console->info("Pluggable [{$this->name}] has been created successfully."); return true; }
php
public function generate(Command $console) { $this->generateFolders(); $this->generateGitkeep(); $this->generateFiles(); $console->info("Pluggable [{$this->name}] has been created successfully."); return true; }
[ "public", "function", "generate", "(", "Command", "$", "console", ")", "{", "$", "this", "->", "generateFolders", "(", ")", ";", "$", "this", "->", "generateGitkeep", "(", ")", ";", "$", "this", "->", "generateFiles", "(", ")", ";", "$", "console", "->", "info", "(", "\"Pluggable [{$this->name}] has been created successfully.\"", ")", ";", "return", "true", ";", "}" ]
Generate pluggable folders and files. @param \Aindong\Pluggables\Console\PluggableMakeCommand $console @return bool
[ "Generate", "pluggable", "folders", "and", "files", "." ]
bf8bab46fb65268043fb4b98db21f8e0338b5e96
https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php#L122-L133
14,874
aindong/pluggables
src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php
PluggableMakeHandler.generateFolders
protected function generateFolders() { if (!$this->finder->isDirectory($this->pluggable->getPath())) { $this->finder->makeDirectory($this->pluggable->getPath()); } $this->finder->makeDirectory($this->getPluggablePath($this->slug, true)); foreach ($this->folders as $folder) { $this->finder->makeDirectory($this->getPluggablePath($this->slug).$folder); } }
php
protected function generateFolders() { if (!$this->finder->isDirectory($this->pluggable->getPath())) { $this->finder->makeDirectory($this->pluggable->getPath()); } $this->finder->makeDirectory($this->getPluggablePath($this->slug, true)); foreach ($this->folders as $folder) { $this->finder->makeDirectory($this->getPluggablePath($this->slug).$folder); } }
[ "protected", "function", "generateFolders", "(", ")", "{", "if", "(", "!", "$", "this", "->", "finder", "->", "isDirectory", "(", "$", "this", "->", "pluggable", "->", "getPath", "(", ")", ")", ")", "{", "$", "this", "->", "finder", "->", "makeDirectory", "(", "$", "this", "->", "pluggable", "->", "getPath", "(", ")", ")", ";", "}", "$", "this", "->", "finder", "->", "makeDirectory", "(", "$", "this", "->", "getPluggablePath", "(", "$", "this", "->", "slug", ",", "true", ")", ")", ";", "foreach", "(", "$", "this", "->", "folders", "as", "$", "folder", ")", "{", "$", "this", "->", "finder", "->", "makeDirectory", "(", "$", "this", "->", "getPluggablePath", "(", "$", "this", "->", "slug", ")", ".", "$", "folder", ")", ";", "}", "}" ]
Generate defined pluggable folders. @return void
[ "Generate", "defined", "pluggable", "folders", "." ]
bf8bab46fb65268043fb4b98db21f8e0338b5e96
https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php#L140-L151
14,875
aindong/pluggables
src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php
PluggableMakeHandler.generateFiles
protected function generateFiles() { foreach ($this->files as $key => $file) { $file = $this->formatContent($file); $this->makeFile($key, $file); } }
php
protected function generateFiles() { foreach ($this->files as $key => $file) { $file = $this->formatContent($file); $this->makeFile($key, $file); } }
[ "protected", "function", "generateFiles", "(", ")", "{", "foreach", "(", "$", "this", "->", "files", "as", "$", "key", "=>", "$", "file", ")", "{", "$", "file", "=", "$", "this", "->", "formatContent", "(", "$", "file", ")", ";", "$", "this", "->", "makeFile", "(", "$", "key", ",", "$", "file", ")", ";", "}", "}" ]
Generate defined pluggable files. @return void
[ "Generate", "defined", "pluggable", "files", "." ]
bf8bab46fb65268043fb4b98db21f8e0338b5e96
https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php#L158-L165
14,876
aindong/pluggables
src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php
PluggableMakeHandler.makeFile
protected function makeFile($key, $file) { return $this->finder->put($this->getDestinationFile($file), $this->getStubContent($key)); }
php
protected function makeFile($key, $file) { return $this->finder->put($this->getDestinationFile($file), $this->getStubContent($key)); }
[ "protected", "function", "makeFile", "(", "$", "key", ",", "$", "file", ")", "{", "return", "$", "this", "->", "finder", "->", "put", "(", "$", "this", "->", "getDestinationFile", "(", "$", "file", ")", ",", "$", "this", "->", "getStubContent", "(", "$", "key", ")", ")", ";", "}" ]
Create pluggable file. @param int $key @param string $file @return int
[ "Create", "pluggable", "file", "." ]
bf8bab46fb65268043fb4b98db21f8e0338b5e96
https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php#L191-L194
14,877
aindong/pluggables
src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php
PluggableMakeHandler.getPluggablePath
protected function getPluggablePath($slug = null, $allowNotExists = false) { if ($slug) { return $this->pluggable->getPluggablePath($slug, $allowNotExists); } return $this->pluggable->getPath(); }
php
protected function getPluggablePath($slug = null, $allowNotExists = false) { if ($slug) { return $this->pluggable->getPluggablePath($slug, $allowNotExists); } return $this->pluggable->getPath(); }
[ "protected", "function", "getPluggablePath", "(", "$", "slug", "=", "null", ",", "$", "allowNotExists", "=", "false", ")", "{", "if", "(", "$", "slug", ")", "{", "return", "$", "this", "->", "pluggable", "->", "getPluggablePath", "(", "$", "slug", ",", "$", "allowNotExists", ")", ";", "}", "return", "$", "this", "->", "pluggable", "->", "getPath", "(", ")", ";", "}" ]
Get the path to the pluggable. @param string $slug @return string
[ "Get", "the", "path", "to", "the", "pluggable", "." ]
bf8bab46fb65268043fb4b98db21f8e0338b5e96
https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Handlers/PluggableMakeHandler.php#L203-L210
14,878
fuzz-productions/laravel-api-data
src/Traits/HasS3File.php
HasS3File.getFileUrl
public function getFileUrl($key, $path = null) { if (is_null($key)) { return null; } $bucket = config('filesystems.disks.s3.bucket'); $client = Storage::disk('s3')->getAdapter()->getClient(); return $this->getRealUrl($client->getObjectUrl($bucket, $path . $key)); }
php
public function getFileUrl($key, $path = null) { if (is_null($key)) { return null; } $bucket = config('filesystems.disks.s3.bucket'); $client = Storage::disk('s3')->getAdapter()->getClient(); return $this->getRealUrl($client->getObjectUrl($bucket, $path . $key)); }
[ "public", "function", "getFileUrl", "(", "$", "key", ",", "$", "path", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "null", ";", "}", "$", "bucket", "=", "config", "(", "'filesystems.disks.s3.bucket'", ")", ";", "$", "client", "=", "Storage", "::", "disk", "(", "'s3'", ")", "->", "getAdapter", "(", ")", "->", "getClient", "(", ")", ";", "return", "$", "this", "->", "getRealUrl", "(", "$", "client", "->", "getObjectUrl", "(", "$", "bucket", ",", "$", "path", ".", "$", "key", ")", ")", ";", "}" ]
Retrieve a file URL @param string $key @param null|string $path @return null|string
[ "Retrieve", "a", "file", "URL" ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Traits/HasS3File.php#L72-L82
14,879
fuzz-productions/laravel-api-data
src/Traits/HasS3File.php
HasS3File.getRealUrl
public function getRealUrl($url) { if (config('services.cdn.base_url')) { $s3_url = self::$s3_base_url . config('filesystems.disks.s3.bucket') . '/'; return str_replace($s3_url, config('services.cdn.base_url'), $url); } else { return $url; } }
php
public function getRealUrl($url) { if (config('services.cdn.base_url')) { $s3_url = self::$s3_base_url . config('filesystems.disks.s3.bucket') . '/'; return str_replace($s3_url, config('services.cdn.base_url'), $url); } else { return $url; } }
[ "public", "function", "getRealUrl", "(", "$", "url", ")", "{", "if", "(", "config", "(", "'services.cdn.base_url'", ")", ")", "{", "$", "s3_url", "=", "self", "::", "$", "s3_base_url", ".", "config", "(", "'filesystems.disks.s3.bucket'", ")", ".", "'/'", ";", "return", "str_replace", "(", "$", "s3_url", ",", "config", "(", "'services.cdn.base_url'", ")", ",", "$", "url", ")", ";", "}", "else", "{", "return", "$", "url", ";", "}", "}" ]
Determine if the base S3 url needs to be switched out with a CDN url @param string $url @return mixed
[ "Determine", "if", "the", "base", "S3", "url", "needs", "to", "be", "switched", "out", "with", "a", "CDN", "url" ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Traits/HasS3File.php#L90-L99
14,880
phramework/validate
src/Validate.php
Validate.registerCustomType
public static function registerCustomType($type, $callback) { if (!is_callable($callback)) { throw new \Exception(__('callback_is_not_function_exception')); } self::$custom_types[$type]= ['callback' => $callback]; }
php
public static function registerCustomType($type, $callback) { if (!is_callable($callback)) { throw new \Exception(__('callback_is_not_function_exception')); } self::$custom_types[$type]= ['callback' => $callback]; }
[ "public", "static", "function", "registerCustomType", "(", "$", "type", ",", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "__", "(", "'callback_is_not_function_exception'", ")", ")", ";", "}", "self", "::", "$", "custom_types", "[", "$", "type", "]", "=", "[", "'callback'", "=>", "$", "callback", "]", ";", "}" ]
Register a custom data type It can be used to validate models @param string $type @param function $callback @throws \Exception
[ "Register", "a", "custom", "data", "type" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L151-L158
14,881
phramework/validate
src/Validate.php
Validate.validateCustomType
public static function validateCustomType($type, $value, $field_name, $model = []) { if (!isset(self::$custom_types[$type])) { throw new \Exception('type_not_found'); } $callback = self::$custom_types[$type]['callback']; $output = false; if ($callback($value, $model, $output) === false) { //Incorrect throw new IncorrectParametersException([$field_name]); } else { //update output return $output; } }
php
public static function validateCustomType($type, $value, $field_name, $model = []) { if (!isset(self::$custom_types[$type])) { throw new \Exception('type_not_found'); } $callback = self::$custom_types[$type]['callback']; $output = false; if ($callback($value, $model, $output) === false) { //Incorrect throw new IncorrectParametersException([$field_name]); } else { //update output return $output; } }
[ "public", "static", "function", "validateCustomType", "(", "$", "type", ",", "$", "value", ",", "$", "field_name", ",", "$", "model", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "custom_types", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'type_not_found'", ")", ";", "}", "$", "callback", "=", "self", "::", "$", "custom_types", "[", "$", "type", "]", "[", "'callback'", "]", ";", "$", "output", "=", "false", ";", "if", "(", "$", "callback", "(", "$", "value", ",", "$", "model", ",", "$", "output", ")", "===", "false", ")", "{", "//Incorrect", "throw", "new", "IncorrectParametersException", "(", "[", "$", "field_name", "]", ")", ";", "}", "else", "{", "//update output", "return", "$", "output", ";", "}", "}" ]
Validate a custom data type. This method uses previous custom-defined datatype to validate it's data. @param string $type Custom type's name @param mixed $value Value to test @param string $field_name [optional] field's name @param array $model [optional] @throws \Exception type_not_found @throws IncorrectParameters if validation fails
[ "Validate", "a", "custom", "data", "type", "." ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L171-L187
14,882
phramework/validate
src/Validate.php
Validate.isValidJsonpCallback
public function isValidJsonpCallback($subject) { $identifier_syntax = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u'; $reserved_words = array('break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false'); return preg_match($identifier_syntax, $subject) && ! in_array(mb_strtolower($subject, 'UTF-8'), $reserved_words); }
php
public function isValidJsonpCallback($subject) { $identifier_syntax = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u'; $reserved_words = array('break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false'); return preg_match($identifier_syntax, $subject) && ! in_array(mb_strtolower($subject, 'UTF-8'), $reserved_words); }
[ "public", "function", "isValidJsonpCallback", "(", "$", "subject", ")", "{", "$", "identifier_syntax", "=", "'/^[$_\\p{L}][$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*+$/u'", ";", "$", "reserved_words", "=", "array", "(", "'break'", ",", "'do'", ",", "'instanceof'", ",", "'typeof'", ",", "'case'", ",", "'else'", ",", "'new'", ",", "'var'", ",", "'catch'", ",", "'finally'", ",", "'return'", ",", "'void'", ",", "'continue'", ",", "'for'", ",", "'switch'", ",", "'while'", ",", "'debugger'", ",", "'function'", ",", "'this'", ",", "'with'", ",", "'default'", ",", "'if'", ",", "'throw'", ",", "'delete'", ",", "'in'", ",", "'try'", ",", "'class'", ",", "'enum'", ",", "'extends'", ",", "'super'", ",", "'const'", ",", "'export'", ",", "'import'", ",", "'implements'", ",", "'let'", ",", "'private'", ",", "'public'", ",", "'yield'", ",", "'interface'", ",", "'package'", ",", "'protected'", ",", "'static'", ",", "'null'", ",", "'true'", ",", "'false'", ")", ";", "return", "preg_match", "(", "$", "identifier_syntax", ",", "$", "subject", ")", "&&", "!", "in_array", "(", "mb_strtolower", "(", "$", "subject", ",", "'UTF-8'", ")", ",", "$", "reserved_words", ")", ";", "}" ]
Check if callback is valid @link http://www.geekality.net/2010/06/27/php-how-to-easily-provide-json-and-jsonp/ source @param string $subject @return boolean
[ "Check", "if", "callback", "is", "valid" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L572-L587
14,883
phramework/validate
src/Validate.php
Validate.int
public static function int($input, $min = null, $max = null, $field_name = 'int') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_INT, Validate::REQUIRED] ]; if ($min !== null) { $model[$field_name]['min'] = $min; } if ($max !== null) { $model[$field_name]['max'] = $max; } $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
php
public static function int($input, $min = null, $max = null, $field_name = 'int') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_INT, Validate::REQUIRED] ]; if ($min !== null) { $model[$field_name]['min'] = $min; } if ($max !== null) { $model[$field_name]['max'] = $max; } $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
[ "public", "static", "function", "int", "(", "$", "input", ",", "$", "min", "=", "null", ",", "$", "max", "=", "null", ",", "$", "field_name", "=", "'int'", ")", "{", "//Define trivial model", "$", "model", "=", "[", "$", "field_name", "=>", "[", "'type'", "=>", "Validate", "::", "TYPE_INT", ",", "Validate", "::", "REQUIRED", "]", "]", ";", "if", "(", "$", "min", "!==", "null", ")", "{", "$", "model", "[", "$", "field_name", "]", "[", "'min'", "]", "=", "$", "min", ";", "}", "if", "(", "$", "max", "!==", "null", ")", "{", "$", "model", "[", "$", "field_name", "]", "[", "'max'", "]", "=", "$", "max", ";", "}", "$", "parameters", "=", "[", "$", "field_name", "=>", "$", "input", "]", ";", "Validate", "::", "model", "(", "$", "parameters", ",", "$", "model", ")", ";", "return", "$", "parameters", "[", "$", "field_name", "]", ";", "}" ]
Validate a signed integer @param string|integer $input Input value @param integer|null $min Minimum value. [optional] Default is NULL, if NULL then the minum value is skipped @param integer|null $max Maximum value. [optional] Default is NULL, if NULL then the maximum value is skipped @param string $field_name [optional] Field's name, used in IncorrectParametersException. Optional default is int @throws IncorrectParameters If valu type is not correct. @return integer Returns the value of the input value as int
[ "Validate", "a", "signed", "integer" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L599-L618
14,884
phramework/validate
src/Validate.php
Validate.uint
public static function uint($input, $min = 0, $max = null, $field_name = 'uint') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_UINT, Validate::REQUIRED] ]; $model[$field_name]['min'] = $min; if ($max !== null) { $model[$field_name]['max'] = $max; } $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
php
public static function uint($input, $min = 0, $max = null, $field_name = 'uint') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_UINT, Validate::REQUIRED] ]; $model[$field_name]['min'] = $min; if ($max !== null) { $model[$field_name]['max'] = $max; } $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
[ "public", "static", "function", "uint", "(", "$", "input", ",", "$", "min", "=", "0", ",", "$", "max", "=", "null", ",", "$", "field_name", "=", "'uint'", ")", "{", "//Define trivial model", "$", "model", "=", "[", "$", "field_name", "=>", "[", "'type'", "=>", "Validate", "::", "TYPE_UINT", ",", "Validate", "::", "REQUIRED", "]", "]", ";", "$", "model", "[", "$", "field_name", "]", "[", "'min'", "]", "=", "$", "min", ";", "if", "(", "$", "max", "!==", "null", ")", "{", "$", "model", "[", "$", "field_name", "]", "[", "'max'", "]", "=", "$", "max", ";", "}", "$", "parameters", "=", "[", "$", "field_name", "=>", "$", "input", "]", ";", "Validate", "::", "model", "(", "$", "parameters", ",", "$", "model", ")", ";", "return", "$", "parameters", "[", "$", "field_name", "]", ";", "}" ]
Validate an unsigned integer @param string|integer $input Input value @param integer $min Minimum value. Optional default is 0. @param integer|null $max Maximum value. Optional default is NULL, if NULL then the maximum value is skipped @param String $field_name Field's name, used in IncorrectParametersException. Optional default is uint @throws IncorrectParameters If valu type is not correct. @return integer Returns the value of the input value as int
[ "Validate", "an", "unsigned", "integer" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L629-L646
14,885
phramework/validate
src/Validate.php
Validate.float
public static function float($input, $min = null, $max = null, $field_name = 'float') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_FLOAT, Validate::REQUIRED] ]; if ($min !== null) { $model[$field_name]['min'] = $min; } if ($max !== null) { $model[$field_name]['max'] = $max; } $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
php
public static function float($input, $min = null, $max = null, $field_name = 'float') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_FLOAT, Validate::REQUIRED] ]; if ($min !== null) { $model[$field_name]['min'] = $min; } if ($max !== null) { $model[$field_name]['max'] = $max; } $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
[ "public", "static", "function", "float", "(", "$", "input", ",", "$", "min", "=", "null", ",", "$", "max", "=", "null", ",", "$", "field_name", "=", "'float'", ")", "{", "//Define trivial model", "$", "model", "=", "[", "$", "field_name", "=>", "[", "'type'", "=>", "Validate", "::", "TYPE_FLOAT", ",", "Validate", "::", "REQUIRED", "]", "]", ";", "if", "(", "$", "min", "!==", "null", ")", "{", "$", "model", "[", "$", "field_name", "]", "[", "'min'", "]", "=", "$", "min", ";", "}", "if", "(", "$", "max", "!==", "null", ")", "{", "$", "model", "[", "$", "field_name", "]", "[", "'max'", "]", "=", "$", "max", ";", "}", "$", "parameters", "=", "[", "$", "field_name", "=>", "$", "input", "]", ";", "Validate", "::", "model", "(", "$", "parameters", ",", "$", "model", ")", ";", "return", "$", "parameters", "[", "$", "field_name", "]", ";", "}" ]
Validate a floating point number @param string|float|int $input @param float|null $min Minimum value. Optional default is NULL, if NULL then the minum value is skipped @param float|null Maximum value. Optional default is NULL, if NULL then the maximum value is skipped @param string $field_name [optional] Field's name, used in IncorrectParametersException. Optional default is number @return float Returns the input value as float @throws IncorrectParameters If value type is not correct.
[ "Validate", "a", "floating", "point", "number" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L658-L677
14,886
phramework/validate
src/Validate.php
Validate.double
public static function double($input, $min = null, $max = null, $field_name = 'double') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_DOUBLE, Validate::REQUIRED] ]; if ($min !== null) { $model[$field_name]['min'] = $min; } if ($max !== null) { $model[$field_name]['max'] = $max; } $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
php
public static function double($input, $min = null, $max = null, $field_name = 'double') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_DOUBLE, Validate::REQUIRED] ]; if ($min !== null) { $model[$field_name]['min'] = $min; } if ($max !== null) { $model[$field_name]['max'] = $max; } $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
[ "public", "static", "function", "double", "(", "$", "input", ",", "$", "min", "=", "null", ",", "$", "max", "=", "null", ",", "$", "field_name", "=", "'double'", ")", "{", "//Define trivial model", "$", "model", "=", "[", "$", "field_name", "=>", "[", "'type'", "=>", "Validate", "::", "TYPE_DOUBLE", ",", "Validate", "::", "REQUIRED", "]", "]", ";", "if", "(", "$", "min", "!==", "null", ")", "{", "$", "model", "[", "$", "field_name", "]", "[", "'min'", "]", "=", "$", "min", ";", "}", "if", "(", "$", "max", "!==", "null", ")", "{", "$", "model", "[", "$", "field_name", "]", "[", "'max'", "]", "=", "$", "max", ";", "}", "$", "parameters", "=", "[", "$", "field_name", "=>", "$", "input", "]", ";", "Validate", "::", "model", "(", "$", "parameters", ",", "$", "model", ")", ";", "return", "$", "parameters", "[", "$", "field_name", "]", ";", "}" ]
Validate a double presision floating point number @param string|double|float|int $input @param double|null $min Minimum value. Optional default is NULL, if NULL then the minum value is skipped @param double|null Maximum value. Optional default is NULL, if NULL then the maximum value is skipped @param string $field_name [optional] Field's name, used in IncorrectParametersException. Optional default is number @return double Returns the input value as double @throws IncorrectParameters If value type is not correct.
[ "Validate", "a", "double", "presision", "floating", "point", "number" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L689-L708
14,887
phramework/validate
src/Validate.php
Validate.url
public static function url($input, $field_name = 'url') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_URL, Validate::REQUIRED] ]; $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
php
public static function url($input, $field_name = 'url') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_URL, Validate::REQUIRED] ]; $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
[ "public", "static", "function", "url", "(", "$", "input", ",", "$", "field_name", "=", "'url'", ")", "{", "//Define trivial model", "$", "model", "=", "[", "$", "field_name", "=>", "[", "'type'", "=>", "Validate", "::", "TYPE_URL", ",", "Validate", "::", "REQUIRED", "]", "]", ";", "$", "parameters", "=", "[", "$", "field_name", "=>", "$", "input", "]", ";", "Validate", "::", "model", "(", "$", "parameters", ",", "$", "model", ")", ";", "return", "$", "parameters", "[", "$", "field_name", "]", ";", "}" ]
Validate a url @param string $input @param string $field_name [optional] Field's name, used in IncorrectParametersException. Optional default is url @return string Return the url @throws IncorrectParameters If value type is not correct.
[ "Validate", "a", "url" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L739-L750
14,888
phramework/validate
src/Validate.php
Validate.permalink
public static function permalink($input, $field_name = 'permalink') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_PERMALINK, Validate::REQUIRED] ]; $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
php
public static function permalink($input, $field_name = 'permalink') { //Define trivial model $model = [ $field_name => ['type' => Validate::TYPE_PERMALINK, Validate::REQUIRED] ]; $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
[ "public", "static", "function", "permalink", "(", "$", "input", ",", "$", "field_name", "=", "'permalink'", ")", "{", "//Define trivial model", "$", "model", "=", "[", "$", "field_name", "=>", "[", "'type'", "=>", "Validate", "::", "TYPE_PERMALINK", ",", "Validate", "::", "REQUIRED", "]", "]", ";", "$", "parameters", "=", "[", "$", "field_name", "=>", "$", "input", "]", ";", "Validate", "::", "model", "(", "$", "parameters", ",", "$", "model", ")", ";", "return", "$", "parameters", "[", "$", "field_name", "]", ";", "}" ]
Validate a permalink id @param string $input @param string $field_name [optional] Field's name, used in IncorrectParametersException. Optional default is permalink @return string Return the permalink @throws IncorrectParameters If value type is not correct.
[ "Validate", "a", "permalink", "id" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L760-L771
14,889
phramework/validate
src/Validate.php
Validate.enum
public static function enum($input, $values, $field_name = 'enum') { //Check if array was given for $values value if (!is_array($values)) { throw new \Exception('Array is expected as values'); } //Define trivial model $model = [ $field_name => [ 'type' => Validate::TYPE_ENUM, 'values' => $values, Validate::REQUIRED ] ]; $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
php
public static function enum($input, $values, $field_name = 'enum') { //Check if array was given for $values value if (!is_array($values)) { throw new \Exception('Array is expected as values'); } //Define trivial model $model = [ $field_name => [ 'type' => Validate::TYPE_ENUM, 'values' => $values, Validate::REQUIRED ] ]; $parameters = [$field_name => $input]; Validate::model($parameters, $model); return $parameters[$field_name]; }
[ "public", "static", "function", "enum", "(", "$", "input", ",", "$", "values", ",", "$", "field_name", "=", "'enum'", ")", "{", "//Check if array was given for $values value", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Array is expected as values'", ")", ";", "}", "//Define trivial model", "$", "model", "=", "[", "$", "field_name", "=>", "[", "'type'", "=>", "Validate", "::", "TYPE_ENUM", ",", "'values'", "=>", "$", "values", ",", "Validate", "::", "REQUIRED", "]", "]", ";", "$", "parameters", "=", "[", "$", "field_name", "=>", "$", "input", "]", ";", "Validate", "::", "model", "(", "$", "parameters", ",", "$", "model", ")", ";", "return", "$", "parameters", "[", "$", "field_name", "]", ";", "}" ]
Check if input value is in allowed values @param string|integer $input Input array to check @param array $values Array of strings or number, defines the allowed input values @param string $field_name [optional] Field's name, used in IncorrectParametersException. Optional default is enum @throws IncorrectParameters If valu type is not correct. @return returns the value of the input value
[ "Check", "if", "input", "value", "is", "in", "allowed", "values" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L803-L822
14,890
phramework/validate
src/Validate.php
Validate.sqlDate
public static function sqlDate($date, $field_name = 'date') { if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/', $date, $matches)) { if (checkdate($matches[2], $matches[3], $matches[1])) { return $date; } } throw new IncorrectParametersException([ $field_name]); }
php
public static function sqlDate($date, $field_name = 'date') { if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/', $date, $matches)) { if (checkdate($matches[2], $matches[3], $matches[1])) { return $date; } } throw new IncorrectParametersException([ $field_name]); }
[ "public", "static", "function", "sqlDate", "(", "$", "date", ",", "$", "field_name", "=", "'date'", ")", "{", "if", "(", "preg_match", "(", "'/^(\\d{4})-(\\d{2})-(\\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/'", ",", "$", "date", ",", "$", "matches", ")", ")", "{", "if", "(", "checkdate", "(", "$", "matches", "[", "2", "]", ",", "$", "matches", "[", "3", "]", ",", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "$", "date", ";", "}", "}", "throw", "new", "IncorrectParametersException", "(", "[", "$", "field_name", "]", ")", ";", "}" ]
Validate SQL date, datetime @param string $date Input date @param string $field_name [optional] Field's name, used in IncorrectParametersException. Optional default is date @return string @throws IncorrectParameters If value type is not correct.
[ "Validate", "SQL", "date", "datetime" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L832-L840
14,891
phramework/validate
src/Validate.php
Validate.operator
public static function operator($operator, $field_name = 'operator') { if (!in_array($operator, self::$operators)) { throw new IncorrectParametersException([ $field_name]); } return $operator; }
php
public static function operator($operator, $field_name = 'operator') { if (!in_array($operator, self::$operators)) { throw new IncorrectParametersException([ $field_name]); } return $operator; }
[ "public", "static", "function", "operator", "(", "$", "operator", ",", "$", "field_name", "=", "'operator'", ")", "{", "if", "(", "!", "in_array", "(", "$", "operator", ",", "self", "::", "$", "operators", ")", ")", "{", "throw", "new", "IncorrectParametersException", "(", "[", "$", "field_name", "]", ")", ";", "}", "return", "$", "operator", ";", "}" ]
Validate an operator @param string $operator @param string $field_name [optional] @return string @throws IncorrectParameters If value type is not correct.
[ "Validate", "an", "operator" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/Validate.php#L872-L878
14,892
constant-null/backstubber
src/Core/ContentProcessor.php
ContentProcessor.setDelimiters
public function setDelimiters($begin, $end) { $this->beginDelimiter = $begin; $this->endDelimiter = $end; // for chaining return $this; }
php
public function setDelimiters($begin, $end) { $this->beginDelimiter = $begin; $this->endDelimiter = $end; // for chaining return $this; }
[ "public", "function", "setDelimiters", "(", "$", "begin", ",", "$", "end", ")", "{", "$", "this", "->", "beginDelimiter", "=", "$", "begin", ";", "$", "this", "->", "endDelimiter", "=", "$", "end", ";", "// for chaining", "return", "$", "this", ";", "}" ]
Set begin and end delimiters which will be used to detect parts to be replaced @param $begin string @param $end string @return $this
[ "Set", "begin", "and", "end", "delimiters", "which", "will", "be", "used", "to", "detect", "parts", "to", "be", "replaced" ]
1e7ee66091bae4e6b709642467609a8566dae479
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Core/ContentProcessor.php#L82-L90
14,893
constant-null/backstubber
src/Core/ContentProcessor.php
ContentProcessor.doRegexpReplace
public function doRegexpReplace($searchPattern, $replaceWith) { $this->content = preg_replace_callback( $searchPattern, function($matches) use ($replaceWith) { $indent = isset($matches['indent']) ? $matches['indent'] : ''; $output = $indent; $output .= isset($matches['start']) ? $matches['start'] : ''; $output .= isset($matches['target']) ? Formatter::indentLines($replaceWith, mb_strlen($indent), true) : ''; $output .= isset($matches['end']) ? $matches['end'] : ''; return $output; }, $this->content ); return $this; }
php
public function doRegexpReplace($searchPattern, $replaceWith) { $this->content = preg_replace_callback( $searchPattern, function($matches) use ($replaceWith) { $indent = isset($matches['indent']) ? $matches['indent'] : ''; $output = $indent; $output .= isset($matches['start']) ? $matches['start'] : ''; $output .= isset($matches['target']) ? Formatter::indentLines($replaceWith, mb_strlen($indent), true) : ''; $output .= isset($matches['end']) ? $matches['end'] : ''; return $output; }, $this->content ); return $this; }
[ "public", "function", "doRegexpReplace", "(", "$", "searchPattern", ",", "$", "replaceWith", ")", "{", "$", "this", "->", "content", "=", "preg_replace_callback", "(", "$", "searchPattern", ",", "function", "(", "$", "matches", ")", "use", "(", "$", "replaceWith", ")", "{", "$", "indent", "=", "isset", "(", "$", "matches", "[", "'indent'", "]", ")", "?", "$", "matches", "[", "'indent'", "]", ":", "''", ";", "$", "output", "=", "$", "indent", ";", "$", "output", ".=", "isset", "(", "$", "matches", "[", "'start'", "]", ")", "?", "$", "matches", "[", "'start'", "]", ":", "''", ";", "$", "output", ".=", "isset", "(", "$", "matches", "[", "'target'", "]", ")", "?", "Formatter", "::", "indentLines", "(", "$", "replaceWith", ",", "mb_strlen", "(", "$", "indent", ")", ",", "true", ")", ":", "''", ";", "$", "output", ".=", "isset", "(", "$", "matches", "[", "'end'", "]", ")", "?", "$", "matches", "[", "'end'", "]", ":", "''", ";", "return", "$", "output", ";", "}", ",", "$", "this", "->", "content", ")", ";", "return", "$", "this", ";", "}" ]
Immediately replaces part of data using regular expression @param $searchPattern string @param $replaceWith string @return $this
[ "Immediately", "replaces", "part", "of", "data", "using", "regular", "expression" ]
1e7ee66091bae4e6b709642467609a8566dae479
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Core/ContentProcessor.php#L137-L154
14,894
constant-null/backstubber
src/Core/ContentProcessor.php
ContentProcessor.doReplace
public function doReplace($searchFor, $replaceWith) { $this->content = str_replace($searchFor, $replaceWith, $this->content); // for chaining return $this; }
php
public function doReplace($searchFor, $replaceWith) { $this->content = str_replace($searchFor, $replaceWith, $this->content); // for chaining return $this; }
[ "public", "function", "doReplace", "(", "$", "searchFor", ",", "$", "replaceWith", ")", "{", "$", "this", "->", "content", "=", "str_replace", "(", "$", "searchFor", ",", "$", "replaceWith", ",", "$", "this", "->", "content", ")", ";", "// for chaining", "return", "$", "this", ";", "}" ]
Immediately replaces part of data @param $searchFor string @param $replaceWith string @return $this
[ "Immediately", "replaces", "part", "of", "data" ]
1e7ee66091bae4e6b709642467609a8566dae479
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Core/ContentProcessor.php#L163-L170
14,895
constant-null/backstubber
src/Core/ContentProcessor.php
ContentProcessor.process
public function process($forceOrder = false) { // sort the replacements by descending // (in that way some problems with replacements naming can be avoided) if (!$forceOrder) { array_multisort( array_map('mb_strlen', array_keys($this->replacements)), SORT_DESC, $this->replacements ); } // decide which function will be used $replaceFunc = $this->isDelimitersUsed() ? 'replaceWithRegexp' : 'replaceBasic'; foreach ($this->replacements as $searchFor => $replaceWith) { $this->$replaceFunc($searchFor, $replaceWith); } // for chaining return $this; }
php
public function process($forceOrder = false) { // sort the replacements by descending // (in that way some problems with replacements naming can be avoided) if (!$forceOrder) { array_multisort( array_map('mb_strlen', array_keys($this->replacements)), SORT_DESC, $this->replacements ); } // decide which function will be used $replaceFunc = $this->isDelimitersUsed() ? 'replaceWithRegexp' : 'replaceBasic'; foreach ($this->replacements as $searchFor => $replaceWith) { $this->$replaceFunc($searchFor, $replaceWith); } // for chaining return $this; }
[ "public", "function", "process", "(", "$", "forceOrder", "=", "false", ")", "{", "// sort the replacements by descending", "// (in that way some problems with replacements naming can be avoided)", "if", "(", "!", "$", "forceOrder", ")", "{", "array_multisort", "(", "array_map", "(", "'mb_strlen'", ",", "array_keys", "(", "$", "this", "->", "replacements", ")", ")", ",", "SORT_DESC", ",", "$", "this", "->", "replacements", ")", ";", "}", "// decide which function will be used", "$", "replaceFunc", "=", "$", "this", "->", "isDelimitersUsed", "(", ")", "?", "'replaceWithRegexp'", ":", "'replaceBasic'", ";", "foreach", "(", "$", "this", "->", "replacements", "as", "$", "searchFor", "=>", "$", "replaceWith", ")", "{", "$", "this", "->", "$", "replaceFunc", "(", "$", "searchFor", ",", "$", "replaceWith", ")", ";", "}", "// for chaining", "return", "$", "this", ";", "}" ]
Start replacing data @param $forceOrder bool keep user defined order of replacements (conflicts possible) @return $this
[ "Start", "replacing", "data" ]
1e7ee66091bae4e6b709642467609a8566dae479
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Core/ContentProcessor.php#L207-L228
14,896
mremi/Dolist
src/Mremi/Dolist/Contact/SavedContactInfo.php
SavedContactInfo.getHandledCodes
public function getHandledCodes() { return array( self::CODE_PENDING => 'pending', self::CODE_ERROR => 'error', self::CODE_SUCCESS => 'success', self::CODE_UNAUTHORIZED_EMAIL => 'unauthorized email', self::CODE_EMAIL_ALREADY_EXIST => 'email already exist', self::CODE_UNAUTHORIZED_OPTOUT_EMAIL => 'unauthorized optout email', self::CODE_UNAUTHORIZED_OPTOUT_MOBILE => 'unauthorized optout mobile', self::CODE_ERROR_ON_INTEREST_TO_ADD => 'error on interest to add', self::CODE_ERROR_ON_INTEREST_TO_DELETE => 'error on interest to delete', ); }
php
public function getHandledCodes() { return array( self::CODE_PENDING => 'pending', self::CODE_ERROR => 'error', self::CODE_SUCCESS => 'success', self::CODE_UNAUTHORIZED_EMAIL => 'unauthorized email', self::CODE_EMAIL_ALREADY_EXIST => 'email already exist', self::CODE_UNAUTHORIZED_OPTOUT_EMAIL => 'unauthorized optout email', self::CODE_UNAUTHORIZED_OPTOUT_MOBILE => 'unauthorized optout mobile', self::CODE_ERROR_ON_INTEREST_TO_ADD => 'error on interest to add', self::CODE_ERROR_ON_INTEREST_TO_DELETE => 'error on interest to delete', ); }
[ "public", "function", "getHandledCodes", "(", ")", "{", "return", "array", "(", "self", "::", "CODE_PENDING", "=>", "'pending'", ",", "self", "::", "CODE_ERROR", "=>", "'error'", ",", "self", "::", "CODE_SUCCESS", "=>", "'success'", ",", "self", "::", "CODE_UNAUTHORIZED_EMAIL", "=>", "'unauthorized email'", ",", "self", "::", "CODE_EMAIL_ALREADY_EXIST", "=>", "'email already exist'", ",", "self", "::", "CODE_UNAUTHORIZED_OPTOUT_EMAIL", "=>", "'unauthorized optout email'", ",", "self", "::", "CODE_UNAUTHORIZED_OPTOUT_MOBILE", "=>", "'unauthorized optout mobile'", ",", "self", "::", "CODE_ERROR_ON_INTEREST_TO_ADD", "=>", "'error on interest to add'", ",", "self", "::", "CODE_ERROR_ON_INTEREST_TO_DELETE", "=>", "'error on interest to delete'", ",", ")", ";", "}" ]
Gets an array of handled codes @return array
[ "Gets", "an", "array", "of", "handled", "codes" ]
452c863aba12ef2965bafdb619c0278f8fc732d0
https://github.com/mremi/Dolist/blob/452c863aba12ef2965bafdb619c0278f8fc732d0/src/Mremi/Dolist/Contact/SavedContactInfo.php#L115-L128
14,897
Wonail/wocenter
helpers/CacheManagerHelper.php
CacheManagerHelper.findCaches
private static function findCaches(array $cachesNames = []) { $caches = []; $components = Yii::$app->getComponents(); $findAll = ($cachesNames === []); foreach ($components as $name => $component) { if (!$findAll && !in_array($name, $cachesNames, true)) { continue; } if ($component instanceof CacheInterface) { $caches[$name] = get_class($component); } elseif (is_array($component) && isset($component['class']) && self::isCacheClass($component['class'])) { $caches[$name] = $component['class']; } elseif (is_string($component) && self::isCacheClass($component)) { $caches[$name] = $component; } elseif ($component instanceof \Closure) { $cache = Yii::$app->get($name); if (self::isCacheClass($cache)) { $cacheClass = get_class($cache); $caches[$name] = $cacheClass; } } } return $caches; }
php
private static function findCaches(array $cachesNames = []) { $caches = []; $components = Yii::$app->getComponents(); $findAll = ($cachesNames === []); foreach ($components as $name => $component) { if (!$findAll && !in_array($name, $cachesNames, true)) { continue; } if ($component instanceof CacheInterface) { $caches[$name] = get_class($component); } elseif (is_array($component) && isset($component['class']) && self::isCacheClass($component['class'])) { $caches[$name] = $component['class']; } elseif (is_string($component) && self::isCacheClass($component)) { $caches[$name] = $component; } elseif ($component instanceof \Closure) { $cache = Yii::$app->get($name); if (self::isCacheClass($cache)) { $cacheClass = get_class($cache); $caches[$name] = $cacheClass; } } } return $caches; }
[ "private", "static", "function", "findCaches", "(", "array", "$", "cachesNames", "=", "[", "]", ")", "{", "$", "caches", "=", "[", "]", ";", "$", "components", "=", "Yii", "::", "$", "app", "->", "getComponents", "(", ")", ";", "$", "findAll", "=", "(", "$", "cachesNames", "===", "[", "]", ")", ";", "foreach", "(", "$", "components", "as", "$", "name", "=>", "$", "component", ")", "{", "if", "(", "!", "$", "findAll", "&&", "!", "in_array", "(", "$", "name", ",", "$", "cachesNames", ",", "true", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "component", "instanceof", "CacheInterface", ")", "{", "$", "caches", "[", "$", "name", "]", "=", "get_class", "(", "$", "component", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "component", ")", "&&", "isset", "(", "$", "component", "[", "'class'", "]", ")", "&&", "self", "::", "isCacheClass", "(", "$", "component", "[", "'class'", "]", ")", ")", "{", "$", "caches", "[", "$", "name", "]", "=", "$", "component", "[", "'class'", "]", ";", "}", "elseif", "(", "is_string", "(", "$", "component", ")", "&&", "self", "::", "isCacheClass", "(", "$", "component", ")", ")", "{", "$", "caches", "[", "$", "name", "]", "=", "$", "component", ";", "}", "elseif", "(", "$", "component", "instanceof", "\\", "Closure", ")", "{", "$", "cache", "=", "Yii", "::", "$", "app", "->", "get", "(", "$", "name", ")", ";", "if", "(", "self", "::", "isCacheClass", "(", "$", "cache", ")", ")", "{", "$", "cacheClass", "=", "get_class", "(", "$", "cache", ")", ";", "$", "caches", "[", "$", "name", "]", "=", "$", "cacheClass", ";", "}", "}", "}", "return", "$", "caches", ";", "}" ]
Returns array of caches in the system, keys are cache components names, values are class names. @param array $cachesNames caches to be found @return array
[ "Returns", "array", "of", "caches", "in", "the", "system", "keys", "are", "cache", "components", "names", "values", "are", "class", "names", "." ]
186c15aad008d32fbf5ad75256cf01581dccf9e6
https://github.com/Wonail/wocenter/blob/186c15aad008d32fbf5ad75256cf01581dccf9e6/helpers/CacheManagerHelper.php#L46-L73
14,898
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php
CartManager.submitCartDirectly
public function submitCartDirectly( ApiOrderInterface $cart, UserInterface $user, $locale ) { $orderWasSubmitted = true; try { $this->checkIfCartIsValid($user, $cart, $locale); // set order-date to current date $cart->setOrderDate(new \DateTime()); // change status of order to confirmed $this->orderManager->convertStatus($cart, OrderStatus::STATUS_CONFIRMED); // order-addresses have to be set to the current contact-addresses $this->reApplyOrderAddresses($cart, $user); $customer = $user->getContact(); // send confirmation email to customer $this->orderEmailManager->sendCustomerConfirmation( $customer->getMainEmail(), $cart, $customer ); $shopOwnerEmail = null; // get responsible person of contacts account if ($customer->getMainAccount() && $customer->getMainAccount()->getResponsiblePerson() && $customer->getMainAccount()->getResponsiblePerson()->getMainEmail() ) { $shopOwnerEmail = $customer->getMainAccount()->getResponsiblePerson()->getMainEmail(); } // send confirmation email to shop owner $this->orderEmailManager->sendShopOwnerConfirmation( $shopOwnerEmail, $cart, $customer ); // flush on success $this->em->flush(); } catch (CartSubmissionException $cse) { $orderWasSubmitted = false; } return $orderWasSubmitted; }
php
public function submitCartDirectly( ApiOrderInterface $cart, UserInterface $user, $locale ) { $orderWasSubmitted = true; try { $this->checkIfCartIsValid($user, $cart, $locale); // set order-date to current date $cart->setOrderDate(new \DateTime()); // change status of order to confirmed $this->orderManager->convertStatus($cart, OrderStatus::STATUS_CONFIRMED); // order-addresses have to be set to the current contact-addresses $this->reApplyOrderAddresses($cart, $user); $customer = $user->getContact(); // send confirmation email to customer $this->orderEmailManager->sendCustomerConfirmation( $customer->getMainEmail(), $cart, $customer ); $shopOwnerEmail = null; // get responsible person of contacts account if ($customer->getMainAccount() && $customer->getMainAccount()->getResponsiblePerson() && $customer->getMainAccount()->getResponsiblePerson()->getMainEmail() ) { $shopOwnerEmail = $customer->getMainAccount()->getResponsiblePerson()->getMainEmail(); } // send confirmation email to shop owner $this->orderEmailManager->sendShopOwnerConfirmation( $shopOwnerEmail, $cart, $customer ); // flush on success $this->em->flush(); } catch (CartSubmissionException $cse) { $orderWasSubmitted = false; } return $orderWasSubmitted; }
[ "public", "function", "submitCartDirectly", "(", "ApiOrderInterface", "$", "cart", ",", "UserInterface", "$", "user", ",", "$", "locale", ")", "{", "$", "orderWasSubmitted", "=", "true", ";", "try", "{", "$", "this", "->", "checkIfCartIsValid", "(", "$", "user", ",", "$", "cart", ",", "$", "locale", ")", ";", "// set order-date to current date", "$", "cart", "->", "setOrderDate", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "// change status of order to confirmed", "$", "this", "->", "orderManager", "->", "convertStatus", "(", "$", "cart", ",", "OrderStatus", "::", "STATUS_CONFIRMED", ")", ";", "// order-addresses have to be set to the current contact-addresses", "$", "this", "->", "reApplyOrderAddresses", "(", "$", "cart", ",", "$", "user", ")", ";", "$", "customer", "=", "$", "user", "->", "getContact", "(", ")", ";", "// send confirmation email to customer", "$", "this", "->", "orderEmailManager", "->", "sendCustomerConfirmation", "(", "$", "customer", "->", "getMainEmail", "(", ")", ",", "$", "cart", ",", "$", "customer", ")", ";", "$", "shopOwnerEmail", "=", "null", ";", "// get responsible person of contacts account", "if", "(", "$", "customer", "->", "getMainAccount", "(", ")", "&&", "$", "customer", "->", "getMainAccount", "(", ")", "->", "getResponsiblePerson", "(", ")", "&&", "$", "customer", "->", "getMainAccount", "(", ")", "->", "getResponsiblePerson", "(", ")", "->", "getMainEmail", "(", ")", ")", "{", "$", "shopOwnerEmail", "=", "$", "customer", "->", "getMainAccount", "(", ")", "->", "getResponsiblePerson", "(", ")", "->", "getMainEmail", "(", ")", ";", "}", "// send confirmation email to shop owner", "$", "this", "->", "orderEmailManager", "->", "sendShopOwnerConfirmation", "(", "$", "shopOwnerEmail", ",", "$", "cart", ",", "$", "customer", ")", ";", "// flush on success", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}", "catch", "(", "CartSubmissionException", "$", "cse", ")", "{", "$", "orderWasSubmitted", "=", "false", ";", "}", "return", "$", "orderWasSubmitted", ";", "}" ]
Submits a cart @param ApiOrderInterface $cart @param string $locale @param UserInterface $user @return bool
[ "Submits", "a", "cart" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php#L288-L340
14,899
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php
CartManager.checkProductsAvailability
private function checkProductsAvailability(OrderInterface $cart) { // no check needed if ($cart->getItems()->isEmpty()) { return true; } $containsInvalidProducts = false; /** @var \Sulu\Bundle\Sales\CoreBundle\Entity\ItemInterface $item */ foreach ($cart->getItems() as $item) { if (!$item->getProduct() || !$item->getProduct()->isValidShopProduct() ) { $containsInvalidProducts = true; $cart->removeItem($item); $this->em->remove($item); } } // persist new cart if ($containsInvalidProducts) { $this->em->flush(); } return !$containsInvalidProducts; }
php
private function checkProductsAvailability(OrderInterface $cart) { // no check needed if ($cart->getItems()->isEmpty()) { return true; } $containsInvalidProducts = false; /** @var \Sulu\Bundle\Sales\CoreBundle\Entity\ItemInterface $item */ foreach ($cart->getItems() as $item) { if (!$item->getProduct() || !$item->getProduct()->isValidShopProduct() ) { $containsInvalidProducts = true; $cart->removeItem($item); $this->em->remove($item); } } // persist new cart if ($containsInvalidProducts) { $this->em->flush(); } return !$containsInvalidProducts; }
[ "private", "function", "checkProductsAvailability", "(", "OrderInterface", "$", "cart", ")", "{", "// no check needed", "if", "(", "$", "cart", "->", "getItems", "(", ")", "->", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "$", "containsInvalidProducts", "=", "false", ";", "/** @var \\Sulu\\Bundle\\Sales\\CoreBundle\\Entity\\ItemInterface $item */", "foreach", "(", "$", "cart", "->", "getItems", "(", ")", "as", "$", "item", ")", "{", "if", "(", "!", "$", "item", "->", "getProduct", "(", ")", "||", "!", "$", "item", "->", "getProduct", "(", ")", "->", "isValidShopProduct", "(", ")", ")", "{", "$", "containsInvalidProducts", "=", "true", ";", "$", "cart", "->", "removeItem", "(", "$", "item", ")", ";", "$", "this", "->", "em", "->", "remove", "(", "$", "item", ")", ";", "}", "}", "// persist new cart", "if", "(", "$", "containsInvalidProducts", ")", "{", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}", "return", "!", "$", "containsInvalidProducts", ";", "}" ]
Removes items from cart that have no valid shop products applied; and returns if all products are still available @param OrderInterface $cart @return bool If all products are available
[ "Removes", "items", "from", "cart", "that", "have", "no", "valid", "shop", "products", "applied", ";", "and", "returns", "if", "all", "products", "are", "still", "available" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php#L366-L390