repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
koolkode/meta
src/DocComment.php
DocComment.parse
protected function parse($comment) { $this->description = ''; $this->tags = []; $comment = preg_replace("'^\s*/*\**'m", '', substr($comment, 0, -2)); $parts = preg_split("'^\s*@([a-zA-Z][a-zA-Z0-9]*)'m", $comment, -1, PREG_SPLIT_DELIM_CAPTURE); $this->description = preg_replace("'^\h+'m", '', trim($parts[0])); for($i = 1, $count = count($parts) - 1; $i < $count; $i += 2) { $this->tags[$parts[$i]][] = trim($parts[$i + 1]); } return $this; }
php
protected function parse($comment) { $this->description = ''; $this->tags = []; $comment = preg_replace("'^\s*/*\**'m", '', substr($comment, 0, -2)); $parts = preg_split("'^\s*@([a-zA-Z][a-zA-Z0-9]*)'m", $comment, -1, PREG_SPLIT_DELIM_CAPTURE); $this->description = preg_replace("'^\h+'m", '', trim($parts[0])); for($i = 1, $count = count($parts) - 1; $i < $count; $i += 2) { $this->tags[$parts[$i]][] = trim($parts[$i + 1]); } return $this; }
[ "protected", "function", "parse", "(", "$", "comment", ")", "{", "$", "this", "->", "description", "=", "''", ";", "$", "this", "->", "tags", "=", "[", "]", ";", "$", "comment", "=", "preg_replace", "(", "\"'^\\s*/*\\**'m\"", ",", "''", ",", "substr", "(", "$", "comment", ",", "0", ",", "-", "2", ")", ")", ";", "$", "parts", "=", "preg_split", "(", "\"'^\\s*@([a-zA-Z][a-zA-Z0-9]*)'m\"", ",", "$", "comment", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "$", "this", "->", "description", "=", "preg_replace", "(", "\"'^\\h+'m\"", ",", "''", ",", "trim", "(", "$", "parts", "[", "0", "]", ")", ")", ";", "for", "(", "$", "i", "=", "1", ",", "$", "count", "=", "count", "(", "$", "parts", ")", "-", "1", ";", "$", "i", "<", "$", "count", ";", "$", "i", "+=", "2", ")", "{", "$", "this", "->", "tags", "[", "$", "parts", "[", "$", "i", "]", "]", "[", "]", "=", "trim", "(", "$", "parts", "[", "$", "i", "+", "1", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Parse the given doc comment and populate description and tags. @param string $comment
[ "Parse", "the", "given", "doc", "comment", "and", "populate", "description", "and", "tags", "." ]
339db24d3ce461190f552c96e243bca21010f360
https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/DocComment.php#L171-L187
train
bound1ess/essence
src/Essence/Matchers/AbstractMatcher.php
AbstractMatcher.setMessage
protected function setMessage($message, array $parameters = []) { $message = sprintf( "%s: %s.", (new \ReflectionClass($this))->getShortName(), $message ); $parameters = array_map([$this->getDumper(), "dump"], $parameters); $this->message = call_user_func_array( "sprintf", array_merge([$message], $parameters) ); }
php
protected function setMessage($message, array $parameters = []) { $message = sprintf( "%s: %s.", (new \ReflectionClass($this))->getShortName(), $message ); $parameters = array_map([$this->getDumper(), "dump"], $parameters); $this->message = call_user_func_array( "sprintf", array_merge([$message], $parameters) ); }
[ "protected", "function", "setMessage", "(", "$", "message", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "message", "=", "sprintf", "(", "\"%s: %s.\"", ",", "(", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ")", "->", "getShortName", "(", ")", ",", "$", "message", ")", ";", "$", "parameters", "=", "array_map", "(", "[", "$", "this", "->", "getDumper", "(", ")", ",", "\"dump\"", "]", ",", "$", "parameters", ")", ";", "$", "this", "->", "message", "=", "call_user_func_array", "(", "\"sprintf\"", ",", "array_merge", "(", "[", "$", "message", "]", ",", "$", "parameters", ")", ")", ";", "}" ]
Sets the error message. @see Essence\Matchers\AbstractMatcher::$message @param string $message @param array $parameters @return void
[ "Sets", "the", "error", "message", "." ]
b773d3f17e192d7c7184ffd3640c668e7d74f69b
https://github.com/bound1ess/essence/blob/b773d3f17e192d7c7184ffd3640c668e7d74f69b/src/Essence/Matchers/AbstractMatcher.php#L130-L144
train
MinyFramework/Miny-Core
src/Extendable.php
Extendable.addMethod
public function addMethod($method, callable $callback) { if (!is_string($method)) { throw new \InvalidArgumentException('$method must be string'); } $this->plugins[$method] = $callback; }
php
public function addMethod($method, callable $callback) { if (!is_string($method)) { throw new \InvalidArgumentException('$method must be string'); } $this->plugins[$method] = $callback; }
[ "public", "function", "addMethod", "(", "$", "method", ",", "callable", "$", "callback", ")", "{", "if", "(", "!", "is_string", "(", "$", "method", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$method must be string'", ")", ";", "}", "$", "this", "->", "plugins", "[", "$", "method", "]", "=", "$", "callback", ";", "}" ]
Dynamically add a method to the class. @param string $method @param callable $callback @throws \InvalidArgumentException
[ "Dynamically", "add", "a", "method", "to", "the", "class", "." ]
a1bfe801a44a49cf01f16411cb4663473e9c827c
https://github.com/MinyFramework/Miny-Core/blob/a1bfe801a44a49cf01f16411cb4663473e9c827c/src/Extendable.php#L32-L38
train
MinyFramework/Miny-Core
src/Extendable.php
Extendable.addSetters
public function addSetters(array $setters) { foreach ($setters as $property => $setter) { if (is_int($property)) { $property = $setter; $setter = 'set' . ucfirst($setter); } $this->setters[$setter] = $property; } }
php
public function addSetters(array $setters) { foreach ($setters as $property => $setter) { if (is_int($property)) { $property = $setter; $setter = 'set' . ucfirst($setter); } $this->setters[$setter] = $property; } }
[ "public", "function", "addSetters", "(", "array", "$", "setters", ")", "{", "foreach", "(", "$", "setters", "as", "$", "property", "=>", "$", "setter", ")", "{", "if", "(", "is_int", "(", "$", "property", ")", ")", "{", "$", "property", "=", "$", "setter", ";", "$", "setter", "=", "'set'", ".", "ucfirst", "(", "$", "setter", ")", ";", "}", "$", "this", "->", "setters", "[", "$", "setter", "]", "=", "$", "property", ";", "}", "}" ]
Register multiple property setters. @param array $setters
[ "Register", "multiple", "property", "setters", "." ]
a1bfe801a44a49cf01f16411cb4663473e9c827c
https://github.com/MinyFramework/Miny-Core/blob/a1bfe801a44a49cf01f16411cb4663473e9c827c/src/Extendable.php#L87-L96
train
anime-db/catalog-bundle
src/Controller/ItemController.php
ItemController.addManuallyAction
public function addManuallyAction(Request $request) { $response = $this->getCacheTimeKeeper()->getResponse(); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } $item = new Item(); /* @var $form Form */ $form = $this->createForm('entity_item', $item) ->handleRequest($request); if ($form->isValid()) { /* @var $rep ItemRepository */ $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item'); // Add a new entry only if no duplicates $duplicate = $rep->findDuplicate($item); if ($duplicate) { $request->getSession()->set(self::NAME_ITEM_ADDED, $item); return $this->redirect($this->generateUrl('item_duplicate')); } else { return $this->addItem($item); } } return $this->render('AnimeDbCatalogBundle:Item:add-manually.html.twig', [ 'form' => $form->createView(), ], $response); }
php
public function addManuallyAction(Request $request) { $response = $this->getCacheTimeKeeper()->getResponse(); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } $item = new Item(); /* @var $form Form */ $form = $this->createForm('entity_item', $item) ->handleRequest($request); if ($form->isValid()) { /* @var $rep ItemRepository */ $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item'); // Add a new entry only if no duplicates $duplicate = $rep->findDuplicate($item); if ($duplicate) { $request->getSession()->set(self::NAME_ITEM_ADDED, $item); return $this->redirect($this->generateUrl('item_duplicate')); } else { return $this->addItem($item); } } return $this->render('AnimeDbCatalogBundle:Item:add-manually.html.twig', [ 'form' => $form->createView(), ], $response); }
[ "public", "function", "addManuallyAction", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "getCacheTimeKeeper", "(", ")", "->", "getResponse", "(", ")", ";", "// response was not modified for this request", "if", "(", "$", "response", "->", "isNotModified", "(", "$", "request", ")", ")", "{", "return", "$", "response", ";", "}", "$", "item", "=", "new", "Item", "(", ")", ";", "/* @var $form Form */", "$", "form", "=", "$", "this", "->", "createForm", "(", "'entity_item'", ",", "$", "item", ")", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "/* @var $rep ItemRepository */", "$", "rep", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'AnimeDbCatalogBundle:Item'", ")", ";", "// Add a new entry only if no duplicates", "$", "duplicate", "=", "$", "rep", "->", "findDuplicate", "(", "$", "item", ")", ";", "if", "(", "$", "duplicate", ")", "{", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "self", "::", "NAME_ITEM_ADDED", ",", "$", "item", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'item_duplicate'", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "addItem", "(", "$", "item", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Item:add-manually.html.twig'", ",", "[", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "]", ",", "$", "response", ")", ";", "}" ]
Addition form. @param Request $request @return Response
[ "Addition", "form", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/ItemController.php#L154-L185
train
anime-db/catalog-bundle
src/Controller/ItemController.php
ItemController.changeAction
public function changeAction(Item $item, Request $request) { /* @var $form Form */ $form = $this->createForm('entity_item', $item) ->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($item); $em->flush(); return $this->redirect($this->generateUrl( 'item_show', ['id' => $item->getId(), 'name' => $item->getUrlName()] )); } return $this->render('AnimeDbCatalogBundle:Item:change.html.twig', [ 'item' => $item, 'form' => $form->createView(), ]); }
php
public function changeAction(Item $item, Request $request) { /* @var $form Form */ $form = $this->createForm('entity_item', $item) ->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($item); $em->flush(); return $this->redirect($this->generateUrl( 'item_show', ['id' => $item->getId(), 'name' => $item->getUrlName()] )); } return $this->render('AnimeDbCatalogBundle:Item:change.html.twig', [ 'item' => $item, 'form' => $form->createView(), ]); }
[ "public", "function", "changeAction", "(", "Item", "$", "item", ",", "Request", "$", "request", ")", "{", "/* @var $form Form */", "$", "form", "=", "$", "this", "->", "createForm", "(", "'entity_item'", ",", "$", "item", ")", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "item", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'item_show'", ",", "[", "'id'", "=>", "$", "item", "->", "getId", "(", ")", ",", "'name'", "=>", "$", "item", "->", "getUrlName", "(", ")", "]", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Item:change.html.twig'", ",", "[", "'item'", "=>", "$", "item", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "]", ")", ";", "}" ]
Change item. @param Item $item @param Request $request @return Response
[ "Change", "item", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/ItemController.php#L195-L215
train
anime-db/catalog-bundle
src/Controller/ItemController.php
ItemController.deleteAction
public function deleteAction(Item $item) { $em = $this->getDoctrine()->getManager(); $em->remove($item); $em->flush(); return $this->redirect($this->generateUrl('home')); }
php
public function deleteAction(Item $item) { $em = $this->getDoctrine()->getManager(); $em->remove($item); $em->flush(); return $this->redirect($this->generateUrl('home')); }
[ "public", "function", "deleteAction", "(", "Item", "$", "item", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "remove", "(", "$", "item", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'home'", ")", ")", ";", "}" ]
Delete item. @param Item $item @return Response
[ "Delete", "item", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/ItemController.php#L224-L231
train
anime-db/catalog-bundle
src/Controller/ItemController.php
ItemController.importAction
public function importAction($plugin, Request $request) { /* @var $chain ChainSearch */ $chain = $this->get('anime_db.plugin.import'); /* @var $import ImportInterface */ if (!($import = $chain->getPlugin($plugin))) { throw $this->createNotFoundException('Plugin \''.$plugin.'\' is not found'); } $form = $this->createForm($import->getForm())->handleRequest($request); $list = []; if ($form->isValid()) { // import items $list = (array) $import->import($form->getData()); // persist entity $em = $this->getDoctrine()->getManager(); foreach ($list as $key => $item) { if ($item instanceof Item) { $em->persist($item); } else { unset($list[$key]); } } } return $this->render('AnimeDbCatalogBundle:Item:import.html.twig', [ 'plugin' => $plugin, 'items' => $list, 'form' => $form->createView(), ]); }
php
public function importAction($plugin, Request $request) { /* @var $chain ChainSearch */ $chain = $this->get('anime_db.plugin.import'); /* @var $import ImportInterface */ if (!($import = $chain->getPlugin($plugin))) { throw $this->createNotFoundException('Plugin \''.$plugin.'\' is not found'); } $form = $this->createForm($import->getForm())->handleRequest($request); $list = []; if ($form->isValid()) { // import items $list = (array) $import->import($form->getData()); // persist entity $em = $this->getDoctrine()->getManager(); foreach ($list as $key => $item) { if ($item instanceof Item) { $em->persist($item); } else { unset($list[$key]); } } } return $this->render('AnimeDbCatalogBundle:Item:import.html.twig', [ 'plugin' => $plugin, 'items' => $list, 'form' => $form->createView(), ]); }
[ "public", "function", "importAction", "(", "$", "plugin", ",", "Request", "$", "request", ")", "{", "/* @var $chain ChainSearch */", "$", "chain", "=", "$", "this", "->", "get", "(", "'anime_db.plugin.import'", ")", ";", "/* @var $import ImportInterface */", "if", "(", "!", "(", "$", "import", "=", "$", "chain", "->", "getPlugin", "(", "$", "plugin", ")", ")", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Plugin \\''", ".", "$", "plugin", ".", "'\\' is not found'", ")", ";", "}", "$", "form", "=", "$", "this", "->", "createForm", "(", "$", "import", "->", "getForm", "(", ")", ")", "->", "handleRequest", "(", "$", "request", ")", ";", "$", "list", "=", "[", "]", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "// import items", "$", "list", "=", "(", "array", ")", "$", "import", "->", "import", "(", "$", "form", "->", "getData", "(", ")", ")", ";", "// persist entity", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "$", "item", "instanceof", "Item", ")", "{", "$", "em", "->", "persist", "(", "$", "item", ")", ";", "}", "else", "{", "unset", "(", "$", "list", "[", "$", "key", "]", ")", ";", "}", "}", "}", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Item:import.html.twig'", ",", "[", "'plugin'", "=>", "$", "plugin", ",", "'items'", "=>", "$", "list", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "]", ")", ";", "}" ]
Import items. @param string $plugin @param Request $request @return Response
[ "Import", "items", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/ItemController.php#L241-L273
train
anime-db/catalog-bundle
src/Controller/ItemController.php
ItemController.duplicateAction
public function duplicateAction(Request $request) { /* @var $rep ItemRepository */ $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item'); // get store item $item = $request->getSession()->get(self::NAME_ITEM_ADDED); if (!($item instanceof Item)) { throw $this->createNotFoundException('Not found item for confirm duplicate'); } // confirm duplicate if ($request->isMethod('POST')) { $request->getSession()->remove(self::NAME_ITEM_ADDED); switch ($request->request->get('do')) { case 'add': return $this->addItem($item->freez($this->getDoctrine())); default: return $this->redirect($this->generateUrl('home')); } } // re searching for duplicates $duplicate = $rep->findDuplicate($item); // now there is no duplication if (!$duplicate) { return $this->addItem($item->freez($this->getDoctrine())); } return $this->render('AnimeDbCatalogBundle:Item:duplicate.html.twig', [ 'items' => $duplicate, ]); }
php
public function duplicateAction(Request $request) { /* @var $rep ItemRepository */ $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item'); // get store item $item = $request->getSession()->get(self::NAME_ITEM_ADDED); if (!($item instanceof Item)) { throw $this->createNotFoundException('Not found item for confirm duplicate'); } // confirm duplicate if ($request->isMethod('POST')) { $request->getSession()->remove(self::NAME_ITEM_ADDED); switch ($request->request->get('do')) { case 'add': return $this->addItem($item->freez($this->getDoctrine())); default: return $this->redirect($this->generateUrl('home')); } } // re searching for duplicates $duplicate = $rep->findDuplicate($item); // now there is no duplication if (!$duplicate) { return $this->addItem($item->freez($this->getDoctrine())); } return $this->render('AnimeDbCatalogBundle:Item:duplicate.html.twig', [ 'items' => $duplicate, ]); }
[ "public", "function", "duplicateAction", "(", "Request", "$", "request", ")", "{", "/* @var $rep ItemRepository */", "$", "rep", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'AnimeDbCatalogBundle:Item'", ")", ";", "// get store item", "$", "item", "=", "$", "request", "->", "getSession", "(", ")", "->", "get", "(", "self", "::", "NAME_ITEM_ADDED", ")", ";", "if", "(", "!", "(", "$", "item", "instanceof", "Item", ")", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Not found item for confirm duplicate'", ")", ";", "}", "// confirm duplicate", "if", "(", "$", "request", "->", "isMethod", "(", "'POST'", ")", ")", "{", "$", "request", "->", "getSession", "(", ")", "->", "remove", "(", "self", "::", "NAME_ITEM_ADDED", ")", ";", "switch", "(", "$", "request", "->", "request", "->", "get", "(", "'do'", ")", ")", "{", "case", "'add'", ":", "return", "$", "this", "->", "addItem", "(", "$", "item", "->", "freez", "(", "$", "this", "->", "getDoctrine", "(", ")", ")", ")", ";", "default", ":", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'home'", ")", ")", ";", "}", "}", "// re searching for duplicates", "$", "duplicate", "=", "$", "rep", "->", "findDuplicate", "(", "$", "item", ")", ";", "// now there is no duplication", "if", "(", "!", "$", "duplicate", ")", "{", "return", "$", "this", "->", "addItem", "(", "$", "item", "->", "freez", "(", "$", "this", "->", "getDoctrine", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Item:duplicate.html.twig'", ",", "[", "'items'", "=>", "$", "duplicate", ",", "]", ")", ";", "}" ]
Confirm duplicate item. @param Request $request @return Response
[ "Confirm", "duplicate", "item", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/ItemController.php#L282-L314
train
anime-db/catalog-bundle
src/Controller/ItemController.php
ItemController.limitControlAction
public function limitControlAction(Request $request, $total = '') { /* @var $controls ListControls */ $controls = $this->get('anime_db.item.list_controls'); if (!is_numeric($total) || $total < 0) { /* @var $rep ItemRepository */ $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item'); $total = $rep->count(); } return $this->render('AnimeDbCatalogBundle:Item:list_controls/limit.html.twig', [ 'limits' => $controls->getLimits($request->query->all()), 'total' => $total, ]); }
php
public function limitControlAction(Request $request, $total = '') { /* @var $controls ListControls */ $controls = $this->get('anime_db.item.list_controls'); if (!is_numeric($total) || $total < 0) { /* @var $rep ItemRepository */ $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item'); $total = $rep->count(); } return $this->render('AnimeDbCatalogBundle:Item:list_controls/limit.html.twig', [ 'limits' => $controls->getLimits($request->query->all()), 'total' => $total, ]); }
[ "public", "function", "limitControlAction", "(", "Request", "$", "request", ",", "$", "total", "=", "''", ")", "{", "/* @var $controls ListControls */", "$", "controls", "=", "$", "this", "->", "get", "(", "'anime_db.item.list_controls'", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "total", ")", "||", "$", "total", "<", "0", ")", "{", "/* @var $rep ItemRepository */", "$", "rep", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'AnimeDbCatalogBundle:Item'", ")", ";", "$", "total", "=", "$", "rep", "->", "count", "(", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Item:list_controls/limit.html.twig'", ",", "[", "'limits'", "=>", "$", "controls", "->", "getLimits", "(", "$", "request", "->", "query", "->", "all", "(", ")", ")", ",", "'total'", "=>", "$", "total", ",", "]", ")", ";", "}" ]
List items limit control. @param Request $request @param string|int $total @return Response
[ "List", "items", "limit", "control", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/ItemController.php#L343-L358
train
anime-db/catalog-bundle
src/Controller/ItemController.php
ItemController.sortControlAction
public function sortControlAction(Request $request) { /* @var $controls ListControls */ $controls = $this->get('anime_db.item.list_controls'); $direction = $controls->getSortDirection($request->query->all()); $sort_direction = [ 'type' => $direction == 'ASC' ? 'DESC' : 'ASC', 'link' => $controls->getSortDirectionLink($request->query->all()), ]; return $this->render('AnimeDbCatalogBundle:Item:list_controls/sort.html.twig', [ 'sort_by' => $controls->getSortColumns($request->query->all()), 'sort_direction' => $sort_direction, ]); }
php
public function sortControlAction(Request $request) { /* @var $controls ListControls */ $controls = $this->get('anime_db.item.list_controls'); $direction = $controls->getSortDirection($request->query->all()); $sort_direction = [ 'type' => $direction == 'ASC' ? 'DESC' : 'ASC', 'link' => $controls->getSortDirectionLink($request->query->all()), ]; return $this->render('AnimeDbCatalogBundle:Item:list_controls/sort.html.twig', [ 'sort_by' => $controls->getSortColumns($request->query->all()), 'sort_direction' => $sort_direction, ]); }
[ "public", "function", "sortControlAction", "(", "Request", "$", "request", ")", "{", "/* @var $controls ListControls */", "$", "controls", "=", "$", "this", "->", "get", "(", "'anime_db.item.list_controls'", ")", ";", "$", "direction", "=", "$", "controls", "->", "getSortDirection", "(", "$", "request", "->", "query", "->", "all", "(", ")", ")", ";", "$", "sort_direction", "=", "[", "'type'", "=>", "$", "direction", "==", "'ASC'", "?", "'DESC'", ":", "'ASC'", ",", "'link'", "=>", "$", "controls", "->", "getSortDirectionLink", "(", "$", "request", "->", "query", "->", "all", "(", ")", ")", ",", "]", ";", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Item:list_controls/sort.html.twig'", ",", "[", "'sort_by'", "=>", "$", "controls", "->", "getSortColumns", "(", "$", "request", "->", "query", "->", "all", "(", ")", ")", ",", "'sort_direction'", "=>", "$", "sort_direction", ",", "]", ")", ";", "}" ]
List items sort control. @param Request $request @return Response
[ "List", "items", "sort", "control", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/ItemController.php#L367-L382
train
jenskooij/cloudcontrol
src/util/Cms.php
Cms.editDocumentLink
public static function editDocumentLink($path) { if (self::isLoggedIn()) { $path = 0 === strpos($path, '/') ? substr($path, 1) : $path; return Request::$subfolders . 'cms/documents/edit-document?slug=' . urlencode($path); } else { return ''; } }
php
public static function editDocumentLink($path) { if (self::isLoggedIn()) { $path = 0 === strpos($path, '/') ? substr($path, 1) : $path; return Request::$subfolders . 'cms/documents/edit-document?slug=' . urlencode($path); } else { return ''; } }
[ "public", "static", "function", "editDocumentLink", "(", "$", "path", ")", "{", "if", "(", "self", "::", "isLoggedIn", "(", ")", ")", "{", "$", "path", "=", "0", "===", "strpos", "(", "$", "path", ",", "'/'", ")", "?", "substr", "(", "$", "path", ",", "1", ")", ":", "$", "path", ";", "return", "Request", "::", "$", "subfolders", ".", "'cms/documents/edit-document?slug='", ".", "urlencode", "(", "$", "path", ")", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Returns the cms link for editing a document @param $path @return string @throws \Exception
[ "Returns", "the", "cms", "link", "for", "editing", "a", "document" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/util/Cms.php#L39-L47
train
jenskooij/cloudcontrol
src/util/Cms.php
Cms.newDocument
public static function newDocument($path = '/', $documentType = '') { if (self::isLoggedIn()) { $return = self::getAssetsIfNotIncluded(); return $return . '<a title="New Document" data-href="' . self::newDocumentLink($path, $documentType) . '" class="ccEditDocumentButton ccNewDocumentButton"></a>'; } else { return ''; } }
php
public static function newDocument($path = '/', $documentType = '') { if (self::isLoggedIn()) { $return = self::getAssetsIfNotIncluded(); return $return . '<a title="New Document" data-href="' . self::newDocumentLink($path, $documentType) . '" class="ccEditDocumentButton ccNewDocumentButton"></a>'; } else { return ''; } }
[ "public", "static", "function", "newDocument", "(", "$", "path", "=", "'/'", ",", "$", "documentType", "=", "''", ")", "{", "if", "(", "self", "::", "isLoggedIn", "(", ")", ")", "{", "$", "return", "=", "self", "::", "getAssetsIfNotIncluded", "(", ")", ";", "return", "$", "return", ".", "'<a title=\"New Document\" data-href=\"'", ".", "self", "::", "newDocumentLink", "(", "$", "path", ",", "$", "documentType", ")", ".", "'\" class=\"ccEditDocumentButton ccNewDocumentButton\"></a>'", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Returns a button with a link for creating a new document @param string $path @param string $documentType @return string @throws \Exception
[ "Returns", "a", "button", "with", "a", "link", "for", "creating", "a", "new", "document" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/util/Cms.php#L56-L65
train
jenskooij/cloudcontrol
src/util/Cms.php
Cms.newDocumentLink
public static function newDocumentLink($path = '/', $documentType = '') { if (self::isLoggedIn()) { $path = 0 === strpos($path, '/') ? $path : '/' . $path; $linkPostFix = ''; if ($documentType !== '') { $linkPostFix = '&amp;documentType=' . $documentType; } return Request::$subfolders . 'cms/documents/new-document?path=' . urlencode($path) . $linkPostFix; } else { return ''; } }
php
public static function newDocumentLink($path = '/', $documentType = '') { if (self::isLoggedIn()) { $path = 0 === strpos($path, '/') ? $path : '/' . $path; $linkPostFix = ''; if ($documentType !== '') { $linkPostFix = '&amp;documentType=' . $documentType; } return Request::$subfolders . 'cms/documents/new-document?path=' . urlencode($path) . $linkPostFix; } else { return ''; } }
[ "public", "static", "function", "newDocumentLink", "(", "$", "path", "=", "'/'", ",", "$", "documentType", "=", "''", ")", "{", "if", "(", "self", "::", "isLoggedIn", "(", ")", ")", "{", "$", "path", "=", "0", "===", "strpos", "(", "$", "path", ",", "'/'", ")", "?", "$", "path", ":", "'/'", ".", "$", "path", ";", "$", "linkPostFix", "=", "''", ";", "if", "(", "$", "documentType", "!==", "''", ")", "{", "$", "linkPostFix", "=", "'&amp;documentType='", ".", "$", "documentType", ";", "}", "return", "Request", "::", "$", "subfolders", ".", "'cms/documents/new-document?path='", ".", "urlencode", "(", "$", "path", ")", ".", "$", "linkPostFix", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Returns the cms link for creating a new document @param string $path @param string $documentType @return string @throws \Exception
[ "Returns", "the", "cms", "link", "for", "creating", "a", "new", "document" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/util/Cms.php#L74-L86
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/storagefacility/AbstractStorageFacility.php
AbstractStorageFacility.resolveFile
public function resolveFile(StorageFacilityParams $params, $fileid) { return new StorageFacilityFile($fileid, $this->generateStoragePath($params, $fileid), $this->generateUrl($params, $fileid)); }
php
public function resolveFile(StorageFacilityParams $params, $fileid) { return new StorageFacilityFile($fileid, $this->generateStoragePath($params, $fileid), $this->generateUrl($params, $fileid)); }
[ "public", "function", "resolveFile", "(", "StorageFacilityParams", "$", "params", ",", "$", "fileid", ")", "{", "return", "new", "StorageFacilityFile", "(", "$", "fileid", ",", "$", "this", "->", "generateStoragePath", "(", "$", "params", ",", "$", "fileid", ")", ",", "$", "this", "->", "generateUrl", "(", "$", "params", ",", "$", "fileid", ")", ")", ";", "}" ]
Using storage facility params, generate a StorageFacilityFile object without querying storage @param StorageFacilityParams $params Parameters used to determine storage location and URL @param string $fileid File identifier of stored file, ex. /path/to/file.jpg @return StorageFacilityFile
[ "Using", "storage", "facility", "params", "generate", "a", "StorageFacilityFile", "object", "without", "querying", "storage" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/storagefacility/AbstractStorageFacility.php#L232-L235
train
Evozon-PHP/Tissue
Adapter/AbstractAdapter.php
AbstractAdapter.createProcessBuilder
protected function createProcessBuilder(array $arguments = [], $timeout = null): ProcessBuilder { $pb = new ProcessBuilder($arguments); if (null !== $timeout) { $pb->setTimeout($timeout); } return $pb; }
php
protected function createProcessBuilder(array $arguments = [], $timeout = null): ProcessBuilder { $pb = new ProcessBuilder($arguments); if (null !== $timeout) { $pb->setTimeout($timeout); } return $pb; }
[ "protected", "function", "createProcessBuilder", "(", "array", "$", "arguments", "=", "[", "]", ",", "$", "timeout", "=", "null", ")", ":", "ProcessBuilder", "{", "$", "pb", "=", "new", "ProcessBuilder", "(", "$", "arguments", ")", ";", "if", "(", "null", "!==", "$", "timeout", ")", "{", "$", "pb", "->", "setTimeout", "(", "$", "timeout", ")", ";", "}", "return", "$", "pb", ";", "}" ]
Creates a new process builder that your might use to interact with your virus-scanner's executable. @param array $arguments An optional array of arguments @param int|null $timeout An optional number of seconds for the process' timeout limit @return ProcessBuilder A new process builder @codeCoverageIgnore
[ "Creates", "a", "new", "process", "builder", "that", "your", "might", "use", "to", "interact", "with", "your", "virus", "-", "scanner", "s", "executable", "." ]
9c9624322e3849abf3e154d94b4467833ae73135
https://github.com/Evozon-PHP/Tissue/blob/9c9624322e3849abf3e154d94b4467833ae73135/Adapter/AbstractAdapter.php#L169-L178
train
ciims/ciims-modules-hybridauth
controllers/DefaultController.php
DefaultController.getUserProfile
public function getUserProfile() { if ($this->_userProfile == NULL) $this->_userProfile = $this->getAdapter()->getUserProfile(); return $this->_userProfile; }
php
public function getUserProfile() { if ($this->_userProfile == NULL) $this->_userProfile = $this->getAdapter()->getUserProfile(); return $this->_userProfile; }
[ "public", "function", "getUserProfile", "(", ")", "{", "if", "(", "$", "this", "->", "_userProfile", "==", "NULL", ")", "$", "this", "->", "_userProfile", "=", "$", "this", "->", "getAdapter", "(", ")", "->", "getUserProfile", "(", ")", ";", "return", "$", "this", "->", "_userProfile", ";", "}" ]
Caches the getUserProfile request to prevent rate limiting issues. @return object
[ "Caches", "the", "getUserProfile", "request", "to", "prevent", "rate", "limiting", "issues", "." ]
417b2682bf3468dd509164a9b773d886359a7aec
https://github.com/ciims/ciims-modules-hybridauth/blob/417b2682bf3468dd509164a9b773d886359a7aec/controllers/DefaultController.php#L59-L65
train
ciims/ciims-modules-hybridauth
controllers/DefaultController.php
DefaultController.setProvider
public function setProvider($provider=NULL) { // Prevent the provider from being NULL if ($provider == NULL) throw new CException(Yii::t('Hybridauth.main', "You haven't supplied a provider")); // Set the property $this->_provider = $provider; return $this->_provider; }
php
public function setProvider($provider=NULL) { // Prevent the provider from being NULL if ($provider == NULL) throw new CException(Yii::t('Hybridauth.main', "You haven't supplied a provider")); // Set the property $this->_provider = $provider; return $this->_provider; }
[ "public", "function", "setProvider", "(", "$", "provider", "=", "NULL", ")", "{", "// Prevent the provider from being NULL", "if", "(", "$", "provider", "==", "NULL", ")", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'Hybridauth.main'", ",", "\"You haven't supplied a provider\"", ")", ")", ";", "// Set the property", "$", "this", "->", "_provider", "=", "$", "provider", ";", "return", "$", "this", "->", "_provider", ";", "}" ]
Sets the provider for this controller to use @param string $provider The Provider Name @return $provider
[ "Sets", "the", "provider", "for", "this", "controller", "to", "use" ]
417b2682bf3468dd509164a9b773d886359a7aec
https://github.com/ciims/ciims-modules-hybridauth/blob/417b2682bf3468dd509164a9b773d886359a7aec/controllers/DefaultController.php#L72-L82
train
ciims/ciims-modules-hybridauth
controllers/DefaultController.php
DefaultController.hybridAuth
private function hybridAuth() { // Preload some configuration options if (strtolower($this->getProvider()) == 'openid') { if (!isset($_GET['openid-identity'])) throw new CException(Yii::t('Hybridauth.main', "You chose OpenID but didn't provide an OpenID identifier")); else $params = array("openid_identifier" => $_GET['openid-identity']); } else $params = array(); // Load HybridAuth $hybridauth = new Hybrid_Auth(Yii::app()->controller->module->getConfig()); if (!$this->adapter) $this->setAdapter($hybridauth->authenticate($this->getProvider(),$params)); // Proceed if we've been connected if ($this->adapter->isUserConnected()) { // If we have an identity on file, then autheticate as that user. if ($this->authenticate()) { Yii::app()->user->setFlash('success', Yii::t('HybridAuth.main', 'You have been sucessfully logged in!')); if (isset($_GET['next'])) $this->redirect($this->createUrl($_GET['next'])); $this->redirect(Yii::app()->getBaseUrl(true)); } else { // If we DON'T have information about this user already on file // If they're not a guest, present them with a form to link their accounts // Otherwise present them with a registration form // We want remote users to have their own identity, rather than just dangling and not being able to actually interact with our site if (!Yii::app()->user->isGuest) $this->renderLinkForm(); else $this->renderRegisterForm(); } } else throw new CHttpException(403, Yii::t('HybridAuth.main', 'Failed to establish remote identity')); }
php
private function hybridAuth() { // Preload some configuration options if (strtolower($this->getProvider()) == 'openid') { if (!isset($_GET['openid-identity'])) throw new CException(Yii::t('Hybridauth.main', "You chose OpenID but didn't provide an OpenID identifier")); else $params = array("openid_identifier" => $_GET['openid-identity']); } else $params = array(); // Load HybridAuth $hybridauth = new Hybrid_Auth(Yii::app()->controller->module->getConfig()); if (!$this->adapter) $this->setAdapter($hybridauth->authenticate($this->getProvider(),$params)); // Proceed if we've been connected if ($this->adapter->isUserConnected()) { // If we have an identity on file, then autheticate as that user. if ($this->authenticate()) { Yii::app()->user->setFlash('success', Yii::t('HybridAuth.main', 'You have been sucessfully logged in!')); if (isset($_GET['next'])) $this->redirect($this->createUrl($_GET['next'])); $this->redirect(Yii::app()->getBaseUrl(true)); } else { // If we DON'T have information about this user already on file // If they're not a guest, present them with a form to link their accounts // Otherwise present them with a registration form // We want remote users to have their own identity, rather than just dangling and not being able to actually interact with our site if (!Yii::app()->user->isGuest) $this->renderLinkForm(); else $this->renderRegisterForm(); } } else throw new CHttpException(403, Yii::t('HybridAuth.main', 'Failed to establish remote identity')); }
[ "private", "function", "hybridAuth", "(", ")", "{", "// Preload some configuration options", "if", "(", "strtolower", "(", "$", "this", "->", "getProvider", "(", ")", ")", "==", "'openid'", ")", "{", "if", "(", "!", "isset", "(", "$", "_GET", "[", "'openid-identity'", "]", ")", ")", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'Hybridauth.main'", ",", "\"You chose OpenID but didn't provide an OpenID identifier\"", ")", ")", ";", "else", "$", "params", "=", "array", "(", "\"openid_identifier\"", "=>", "$", "_GET", "[", "'openid-identity'", "]", ")", ";", "}", "else", "$", "params", "=", "array", "(", ")", ";", "// Load HybridAuth", "$", "hybridauth", "=", "new", "Hybrid_Auth", "(", "Yii", "::", "app", "(", ")", "->", "controller", "->", "module", "->", "getConfig", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "adapter", ")", "$", "this", "->", "setAdapter", "(", "$", "hybridauth", "->", "authenticate", "(", "$", "this", "->", "getProvider", "(", ")", ",", "$", "params", ")", ")", ";", "// Proceed if we've been connected", "if", "(", "$", "this", "->", "adapter", "->", "isUserConnected", "(", ")", ")", "{", "// If we have an identity on file, then autheticate as that user.", "if", "(", "$", "this", "->", "authenticate", "(", ")", ")", "{", "Yii", "::", "app", "(", ")", "->", "user", "->", "setFlash", "(", "'success'", ",", "Yii", "::", "t", "(", "'HybridAuth.main'", ",", "'You have been sucessfully logged in!'", ")", ")", ";", "if", "(", "isset", "(", "$", "_GET", "[", "'next'", "]", ")", ")", "$", "this", "->", "redirect", "(", "$", "this", "->", "createUrl", "(", "$", "_GET", "[", "'next'", "]", ")", ")", ";", "$", "this", "->", "redirect", "(", "Yii", "::", "app", "(", ")", "->", "getBaseUrl", "(", "true", ")", ")", ";", "}", "else", "{", "// If we DON'T have information about this user already on file", "// If they're not a guest, present them with a form to link their accounts", "// Otherwise present them with a registration form", "// We want remote users to have their own identity, rather than just dangling and not being able to actually interact with our site", "if", "(", "!", "Yii", "::", "app", "(", ")", "->", "user", "->", "isGuest", ")", "$", "this", "->", "renderLinkForm", "(", ")", ";", "else", "$", "this", "->", "renderRegisterForm", "(", ")", ";", "}", "}", "else", "throw", "new", "CHttpException", "(", "403", ",", "Yii", "::", "t", "(", "'HybridAuth.main'", ",", "'Failed to establish remote identity'", ")", ")", ";", "}" ]
Handles authenticating the user against the remote identity
[ "Handles", "authenticating", "the", "user", "against", "the", "remote", "identity" ]
417b2682bf3468dd509164a9b773d886359a7aec
https://github.com/ciims/ciims-modules-hybridauth/blob/417b2682bf3468dd509164a9b773d886359a7aec/controllers/DefaultController.php#L124-L168
train
ciims/ciims-modules-hybridauth
controllers/DefaultController.php
DefaultController.authenticate
private function authenticate() { $form = new RemoteIdentityForm; $form->attributes = array( 'adapter' => $this->getUserProfile(), 'provider' => $this->getProvider() ); return $form->login(); }
php
private function authenticate() { $form = new RemoteIdentityForm; $form->attributes = array( 'adapter' => $this->getUserProfile(), 'provider' => $this->getProvider() ); return $form->login(); }
[ "private", "function", "authenticate", "(", ")", "{", "$", "form", "=", "new", "RemoteIdentityForm", ";", "$", "form", "->", "attributes", "=", "array", "(", "'adapter'", "=>", "$", "this", "->", "getUserProfile", "(", ")", ",", "'provider'", "=>", "$", "this", "->", "getProvider", "(", ")", ")", ";", "return", "$", "form", "->", "login", "(", ")", ";", "}" ]
Authenticates in as the user @return boolean
[ "Authenticates", "in", "as", "the", "user" ]
417b2682bf3468dd509164a9b773d886359a7aec
https://github.com/ciims/ciims-modules-hybridauth/blob/417b2682bf3468dd509164a9b773d886359a7aec/controllers/DefaultController.php#L174-L183
train
ciims/ciims-modules-hybridauth
controllers/DefaultController.php
DefaultController.renderLinkForm
private function renderLinkForm() { $this->layout = '//layouts/main'; $this->setPageTitle(Yii::t('HybridAuth.main', '{{app_name}} | {{label}}', array( '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('HybridAuth.main', 'Link Your Account') ))); $form = new RemoteLinkAccountForm; if (Cii::get($_POST, 'RemoteLinkAccountForm', false)) { // Populate the model $form->attributes = Cii::get($_POST, 'RemoteLinkAccountForm', false); $form->provider = $this->getProvider(); $form->adapter = $this->getUserProfile(); if ($form->save()) { if ($this->authenticate()) { Yii::app()->user->setFlash('success', Yii::t('HybridAuth.main', 'You have successfully logged in via {{provider}}', array('{{provider}}' => $this->getProvider() ))); $this->redirect(Yii::app()->user->returnUrl); } } } // Reuse the register form $this->render('/linkaccount', array('model' => $form)); }
php
private function renderLinkForm() { $this->layout = '//layouts/main'; $this->setPageTitle(Yii::t('HybridAuth.main', '{{app_name}} | {{label}}', array( '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('HybridAuth.main', 'Link Your Account') ))); $form = new RemoteLinkAccountForm; if (Cii::get($_POST, 'RemoteLinkAccountForm', false)) { // Populate the model $form->attributes = Cii::get($_POST, 'RemoteLinkAccountForm', false); $form->provider = $this->getProvider(); $form->adapter = $this->getUserProfile(); if ($form->save()) { if ($this->authenticate()) { Yii::app()->user->setFlash('success', Yii::t('HybridAuth.main', 'You have successfully logged in via {{provider}}', array('{{provider}}' => $this->getProvider() ))); $this->redirect(Yii::app()->user->returnUrl); } } } // Reuse the register form $this->render('/linkaccount', array('model' => $form)); }
[ "private", "function", "renderLinkForm", "(", ")", "{", "$", "this", "->", "layout", "=", "'//layouts/main'", ";", "$", "this", "->", "setPageTitle", "(", "Yii", "::", "t", "(", "'HybridAuth.main'", ",", "'{{app_name}} | {{label}}'", ",", "array", "(", "'{{app_name}}'", "=>", "Cii", "::", "getConfig", "(", "'name'", ",", "Yii", "::", "app", "(", ")", "->", "name", ")", ",", "'{{label}}'", "=>", "Yii", "::", "t", "(", "'HybridAuth.main'", ",", "'Link Your Account'", ")", ")", ")", ")", ";", "$", "form", "=", "new", "RemoteLinkAccountForm", ";", "if", "(", "Cii", "::", "get", "(", "$", "_POST", ",", "'RemoteLinkAccountForm'", ",", "false", ")", ")", "{", "// Populate the model", "$", "form", "->", "attributes", "=", "Cii", "::", "get", "(", "$", "_POST", ",", "'RemoteLinkAccountForm'", ",", "false", ")", ";", "$", "form", "->", "provider", "=", "$", "this", "->", "getProvider", "(", ")", ";", "$", "form", "->", "adapter", "=", "$", "this", "->", "getUserProfile", "(", ")", ";", "if", "(", "$", "form", "->", "save", "(", ")", ")", "{", "if", "(", "$", "this", "->", "authenticate", "(", ")", ")", "{", "Yii", "::", "app", "(", ")", "->", "user", "->", "setFlash", "(", "'success'", ",", "Yii", "::", "t", "(", "'HybridAuth.main'", ",", "'You have successfully logged in via {{provider}}'", ",", "array", "(", "'{{provider}}'", "=>", "$", "this", "->", "getProvider", "(", ")", ")", ")", ")", ";", "$", "this", "->", "redirect", "(", "Yii", "::", "app", "(", ")", "->", "user", "->", "returnUrl", ")", ";", "}", "}", "}", "// Reuse the register form", "$", "this", "->", "render", "(", "'/linkaccount'", ",", "array", "(", "'model'", "=>", "$", "form", ")", ")", ";", "}" ]
Renders the linking form
[ "Renders", "the", "linking", "form" ]
417b2682bf3468dd509164a9b773d886359a7aec
https://github.com/ciims/ciims-modules-hybridauth/blob/417b2682bf3468dd509164a9b773d886359a7aec/controllers/DefaultController.php#L188-L218
train
frameworkwtf/core
src/Config.php
Config.getGroup
protected function getGroup(string $name): array { if (!$this->container->has('config_'.$name)) { $this->loadGroup($name); } return $this->container->get('config_'.$name); }
php
protected function getGroup(string $name): array { if (!$this->container->has('config_'.$name)) { $this->loadGroup($name); } return $this->container->get('config_'.$name); }
[ "protected", "function", "getGroup", "(", "string", "$", "name", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "container", "->", "has", "(", "'config_'", ".", "$", "name", ")", ")", "{", "$", "this", "->", "loadGroup", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "container", "->", "get", "(", "'config_'", ".", "$", "name", ")", ";", "}" ]
Loads a group configuration file it has not been loaded before and returns its options. If the group doesn't exist creates an empty one. @param string $name Name of the configuration group to load @return array Array of options for this group
[ "Loads", "a", "group", "configuration", "file", "it", "has", "not", "been", "loaded", "before", "and", "returns", "its", "options", ".", "If", "the", "group", "doesn", "t", "exist", "creates", "an", "empty", "one", "." ]
8104ca140ec287c26724389780e5e1dba57a030a
https://github.com/frameworkwtf/core/blob/8104ca140ec287c26724389780e5e1dba57a030a/src/Config.php#L72-L79
train
frameworkwtf/core
src/Config.php
Config.loadGroup
protected function loadGroup(string $name): void { $file = $this->container->get('config_dir').'/'.$name.'.php'; $data = \is_file($file) ? include($file) : []; $this->container['config_'.$name] = $data; }
php
protected function loadGroup(string $name): void { $file = $this->container->get('config_dir').'/'.$name.'.php'; $data = \is_file($file) ? include($file) : []; $this->container['config_'.$name] = $data; }
[ "protected", "function", "loadGroup", "(", "string", "$", "name", ")", ":", "void", "{", "$", "file", "=", "$", "this", "->", "container", "->", "get", "(", "'config_dir'", ")", ".", "'/'", ".", "$", "name", ".", "'.php'", ";", "$", "data", "=", "\\", "is_file", "(", "$", "file", ")", "?", "include", "(", "$", "file", ")", ":", "[", "]", ";", "$", "this", "->", "container", "[", "'config_'", ".", "$", "name", "]", "=", "$", "data", ";", "}" ]
Load group from file by group name. @param string $name
[ "Load", "group", "from", "file", "by", "group", "name", "." ]
8104ca140ec287c26724389780e5e1dba57a030a
https://github.com/frameworkwtf/core/blob/8104ca140ec287c26724389780e5e1dba57a030a/src/Config.php#L86-L91
train
PenoaksDev/Milky-Framework
src/Milky/Filesystem/FilesystemManager.php
FilesystemManager.get
protected function get( $name ) { return isset( $this->disks[$name] ) ? $this->disks[$name] : $this->resolve( $name ); }
php
protected function get( $name ) { return isset( $this->disks[$name] ) ? $this->disks[$name] : $this->resolve( $name ); }
[ "protected", "function", "get", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "disks", "[", "$", "name", "]", ")", "?", "$", "this", "->", "disks", "[", "$", "name", "]", ":", "$", "this", "->", "resolve", "(", "$", "name", ")", ";", "}" ]
Attempt to get the disk from the local cache. @param string $name @return Filesystem
[ "Attempt", "to", "get", "the", "disk", "from", "the", "local", "cache", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Filesystem/FilesystemManager.php#L75-L78
train
zicht/tinymce-bundle
src/Zicht/Bundle/TinymceBundle/DependencyInjection/ZichtTinymceExtension.php
ZichtTinymceExtension.load
public function load(array $configs, ContainerBuilder $container) { // Get default configuration of the bundle $config = $this->processConfiguration(new Configuration(), $configs); if (empty($config['theme'])) { $config['theme'] = array( 'simple' => array(), ); } else { foreach ($config['theme'] as &$bundleTheme) { // Quick fix for the removed obsolete themes if (isset($bundleTheme['theme']) && in_array($bundleTheme['theme'], array('advanced', 'simple'))) { $bundleTheme['theme'] = 'modern'; } unset($bundleTheme); } } $container->setParameter('zicht_tinymce.config', $config); // load dependency injection config $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('service.xml'); }
php
public function load(array $configs, ContainerBuilder $container) { // Get default configuration of the bundle $config = $this->processConfiguration(new Configuration(), $configs); if (empty($config['theme'])) { $config['theme'] = array( 'simple' => array(), ); } else { foreach ($config['theme'] as &$bundleTheme) { // Quick fix for the removed obsolete themes if (isset($bundleTheme['theme']) && in_array($bundleTheme['theme'], array('advanced', 'simple'))) { $bundleTheme['theme'] = 'modern'; } unset($bundleTheme); } } $container->setParameter('zicht_tinymce.config', $config); // load dependency injection config $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('service.xml'); }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "// Get default configuration of the bundle", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "new", "Configuration", "(", ")", ",", "$", "configs", ")", ";", "if", "(", "empty", "(", "$", "config", "[", "'theme'", "]", ")", ")", "{", "$", "config", "[", "'theme'", "]", "=", "array", "(", "'simple'", "=>", "array", "(", ")", ",", ")", ";", "}", "else", "{", "foreach", "(", "$", "config", "[", "'theme'", "]", "as", "&", "$", "bundleTheme", ")", "{", "// Quick fix for the removed obsolete themes", "if", "(", "isset", "(", "$", "bundleTheme", "[", "'theme'", "]", ")", "&&", "in_array", "(", "$", "bundleTheme", "[", "'theme'", "]", ",", "array", "(", "'advanced'", ",", "'simple'", ")", ")", ")", "{", "$", "bundleTheme", "[", "'theme'", "]", "=", "'modern'", ";", "}", "unset", "(", "$", "bundleTheme", ")", ";", "}", "}", "$", "container", "->", "setParameter", "(", "'zicht_tinymce.config'", ",", "$", "config", ")", ";", "// load dependency injection config", "$", "loader", "=", "new", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "$", "loader", "->", "load", "(", "'service.xml'", ")", ";", "}" ]
Loads the ZichtTinymce configuration. @param array $configs An array of configuration values @param ContainerBuilder $container A ContainerBuilder instance
[ "Loads", "the", "ZichtTinymce", "configuration", "." ]
43d2eb4eb3f7f0e4752fb496f4aada6f2d805c96
https://github.com/zicht/tinymce-bundle/blob/43d2eb4eb3f7f0e4752fb496f4aada6f2d805c96/src/Zicht/Bundle/TinymceBundle/DependencyInjection/ZichtTinymceExtension.php#L21-L45
train
ZFrapid/zf2rapid-domain
src/ZF2rapidDomain/TableGateway/AbstractTableGateway.php
AbstractTableGateway.fetchCollection
protected function fetchCollection(Select $select) { $collection = []; /** @var EntityInterface $entity */ foreach ($this->selectWith($select) as $entity) { $collection[$entity->getIdentifier()] = $entity; } return $collection; }
php
protected function fetchCollection(Select $select) { $collection = []; /** @var EntityInterface $entity */ foreach ($this->selectWith($select) as $entity) { $collection[$entity->getIdentifier()] = $entity; } return $collection; }
[ "protected", "function", "fetchCollection", "(", "Select", "$", "select", ")", "{", "$", "collection", "=", "[", "]", ";", "/** @var EntityInterface $entity */", "foreach", "(", "$", "this", "->", "selectWith", "(", "$", "select", ")", "as", "$", "entity", ")", "{", "$", "collection", "[", "$", "entity", "->", "getIdentifier", "(", ")", "]", "=", "$", "entity", ";", "}", "return", "$", "collection", ";", "}" ]
Fetch array collection of entities @param Select $select @return array
[ "Fetch", "array", "collection", "of", "entities" ]
9455689cac06b42025c144878604d27c28b4bb04
https://github.com/ZFrapid/zf2rapid-domain/blob/9455689cac06b42025c144878604d27c28b4bb04/src/ZF2rapidDomain/TableGateway/AbstractTableGateway.php#L48-L58
train
ZFrapid/zf2rapid-domain
src/ZF2rapidDomain/TableGateway/AbstractTableGateway.php
AbstractTableGateway.insertEntity
public function insertEntity(EntityInterface $entity) { $insert = $this->getSql()->insert(); $insert->values($this->getHydrator()->extract($entity)); try { $this->insertWith($insert); } catch (RuntimeException $e) { return false; } return true; }
php
public function insertEntity(EntityInterface $entity) { $insert = $this->getSql()->insert(); $insert->values($this->getHydrator()->extract($entity)); try { $this->insertWith($insert); } catch (RuntimeException $e) { return false; } return true; }
[ "public", "function", "insertEntity", "(", "EntityInterface", "$", "entity", ")", "{", "$", "insert", "=", "$", "this", "->", "getSql", "(", ")", "->", "insert", "(", ")", ";", "$", "insert", "->", "values", "(", "$", "this", "->", "getHydrator", "(", ")", "->", "extract", "(", "$", "entity", ")", ")", ";", "try", "{", "$", "this", "->", "insertWith", "(", "$", "insert", ")", ";", "}", "catch", "(", "RuntimeException", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Insert an new entity @param EntityInterface $entity @return bool
[ "Insert", "an", "new", "entity" ]
9455689cac06b42025c144878604d27c28b4bb04
https://github.com/ZFrapid/zf2rapid-domain/blob/9455689cac06b42025c144878604d27c28b4bb04/src/ZF2rapidDomain/TableGateway/AbstractTableGateway.php#L145-L157
train
ZFrapid/zf2rapid-domain
src/ZF2rapidDomain/TableGateway/AbstractTableGateway.php
AbstractTableGateway.updateEntity
public function updateEntity(EntityInterface $entity) { $update = $this->getSql()->update(); $update->set($this->getHydrator()->extract($entity)); $update->where->equalTo($this->getPrimaryKey(), $entity->getIdentifier()); try { $this->updateWith($update); } catch (RuntimeException $e) { return false; } return true; }
php
public function updateEntity(EntityInterface $entity) { $update = $this->getSql()->update(); $update->set($this->getHydrator()->extract($entity)); $update->where->equalTo($this->getPrimaryKey(), $entity->getIdentifier()); try { $this->updateWith($update); } catch (RuntimeException $e) { return false; } return true; }
[ "public", "function", "updateEntity", "(", "EntityInterface", "$", "entity", ")", "{", "$", "update", "=", "$", "this", "->", "getSql", "(", ")", "->", "update", "(", ")", ";", "$", "update", "->", "set", "(", "$", "this", "->", "getHydrator", "(", ")", "->", "extract", "(", "$", "entity", ")", ")", ";", "$", "update", "->", "where", "->", "equalTo", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ",", "$", "entity", "->", "getIdentifier", "(", ")", ")", ";", "try", "{", "$", "this", "->", "updateWith", "(", "$", "update", ")", ";", "}", "catch", "(", "RuntimeException", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Update an existing entity @param EntityInterface $entity @return bool
[ "Update", "an", "existing", "entity" ]
9455689cac06b42025c144878604d27c28b4bb04
https://github.com/ZFrapid/zf2rapid-domain/blob/9455689cac06b42025c144878604d27c28b4bb04/src/ZF2rapidDomain/TableGateway/AbstractTableGateway.php#L166-L179
train
agentmedia/phine-core
src/Core/Logic/Installation/Installer.php
Installer.UpdateBundleVersions
private function UpdateBundleVersions() { $this->ClearInstalledBundles(); $bundles = PathUtil::Bundles(); foreach ($bundles as $bundle) { if (!array_key_exists($bundle, $this->failedBundles)) { $this->UpdateBundleVersion($bundle); } } }
php
private function UpdateBundleVersions() { $this->ClearInstalledBundles(); $bundles = PathUtil::Bundles(); foreach ($bundles as $bundle) { if (!array_key_exists($bundle, $this->failedBundles)) { $this->UpdateBundleVersion($bundle); } } }
[ "private", "function", "UpdateBundleVersions", "(", ")", "{", "$", "this", "->", "ClearInstalledBundles", "(", ")", ";", "$", "bundles", "=", "PathUtil", "::", "Bundles", "(", ")", ";", "foreach", "(", "$", "bundles", "as", "$", "bundle", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "bundle", ",", "$", "this", "->", "failedBundles", ")", ")", "{", "$", "this", "->", "UpdateBundleVersion", "(", "$", "bundle", ")", ";", "}", "}", "}" ]
Updates database to store current bundle versions
[ "Updates", "database", "to", "store", "current", "bundle", "versions" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/Installer.php#L169-L180
train
agentmedia/phine-core
src/Core/Logic/Installation/Installer.php
Installer.UpdateBundleVersion
private function UpdateBundleVersion($bundle) { $instBundle = InstalledBundle::Schema()->ByBundle($bundle); if (!$instBundle) { $instBundle = new InstalledBundle(); } $instBundle->SetVersion($this->installedBundles[$bundle]); $instBundle->SetBundle($bundle); $instBundle->SetLastUpdate(Date::Now()); $instBundle->Save(); }
php
private function UpdateBundleVersion($bundle) { $instBundle = InstalledBundle::Schema()->ByBundle($bundle); if (!$instBundle) { $instBundle = new InstalledBundle(); } $instBundle->SetVersion($this->installedBundles[$bundle]); $instBundle->SetBundle($bundle); $instBundle->SetLastUpdate(Date::Now()); $instBundle->Save(); }
[ "private", "function", "UpdateBundleVersion", "(", "$", "bundle", ")", "{", "$", "instBundle", "=", "InstalledBundle", "::", "Schema", "(", ")", "->", "ByBundle", "(", "$", "bundle", ")", ";", "if", "(", "!", "$", "instBundle", ")", "{", "$", "instBundle", "=", "new", "InstalledBundle", "(", ")", ";", "}", "$", "instBundle", "->", "SetVersion", "(", "$", "this", "->", "installedBundles", "[", "$", "bundle", "]", ")", ";", "$", "instBundle", "->", "SetBundle", "(", "$", "bundle", ")", ";", "$", "instBundle", "->", "SetLastUpdate", "(", "Date", "::", "Now", "(", ")", ")", ";", "$", "instBundle", "->", "Save", "(", ")", ";", "}" ]
Updates the version of the bundle @param string $bundle The bundle name
[ "Updates", "the", "version", "of", "the", "bundle" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/Installer.php#L186-L197
train
agentmedia/phine-core
src/Core/Logic/Installation/Installer.php
Installer.ClearInstalledBundles
private function ClearInstalledBundles() { //Clear bundles without code folder $bundles = PathUtil::Bundles(); $sql = new Sql\Builder($this->connection); $inList = $sql->InListFromValues($bundles); $tbl = InstalledBundle::Schema()->Table(); $where = $sql->NotIn($tbl->Field('Bundle'), $inList); InstalledBundle::Schema()->Delete($where); //Clear failed bundles $failedList = $sql->InListFromValues(array_keys($this->failedBundles)); if ($failedList) { InstalledBundle::Schema()->Delete($sql->In($tbl->Field('Bundle'), $failedList)); } }
php
private function ClearInstalledBundles() { //Clear bundles without code folder $bundles = PathUtil::Bundles(); $sql = new Sql\Builder($this->connection); $inList = $sql->InListFromValues($bundles); $tbl = InstalledBundle::Schema()->Table(); $where = $sql->NotIn($tbl->Field('Bundle'), $inList); InstalledBundle::Schema()->Delete($where); //Clear failed bundles $failedList = $sql->InListFromValues(array_keys($this->failedBundles)); if ($failedList) { InstalledBundle::Schema()->Delete($sql->In($tbl->Field('Bundle'), $failedList)); } }
[ "private", "function", "ClearInstalledBundles", "(", ")", "{", "//Clear bundles without code folder", "$", "bundles", "=", "PathUtil", "::", "Bundles", "(", ")", ";", "$", "sql", "=", "new", "Sql", "\\", "Builder", "(", "$", "this", "->", "connection", ")", ";", "$", "inList", "=", "$", "sql", "->", "InListFromValues", "(", "$", "bundles", ")", ";", "$", "tbl", "=", "InstalledBundle", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "where", "=", "$", "sql", "->", "NotIn", "(", "$", "tbl", "->", "Field", "(", "'Bundle'", ")", ",", "$", "inList", ")", ";", "InstalledBundle", "::", "Schema", "(", ")", "->", "Delete", "(", "$", "where", ")", ";", "//Clear failed bundles", "$", "failedList", "=", "$", "sql", "->", "InListFromValues", "(", "array_keys", "(", "$", "this", "->", "failedBundles", ")", ")", ";", "if", "(", "$", "failedList", ")", "{", "InstalledBundle", "::", "Schema", "(", ")", "->", "Delete", "(", "$", "sql", "->", "In", "(", "$", "tbl", "->", "Field", "(", "'Bundle'", ")", ",", "$", "failedList", ")", ")", ";", "}", "}" ]
Clears installed bundles
[ "Clears", "installed", "bundles" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/Installer.php#L203-L219
train
agentmedia/phine-core
src/Core/Logic/Installation/Installer.php
Installer.InstallBundle
private function InstallBundle($bundle) { $manifest = ClassFinder::Manifest($bundle); foreach ($manifest->Dependencies() as $dependency) { if (!$this->InstallDependency($dependency)) { return false; } } $bundleInstaller = new BundleInstaller($manifest, $this->connection, $this->InstalledVersion($bundle)); $result = true; try { $bundleInstaller->ExecuteSql(); $this->installedBundles[$bundle] = $manifest->Version(); } catch (\Exception $exc) { $this->failedBundles[$bundle] = $exc->getMessage(); $result = false; } $this->ReportProgress(); return $result; }
php
private function InstallBundle($bundle) { $manifest = ClassFinder::Manifest($bundle); foreach ($manifest->Dependencies() as $dependency) { if (!$this->InstallDependency($dependency)) { return false; } } $bundleInstaller = new BundleInstaller($manifest, $this->connection, $this->InstalledVersion($bundle)); $result = true; try { $bundleInstaller->ExecuteSql(); $this->installedBundles[$bundle] = $manifest->Version(); } catch (\Exception $exc) { $this->failedBundles[$bundle] = $exc->getMessage(); $result = false; } $this->ReportProgress(); return $result; }
[ "private", "function", "InstallBundle", "(", "$", "bundle", ")", "{", "$", "manifest", "=", "ClassFinder", "::", "Manifest", "(", "$", "bundle", ")", ";", "foreach", "(", "$", "manifest", "->", "Dependencies", "(", ")", "as", "$", "dependency", ")", "{", "if", "(", "!", "$", "this", "->", "InstallDependency", "(", "$", "dependency", ")", ")", "{", "return", "false", ";", "}", "}", "$", "bundleInstaller", "=", "new", "BundleInstaller", "(", "$", "manifest", ",", "$", "this", "->", "connection", ",", "$", "this", "->", "InstalledVersion", "(", "$", "bundle", ")", ")", ";", "$", "result", "=", "true", ";", "try", "{", "$", "bundleInstaller", "->", "ExecuteSql", "(", ")", ";", "$", "this", "->", "installedBundles", "[", "$", "bundle", "]", "=", "$", "manifest", "->", "Version", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exc", ")", "{", "$", "this", "->", "failedBundles", "[", "$", "bundle", "]", "=", "$", "exc", "->", "getMessage", "(", ")", ";", "$", "result", "=", "false", ";", "}", "$", "this", "->", "ReportProgress", "(", ")", ";", "return", "$", "result", ";", "}" ]
Installs a single bundle @param string $bundle @return boolean
[ "Installs", "a", "single", "bundle" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/Installer.php#L237-L261
train
agentmedia/phine-core
src/Core/Logic/Installation/Installer.php
Installer.InstallDependency
private function InstallDependency(BundleDependency $dependency) { $bundle = $dependency->BundleName(); if (array_key_exists($bundle, $this->failedBundles)) { return false; } $installedVersion = $this->InstalledVersion($bundle); $manifest = ClassFinder::Manifest($bundle); if (!$installedVersion || version_compare($installedVersion, $manifest->Version()) < 0) { if (!$this->InstallBundle($bundle)) { return false; } } return true; }
php
private function InstallDependency(BundleDependency $dependency) { $bundle = $dependency->BundleName(); if (array_key_exists($bundle, $this->failedBundles)) { return false; } $installedVersion = $this->InstalledVersion($bundle); $manifest = ClassFinder::Manifest($bundle); if (!$installedVersion || version_compare($installedVersion, $manifest->Version()) < 0) { if (!$this->InstallBundle($bundle)) { return false; } } return true; }
[ "private", "function", "InstallDependency", "(", "BundleDependency", "$", "dependency", ")", "{", "$", "bundle", "=", "$", "dependency", "->", "BundleName", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "bundle", ",", "$", "this", "->", "failedBundles", ")", ")", "{", "return", "false", ";", "}", "$", "installedVersion", "=", "$", "this", "->", "InstalledVersion", "(", "$", "bundle", ")", ";", "$", "manifest", "=", "ClassFinder", "::", "Manifest", "(", "$", "bundle", ")", ";", "if", "(", "!", "$", "installedVersion", "||", "version_compare", "(", "$", "installedVersion", ",", "$", "manifest", "->", "Version", "(", ")", ")", "<", "0", ")", "{", "if", "(", "!", "$", "this", "->", "InstallBundle", "(", "$", "bundle", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Installs a dependency @param BundleDependency $dependency @return boolean
[ "Installs", "a", "dependency" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/Installer.php#L267-L284
train
prolic/HumusPHPUnitModule
src/HumusPHPUnitModule/Runner.php
Runner.getModuleOutput
protected function getModuleOutput($module) { $console = $this->console; $head = sprintf( "%s\n%s\n%s\n", str_repeat( '-', $console->getWidth() ), 'Testing Module: ' . $module, str_repeat( '-', $console->getWidth() ) ); return $console->colorize($head, ColorInterface::BLUE); }
php
protected function getModuleOutput($module) { $console = $this->console; $head = sprintf( "%s\n%s\n%s\n", str_repeat( '-', $console->getWidth() ), 'Testing Module: ' . $module, str_repeat( '-', $console->getWidth() ) ); return $console->colorize($head, ColorInterface::BLUE); }
[ "protected", "function", "getModuleOutput", "(", "$", "module", ")", "{", "$", "console", "=", "$", "this", "->", "console", ";", "$", "head", "=", "sprintf", "(", "\"%s\\n%s\\n%s\\n\"", ",", "str_repeat", "(", "'-'", ",", "$", "console", "->", "getWidth", "(", ")", ")", ",", "'Testing Module: '", ".", "$", "module", ",", "str_repeat", "(", "'-'", ",", "$", "console", "->", "getWidth", "(", ")", ")", ")", ";", "return", "$", "console", "->", "colorize", "(", "$", "head", ",", "ColorInterface", "::", "BLUE", ")", ";", "}" ]
Get module output @param string $module @return string
[ "Get", "module", "output" ]
ee7c4a01c915a53506c5395e41ec8c26ac4ed7e9
https://github.com/prolic/HumusPHPUnitModule/blob/ee7c4a01c915a53506c5395e41ec8c26ac4ed7e9/src/HumusPHPUnitModule/Runner.php#L272-L290
train
prolic/HumusPHPUnitModule
src/HumusPHPUnitModule/Runner.php
Runner.renderTable
protected function renderTable($data, $cols, $consoleWidth) { $result = ''; $padding = 2; // If there is only 1 column, just concatenate it if ($cols == 1) { foreach ($data as $row) { $result .= $row[0] . "\n"; } return $result; } // Get the string wrapper supporting UTF-8 character encoding $strWrapper = StringUtils::getWrapper('UTF-8'); // Determine max width for each column $maxW = array(); for ($x = 1; $x <= $cols; $x += 1) { $maxW[$x] = 0; foreach ($data as $row) { $maxW[$x] = max($maxW[$x], $strWrapper->strlen($row[$x-1]) + $padding * 2); } } /* * Check if the sum of x-1 columns fit inside console window width - 10 * chars. If columns do not fit inside console window, then we'll just * concatenate them and output as is. */ $width = 0; for ($x = 1; $x < $cols; $x += 1) { $width += $maxW[$x]; } if ($width >= $consoleWidth - 10) { foreach ($data as $row) { $result .= implode(" ", $row) . "\n"; } return $result; } /* * Use Zend\Text\Table to render the table. * The last column will use the remaining space in console window * (minus 1 character to prevent double wrapping at the edge of the * screen). */ $maxW[$cols] = $consoleWidth - $width -1; $table = new Table\Table(); $table->setColumnWidths($maxW); $table->setDecorator(new Table\Decorator\Blank()); $table->setPadding(2); foreach ($data as $row) { $table->appendRow($row); } return $table->render(); }
php
protected function renderTable($data, $cols, $consoleWidth) { $result = ''; $padding = 2; // If there is only 1 column, just concatenate it if ($cols == 1) { foreach ($data as $row) { $result .= $row[0] . "\n"; } return $result; } // Get the string wrapper supporting UTF-8 character encoding $strWrapper = StringUtils::getWrapper('UTF-8'); // Determine max width for each column $maxW = array(); for ($x = 1; $x <= $cols; $x += 1) { $maxW[$x] = 0; foreach ($data as $row) { $maxW[$x] = max($maxW[$x], $strWrapper->strlen($row[$x-1]) + $padding * 2); } } /* * Check if the sum of x-1 columns fit inside console window width - 10 * chars. If columns do not fit inside console window, then we'll just * concatenate them and output as is. */ $width = 0; for ($x = 1; $x < $cols; $x += 1) { $width += $maxW[$x]; } if ($width >= $consoleWidth - 10) { foreach ($data as $row) { $result .= implode(" ", $row) . "\n"; } return $result; } /* * Use Zend\Text\Table to render the table. * The last column will use the remaining space in console window * (minus 1 character to prevent double wrapping at the edge of the * screen). */ $maxW[$cols] = $consoleWidth - $width -1; $table = new Table\Table(); $table->setColumnWidths($maxW); $table->setDecorator(new Table\Decorator\Blank()); $table->setPadding(2); foreach ($data as $row) { $table->appendRow($row); } return $table->render(); }
[ "protected", "function", "renderTable", "(", "$", "data", ",", "$", "cols", ",", "$", "consoleWidth", ")", "{", "$", "result", "=", "''", ";", "$", "padding", "=", "2", ";", "// If there is only 1 column, just concatenate it", "if", "(", "$", "cols", "==", "1", ")", "{", "foreach", "(", "$", "data", "as", "$", "row", ")", "{", "$", "result", ".=", "$", "row", "[", "0", "]", ".", "\"\\n\"", ";", "}", "return", "$", "result", ";", "}", "// Get the string wrapper supporting UTF-8 character encoding", "$", "strWrapper", "=", "StringUtils", "::", "getWrapper", "(", "'UTF-8'", ")", ";", "// Determine max width for each column", "$", "maxW", "=", "array", "(", ")", ";", "for", "(", "$", "x", "=", "1", ";", "$", "x", "<=", "$", "cols", ";", "$", "x", "+=", "1", ")", "{", "$", "maxW", "[", "$", "x", "]", "=", "0", ";", "foreach", "(", "$", "data", "as", "$", "row", ")", "{", "$", "maxW", "[", "$", "x", "]", "=", "max", "(", "$", "maxW", "[", "$", "x", "]", ",", "$", "strWrapper", "->", "strlen", "(", "$", "row", "[", "$", "x", "-", "1", "]", ")", "+", "$", "padding", "*", "2", ")", ";", "}", "}", "/*\n * Check if the sum of x-1 columns fit inside console window width - 10\n * chars. If columns do not fit inside console window, then we'll just\n * concatenate them and output as is.\n */", "$", "width", "=", "0", ";", "for", "(", "$", "x", "=", "1", ";", "$", "x", "<", "$", "cols", ";", "$", "x", "+=", "1", ")", "{", "$", "width", "+=", "$", "maxW", "[", "$", "x", "]", ";", "}", "if", "(", "$", "width", ">=", "$", "consoleWidth", "-", "10", ")", "{", "foreach", "(", "$", "data", "as", "$", "row", ")", "{", "$", "result", ".=", "implode", "(", "\" \"", ",", "$", "row", ")", ".", "\"\\n\"", ";", "}", "return", "$", "result", ";", "}", "/*\n * Use Zend\\Text\\Table to render the table.\n * The last column will use the remaining space in console window\n * (minus 1 character to prevent double wrapping at the edge of the\n * screen).\n */", "$", "maxW", "[", "$", "cols", "]", "=", "$", "consoleWidth", "-", "$", "width", "-", "1", ";", "$", "table", "=", "new", "Table", "\\", "Table", "(", ")", ";", "$", "table", "->", "setColumnWidths", "(", "$", "maxW", ")", ";", "$", "table", "->", "setDecorator", "(", "new", "Table", "\\", "Decorator", "\\", "Blank", "(", ")", ")", ";", "$", "table", "->", "setPadding", "(", "2", ")", ";", "foreach", "(", "$", "data", "as", "$", "row", ")", "{", "$", "table", "->", "appendRow", "(", "$", "row", ")", ";", "}", "return", "$", "table", "->", "render", "(", ")", ";", "}" ]
Render a text table containing the data provided, that will fit inside console window's width. @param $data @param $cols @param $consoleWidth @return string
[ "Render", "a", "text", "table", "containing", "the", "data", "provided", "that", "will", "fit", "inside", "console", "window", "s", "width", "." ]
ee7c4a01c915a53506c5395e41ec8c26ac4ed7e9
https://github.com/prolic/HumusPHPUnitModule/blob/ee7c4a01c915a53506c5395e41ec8c26ac4ed7e9/src/HumusPHPUnitModule/Runner.php#L300-L360
train
clacy-builders/graphics-php
src/Angle.php
Angle.copy
public function copy() { $angle = new Angle(); $angle->radians = $this->radians; $angle->sin = $this->sin; $angle->cos = $this->cos; $angle->tan = $this->tan; return $angle; }
php
public function copy() { $angle = new Angle(); $angle->radians = $this->radians; $angle->sin = $this->sin; $angle->cos = $this->cos; $angle->tan = $this->tan; return $angle; }
[ "public", "function", "copy", "(", ")", "{", "$", "angle", "=", "new", "Angle", "(", ")", ";", "$", "angle", "->", "radians", "=", "$", "this", "->", "radians", ";", "$", "angle", "->", "sin", "=", "$", "this", "->", "sin", ";", "$", "angle", "->", "cos", "=", "$", "this", "->", "cos", ";", "$", "angle", "->", "tan", "=", "$", "this", "->", "tan", ";", "return", "$", "angle", ";", "}" ]
Returns a copy of the current angle. @return Angle
[ "Returns", "a", "copy", "of", "the", "current", "angle", "." ]
c56556c9265ea4537efdc14ae89a8f36454812d9
https://github.com/clacy-builders/graphics-php/blob/c56556c9265ea4537efdc14ae89a8f36454812d9/src/Angle.php#L38-L46
train
clacy-builders/graphics-php
src/Angle.php
Angle.set
public function set($radians) { $this->radians = $radians; $this->sin = sin($radians); $this->cos = cos($radians); $this->tan = tan($radians); return $this; }
php
public function set($radians) { $this->radians = $radians; $this->sin = sin($radians); $this->cos = cos($radians); $this->tan = tan($radians); return $this; }
[ "public", "function", "set", "(", "$", "radians", ")", "{", "$", "this", "->", "radians", "=", "$", "radians", ";", "$", "this", "->", "sin", "=", "sin", "(", "$", "radians", ")", ";", "$", "this", "->", "cos", "=", "cos", "(", "$", "radians", ")", ";", "$", "this", "->", "tan", "=", "tan", "(", "$", "radians", ")", ";", "return", "$", "this", ";", "}" ]
Resets the angle in radians. @param float $radians
[ "Resets", "the", "angle", "in", "radians", "." ]
c56556c9265ea4537efdc14ae89a8f36454812d9
https://github.com/clacy-builders/graphics-php/blob/c56556c9265ea4537efdc14ae89a8f36454812d9/src/Angle.php#L53-L60
train
ekyna/Resource
Doctrine/ORM/Listener/EntityListener.php
EntityListener.onFlush
public function onFlush(OnFlushEventArgs $eventArgs) { $this->eventQueue->setOpened(true); $uow = $eventArgs->getEntityManager()->getUnitOfWork(); foreach ($uow->getScheduledEntityInsertions() as $entity) { if ($entity instanceof ResourceInterface) { $this->eventQueue->scheduleInsert($entity); } } foreach ($uow->getScheduledEntityUpdates() as $entity) { if ($entity instanceof ResourceInterface) { $this->eventQueue->scheduleUpdate($entity); } } // TODO move collections before update ? foreach ($uow->getScheduledCollectionDeletions() as $col) { foreach ($col as $c) { foreach ($c as $entity) { if ($entity instanceof ResourceInterface) { $this->eventQueue->scheduleDelete($entity); } } } } foreach ($uow->getScheduledCollectionUpdates() as $col) { foreach ($col as $c) { foreach ($c as $entity) { if ($entity instanceof ResourceInterface) { if ($entity->getId()) { $this->eventQueue->scheduleUpdate($entity); } else { $this->eventQueue->scheduleInsert($entity); } } } } } foreach ($uow->getScheduledEntityDeletions() as $entity) { if ($entity instanceof ResourceInterface) { $this->eventQueue->scheduleDelete($entity); } } $this->eventQueue->flush(); $this->eventQueue->setOpened(false); }
php
public function onFlush(OnFlushEventArgs $eventArgs) { $this->eventQueue->setOpened(true); $uow = $eventArgs->getEntityManager()->getUnitOfWork(); foreach ($uow->getScheduledEntityInsertions() as $entity) { if ($entity instanceof ResourceInterface) { $this->eventQueue->scheduleInsert($entity); } } foreach ($uow->getScheduledEntityUpdates() as $entity) { if ($entity instanceof ResourceInterface) { $this->eventQueue->scheduleUpdate($entity); } } // TODO move collections before update ? foreach ($uow->getScheduledCollectionDeletions() as $col) { foreach ($col as $c) { foreach ($c as $entity) { if ($entity instanceof ResourceInterface) { $this->eventQueue->scheduleDelete($entity); } } } } foreach ($uow->getScheduledCollectionUpdates() as $col) { foreach ($col as $c) { foreach ($c as $entity) { if ($entity instanceof ResourceInterface) { if ($entity->getId()) { $this->eventQueue->scheduleUpdate($entity); } else { $this->eventQueue->scheduleInsert($entity); } } } } } foreach ($uow->getScheduledEntityDeletions() as $entity) { if ($entity instanceof ResourceInterface) { $this->eventQueue->scheduleDelete($entity); } } $this->eventQueue->flush(); $this->eventQueue->setOpened(false); }
[ "public", "function", "onFlush", "(", "OnFlushEventArgs", "$", "eventArgs", ")", "{", "$", "this", "->", "eventQueue", "->", "setOpened", "(", "true", ")", ";", "$", "uow", "=", "$", "eventArgs", "->", "getEntityManager", "(", ")", "->", "getUnitOfWork", "(", ")", ";", "foreach", "(", "$", "uow", "->", "getScheduledEntityInsertions", "(", ")", "as", "$", "entity", ")", "{", "if", "(", "$", "entity", "instanceof", "ResourceInterface", ")", "{", "$", "this", "->", "eventQueue", "->", "scheduleInsert", "(", "$", "entity", ")", ";", "}", "}", "foreach", "(", "$", "uow", "->", "getScheduledEntityUpdates", "(", ")", "as", "$", "entity", ")", "{", "if", "(", "$", "entity", "instanceof", "ResourceInterface", ")", "{", "$", "this", "->", "eventQueue", "->", "scheduleUpdate", "(", "$", "entity", ")", ";", "}", "}", "// TODO move collections before update ?", "foreach", "(", "$", "uow", "->", "getScheduledCollectionDeletions", "(", ")", "as", "$", "col", ")", "{", "foreach", "(", "$", "col", "as", "$", "c", ")", "{", "foreach", "(", "$", "c", "as", "$", "entity", ")", "{", "if", "(", "$", "entity", "instanceof", "ResourceInterface", ")", "{", "$", "this", "->", "eventQueue", "->", "scheduleDelete", "(", "$", "entity", ")", ";", "}", "}", "}", "}", "foreach", "(", "$", "uow", "->", "getScheduledCollectionUpdates", "(", ")", "as", "$", "col", ")", "{", "foreach", "(", "$", "col", "as", "$", "c", ")", "{", "foreach", "(", "$", "c", "as", "$", "entity", ")", "{", "if", "(", "$", "entity", "instanceof", "ResourceInterface", ")", "{", "if", "(", "$", "entity", "->", "getId", "(", ")", ")", "{", "$", "this", "->", "eventQueue", "->", "scheduleUpdate", "(", "$", "entity", ")", ";", "}", "else", "{", "$", "this", "->", "eventQueue", "->", "scheduleInsert", "(", "$", "entity", ")", ";", "}", "}", "}", "}", "}", "foreach", "(", "$", "uow", "->", "getScheduledEntityDeletions", "(", ")", "as", "$", "entity", ")", "{", "if", "(", "$", "entity", "instanceof", "ResourceInterface", ")", "{", "$", "this", "->", "eventQueue", "->", "scheduleDelete", "(", "$", "entity", ")", ";", "}", "}", "$", "this", "->", "eventQueue", "->", "flush", "(", ")", ";", "$", "this", "->", "eventQueue", "->", "setOpened", "(", "false", ")", ";", "}" ]
On flush event handler. @param OnFlushEventArgs $eventArgs @see \Doctrine\ORM\UniOfWork::commit
[ "On", "flush", "event", "handler", "." ]
96ee3d28e02bd9513705408e3bb7f88a76e52f56
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/Doctrine/ORM/Listener/EntityListener.php#L41-L92
train
dsv-su/daisy-api-client-php
src/CourseSegmentInstance.php
CourseSegmentInstance.find
public static function find(array $query) { if (isset($query['semester']) && $query['semester'] instanceof Semester) { $query['semester'] = $query['semester']->daisyFormat(); } $csis = Client::get("courseSegment", $query); return array_map(function ($data) { return new self($data); }, $csis); }
php
public static function find(array $query) { if (isset($query['semester']) && $query['semester'] instanceof Semester) { $query['semester'] = $query['semester']->daisyFormat(); } $csis = Client::get("courseSegment", $query); return array_map(function ($data) { return new self($data); }, $csis); }
[ "public", "static", "function", "find", "(", "array", "$", "query", ")", "{", "if", "(", "isset", "(", "$", "query", "[", "'semester'", "]", ")", "&&", "$", "query", "[", "'semester'", "]", "instanceof", "Semester", ")", "{", "$", "query", "[", "'semester'", "]", "=", "$", "query", "[", "'semester'", "]", "->", "daisyFormat", "(", ")", ";", "}", "$", "csis", "=", "Client", "::", "get", "(", "\"courseSegment\"", ",", "$", "query", ")", ";", "return", "array_map", "(", "function", "(", "$", "data", ")", "{", "return", "new", "self", "(", "$", "data", ")", ";", "}", ",", "$", "csis", ")", ";", "}" ]
Retrieve an array of CourseSegmentInstance objects according to a search query. @param array $query The query. @return CourseSegmentInstance[]
[ "Retrieve", "an", "array", "of", "CourseSegmentInstance", "objects", "according", "to", "a", "search", "query", "." ]
aa6817ed45fdf3629c9683ea8a8e70a80f59b441
https://github.com/dsv-su/daisy-api-client-php/blob/aa6817ed45fdf3629c9683ea8a8e70a80f59b441/src/CourseSegmentInstance.php#L18-L26
train
congraphcms/core
Validation/Validator.php
Validator.addUniqueRuleException
protected function addUniqueRuleException(array $rules, $id) { // update all unique rules foreach ($rules as $key => &$rule) { if(is_array($rule)) { $rule = $this->addUniqueRuleException($rule, $id); continue; } // check for unique rule $unique_pos = strpos($rule, 'unique:'); // if rule has unique restriction if($unique_pos !== false) { // find if there is other rules after unique rule // if there are put cursor between these rules, // otherwise put it on the end of string $next_rule_pos = strpos($rule, '|', $unique_pos); if($next_rule_pos !== false) { $insert_pos = $next_rule_pos; } else { $insert_pos = strlen($rule); } // add exception for this id $rule = substr_replace($rule, ',' . $id . ',id', $insert_pos, 0); } } return $rules; }
php
protected function addUniqueRuleException(array $rules, $id) { // update all unique rules foreach ($rules as $key => &$rule) { if(is_array($rule)) { $rule = $this->addUniqueRuleException($rule, $id); continue; } // check for unique rule $unique_pos = strpos($rule, 'unique:'); // if rule has unique restriction if($unique_pos !== false) { // find if there is other rules after unique rule // if there are put cursor between these rules, // otherwise put it on the end of string $next_rule_pos = strpos($rule, '|', $unique_pos); if($next_rule_pos !== false) { $insert_pos = $next_rule_pos; } else { $insert_pos = strlen($rule); } // add exception for this id $rule = substr_replace($rule, ',' . $id . ',id', $insert_pos, 0); } } return $rules; }
[ "protected", "function", "addUniqueRuleException", "(", "array", "$", "rules", ",", "$", "id", ")", "{", "// update all unique rules", "foreach", "(", "$", "rules", "as", "$", "key", "=>", "&", "$", "rule", ")", "{", "if", "(", "is_array", "(", "$", "rule", ")", ")", "{", "$", "rule", "=", "$", "this", "->", "addUniqueRuleException", "(", "$", "rule", ",", "$", "id", ")", ";", "continue", ";", "}", "// check for unique rule", "$", "unique_pos", "=", "strpos", "(", "$", "rule", ",", "'unique:'", ")", ";", "// if rule has unique restriction", "if", "(", "$", "unique_pos", "!==", "false", ")", "{", "// find if there is other rules after unique rule", "// if there are put cursor between these rules, ", "// otherwise put it on the end of string", "$", "next_rule_pos", "=", "strpos", "(", "$", "rule", ",", "'|'", ",", "$", "unique_pos", ")", ";", "if", "(", "$", "next_rule_pos", "!==", "false", ")", "{", "$", "insert_pos", "=", "$", "next_rule_pos", ";", "}", "else", "{", "$", "insert_pos", "=", "strlen", "(", "$", "rule", ")", ";", "}", "// add exception for this id", "$", "rule", "=", "substr_replace", "(", "$", "rule", ",", "','", ".", "$", "id", ".", "',id'", ",", "$", "insert_pos", ",", "0", ")", ";", "}", "}", "return", "$", "rules", ";", "}" ]
Add exception to any unique rules for given object id @param array $params @param array $rules @return array
[ "Add", "exception", "to", "any", "unique", "rules", "for", "given", "object", "id" ]
d017d3951b446fb2ac93b8fcee120549bb125b17
https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Validation/Validator.php#L125-L162
train
congraphcms/core
Validation/Validator.php
Validator.newValidator
public function newValidator(array &$params, array $rules, $clean = true) { // if validating update params // unique rule should skip entry with this id // check if these are update params if(!empty($params['id'])) { // add exception for this id on all unique rules $rules = $this->addUniqueRuleException($rules, $params['id']); } if($clean) { $params = $this->cleanParams($params, $rules); } return ValidatorFacade::make($params, $rules); }
php
public function newValidator(array &$params, array $rules, $clean = true) { // if validating update params // unique rule should skip entry with this id // check if these are update params if(!empty($params['id'])) { // add exception for this id on all unique rules $rules = $this->addUniqueRuleException($rules, $params['id']); } if($clean) { $params = $this->cleanParams($params, $rules); } return ValidatorFacade::make($params, $rules); }
[ "public", "function", "newValidator", "(", "array", "&", "$", "params", ",", "array", "$", "rules", ",", "$", "clean", "=", "true", ")", "{", "// if validating update params ", "// unique rule should skip entry with this id", "// check if these are update params", "if", "(", "!", "empty", "(", "$", "params", "[", "'id'", "]", ")", ")", "{", "// add exception for this id on all unique rules", "$", "rules", "=", "$", "this", "->", "addUniqueRuleException", "(", "$", "rules", ",", "$", "params", "[", "'id'", "]", ")", ";", "}", "if", "(", "$", "clean", ")", "{", "$", "params", "=", "$", "this", "->", "cleanParams", "(", "$", "params", ",", "$", "rules", ")", ";", "}", "return", "ValidatorFacade", "::", "make", "(", "$", "params", ",", "$", "rules", ")", ";", "}" ]
Set new validator instance @param array $params @param array $rules @return Illuminate\Validation\Validator
[ "Set", "new", "validator", "instance" ]
d017d3951b446fb2ac93b8fcee120549bb125b17
https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Validation/Validator.php#L182-L201
train
horntell/php-sdk
lib/guzzle/GuzzleHttp/Post/PostBody.php
PostBody.getBody
private function getBody() { if ($this->body) { return $this->body; } elseif ($this->files || $this->forceMultipart) { return $this->body = $this->createMultipart(); } elseif ($this->fields) { return $this->body = $this->createUrlEncoded(); } else { return $this->body = Stream::factory(); } }
php
private function getBody() { if ($this->body) { return $this->body; } elseif ($this->files || $this->forceMultipart) { return $this->body = $this->createMultipart(); } elseif ($this->fields) { return $this->body = $this->createUrlEncoded(); } else { return $this->body = Stream::factory(); } }
[ "private", "function", "getBody", "(", ")", "{", "if", "(", "$", "this", "->", "body", ")", "{", "return", "$", "this", "->", "body", ";", "}", "elseif", "(", "$", "this", "->", "files", "||", "$", "this", "->", "forceMultipart", ")", "{", "return", "$", "this", "->", "body", "=", "$", "this", "->", "createMultipart", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "fields", ")", "{", "return", "$", "this", "->", "body", "=", "$", "this", "->", "createUrlEncoded", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "body", "=", "Stream", "::", "factory", "(", ")", ";", "}", "}" ]
Return a stream object that is built from the POST fields and files. If one has already been created, the previously created stream will be returned.
[ "Return", "a", "stream", "object", "that", "is", "built", "from", "the", "POST", "fields", "and", "files", "." ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Post/PostBody.php#L226-L237
train
Kris-Kuiper/sFire-Framework
src/Utils/URLParser.php
URLParser.generate
public function generate($till = self :: UNTIL_FRAGMENT) { $url = null !== $this -> getScheme() ? $this -> getScheme() . '://' : ''; if($till !== self :: UNTIL_SCHEME) { $url .= null !== $this -> getUser() ? $this -> getUser() . ':' : ''; if($till !== self :: UNTIL_USER) { $url .= null !== $this -> getUser() ? $this -> getPassword() . '@' : ''; if($till !== self :: UNTIL_PASSWORD) { $url .= $this -> getHost(); if($till !== self :: UNTIL_HOST) { $url .= null !== $this -> getPath() ? $this -> getPath() : '/'; if($till !== self :: UNTIL_PATH) { $url .= null !== $this -> getQuery() ? '?' . $this -> getQuery() : ''; if($till !== self :: UNTIL_QUERY) { $url .= '#' . $this -> getFragment(); } } } } } } return $url; }
php
public function generate($till = self :: UNTIL_FRAGMENT) { $url = null !== $this -> getScheme() ? $this -> getScheme() . '://' : ''; if($till !== self :: UNTIL_SCHEME) { $url .= null !== $this -> getUser() ? $this -> getUser() . ':' : ''; if($till !== self :: UNTIL_USER) { $url .= null !== $this -> getUser() ? $this -> getPassword() . '@' : ''; if($till !== self :: UNTIL_PASSWORD) { $url .= $this -> getHost(); if($till !== self :: UNTIL_HOST) { $url .= null !== $this -> getPath() ? $this -> getPath() : '/'; if($till !== self :: UNTIL_PATH) { $url .= null !== $this -> getQuery() ? '?' . $this -> getQuery() : ''; if($till !== self :: UNTIL_QUERY) { $url .= '#' . $this -> getFragment(); } } } } } } return $url; }
[ "public", "function", "generate", "(", "$", "till", "=", "self", "::", "UNTIL_FRAGMENT", ")", "{", "$", "url", "=", "null", "!==", "$", "this", "->", "getScheme", "(", ")", "?", "$", "this", "->", "getScheme", "(", ")", ".", "'://'", ":", "''", ";", "if", "(", "$", "till", "!==", "self", "::", "UNTIL_SCHEME", ")", "{", "$", "url", ".=", "null", "!==", "$", "this", "->", "getUser", "(", ")", "?", "$", "this", "->", "getUser", "(", ")", ".", "':'", ":", "''", ";", "if", "(", "$", "till", "!==", "self", "::", "UNTIL_USER", ")", "{", "$", "url", ".=", "null", "!==", "$", "this", "->", "getUser", "(", ")", "?", "$", "this", "->", "getPassword", "(", ")", ".", "'@'", ":", "''", ";", "if", "(", "$", "till", "!==", "self", "::", "UNTIL_PASSWORD", ")", "{", "$", "url", ".=", "$", "this", "->", "getHost", "(", ")", ";", "if", "(", "$", "till", "!==", "self", "::", "UNTIL_HOST", ")", "{", "$", "url", ".=", "null", "!==", "$", "this", "->", "getPath", "(", ")", "?", "$", "this", "->", "getPath", "(", ")", ":", "'/'", ";", "if", "(", "$", "till", "!==", "self", "::", "UNTIL_PATH", ")", "{", "$", "url", ".=", "null", "!==", "$", "this", "->", "getQuery", "(", ")", "?", "'?'", ".", "$", "this", "->", "getQuery", "(", ")", ":", "''", ";", "if", "(", "$", "till", "!==", "self", "::", "UNTIL_QUERY", ")", "{", "$", "url", ".=", "'#'", ".", "$", "this", "->", "getFragment", "(", ")", ";", "}", "}", "}", "}", "}", "}", "return", "$", "url", ";", "}" ]
Adds all the components of the url until the end or until the first parameter has been reached to generate a URL @param string $till @return string
[ "Adds", "all", "the", "components", "of", "the", "url", "until", "the", "end", "or", "until", "the", "first", "parameter", "has", "been", "reached", "to", "generate", "a", "URL" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Utils/URLParser.php#L161-L195
train
jmfeurprier/perf-database
lib/perf/Db/Connection.php
Connection.pdoPrepare
private function pdoPrepare($sql) { try { $pdoStatement = $this->getPdo()->prepare($sql); } catch (\PDOException $e) { throw new \RuntimeException("Failed to prepare SQL query: {$sql} << {$e->getMessage()}", 0, $e); } return $pdoStatement; }
php
private function pdoPrepare($sql) { try { $pdoStatement = $this->getPdo()->prepare($sql); } catch (\PDOException $e) { throw new \RuntimeException("Failed to prepare SQL query: {$sql} << {$e->getMessage()}", 0, $e); } return $pdoStatement; }
[ "private", "function", "pdoPrepare", "(", "$", "sql", ")", "{", "try", "{", "$", "pdoStatement", "=", "$", "this", "->", "getPdo", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Failed to prepare SQL query: {$sql} << {$e->getMessage()}\"", ",", "0", ",", "$", "e", ")", ";", "}", "return", "$", "pdoStatement", ";", "}" ]
Prepares a PDO statement. @param string $sql @return \PDOStatement @throws \RuntimeException
[ "Prepares", "a", "PDO", "statement", "." ]
9b39dc76be9f8a33d02aadc168fdb74d786f0ff2
https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/Connection.php#L165-L174
train
jmfeurprier/perf-database
lib/perf/Db/Connection.php
Connection.escapeAndQuote
public function escapeAndQuote($value) { if (null === $value) { $pdoType = \PDO::PARAM_NULL; } else { $pdoType = \PDO::PARAM_STR; } return $this->getPdo()->quote($value, $pdoType); }
php
public function escapeAndQuote($value) { if (null === $value) { $pdoType = \PDO::PARAM_NULL; } else { $pdoType = \PDO::PARAM_STR; } return $this->getPdo()->quote($value, $pdoType); }
[ "public", "function", "escapeAndQuote", "(", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "$", "pdoType", "=", "\\", "PDO", "::", "PARAM_NULL", ";", "}", "else", "{", "$", "pdoType", "=", "\\", "PDO", "::", "PARAM_STR", ";", "}", "return", "$", "this", "->", "getPdo", "(", ")", "->", "quote", "(", "$", "value", ",", "$", "pdoType", ")", ";", "}" ]
Escapes and quotes provided scalar value. @param string $value Value to be escaped and quoted. @return string The escaped and quoted value. @throws \RuntimeException
[ "Escapes", "and", "quotes", "provided", "scalar", "value", "." ]
9b39dc76be9f8a33d02aadc168fdb74d786f0ff2
https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/Connection.php#L222-L231
train
jmfeurprier/perf-database
lib/perf/Db/Connection.php
Connection.getPdo
public function getPdo() { if (!$this->pdo) { $this->connect(); } $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC); return $this->pdo; }
php
public function getPdo() { if (!$this->pdo) { $this->connect(); } $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC); return $this->pdo; }
[ "public", "function", "getPdo", "(", ")", "{", "if", "(", "!", "$", "this", "->", "pdo", ")", "{", "$", "this", "->", "connect", "(", ")", ";", "}", "$", "this", "->", "pdo", "->", "setAttribute", "(", "\\", "PDO", "::", "ATTR_ERRMODE", ",", "\\", "PDO", "::", "ERRMODE_EXCEPTION", ")", ";", "$", "this", "->", "pdo", "->", "setAttribute", "(", "\\", "PDO", "::", "ATTR_DEFAULT_FETCH_MODE", ",", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "return", "$", "this", "->", "pdo", ";", "}" ]
Returns the wrapped PDO object. @return \PDO @throws \RuntimeException
[ "Returns", "the", "wrapped", "PDO", "object", "." ]
9b39dc76be9f8a33d02aadc168fdb74d786f0ff2
https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/Connection.php#L283-L293
train
jmfeurprier/perf-database
lib/perf/Db/Connection.php
Connection.connect
private function connect() { $dsn = "{$this->credentials->getDriver()}:host={$this->credentials->getHost()}"; try { $pdo = new \PDO($dsn, $this->credentials->getUsername(), $this->credentials->getPassword()); } catch (\PDOException $e) { throw new \RuntimeException('Failed to connect to database.', 0, $e); } $this->pdo = $pdo; if (null !== $this->credentials->getCharset()) { $this->setCharset($this->credentials->getCharset()); } if (null !== $this->credentials->getDatabase()) { $this->selectDatabase($this->credentials->getDatabase()); } }
php
private function connect() { $dsn = "{$this->credentials->getDriver()}:host={$this->credentials->getHost()}"; try { $pdo = new \PDO($dsn, $this->credentials->getUsername(), $this->credentials->getPassword()); } catch (\PDOException $e) { throw new \RuntimeException('Failed to connect to database.', 0, $e); } $this->pdo = $pdo; if (null !== $this->credentials->getCharset()) { $this->setCharset($this->credentials->getCharset()); } if (null !== $this->credentials->getDatabase()) { $this->selectDatabase($this->credentials->getDatabase()); } }
[ "private", "function", "connect", "(", ")", "{", "$", "dsn", "=", "\"{$this->credentials->getDriver()}:host={$this->credentials->getHost()}\"", ";", "try", "{", "$", "pdo", "=", "new", "\\", "PDO", "(", "$", "dsn", ",", "$", "this", "->", "credentials", "->", "getUsername", "(", ")", ",", "$", "this", "->", "credentials", "->", "getPassword", "(", ")", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Failed to connect to database.'", ",", "0", ",", "$", "e", ")", ";", "}", "$", "this", "->", "pdo", "=", "$", "pdo", ";", "if", "(", "null", "!==", "$", "this", "->", "credentials", "->", "getCharset", "(", ")", ")", "{", "$", "this", "->", "setCharset", "(", "$", "this", "->", "credentials", "->", "getCharset", "(", ")", ")", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "credentials", "->", "getDatabase", "(", ")", ")", "{", "$", "this", "->", "selectDatabase", "(", "$", "this", "->", "credentials", "->", "getDatabase", "(", ")", ")", ";", "}", "}" ]
Attempts to connect to database. @return void @throws \RuntimeException
[ "Attempts", "to", "connect", "to", "database", "." ]
9b39dc76be9f8a33d02aadc168fdb74d786f0ff2
https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/Connection.php#L301-L320
train
Vectrex/vxPHP
src/User/SimpleSessionUserProvider.php
SimpleSessionUserProvider.unsetSessionUser
public function unsetSessionUser($sessionKey = NULL) { $sessionKey = $sessionKey ?: SessionUser::DEFAULT_KEY_NAME; $user = Session::getSessionDataBag()->get($sessionKey); if($user) { if(!$user instanceof SessionUser) { throw new UserException(sprintf("Session key '%s' doesn't hold a SessionUser instance.", $sessionKey)); } Session::getSessionDataBag()->remove($sessionKey); } return $user; }
php
public function unsetSessionUser($sessionKey = NULL) { $sessionKey = $sessionKey ?: SessionUser::DEFAULT_KEY_NAME; $user = Session::getSessionDataBag()->get($sessionKey); if($user) { if(!$user instanceof SessionUser) { throw new UserException(sprintf("Session key '%s' doesn't hold a SessionUser instance.", $sessionKey)); } Session::getSessionDataBag()->remove($sessionKey); } return $user; }
[ "public", "function", "unsetSessionUser", "(", "$", "sessionKey", "=", "NULL", ")", "{", "$", "sessionKey", "=", "$", "sessionKey", "?", ":", "SessionUser", "::", "DEFAULT_KEY_NAME", ";", "$", "user", "=", "Session", "::", "getSessionDataBag", "(", ")", "->", "get", "(", "$", "sessionKey", ")", ";", "if", "(", "$", "user", ")", "{", "if", "(", "!", "$", "user", "instanceof", "SessionUser", ")", "{", "throw", "new", "UserException", "(", "sprintf", "(", "\"Session key '%s' doesn't hold a SessionUser instance.\"", ",", "$", "sessionKey", ")", ")", ";", "}", "Session", "::", "getSessionDataBag", "(", ")", "->", "remove", "(", "$", "sessionKey", ")", ";", "}", "return", "$", "user", ";", "}" ]
remove session user from session returns the removed session user @param string $sessionKey @throws UserException @return \vxPHP\User\SessionUser|mixed
[ "remove", "session", "user", "from", "session", "returns", "the", "removed", "session", "user" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/User/SimpleSessionUserProvider.php#L59-L76
train
Vectrex/vxPHP
src/User/SimpleSessionUserProvider.php
SimpleSessionUserProvider.getSessionUser
public function getSessionUser($sessionKey = NULL) { $sessionKey = $sessionKey ?: SessionUser::DEFAULT_KEY_NAME; $sessionUser = Session::getSessionDataBag()->get($sessionKey); if($sessionUser instanceof SessionUser) { return $sessionUser; } }
php
public function getSessionUser($sessionKey = NULL) { $sessionKey = $sessionKey ?: SessionUser::DEFAULT_KEY_NAME; $sessionUser = Session::getSessionDataBag()->get($sessionKey); if($sessionUser instanceof SessionUser) { return $sessionUser; } }
[ "public", "function", "getSessionUser", "(", "$", "sessionKey", "=", "NULL", ")", "{", "$", "sessionKey", "=", "$", "sessionKey", "?", ":", "SessionUser", "::", "DEFAULT_KEY_NAME", ";", "$", "sessionUser", "=", "Session", "::", "getSessionDataBag", "(", ")", "->", "get", "(", "$", "sessionKey", ")", ";", "if", "(", "$", "sessionUser", "instanceof", "SessionUser", ")", "{", "return", "$", "sessionUser", ";", "}", "}" ]
retrieve a stored session user stored under a session key returns stored value only, when it is a SessionUser instance @param string $sessionKey @return \vxPHP\User\SessionUser
[ "retrieve", "a", "stored", "session", "user", "stored", "under", "a", "session", "key", "returns", "stored", "value", "only", "when", "it", "is", "a", "SessionUser", "instance" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/User/SimpleSessionUserProvider.php#L85-L95
train
Becklyn/Gluggi
src/Twig/TwigExtension.php
TwigExtension.elementsOverview
public function elementsOverview (array $list, array $options = []) { $options = array_replace( [ "includeNavigation" => true ], $options ); // this is a flag which tells the component that it is rendered in an elements overview $options["inElementsOverview"] = true; $elements = array_map( function ($reference) { return new Element($reference); }, $list ); return $this->application["twig"]->render("@core/elements_overview.twig", [ "elements" => $elements, "options" => $options ]); }
php
public function elementsOverview (array $list, array $options = []) { $options = array_replace( [ "includeNavigation" => true ], $options ); // this is a flag which tells the component that it is rendered in an elements overview $options["inElementsOverview"] = true; $elements = array_map( function ($reference) { return new Element($reference); }, $list ); return $this->application["twig"]->render("@core/elements_overview.twig", [ "elements" => $elements, "options" => $options ]); }
[ "public", "function", "elementsOverview", "(", "array", "$", "list", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_replace", "(", "[", "\"includeNavigation\"", "=>", "true", "]", ",", "$", "options", ")", ";", "// this is a flag which tells the component that it is rendered in an elements overview", "$", "options", "[", "\"inElementsOverview\"", "]", "=", "true", ";", "$", "elements", "=", "array_map", "(", "function", "(", "$", "reference", ")", "{", "return", "new", "Element", "(", "$", "reference", ")", ";", "}", ",", "$", "list", ")", ";", "return", "$", "this", "->", "application", "[", "\"twig\"", "]", "->", "render", "(", "\"@core/elements_overview.twig\"", ",", "[", "\"elements\"", "=>", "$", "elements", ",", "\"options\"", "=>", "$", "options", "]", ")", ";", "}" ]
Renders a overview of the given elements @param string[] $list @param array $options @return
[ "Renders", "a", "overview", "of", "the", "given", "elements" ]
837e7ee8d34f5b16a7f1ef53ca64b1ea8722b786
https://github.com/Becklyn/Gluggi/blob/837e7ee8d34f5b16a7f1ef53ca64b1ea8722b786/src/Twig/TwigExtension.php#L124-L149
train
Subscribo/config
src/Subscribo/Config/Config.php
Config.get
public function get($key, $default = null, $package = null) { if ($package) { return $this->getForPackage($package, $key, $default); } return Arr::get($this->mainConfiguration, $key, $default); }
php
public function get($key, $default = null, $package = null) { if ($package) { return $this->getForPackage($package, $key, $default); } return Arr::get($this->mainConfiguration, $key, $default); }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ",", "$", "package", "=", "null", ")", "{", "if", "(", "$", "package", ")", "{", "return", "$", "this", "->", "getForPackage", "(", "$", "package", ",", "$", "key", ",", "$", "default", ")", ";", "}", "return", "Arr", "::", "get", "(", "$", "this", "->", "mainConfiguration", ",", "$", "key", ",", "$", "default", ")", ";", "}" ]
Return value stored under provided key @param string $key Array key with dot notation @param mixed $default What to return, if key is not found @param string|null $package If provided, return value for given package @return mixed|null
[ "Return", "value", "stored", "under", "provided", "key" ]
eadd7c0059d8302619f4b428f664db36508acb7a
https://github.com/Subscribo/config/blob/eadd7c0059d8302619f4b428f664db36508acb7a/src/Subscribo/Config/Config.php#L105-L112
train
Subscribo/config
src/Subscribo/Config/Config.php
Config.getForPackage
public function getForPackage($package, $key, $default = null) { if (empty($this->packagesConfiguration[$package])) { return $default; } return Arr::get($this->packagesConfiguration[$package], $key, $default); }
php
public function getForPackage($package, $key, $default = null) { if (empty($this->packagesConfiguration[$package])) { return $default; } return Arr::get($this->packagesConfiguration[$package], $key, $default); }
[ "public", "function", "getForPackage", "(", "$", "package", ",", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "packagesConfiguration", "[", "$", "package", "]", ")", ")", "{", "return", "$", "default", ";", "}", "return", "Arr", "::", "get", "(", "$", "this", "->", "packagesConfiguration", "[", "$", "package", "]", ",", "$", "key", ",", "$", "default", ")", ";", "}" ]
Return value stored under provided key for given package @param string $package Package name @param string $key Array key with dot notation @param mixed $default What to return, if key is not found @return mixed|null
[ "Return", "value", "stored", "under", "provided", "key", "for", "given", "package" ]
eadd7c0059d8302619f4b428f664db36508acb7a
https://github.com/Subscribo/config/blob/eadd7c0059d8302619f4b428f664db36508acb7a/src/Subscribo/Config/Config.php#L122-L128
train
Subscribo/config
src/Subscribo/Config/Config.php
Config.set
public function set($key, $value, $package = null) { if ( ! is_null($package)) { $this->setForPackage($package, $key, $value); return $this; } $mainConfiguration = $this->mainConfiguration; Arr::set($mainConfiguration, $key, $value); return $this; }
php
public function set($key, $value, $package = null) { if ( ! is_null($package)) { $this->setForPackage($package, $key, $value); return $this; } $mainConfiguration = $this->mainConfiguration; Arr::set($mainConfiguration, $key, $value); return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "package", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "package", ")", ")", "{", "$", "this", "->", "setForPackage", "(", "$", "package", ",", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}", "$", "mainConfiguration", "=", "$", "this", "->", "mainConfiguration", ";", "Arr", "::", "set", "(", "$", "mainConfiguration", ",", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Store given value under given key @param string $key Array key with dot notation @param mixed $value Value to store @param string|null $package If provided, return value for given package @return $this
[ "Store", "given", "value", "under", "given", "key" ]
eadd7c0059d8302619f4b428f664db36508acb7a
https://github.com/Subscribo/config/blob/eadd7c0059d8302619f4b428f664db36508acb7a/src/Subscribo/Config/Config.php#L138-L147
train
Subscribo/config
src/Subscribo/Config/Config.php
Config.setForPackage
public function setForPackage($package, $key, $value) { $packageConfiguration = empty($this->packagesConfiguration[$package]) ? array() : $this->packagesConfiguration[$package]; Arr::set($packageConfiguration, $key, $value); $this->packagesConfiguration[$package] = $packageConfiguration; return $this; }
php
public function setForPackage($package, $key, $value) { $packageConfiguration = empty($this->packagesConfiguration[$package]) ? array() : $this->packagesConfiguration[$package]; Arr::set($packageConfiguration, $key, $value); $this->packagesConfiguration[$package] = $packageConfiguration; return $this; }
[ "public", "function", "setForPackage", "(", "$", "package", ",", "$", "key", ",", "$", "value", ")", "{", "$", "packageConfiguration", "=", "empty", "(", "$", "this", "->", "packagesConfiguration", "[", "$", "package", "]", ")", "?", "array", "(", ")", ":", "$", "this", "->", "packagesConfiguration", "[", "$", "package", "]", ";", "Arr", "::", "set", "(", "$", "packageConfiguration", ",", "$", "key", ",", "$", "value", ")", ";", "$", "this", "->", "packagesConfiguration", "[", "$", "package", "]", "=", "$", "packageConfiguration", ";", "return", "$", "this", ";", "}" ]
Store given value under given key for given package @param string $package Package name @param string $key Array key with dot notation @param mixed $value Value to store @return $this
[ "Store", "given", "value", "under", "given", "key", "for", "given", "package" ]
eadd7c0059d8302619f4b428f664db36508acb7a
https://github.com/Subscribo/config/blob/eadd7c0059d8302619f4b428f664db36508acb7a/src/Subscribo/Config/Config.php#L157-L163
train
Subscribo/config
src/Subscribo/Config/Config.php
Config.findFile
public function findFile($filePath) { if (file_exists($filePath)) { return $filePath; } foreach ($this->supportedExtensions as $extension) { $extendedFilePath = $filePath.'.'.$extension; if (file_exists($extendedFilePath)) { return $extendedFilePath; } $extendedFilePath = $filePath.'.'.strtoupper($extension); if (file_exists($extendedFilePath)) { return $extendedFilePath; } $extendedFilePath = $filePath.'.'.ucfirst($extension); if (file_exists($extendedFilePath)) { return $extendedFilePath; } } return null; }
php
public function findFile($filePath) { if (file_exists($filePath)) { return $filePath; } foreach ($this->supportedExtensions as $extension) { $extendedFilePath = $filePath.'.'.$extension; if (file_exists($extendedFilePath)) { return $extendedFilePath; } $extendedFilePath = $filePath.'.'.strtoupper($extension); if (file_exists($extendedFilePath)) { return $extendedFilePath; } $extendedFilePath = $filePath.'.'.ucfirst($extension); if (file_exists($extendedFilePath)) { return $extendedFilePath; } } return null; }
[ "public", "function", "findFile", "(", "$", "filePath", ")", "{", "if", "(", "file_exists", "(", "$", "filePath", ")", ")", "{", "return", "$", "filePath", ";", "}", "foreach", "(", "$", "this", "->", "supportedExtensions", "as", "$", "extension", ")", "{", "$", "extendedFilePath", "=", "$", "filePath", ".", "'.'", ".", "$", "extension", ";", "if", "(", "file_exists", "(", "$", "extendedFilePath", ")", ")", "{", "return", "$", "extendedFilePath", ";", "}", "$", "extendedFilePath", "=", "$", "filePath", ".", "'.'", ".", "strtoupper", "(", "$", "extension", ")", ";", "if", "(", "file_exists", "(", "$", "extendedFilePath", ")", ")", "{", "return", "$", "extendedFilePath", ";", "}", "$", "extendedFilePath", "=", "$", "filePath", ".", "'.'", ".", "ucfirst", "(", "$", "extension", ")", ";", "if", "(", "file_exists", "(", "$", "extendedFilePath", ")", ")", "{", "return", "$", "extendedFilePath", ";", "}", "}", "return", "null", ";", "}" ]
Tries to find existing file with supported extension @param $filePath @return null|string
[ "Tries", "to", "find", "existing", "file", "with", "supported", "extension" ]
eadd7c0059d8302619f4b428f664db36508acb7a
https://github.com/Subscribo/config/blob/eadd7c0059d8302619f4b428f664db36508acb7a/src/Subscribo/Config/Config.php#L277-L298
train
Subscribo/config
src/Subscribo/Config/Config.php
Config.processFile
private function processFile($filePath, $group = null, $baseDir = null) { if (is_null($baseDir)) { $baseDir = $this->baseDirectory; } if ( ! is_string($baseDir)) { $baseDir = ''; } if ($baseDir) { $baseDir = rtrim($baseDir, '/').'/'; } $content = $this->findAndParseFile($baseDir.$filePath); if (empty($content)) { return null; } if (is_null($group)) { $fileNameBase = $this->extractFileNameBase($filePath); if ('config' === strtolower($fileNameBase)) { $group = false; } else { $group = $fileNameBase; } } elseif (true === $group) { $fileNameBase = $this->extractFileNameBase($filePath); $group = $fileNameBase; } if ($group) { $result = array($group => $content); } else { $result = $content; } return $result; }
php
private function processFile($filePath, $group = null, $baseDir = null) { if (is_null($baseDir)) { $baseDir = $this->baseDirectory; } if ( ! is_string($baseDir)) { $baseDir = ''; } if ($baseDir) { $baseDir = rtrim($baseDir, '/').'/'; } $content = $this->findAndParseFile($baseDir.$filePath); if (empty($content)) { return null; } if (is_null($group)) { $fileNameBase = $this->extractFileNameBase($filePath); if ('config' === strtolower($fileNameBase)) { $group = false; } else { $group = $fileNameBase; } } elseif (true === $group) { $fileNameBase = $this->extractFileNameBase($filePath); $group = $fileNameBase; } if ($group) { $result = array($group => $content); } else { $result = $content; } return $result; }
[ "private", "function", "processFile", "(", "$", "filePath", ",", "$", "group", "=", "null", ",", "$", "baseDir", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "baseDir", ")", ")", "{", "$", "baseDir", "=", "$", "this", "->", "baseDirectory", ";", "}", "if", "(", "!", "is_string", "(", "$", "baseDir", ")", ")", "{", "$", "baseDir", "=", "''", ";", "}", "if", "(", "$", "baseDir", ")", "{", "$", "baseDir", "=", "rtrim", "(", "$", "baseDir", ",", "'/'", ")", ".", "'/'", ";", "}", "$", "content", "=", "$", "this", "->", "findAndParseFile", "(", "$", "baseDir", ".", "$", "filePath", ")", ";", "if", "(", "empty", "(", "$", "content", ")", ")", "{", "return", "null", ";", "}", "if", "(", "is_null", "(", "$", "group", ")", ")", "{", "$", "fileNameBase", "=", "$", "this", "->", "extractFileNameBase", "(", "$", "filePath", ")", ";", "if", "(", "'config'", "===", "strtolower", "(", "$", "fileNameBase", ")", ")", "{", "$", "group", "=", "false", ";", "}", "else", "{", "$", "group", "=", "$", "fileNameBase", ";", "}", "}", "elseif", "(", "true", "===", "$", "group", ")", "{", "$", "fileNameBase", "=", "$", "this", "->", "extractFileNameBase", "(", "$", "filePath", ")", ";", "$", "group", "=", "$", "fileNameBase", ";", "}", "if", "(", "$", "group", ")", "{", "$", "result", "=", "array", "(", "$", "group", "=>", "$", "content", ")", ";", "}", "else", "{", "$", "result", "=", "$", "content", ";", "}", "return", "$", "result", ";", "}" ]
Processing the file, optionally putting result under group @param string $filePath @param string|null|bool $group Whether parsed file content should be under some group. False - no group (root node) True - Group same as file base name (without extension) String - under provided string Null (default) - based on file base name - if it is 'config' then root, otherwise file name @param string|null $baseDir If provided, then prepended to $filePath, is null, then Application path is prepended @return array|null
[ "Processing", "the", "file", "optionally", "putting", "result", "under", "group" ]
eadd7c0059d8302619f4b428f664db36508acb7a
https://github.com/Subscribo/config/blob/eadd7c0059d8302619f4b428f664db36508acb7a/src/Subscribo/Config/Config.php#L353-L385
train
Subscribo/config
src/Subscribo/Config/Config.php
Config.extractFileNameBase
private function extractFileNameBase($filePath) { $directories = explode('/', $filePath); $fileName = array_pop($directories); $fileNameParts = explode('.', $fileName); if (count($fileNameParts) > 1) { $extension = array_pop($fileNameParts); } $result = implode('.', $fileNameParts); return $result; }
php
private function extractFileNameBase($filePath) { $directories = explode('/', $filePath); $fileName = array_pop($directories); $fileNameParts = explode('.', $fileName); if (count($fileNameParts) > 1) { $extension = array_pop($fileNameParts); } $result = implode('.', $fileNameParts); return $result; }
[ "private", "function", "extractFileNameBase", "(", "$", "filePath", ")", "{", "$", "directories", "=", "explode", "(", "'/'", ",", "$", "filePath", ")", ";", "$", "fileName", "=", "array_pop", "(", "$", "directories", ")", ";", "$", "fileNameParts", "=", "explode", "(", "'.'", ",", "$", "fileName", ")", ";", "if", "(", "count", "(", "$", "fileNameParts", ")", ">", "1", ")", "{", "$", "extension", "=", "array_pop", "(", "$", "fileNameParts", ")", ";", "}", "$", "result", "=", "implode", "(", "'.'", ",", "$", "fileNameParts", ")", ";", "return", "$", "result", ";", "}" ]
Return file name base, without directories and without extension @param string $filePath @return string
[ "Return", "file", "name", "base", "without", "directories", "and", "without", "extension" ]
eadd7c0059d8302619f4b428f664db36508acb7a
https://github.com/Subscribo/config/blob/eadd7c0059d8302619f4b428f664db36508acb7a/src/Subscribo/Config/Config.php#L394-L404
train
Subscribo/config
src/Subscribo/Config/Config.php
Config.assembleEnvironmentFilePath
private function assembleEnvironmentFilePath($filePath, $environment = true) { if (true === $environment) { $environment = $this->environmentInstance->getEnvironment(); } $directories = explode('/', $filePath); $fileName = array_pop($directories); $fileNameWithoutExtension = $this->extractFileNameBase($filePath); array_push($directories, $this->environmentSubdirectoryName, $environment, $fileNameWithoutExtension); $result = implode('/', $directories); return $result; }
php
private function assembleEnvironmentFilePath($filePath, $environment = true) { if (true === $environment) { $environment = $this->environmentInstance->getEnvironment(); } $directories = explode('/', $filePath); $fileName = array_pop($directories); $fileNameWithoutExtension = $this->extractFileNameBase($filePath); array_push($directories, $this->environmentSubdirectoryName, $environment, $fileNameWithoutExtension); $result = implode('/', $directories); return $result; }
[ "private", "function", "assembleEnvironmentFilePath", "(", "$", "filePath", ",", "$", "environment", "=", "true", ")", "{", "if", "(", "true", "===", "$", "environment", ")", "{", "$", "environment", "=", "$", "this", "->", "environmentInstance", "->", "getEnvironment", "(", ")", ";", "}", "$", "directories", "=", "explode", "(", "'/'", ",", "$", "filePath", ")", ";", "$", "fileName", "=", "array_pop", "(", "$", "directories", ")", ";", "$", "fileNameWithoutExtension", "=", "$", "this", "->", "extractFileNameBase", "(", "$", "filePath", ")", ";", "array_push", "(", "$", "directories", ",", "$", "this", "->", "environmentSubdirectoryName", ",", "$", "environment", ",", "$", "fileNameWithoutExtension", ")", ";", "$", "result", "=", "implode", "(", "'/'", ",", "$", "directories", ")", ";", "return", "$", "result", ";", "}" ]
Assemble path to configuration file with environment taken into account @param string $filePath Path to configuration file for all environments @param string|bool $environment Environment name, true for predefined for Config object (usually the current one) @return string
[ "Assemble", "path", "to", "configuration", "file", "with", "environment", "taken", "into", "account" ]
eadd7c0059d8302619f4b428f664db36508acb7a
https://github.com/Subscribo/config/blob/eadd7c0059d8302619f4b428f664db36508acb7a/src/Subscribo/Config/Config.php#L413-L424
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/images/Thumbnails.php
Thumbnails.getDesiredImageQuality
protected function getDesiredImageQuality($ext, $format) { switch ($ext) { case 'jpeg': case 'jpg': $qualityConfig = $this->jpegQuality; break; case 'png': $qualityConfig = $this->pngQuality; break; default: $qualityConfig = null; } if (empty($qualityConfig)) { return null; } if (is_array($qualityConfig)) { if (isset($qualityConfig[$format])) { return $qualityConfig[$format]; } if (isset($qualityConfig['default'])) { return $qualityConfig['default']; } } return $qualityConfig; }
php
protected function getDesiredImageQuality($ext, $format) { switch ($ext) { case 'jpeg': case 'jpg': $qualityConfig = $this->jpegQuality; break; case 'png': $qualityConfig = $this->pngQuality; break; default: $qualityConfig = null; } if (empty($qualityConfig)) { return null; } if (is_array($qualityConfig)) { if (isset($qualityConfig[$format])) { return $qualityConfig[$format]; } if (isset($qualityConfig['default'])) { return $qualityConfig['default']; } } return $qualityConfig; }
[ "protected", "function", "getDesiredImageQuality", "(", "$", "ext", ",", "$", "format", ")", "{", "switch", "(", "$", "ext", ")", "{", "case", "'jpeg'", ":", "case", "'jpg'", ":", "$", "qualityConfig", "=", "$", "this", "->", "jpegQuality", ";", "break", ";", "case", "'png'", ":", "$", "qualityConfig", "=", "$", "this", "->", "pngQuality", ";", "break", ";", "default", ":", "$", "qualityConfig", "=", "null", ";", "}", "if", "(", "empty", "(", "$", "qualityConfig", ")", ")", "{", "return", "null", ";", "}", "if", "(", "is_array", "(", "$", "qualityConfig", ")", ")", "{", "if", "(", "isset", "(", "$", "qualityConfig", "[", "$", "format", "]", ")", ")", "{", "return", "$", "qualityConfig", "[", "$", "format", "]", ";", "}", "if", "(", "isset", "(", "$", "qualityConfig", "[", "'default'", "]", ")", ")", "{", "return", "$", "qualityConfig", "[", "'default'", "]", ";", "}", "}", "return", "$", "qualityConfig", ";", "}" ]
Figure out image quality. @param string $format @returns mixed - string/integer quality or null if no config value is set
[ "Figure", "out", "image", "quality", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/images/Thumbnails.php#L225-L253
train
ARCANESOFT/SEO
src/Http/Controllers/Admin/RedirectsController.php
RedirectsController.index
public function index() { $this->authorize(RedirectsPolicy::PERMISSION_LIST); $redirects = Redirect::query()->paginate(50); $this->setTitle($title = trans('seo::redirects.titles.redirections-list')); $this->addBreadcrumb($title); return $this->view('admin.redirects.index', compact('redirects')); }
php
public function index() { $this->authorize(RedirectsPolicy::PERMISSION_LIST); $redirects = Redirect::query()->paginate(50); $this->setTitle($title = trans('seo::redirects.titles.redirections-list')); $this->addBreadcrumb($title); return $this->view('admin.redirects.index', compact('redirects')); }
[ "public", "function", "index", "(", ")", "{", "$", "this", "->", "authorize", "(", "RedirectsPolicy", "::", "PERMISSION_LIST", ")", ";", "$", "redirects", "=", "Redirect", "::", "query", "(", ")", "->", "paginate", "(", "50", ")", ";", "$", "this", "->", "setTitle", "(", "$", "title", "=", "trans", "(", "'seo::redirects.titles.redirections-list'", ")", ")", ";", "$", "this", "->", "addBreadcrumb", "(", "$", "title", ")", ";", "return", "$", "this", "->", "view", "(", "'admin.redirects.index'", ",", "compact", "(", "'redirects'", ")", ")", ";", "}" ]
Get the index page. @return \Illuminate\View\View
[ "Get", "the", "index", "page", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Controllers/Admin/RedirectsController.php#L44-L54
train
ARCANESOFT/SEO
src/Http/Controllers/Admin/RedirectsController.php
RedirectsController.create
public function create() { $this->authorize(RedirectsPolicy::PERMISSION_CREATE); $statuses = RedirectStatuses::all(); $this->setTitle($title = trans('seo::redirects.titles.create-redirection')); $this->addBreadcrumb($title); return $this->view('admin.redirects.create', compact('statuses')); }
php
public function create() { $this->authorize(RedirectsPolicy::PERMISSION_CREATE); $statuses = RedirectStatuses::all(); $this->setTitle($title = trans('seo::redirects.titles.create-redirection')); $this->addBreadcrumb($title); return $this->view('admin.redirects.create', compact('statuses')); }
[ "public", "function", "create", "(", ")", "{", "$", "this", "->", "authorize", "(", "RedirectsPolicy", "::", "PERMISSION_CREATE", ")", ";", "$", "statuses", "=", "RedirectStatuses", "::", "all", "(", ")", ";", "$", "this", "->", "setTitle", "(", "$", "title", "=", "trans", "(", "'seo::redirects.titles.create-redirection'", ")", ")", ";", "$", "this", "->", "addBreadcrumb", "(", "$", "title", ")", ";", "return", "$", "this", "->", "view", "(", "'admin.redirects.create'", ",", "compact", "(", "'statuses'", ")", ")", ";", "}" ]
Get the create form. @return \Illuminate\View\View
[ "Get", "the", "create", "form", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Controllers/Admin/RedirectsController.php#L61-L71
train
ARCANESOFT/SEO
src/Http/Controllers/Admin/RedirectsController.php
RedirectsController.store
public function store(CreateRedirectRequest $request) { $this->authorize(RedirectsPolicy::PERMISSION_CREATE); $redirect = Redirect::createRedirect( $request->getValidatedData() ); $this->transNotification('created', [], $redirect->toArray()); return redirect()->route('admin::seo.redirects.show', [$redirect]); }
php
public function store(CreateRedirectRequest $request) { $this->authorize(RedirectsPolicy::PERMISSION_CREATE); $redirect = Redirect::createRedirect( $request->getValidatedData() ); $this->transNotification('created', [], $redirect->toArray()); return redirect()->route('admin::seo.redirects.show', [$redirect]); }
[ "public", "function", "store", "(", "CreateRedirectRequest", "$", "request", ")", "{", "$", "this", "->", "authorize", "(", "RedirectsPolicy", "::", "PERMISSION_CREATE", ")", ";", "$", "redirect", "=", "Redirect", "::", "createRedirect", "(", "$", "request", "->", "getValidatedData", "(", ")", ")", ";", "$", "this", "->", "transNotification", "(", "'created'", ",", "[", "]", ",", "$", "redirect", "->", "toArray", "(", ")", ")", ";", "return", "redirect", "(", ")", "->", "route", "(", "'admin::seo.redirects.show'", ",", "[", "$", "redirect", "]", ")", ";", "}" ]
Store the new redirect. @param \Arcanesoft\Seo\Http\Requests\Admin\Redirects\CreateRedirectRequest $request @return \Illuminate\Http\RedirectResponse
[ "Store", "the", "new", "redirect", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Controllers/Admin/RedirectsController.php#L80-L91
train
ARCANESOFT/SEO
src/Http/Controllers/Admin/RedirectsController.php
RedirectsController.show
public function show(Redirect $redirect) { $this->authorize(RedirectsPolicy::PERMISSION_SHOW); $this->setTitle($title = trans('seo::redirects.titles.redirection-details')); $this->addBreadcrumb($title); return $this->view('admin.redirects.show', compact('redirect')); }
php
public function show(Redirect $redirect) { $this->authorize(RedirectsPolicy::PERMISSION_SHOW); $this->setTitle($title = trans('seo::redirects.titles.redirection-details')); $this->addBreadcrumb($title); return $this->view('admin.redirects.show', compact('redirect')); }
[ "public", "function", "show", "(", "Redirect", "$", "redirect", ")", "{", "$", "this", "->", "authorize", "(", "RedirectsPolicy", "::", "PERMISSION_SHOW", ")", ";", "$", "this", "->", "setTitle", "(", "$", "title", "=", "trans", "(", "'seo::redirects.titles.redirection-details'", ")", ")", ";", "$", "this", "->", "addBreadcrumb", "(", "$", "title", ")", ";", "return", "$", "this", "->", "view", "(", "'admin.redirects.show'", ",", "compact", "(", "'redirect'", ")", ")", ";", "}" ]
Show the redirect details page. @param \Arcanesoft\Seo\Models\Redirect $redirect @return \Illuminate\View\View
[ "Show", "the", "redirect", "details", "page", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Controllers/Admin/RedirectsController.php#L100-L108
train
ARCANESOFT/SEO
src/Http/Controllers/Admin/RedirectsController.php
RedirectsController.edit
public function edit(Redirect $redirect) { $this->authorize(RedirectsPolicy::PERMISSION_UPDATE); $statuses = RedirectStatuses::all(); $this->setTitle($title = trans('seo::redirects.titles.edit-redirection')); $this->addBreadcrumb($title); return $this->view('admin.redirects.edit', compact('redirect', 'statuses')); }
php
public function edit(Redirect $redirect) { $this->authorize(RedirectsPolicy::PERMISSION_UPDATE); $statuses = RedirectStatuses::all(); $this->setTitle($title = trans('seo::redirects.titles.edit-redirection')); $this->addBreadcrumb($title); return $this->view('admin.redirects.edit', compact('redirect', 'statuses')); }
[ "public", "function", "edit", "(", "Redirect", "$", "redirect", ")", "{", "$", "this", "->", "authorize", "(", "RedirectsPolicy", "::", "PERMISSION_UPDATE", ")", ";", "$", "statuses", "=", "RedirectStatuses", "::", "all", "(", ")", ";", "$", "this", "->", "setTitle", "(", "$", "title", "=", "trans", "(", "'seo::redirects.titles.edit-redirection'", ")", ")", ";", "$", "this", "->", "addBreadcrumb", "(", "$", "title", ")", ";", "return", "$", "this", "->", "view", "(", "'admin.redirects.edit'", ",", "compact", "(", "'redirect'", ",", "'statuses'", ")", ")", ";", "}" ]
Get the edit page. @param \Arcanesoft\Seo\Models\Redirect $redirect @return \Illuminate\View\View
[ "Get", "the", "edit", "page", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Controllers/Admin/RedirectsController.php#L117-L127
train
ARCANESOFT/SEO
src/Http/Controllers/Admin/RedirectsController.php
RedirectsController.update
public function update(Redirect $redirect, UpdateRedirectRequest $request) { $this->authorize(RedirectsPolicy::PERMISSION_UPDATE); $redirect->update($request->getValidatedData()); $this->transNotification('updated', [], $redirect->toArray()); return redirect()->route('admin::seo.redirects.show', [$redirect]); }
php
public function update(Redirect $redirect, UpdateRedirectRequest $request) { $this->authorize(RedirectsPolicy::PERMISSION_UPDATE); $redirect->update($request->getValidatedData()); $this->transNotification('updated', [], $redirect->toArray()); return redirect()->route('admin::seo.redirects.show', [$redirect]); }
[ "public", "function", "update", "(", "Redirect", "$", "redirect", ",", "UpdateRedirectRequest", "$", "request", ")", "{", "$", "this", "->", "authorize", "(", "RedirectsPolicy", "::", "PERMISSION_UPDATE", ")", ";", "$", "redirect", "->", "update", "(", "$", "request", "->", "getValidatedData", "(", ")", ")", ";", "$", "this", "->", "transNotification", "(", "'updated'", ",", "[", "]", ",", "$", "redirect", "->", "toArray", "(", ")", ")", ";", "return", "redirect", "(", ")", "->", "route", "(", "'admin::seo.redirects.show'", ",", "[", "$", "redirect", "]", ")", ";", "}" ]
Update the redirect. @param \Arcanesoft\Seo\Models\Redirect $redirect @param \Arcanesoft\Seo\Http\Requests\Admin\Redirects\UpdateRedirectRequest $request @return \Illuminate\Http\RedirectResponse
[ "Update", "the", "redirect", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Controllers/Admin/RedirectsController.php#L137-L146
train
ARCANESOFT/SEO
src/Http/Controllers/Admin/RedirectsController.php
RedirectsController.delete
public function delete(Redirect $redirect) { $this->authorize(RedirectsPolicy::PERMISSION_DELETE); $redirect->delete(); return $this->jsonResponseSuccess([ 'message' => $this->transNotification('deleted', [], $redirect->toArray()) ]); }
php
public function delete(Redirect $redirect) { $this->authorize(RedirectsPolicy::PERMISSION_DELETE); $redirect->delete(); return $this->jsonResponseSuccess([ 'message' => $this->transNotification('deleted', [], $redirect->toArray()) ]); }
[ "public", "function", "delete", "(", "Redirect", "$", "redirect", ")", "{", "$", "this", "->", "authorize", "(", "RedirectsPolicy", "::", "PERMISSION_DELETE", ")", ";", "$", "redirect", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "jsonResponseSuccess", "(", "[", "'message'", "=>", "$", "this", "->", "transNotification", "(", "'deleted'", ",", "[", "]", ",", "$", "redirect", "->", "toArray", "(", ")", ")", "]", ")", ";", "}" ]
Delete a redirect record. @param \Arcanesoft\Seo\Models\Redirect $redirect @return \Illuminate\Http\JsonResponse
[ "Delete", "a", "redirect", "record", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Controllers/Admin/RedirectsController.php#L155-L164
train
ARCANESOFT/SEO
src/Http/Controllers/Admin/RedirectsController.php
RedirectsController.transNotification
protected function transNotification($action, array $replace = [], array $context = []) { $title = trans("seo::redirects.messages.{$action}.title"); $message = trans("seo::redirects.messages.{$action}.message", $replace); Log::info($message, $context); $this->notifySuccess($message, $title); return $message; }
php
protected function transNotification($action, array $replace = [], array $context = []) { $title = trans("seo::redirects.messages.{$action}.title"); $message = trans("seo::redirects.messages.{$action}.message", $replace); Log::info($message, $context); $this->notifySuccess($message, $title); return $message; }
[ "protected", "function", "transNotification", "(", "$", "action", ",", "array", "$", "replace", "=", "[", "]", ",", "array", "$", "context", "=", "[", "]", ")", "{", "$", "title", "=", "trans", "(", "\"seo::redirects.messages.{$action}.title\"", ")", ";", "$", "message", "=", "trans", "(", "\"seo::redirects.messages.{$action}.message\"", ",", "$", "replace", ")", ";", "Log", "::", "info", "(", "$", "message", ",", "$", "context", ")", ";", "$", "this", "->", "notifySuccess", "(", "$", "message", ",", "$", "title", ")", ";", "return", "$", "message", ";", "}" ]
Notify with translation. @todo: Refactor this method to the core package ? @param string $action @param array $replace @param array $context @return string
[ "Notify", "with", "translation", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Http/Controllers/Admin/RedirectsController.php#L182-L191
train
Giftbit/lightrail-client-php
lib/LightrailShopperTokenFactory.php
LightrailShopperTokenFactory.generate
public static function generate($contact, $options = array()) { if (!isset(Lightrail::$apiKey) || empty(Lightrail::$apiKey)) { throw new Exceptions\BadParameterException("Lightrail.apiKey is empty or not set."); } if (!isset(Lightrail::$sharedSecret) || empty(Lightrail::$sharedSecret)) { throw new Exceptions\BadParameterException('Lightrail.sharedSecret is not set.'); } if (isset($contact['shopperId'])) { $g = array('shi' => $contact['shopperId']); } elseif (isset($contact['contactId'])) { $g = array('coi' => $contact['contactId']); } elseif (isset($contact['userSuppliedId'])) { $g = array('cui' => $contact['userSuppliedId']); } else { throw new Exceptions\BadParameterException("contact must set one of: shopperId, contactId, userSuppliedId"); } $validityInSeconds = 43200; $metadata = null; if (is_numeric($options)) { // Support for legacy code when the second param was validityInSeconds. $validityInSeconds = $options; } elseif (is_array($options)) { if (isset($options['validityInSeconds'])) { $validityInSeconds = $options['validityInSeconds']; } if (isset($options['metadata'])) { $metadata = $options['metadata']; } } if ($validityInSeconds <= 0) { throw new Exceptions\BadParameterException("validityInSeconds must be > 0"); } $payload = explode('.', Lightrail::$apiKey); $payload = json_decode(base64_decode($payload[1]), true); $iat = time(); $token = array( 'g' => array( 'gui' => $payload['g']['gui'], 'gmi' => $payload['g']['gmi'] ) + $g, 'iat' => $iat, 'exp' => $iat + $validityInSeconds, 'iss' => "MERCHANT", 'roles' => ['shopper'] ); if (!is_null($metadata)) { $token['metadata'] = $metadata; } $jwt = \Firebase\JWT\JWT::encode($token, Lightrail::$sharedSecret, 'HS256'); return $jwt; }
php
public static function generate($contact, $options = array()) { if (!isset(Lightrail::$apiKey) || empty(Lightrail::$apiKey)) { throw new Exceptions\BadParameterException("Lightrail.apiKey is empty or not set."); } if (!isset(Lightrail::$sharedSecret) || empty(Lightrail::$sharedSecret)) { throw new Exceptions\BadParameterException('Lightrail.sharedSecret is not set.'); } if (isset($contact['shopperId'])) { $g = array('shi' => $contact['shopperId']); } elseif (isset($contact['contactId'])) { $g = array('coi' => $contact['contactId']); } elseif (isset($contact['userSuppliedId'])) { $g = array('cui' => $contact['userSuppliedId']); } else { throw new Exceptions\BadParameterException("contact must set one of: shopperId, contactId, userSuppliedId"); } $validityInSeconds = 43200; $metadata = null; if (is_numeric($options)) { // Support for legacy code when the second param was validityInSeconds. $validityInSeconds = $options; } elseif (is_array($options)) { if (isset($options['validityInSeconds'])) { $validityInSeconds = $options['validityInSeconds']; } if (isset($options['metadata'])) { $metadata = $options['metadata']; } } if ($validityInSeconds <= 0) { throw new Exceptions\BadParameterException("validityInSeconds must be > 0"); } $payload = explode('.', Lightrail::$apiKey); $payload = json_decode(base64_decode($payload[1]), true); $iat = time(); $token = array( 'g' => array( 'gui' => $payload['g']['gui'], 'gmi' => $payload['g']['gmi'] ) + $g, 'iat' => $iat, 'exp' => $iat + $validityInSeconds, 'iss' => "MERCHANT", 'roles' => ['shopper'] ); if (!is_null($metadata)) { $token['metadata'] = $metadata; } $jwt = \Firebase\JWT\JWT::encode($token, Lightrail::$sharedSecret, 'HS256'); return $jwt; }
[ "public", "static", "function", "generate", "(", "$", "contact", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "Lightrail", "::", "$", "apiKey", ")", "||", "empty", "(", "Lightrail", "::", "$", "apiKey", ")", ")", "{", "throw", "new", "Exceptions", "\\", "BadParameterException", "(", "\"Lightrail.apiKey is empty or not set.\"", ")", ";", "}", "if", "(", "!", "isset", "(", "Lightrail", "::", "$", "sharedSecret", ")", "||", "empty", "(", "Lightrail", "::", "$", "sharedSecret", ")", ")", "{", "throw", "new", "Exceptions", "\\", "BadParameterException", "(", "'Lightrail.sharedSecret is not set.'", ")", ";", "}", "if", "(", "isset", "(", "$", "contact", "[", "'shopperId'", "]", ")", ")", "{", "$", "g", "=", "array", "(", "'shi'", "=>", "$", "contact", "[", "'shopperId'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "contact", "[", "'contactId'", "]", ")", ")", "{", "$", "g", "=", "array", "(", "'coi'", "=>", "$", "contact", "[", "'contactId'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "contact", "[", "'userSuppliedId'", "]", ")", ")", "{", "$", "g", "=", "array", "(", "'cui'", "=>", "$", "contact", "[", "'userSuppliedId'", "]", ")", ";", "}", "else", "{", "throw", "new", "Exceptions", "\\", "BadParameterException", "(", "\"contact must set one of: shopperId, contactId, userSuppliedId\"", ")", ";", "}", "$", "validityInSeconds", "=", "43200", ";", "$", "metadata", "=", "null", ";", "if", "(", "is_numeric", "(", "$", "options", ")", ")", "{", "// Support for legacy code when the second param was validityInSeconds.", "$", "validityInSeconds", "=", "$", "options", ";", "}", "elseif", "(", "is_array", "(", "$", "options", ")", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'validityInSeconds'", "]", ")", ")", "{", "$", "validityInSeconds", "=", "$", "options", "[", "'validityInSeconds'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'metadata'", "]", ")", ")", "{", "$", "metadata", "=", "$", "options", "[", "'metadata'", "]", ";", "}", "}", "if", "(", "$", "validityInSeconds", "<=", "0", ")", "{", "throw", "new", "Exceptions", "\\", "BadParameterException", "(", "\"validityInSeconds must be > 0\"", ")", ";", "}", "$", "payload", "=", "explode", "(", "'.'", ",", "Lightrail", "::", "$", "apiKey", ")", ";", "$", "payload", "=", "json_decode", "(", "base64_decode", "(", "$", "payload", "[", "1", "]", ")", ",", "true", ")", ";", "$", "iat", "=", "time", "(", ")", ";", "$", "token", "=", "array", "(", "'g'", "=>", "array", "(", "'gui'", "=>", "$", "payload", "[", "'g'", "]", "[", "'gui'", "]", ",", "'gmi'", "=>", "$", "payload", "[", "'g'", "]", "[", "'gmi'", "]", ")", "+", "$", "g", ",", "'iat'", "=>", "$", "iat", ",", "'exp'", "=>", "$", "iat", "+", "$", "validityInSeconds", ",", "'iss'", "=>", "\"MERCHANT\"", ",", "'roles'", "=>", "[", "'shopper'", "]", ")", ";", "if", "(", "!", "is_null", "(", "$", "metadata", ")", ")", "{", "$", "token", "[", "'metadata'", "]", "=", "$", "metadata", ";", "}", "$", "jwt", "=", "\\", "Firebase", "\\", "JWT", "\\", "JWT", "::", "encode", "(", "$", "token", ",", "Lightrail", "::", "$", "sharedSecret", ",", "'HS256'", ")", ";", "return", "$", "jwt", ";", "}" ]
Generate a shopper token that can be used to make Lightrail calls restricted to that particular shopper. The shopper can be defined by the contactId, userSuppliedId, or shopperId. eg: `generateShopperToken(array("shopperId" => "user-12345"));` eg: `generateShopperToken(array("shopperId" => "user-12345"), array("validityInSeconds" => 43200, "metadata" => array("foo" => "bar")));` @param $contact array an associative array that defines one of: contactId, userSuppliedId or shopperId @param $options array an associative array that may define: `validityInSeconds` the number of seconds the shopper token will be valid for, `metadata` additional data that can be signed in the shopper token. @return string the shopper token
[ "Generate", "a", "shopper", "token", "that", "can", "be", "used", "to", "make", "Lightrail", "calls", "restricted", "to", "that", "particular", "shopper", ".", "The", "shopper", "can", "be", "defined", "by", "the", "contactId", "userSuppliedId", "or", "shopperId", "." ]
7302aca93e52a6264f7b0e3941428e28804fd7f0
https://github.com/Giftbit/lightrail-client-php/blob/7302aca93e52a6264f7b0e3941428e28804fd7f0/lib/LightrailShopperTokenFactory.php#L20-L77
train
tonis-io-legacy/web
src/AppFactory.php
AppFactory.prepareServices
private function prepareServices() { $services = new Container; $services->set(Router::class, new Router, true); $services->set(Dispatcher::class, new Dispatcher, true); $services->set(PackageManager::class, new PackageManager, true); $services->set(EventManager::class, new EventManager, true); $services->set(ViewManager::class, ViewManagerFactory::class); return $services; }
php
private function prepareServices() { $services = new Container; $services->set(Router::class, new Router, true); $services->set(Dispatcher::class, new Dispatcher, true); $services->set(PackageManager::class, new PackageManager, true); $services->set(EventManager::class, new EventManager, true); $services->set(ViewManager::class, ViewManagerFactory::class); return $services; }
[ "private", "function", "prepareServices", "(", ")", "{", "$", "services", "=", "new", "Container", ";", "$", "services", "->", "set", "(", "Router", "::", "class", ",", "new", "Router", ",", "true", ")", ";", "$", "services", "->", "set", "(", "Dispatcher", "::", "class", ",", "new", "Dispatcher", ",", "true", ")", ";", "$", "services", "->", "set", "(", "PackageManager", "::", "class", ",", "new", "PackageManager", ",", "true", ")", ";", "$", "services", "->", "set", "(", "EventManager", "::", "class", ",", "new", "EventManager", ",", "true", ")", ";", "$", "services", "->", "set", "(", "ViewManager", "::", "class", ",", "ViewManagerFactory", "::", "class", ")", ";", "return", "$", "services", ";", "}" ]
Prepares services required by Tonis. We'll put them in the DIC so that they're available to other factories if necessary. @return Container
[ "Prepares", "services", "required", "by", "Tonis", ".", "We", "ll", "put", "them", "in", "the", "DIC", "so", "that", "they", "re", "available", "to", "other", "factories", "if", "necessary", "." ]
730bec77457afeb91ce4ca9fbbf85c469c2fb8bc
https://github.com/tonis-io-legacy/web/blob/730bec77457afeb91ce4ca9fbbf85c469c2fb8bc/src/AppFactory.php#L91-L102
train
libreworks/microformats
src/AddressFormatter.php
AddressFormatter.format
public function format(Address $address) { $fields = [ 'p-street-address' => $address->getStreet(), 'p-extended-address' => $address->getExtended(), 'p-post-office-box' => $address->getPobox(), 'p-locality' => $address->getLocality(), 'p-region' => $address->getRegion(), 'p-postal-code' => $address->getPostal(), 'p-country' => $address->getCountry() ]; $tags = []; foreach ($fields as $k => $v) { if (strlen($v) > 0) { $tags[] = '<span class="' . $k . '">' . htmlspecialchars($v) . '</span>'; } } $geo = $address->getGeo(); if ($geo !== null) { $tags[] = '<span class="p-geo">' . $this->geoFormatter->format($geo) . '</span>'; } return '<span class="h-adr">' . implode(' ', $tags) . '</span>'; }
php
public function format(Address $address) { $fields = [ 'p-street-address' => $address->getStreet(), 'p-extended-address' => $address->getExtended(), 'p-post-office-box' => $address->getPobox(), 'p-locality' => $address->getLocality(), 'p-region' => $address->getRegion(), 'p-postal-code' => $address->getPostal(), 'p-country' => $address->getCountry() ]; $tags = []; foreach ($fields as $k => $v) { if (strlen($v) > 0) { $tags[] = '<span class="' . $k . '">' . htmlspecialchars($v) . '</span>'; } } $geo = $address->getGeo(); if ($geo !== null) { $tags[] = '<span class="p-geo">' . $this->geoFormatter->format($geo) . '</span>'; } return '<span class="h-adr">' . implode(' ', $tags) . '</span>'; }
[ "public", "function", "format", "(", "Address", "$", "address", ")", "{", "$", "fields", "=", "[", "'p-street-address'", "=>", "$", "address", "->", "getStreet", "(", ")", ",", "'p-extended-address'", "=>", "$", "address", "->", "getExtended", "(", ")", ",", "'p-post-office-box'", "=>", "$", "address", "->", "getPobox", "(", ")", ",", "'p-locality'", "=>", "$", "address", "->", "getLocality", "(", ")", ",", "'p-region'", "=>", "$", "address", "->", "getRegion", "(", ")", ",", "'p-postal-code'", "=>", "$", "address", "->", "getPostal", "(", ")", ",", "'p-country'", "=>", "$", "address", "->", "getCountry", "(", ")", "]", ";", "$", "tags", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "strlen", "(", "$", "v", ")", ">", "0", ")", "{", "$", "tags", "[", "]", "=", "'<span class=\"'", ".", "$", "k", ".", "'\">'", ".", "htmlspecialchars", "(", "$", "v", ")", ".", "'</span>'", ";", "}", "}", "$", "geo", "=", "$", "address", "->", "getGeo", "(", ")", ";", "if", "(", "$", "geo", "!==", "null", ")", "{", "$", "tags", "[", "]", "=", "'<span class=\"p-geo\">'", ".", "$", "this", "->", "geoFormatter", "->", "format", "(", "$", "geo", ")", ".", "'</span>'", ";", "}", "return", "'<span class=\"h-adr\">'", ".", "implode", "(", "' '", ",", "$", "tags", ")", ".", "'</span>'", ";", "}" ]
Formats an address. @param \Libreworks\Microformats\Address $address @return string The HTML markup
[ "Formats", "an", "address", "." ]
f208650cb83e8711f5f35878cfa285b7cb505d3d
https://github.com/libreworks/microformats/blob/f208650cb83e8711f5f35878cfa285b7cb505d3d/src/AddressFormatter.php#L51-L73
train
KDF5000/EasyThink
src/ThinkPHP/Library/Vendor/phpRPC/phprpc_date.php
PHPRPC_Date.addMilliseconds
function addMilliseconds($milliseconds) { if (!is_int($milliseconds)) return false; if ($milliseconds == 0) return true; $millisecond = $this->millisecond + $milliseconds; $milliseconds = $millisecond % 1000; if ($milliseconds < 0) { $milliseconds += 1000; } $seconds = (int)(($millisecond - $milliseconds) / 1000); $millisecond = (int)$milliseconds; if ($this->addSeconds($seconds)) { $this->millisecond = (int)$milliseconds; return true; } else { return false; } }
php
function addMilliseconds($milliseconds) { if (!is_int($milliseconds)) return false; if ($milliseconds == 0) return true; $millisecond = $this->millisecond + $milliseconds; $milliseconds = $millisecond % 1000; if ($milliseconds < 0) { $milliseconds += 1000; } $seconds = (int)(($millisecond - $milliseconds) / 1000); $millisecond = (int)$milliseconds; if ($this->addSeconds($seconds)) { $this->millisecond = (int)$milliseconds; return true; } else { return false; } }
[ "function", "addMilliseconds", "(", "$", "milliseconds", ")", "{", "if", "(", "!", "is_int", "(", "$", "milliseconds", ")", ")", "return", "false", ";", "if", "(", "$", "milliseconds", "==", "0", ")", "return", "true", ";", "$", "millisecond", "=", "$", "this", "->", "millisecond", "+", "$", "milliseconds", ";", "$", "milliseconds", "=", "$", "millisecond", "%", "1000", ";", "if", "(", "$", "milliseconds", "<", "0", ")", "{", "$", "milliseconds", "+=", "1000", ";", "}", "$", "seconds", "=", "(", "int", ")", "(", "(", "$", "millisecond", "-", "$", "milliseconds", ")", "/", "1000", ")", ";", "$", "millisecond", "=", "(", "int", ")", "$", "milliseconds", ";", "if", "(", "$", "this", "->", "addSeconds", "(", "$", "seconds", ")", ")", "{", "$", "this", "->", "millisecond", "=", "(", "int", ")", "$", "milliseconds", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
public instance methods
[ "public", "instance", "methods" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Vendor/phpRPC/phprpc_date.php#L74-L91
train
KDF5000/EasyThink
src/ThinkPHP/Library/Vendor/phpRPC/phprpc_date.php
PHPRPC_Date.dayOfWeek
function dayOfWeek() { $num = func_num_args(); if ($num == 3) { $args = func_get_args(); $y = $args[0]; $m = $args[1]; $d = $args[2]; } else { $y = $this->year; $m = $this->month; $d = $this->day; } $d += $m < 3 ? $y-- : $y - 2; return ((int)(23 * $m / 9) + $d + 4 + (int)($y / 4) - (int)($y / 100) + (int)($y / 400)) % 7; }
php
function dayOfWeek() { $num = func_num_args(); if ($num == 3) { $args = func_get_args(); $y = $args[0]; $m = $args[1]; $d = $args[2]; } else { $y = $this->year; $m = $this->month; $d = $this->day; } $d += $m < 3 ? $y-- : $y - 2; return ((int)(23 * $m / 9) + $d + 4 + (int)($y / 4) - (int)($y / 100) + (int)($y / 400)) % 7; }
[ "function", "dayOfWeek", "(", ")", "{", "$", "num", "=", "func_num_args", "(", ")", ";", "if", "(", "$", "num", "==", "3", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "y", "=", "$", "args", "[", "0", "]", ";", "$", "m", "=", "$", "args", "[", "1", "]", ";", "$", "d", "=", "$", "args", "[", "2", "]", ";", "}", "else", "{", "$", "y", "=", "$", "this", "->", "year", ";", "$", "m", "=", "$", "this", "->", "month", ";", "$", "d", "=", "$", "this", "->", "day", ";", "}", "$", "d", "+=", "$", "m", "<", "3", "?", "$", "y", "--", ":", "$", "y", "-", "2", ";", "return", "(", "(", "int", ")", "(", "23", "*", "$", "m", "/", "9", ")", "+", "$", "d", "+", "4", "+", "(", "int", ")", "(", "$", "y", "/", "4", ")", "-", "(", "int", ")", "(", "$", "y", "/", "100", ")", "+", "(", "int", ")", "(", "$", "y", "/", "400", ")", ")", "%", "7", ";", "}" ]
public instance & static methods
[ "public", "instance", "&", "static", "methods" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Vendor/phpRPC/phprpc_date.php#L382-L397
train
koolkode/context
src/CompiledContainer.php
CompiledContainer.callFactoryMethod
protected function callFactoryMethod($typeName, $factory, $methodName, array $resolvers = NULL, InjectionPointInterface $point = NULL) { $ref = new \ReflectionMethod(get_class($factory), $methodName); foreach($ref->getParameters() as $param) { if(Configuration::class === $this->getParamType($param)) { $resolvers[$param->name] = $this->config->getConfig(str_replace('\\', '.', $typeName)); } } $args = $this->populateArguments($ref, 0, $resolvers, $point); switch(count($args)) { case 0: return $factory->$methodName(); case 1: return $factory->$methodName($args[0]); case 2: return $factory->$methodName($args[0], $args[1]); case 3: return $factory->$methodName($args[0], $args[1], $args[2]); case 4: return $factory->$methodName($args[0], $args[1], $args[2], $args[3]); } return call_user_func_array([$factory, $methodName], $args); }
php
protected function callFactoryMethod($typeName, $factory, $methodName, array $resolvers = NULL, InjectionPointInterface $point = NULL) { $ref = new \ReflectionMethod(get_class($factory), $methodName); foreach($ref->getParameters() as $param) { if(Configuration::class === $this->getParamType($param)) { $resolvers[$param->name] = $this->config->getConfig(str_replace('\\', '.', $typeName)); } } $args = $this->populateArguments($ref, 0, $resolvers, $point); switch(count($args)) { case 0: return $factory->$methodName(); case 1: return $factory->$methodName($args[0]); case 2: return $factory->$methodName($args[0], $args[1]); case 3: return $factory->$methodName($args[0], $args[1], $args[2]); case 4: return $factory->$methodName($args[0], $args[1], $args[2], $args[3]); } return call_user_func_array([$factory, $methodName], $args); }
[ "protected", "function", "callFactoryMethod", "(", "$", "typeName", ",", "$", "factory", ",", "$", "methodName", ",", "array", "$", "resolvers", "=", "NULL", ",", "InjectionPointInterface", "$", "point", "=", "NULL", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionMethod", "(", "get_class", "(", "$", "factory", ")", ",", "$", "methodName", ")", ";", "foreach", "(", "$", "ref", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "if", "(", "Configuration", "::", "class", "===", "$", "this", "->", "getParamType", "(", "$", "param", ")", ")", "{", "$", "resolvers", "[", "$", "param", "->", "name", "]", "=", "$", "this", "->", "config", "->", "getConfig", "(", "str_replace", "(", "'\\\\'", ",", "'.'", ",", "$", "typeName", ")", ")", ";", "}", "}", "$", "args", "=", "$", "this", "->", "populateArguments", "(", "$", "ref", ",", "0", ",", "$", "resolvers", ",", "$", "point", ")", ";", "switch", "(", "count", "(", "$", "args", ")", ")", "{", "case", "0", ":", "return", "$", "factory", "->", "$", "methodName", "(", ")", ";", "case", "1", ":", "return", "$", "factory", "->", "$", "methodName", "(", "$", "args", "[", "0", "]", ")", ";", "case", "2", ":", "return", "$", "factory", "->", "$", "methodName", "(", "$", "args", "[", "0", "]", ",", "$", "args", "[", "1", "]", ")", ";", "case", "3", ":", "return", "$", "factory", "->", "$", "methodName", "(", "$", "args", "[", "0", "]", ",", "$", "args", "[", "1", "]", ",", "$", "args", "[", "2", "]", ")", ";", "case", "4", ":", "return", "$", "factory", "->", "$", "methodName", "(", "$", "args", "[", "0", "]", ",", "$", "args", "[", "1", "]", ",", "$", "args", "[", "2", "]", ",", "$", "args", "[", "3", "]", ")", ";", "}", "return", "call_user_func_array", "(", "[", "$", "factory", ",", "$", "methodName", "]", ",", "$", "args", ")", ";", "}" ]
Create an object instance by calling a factory method on an object. @param string $typeName The bound type name of the target type. @param object $factory The factory instance to be used. @param string $methodName The name of the factory method to be called. @param array<string, mixed> $resolvers Param resolvers applied to factory method arguments. @param InjectionPointInterface $point Injection point that receives the generated object. @return object The created object instance.
[ "Create", "an", "object", "instance", "by", "calling", "a", "factory", "method", "on", "an", "object", "." ]
f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36
https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/CompiledContainer.php#L194-L223
train
koolkode/context
src/CompiledContainer.php
CompiledContainer.reviveMarker
protected function reviveMarker($typeName, array $params = NULL) { static $refs = []; if(empty($refs[$typeName])) { $refs[$typeName] = new \ReflectionClass($typeName); } $marker = $refs[$typeName]->newInstanceWithoutConstructor(); foreach((array)$params as $k => $v) { $marker->$k = $v; } return $marker; }
php
protected function reviveMarker($typeName, array $params = NULL) { static $refs = []; if(empty($refs[$typeName])) { $refs[$typeName] = new \ReflectionClass($typeName); } $marker = $refs[$typeName]->newInstanceWithoutConstructor(); foreach((array)$params as $k => $v) { $marker->$k = $v; } return $marker; }
[ "protected", "function", "reviveMarker", "(", "$", "typeName", ",", "array", "$", "params", "=", "NULL", ")", "{", "static", "$", "refs", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "refs", "[", "$", "typeName", "]", ")", ")", "{", "$", "refs", "[", "$", "typeName", "]", "=", "new", "\\", "ReflectionClass", "(", "$", "typeName", ")", ";", "}", "$", "marker", "=", "$", "refs", "[", "$", "typeName", "]", "->", "newInstanceWithoutConstructor", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "params", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "marker", "->", "$", "k", "=", "$", "v", ";", "}", "return", "$", "marker", ";", "}" ]
Revives a marker instance by creating it without constructor invocation. @param string $typeName @param array<string, mixed> $params @return Marker
[ "Revives", "a", "marker", "instance", "by", "creating", "it", "without", "constructor", "invocation", "." ]
f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36
https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/CompiledContainer.php#L232-L249
train
kambalabs/KmbDomain
src/KmbDomain/Service/GroupParameterFactory.php
GroupParameterFactory.createFromImportedData
public function createFromImportedData($name, $data) { if (!is_array($data)) { return new GroupParameter($name, [$data]); } elseif (!$this->isAssociativeArray($data)) { return new GroupParameter($name, $data); } $parameter = new GroupParameter($name); foreach ($data as $childName => $childData) { $parameter->addChild($this->createFromImportedData($childName, $childData)); } return $parameter; }
php
public function createFromImportedData($name, $data) { if (!is_array($data)) { return new GroupParameter($name, [$data]); } elseif (!$this->isAssociativeArray($data)) { return new GroupParameter($name, $data); } $parameter = new GroupParameter($name); foreach ($data as $childName => $childData) { $parameter->addChild($this->createFromImportedData($childName, $childData)); } return $parameter; }
[ "public", "function", "createFromImportedData", "(", "$", "name", ",", "$", "data", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "new", "GroupParameter", "(", "$", "name", ",", "[", "$", "data", "]", ")", ";", "}", "elseif", "(", "!", "$", "this", "->", "isAssociativeArray", "(", "$", "data", ")", ")", "{", "return", "new", "GroupParameter", "(", "$", "name", ",", "$", "data", ")", ";", "}", "$", "parameter", "=", "new", "GroupParameter", "(", "$", "name", ")", ";", "foreach", "(", "$", "data", "as", "$", "childName", "=>", "$", "childData", ")", "{", "$", "parameter", "->", "addChild", "(", "$", "this", "->", "createFromImportedData", "(", "$", "childName", ",", "$", "childData", ")", ")", ";", "}", "return", "$", "parameter", ";", "}" ]
Create GroupParameter instance from imported data. @param string $name @param array $data @return GroupParameter
[ "Create", "GroupParameter", "instance", "from", "imported", "data", "." ]
b1631bd936c6c6798076b51dfaebd706e1bdc8c2
https://github.com/kambalabs/KmbDomain/blob/b1631bd936c6c6798076b51dfaebd706e1bdc8c2/src/KmbDomain/Service/GroupParameterFactory.php#L35-L47
train
kambalabs/KmbDomain
src/KmbDomain/Service/GroupParameterFactory.php
GroupParameterFactory.createRequiredFromTemplates
public function createRequiredFromTemplates($templates) { $parameters = []; if (!empty($templates)) { foreach ($templates as $template) { if ($template->required) { $parameters[] = $this->createFromTemplate($template); } } } return $parameters; }
php
public function createRequiredFromTemplates($templates) { $parameters = []; if (!empty($templates)) { foreach ($templates as $template) { if ($template->required) { $parameters[] = $this->createFromTemplate($template); } } } return $parameters; }
[ "public", "function", "createRequiredFromTemplates", "(", "$", "templates", ")", "{", "$", "parameters", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "templates", ")", ")", "{", "foreach", "(", "$", "templates", "as", "$", "template", ")", "{", "if", "(", "$", "template", "->", "required", ")", "{", "$", "parameters", "[", "]", "=", "$", "this", "->", "createFromTemplate", "(", "$", "template", ")", ";", "}", "}", "}", "return", "$", "parameters", ";", "}" ]
Create GroupParameter instances from all given required templates. @param \stdClass[] $templates @return GroupParameter[]
[ "Create", "GroupParameter", "instances", "from", "all", "given", "required", "templates", "." ]
b1631bd936c6c6798076b51dfaebd706e1bdc8c2
https://github.com/kambalabs/KmbDomain/blob/b1631bd936c6c6798076b51dfaebd706e1bdc8c2/src/KmbDomain/Service/GroupParameterFactory.php#L60-L71
train
kambalabs/KmbDomain
src/KmbDomain/Service/GroupParameterFactory.php
GroupParameterFactory.createFromTemplate
public function createFromTemplate($template) { $parameter = new GroupParameter(); $parameter->setName($template->name); $parameter->setTemplate($template); if ($template->type == GroupParameterType::HASHTABLE && isset($template->entries)) { $parameter->setChildren($this->createRequiredFromTemplates($template->entries)); } elseif ($template->type != GroupParameterType::HASHTABLE && $template->type != GroupParameterType::EDITABLE_HASHTABLE) { if ($template->type == GroupParameterType::BOOLEAN) { $value = true; } else { $value = empty($template->values) ? '' : $template->values[0]; } $parameter->addValue($value); } return $parameter; }
php
public function createFromTemplate($template) { $parameter = new GroupParameter(); $parameter->setName($template->name); $parameter->setTemplate($template); if ($template->type == GroupParameterType::HASHTABLE && isset($template->entries)) { $parameter->setChildren($this->createRequiredFromTemplates($template->entries)); } elseif ($template->type != GroupParameterType::HASHTABLE && $template->type != GroupParameterType::EDITABLE_HASHTABLE) { if ($template->type == GroupParameterType::BOOLEAN) { $value = true; } else { $value = empty($template->values) ? '' : $template->values[0]; } $parameter->addValue($value); } return $parameter; }
[ "public", "function", "createFromTemplate", "(", "$", "template", ")", "{", "$", "parameter", "=", "new", "GroupParameter", "(", ")", ";", "$", "parameter", "->", "setName", "(", "$", "template", "->", "name", ")", ";", "$", "parameter", "->", "setTemplate", "(", "$", "template", ")", ";", "if", "(", "$", "template", "->", "type", "==", "GroupParameterType", "::", "HASHTABLE", "&&", "isset", "(", "$", "template", "->", "entries", ")", ")", "{", "$", "parameter", "->", "setChildren", "(", "$", "this", "->", "createRequiredFromTemplates", "(", "$", "template", "->", "entries", ")", ")", ";", "}", "elseif", "(", "$", "template", "->", "type", "!=", "GroupParameterType", "::", "HASHTABLE", "&&", "$", "template", "->", "type", "!=", "GroupParameterType", "::", "EDITABLE_HASHTABLE", ")", "{", "if", "(", "$", "template", "->", "type", "==", "GroupParameterType", "::", "BOOLEAN", ")", "{", "$", "value", "=", "true", ";", "}", "else", "{", "$", "value", "=", "empty", "(", "$", "template", "->", "values", ")", "?", "''", ":", "$", "template", "->", "values", "[", "0", "]", ";", "}", "$", "parameter", "->", "addValue", "(", "$", "value", ")", ";", "}", "return", "$", "parameter", ";", "}" ]
Create GroupParameter instance from given template. @param \stdClass $template @return GroupParameter
[ "Create", "GroupParameter", "instance", "from", "given", "template", "." ]
b1631bd936c6c6798076b51dfaebd706e1bdc8c2
https://github.com/kambalabs/KmbDomain/blob/b1631bd936c6c6798076b51dfaebd706e1bdc8c2/src/KmbDomain/Service/GroupParameterFactory.php#L79-L95
train
phossa/phossa-config
src/Phossa/Config/Loader/Loader.php
Loader.setRootDir
protected function setRootDir(/*# string */ $rootDir) { // validate root directory if (!is_string($rootDir) || !is_dir($rootDir) || !is_readable($rootDir)) { throw new InvalidArgumentException( Message::get(Message::CONFIG_DIR_INVALID, $rootDir), Message::CONFIG_DIR_INVALID ); } $this->root_dir = rtrim($rootDir, '/\\'); return $this; }
php
protected function setRootDir(/*# string */ $rootDir) { // validate root directory if (!is_string($rootDir) || !is_dir($rootDir) || !is_readable($rootDir)) { throw new InvalidArgumentException( Message::get(Message::CONFIG_DIR_INVALID, $rootDir), Message::CONFIG_DIR_INVALID ); } $this->root_dir = rtrim($rootDir, '/\\'); return $this; }
[ "protected", "function", "setRootDir", "(", "/*# string */", "$", "rootDir", ")", "{", "// validate root directory", "if", "(", "!", "is_string", "(", "$", "rootDir", ")", "||", "!", "is_dir", "(", "$", "rootDir", ")", "||", "!", "is_readable", "(", "$", "rootDir", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "Message", "::", "get", "(", "Message", "::", "CONFIG_DIR_INVALID", ",", "$", "rootDir", ")", ",", "Message", "::", "CONFIG_DIR_INVALID", ")", ";", "}", "$", "this", "->", "root_dir", "=", "rtrim", "(", "$", "rootDir", ",", "'/\\\\'", ")", ";", "return", "$", "this", ";", "}" ]
Set root directory @param string $rootDir @return self @throws InvalidArgumentException if dir is bad @access protected
[ "Set", "root", "directory" ]
fdb90831da06408bb674ab777754e67025604bed
https://github.com/phossa/phossa-config/blob/fdb90831da06408bb674ab777754e67025604bed/src/Phossa/Config/Loader/Loader.php#L121-L134
train
Linkvalue-Interne/MobileNotif
src/Model/Message.php
Message.addToken
public function addToken($token) { if (!in_array($token, $this->tokens)) { $this->tokens[] = $token; } return $this; }
php
public function addToken($token) { if (!in_array($token, $this->tokens)) { $this->tokens[] = $token; } return $this; }
[ "public", "function", "addToken", "(", "$", "token", ")", "{", "if", "(", "!", "in_array", "(", "$", "token", ",", "$", "this", "->", "tokens", ")", ")", "{", "$", "this", "->", "tokens", "[", "]", "=", "$", "token", ";", "}", "return", "$", "this", ";", "}" ]
Add a token device. @param string $token @return self
[ "Add", "a", "token", "device", "." ]
e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6
https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Model/Message.php#L84-L91
train
agentmedia/phine-core
src/Core/Logic/Tree/PageContentTreeProvider.php
PageContentTreeProvider.TopMost
function TopMost() { $sql = Access::SqlBuilder(); $tbl = PageContent::Schema()->Table(); $where = $sql->Equals($tbl->Field('Page'), $sql->Value($this->page->GetID()))-> And_($sql->Equals($tbl->Field('Area'), $sql->Value($this->area->GetID())))-> And_($sql->IsNull($tbl->Field('Parent'))) ->And_($sql->IsNull($tbl->Field('Previous'))); return PageContent::Schema()->First($where); }
php
function TopMost() { $sql = Access::SqlBuilder(); $tbl = PageContent::Schema()->Table(); $where = $sql->Equals($tbl->Field('Page'), $sql->Value($this->page->GetID()))-> And_($sql->Equals($tbl->Field('Area'), $sql->Value($this->area->GetID())))-> And_($sql->IsNull($tbl->Field('Parent'))) ->And_($sql->IsNull($tbl->Field('Previous'))); return PageContent::Schema()->First($where); }
[ "function", "TopMost", "(", ")", "{", "$", "sql", "=", "Access", "::", "SqlBuilder", "(", ")", ";", "$", "tbl", "=", "PageContent", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "where", "=", "$", "sql", "->", "Equals", "(", "$", "tbl", "->", "Field", "(", "'Page'", ")", ",", "$", "sql", "->", "Value", "(", "$", "this", "->", "page", "->", "GetID", "(", ")", ")", ")", "->", "And_", "(", "$", "sql", "->", "Equals", "(", "$", "tbl", "->", "Field", "(", "'Area'", ")", ",", "$", "sql", "->", "Value", "(", "$", "this", "->", "area", "->", "GetID", "(", ")", ")", ")", ")", "->", "And_", "(", "$", "sql", "->", "IsNull", "(", "$", "tbl", "->", "Field", "(", "'Parent'", ")", ")", ")", "->", "And_", "(", "$", "sql", "->", "IsNull", "(", "$", "tbl", "->", "Field", "(", "'Previous'", ")", ")", ")", ";", "return", "PageContent", "::", "Schema", "(", ")", "->", "First", "(", "$", "where", ")", ";", "}" ]
Returns the root and first content element in a page and area @return PageContent Returns the first and root content
[ "Returns", "the", "root", "and", "first", "content", "element", "in", "a", "page", "and", "area" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Tree/PageContentTreeProvider.php#L38-L48
train
JuniorZavaleta/MySqlCsvExporter
src/CsvExport.php
CsvGenerator.setCredentials
public function setCredentials($credentials) { if (function_exists('env')) { $host = env('DB_HOST'); $dbname = env('DB_DATABASE'); $username = env('DB_USERNAME'); $password = env('DB_PASSWORD'); } else { $host = $credentials['host']; $dbname = $credentials['dbname']; $username = $credentials['username']; $password = $credentials['password']; } $this->db = new PDO( "mysql:host={$host};dbname={$dbname};charset=utf8mb4", $username, $password ); }
php
public function setCredentials($credentials) { if (function_exists('env')) { $host = env('DB_HOST'); $dbname = env('DB_DATABASE'); $username = env('DB_USERNAME'); $password = env('DB_PASSWORD'); } else { $host = $credentials['host']; $dbname = $credentials['dbname']; $username = $credentials['username']; $password = $credentials['password']; } $this->db = new PDO( "mysql:host={$host};dbname={$dbname};charset=utf8mb4", $username, $password ); }
[ "public", "function", "setCredentials", "(", "$", "credentials", ")", "{", "if", "(", "function_exists", "(", "'env'", ")", ")", "{", "$", "host", "=", "env", "(", "'DB_HOST'", ")", ";", "$", "dbname", "=", "env", "(", "'DB_DATABASE'", ")", ";", "$", "username", "=", "env", "(", "'DB_USERNAME'", ")", ";", "$", "password", "=", "env", "(", "'DB_PASSWORD'", ")", ";", "}", "else", "{", "$", "host", "=", "$", "credentials", "[", "'host'", "]", ";", "$", "dbname", "=", "$", "credentials", "[", "'dbname'", "]", ";", "$", "username", "=", "$", "credentials", "[", "'username'", "]", ";", "$", "password", "=", "$", "credentials", "[", "'password'", "]", ";", "}", "$", "this", "->", "db", "=", "new", "PDO", "(", "\"mysql:host={$host};dbname={$dbname};charset=utf8mb4\"", ",", "$", "username", ",", "$", "password", ")", ";", "}" ]
Set the credentials to connect with mysql @param array $credentials
[ "Set", "the", "credentials", "to", "connect", "with", "mysql" ]
88e67a035e2eaf3a617b0595309fe680bb62a6cb
https://github.com/JuniorZavaleta/MySqlCsvExporter/blob/88e67a035e2eaf3a617b0595309fe680bb62a6cb/src/CsvExport.php#L87-L106
train
JuniorZavaleta/MySqlCsvExporter
src/CsvExport.php
CsvGenerator.setTitles
public function setTitles($titles) { $titles = is_array($titles) ? $titles : func_get_args(); if (count($titles) > 0) { $this->titles = '"'.implode('", "',$titles).'"'; } }
php
public function setTitles($titles) { $titles = is_array($titles) ? $titles : func_get_args(); if (count($titles) > 0) { $this->titles = '"'.implode('", "',$titles).'"'; } }
[ "public", "function", "setTitles", "(", "$", "titles", ")", "{", "$", "titles", "=", "is_array", "(", "$", "titles", ")", "?", "$", "titles", ":", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "titles", ")", ">", "0", ")", "{", "$", "this", "->", "titles", "=", "'\"'", ".", "implode", "(", "'\", \"'", ",", "$", "titles", ")", ".", "'\"'", ";", "}", "}" ]
Set the titles for the csv @param mixed $titles
[ "Set", "the", "titles", "for", "the", "csv" ]
88e67a035e2eaf3a617b0595309fe680bb62a6cb
https://github.com/JuniorZavaleta/MySqlCsvExporter/blob/88e67a035e2eaf3a617b0595309fe680bb62a6cb/src/CsvExport.php#L112-L119
train
JuniorZavaleta/MySqlCsvExporter
src/CsvExport.php
CsvGenerator.setColumns
public function setColumns($columns) { $columns = is_array($columns) ? $columns : func_get_args(); if (count($columns) > 0) { $this->columns = implode(', ', $columns); } }
php
public function setColumns($columns) { $columns = is_array($columns) ? $columns : func_get_args(); if (count($columns) > 0) { $this->columns = implode(', ', $columns); } }
[ "public", "function", "setColumns", "(", "$", "columns", ")", "{", "$", "columns", "=", "is_array", "(", "$", "columns", ")", "?", "$", "columns", ":", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "columns", ")", ">", "0", ")", "{", "$", "this", "->", "columns", "=", "implode", "(", "', '", ",", "$", "columns", ")", ";", "}", "}" ]
Set the columns to export @param mixed $columns
[ "Set", "the", "columns", "to", "export" ]
88e67a035e2eaf3a617b0595309fe680bb62a6cb
https://github.com/JuniorZavaleta/MySqlCsvExporter/blob/88e67a035e2eaf3a617b0595309fe680bb62a6cb/src/CsvExport.php#L125-L132
train
JuniorZavaleta/MySqlCsvExporter
src/CsvExport.php
CsvGenerator.join
public function join($table, $key_one, $operator, $key_two = null) { if (is_null($key_two)) { $key_two = $operator; $operator = '='; } $this->joins .= " JOIN {$table} ON {$key_one} {$operator} {$key_two} "; return $this; }
php
public function join($table, $key_one, $operator, $key_two = null) { if (is_null($key_two)) { $key_two = $operator; $operator = '='; } $this->joins .= " JOIN {$table} ON {$key_one} {$operator} {$key_two} "; return $this; }
[ "public", "function", "join", "(", "$", "table", ",", "$", "key_one", ",", "$", "operator", ",", "$", "key_two", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key_two", ")", ")", "{", "$", "key_two", "=", "$", "operator", ";", "$", "operator", "=", "'='", ";", "}", "$", "this", "->", "joins", ".=", "\" JOIN {$table} ON {$key_one} {$operator} {$key_two} \"", ";", "return", "$", "this", ";", "}" ]
Add a join to the query @param string $table table to join @param string $key_one first key @param mixed $operator operator or second key @param string $key_two second key if operator exists @return CsvGenerator
[ "Add", "a", "join", "to", "the", "query" ]
88e67a035e2eaf3a617b0595309fe680bb62a6cb
https://github.com/JuniorZavaleta/MySqlCsvExporter/blob/88e67a035e2eaf3a617b0595309fe680bb62a6cb/src/CsvExport.php#L151-L161
train
JuniorZavaleta/MySqlCsvExporter
src/CsvExport.php
CsvGenerator.where
public function where($field, $value, $not = false) { $reserverd_word = $this->with_where ? 'AND' : 'WHERE'; $operator = $not ? '!=' : '='; $this->query .= "{$reserverd_word} {$field} {$operator} '{$value}'"; $this->with_where = true; return $this; }
php
public function where($field, $value, $not = false) { $reserverd_word = $this->with_where ? 'AND' : 'WHERE'; $operator = $not ? '!=' : '='; $this->query .= "{$reserverd_word} {$field} {$operator} '{$value}'"; $this->with_where = true; return $this; }
[ "public", "function", "where", "(", "$", "field", ",", "$", "value", ",", "$", "not", "=", "false", ")", "{", "$", "reserverd_word", "=", "$", "this", "->", "with_where", "?", "'AND'", ":", "'WHERE'", ";", "$", "operator", "=", "$", "not", "?", "'!='", ":", "'='", ";", "$", "this", "->", "query", ".=", "\"{$reserverd_word} {$field} {$operator} '{$value}'\"", ";", "$", "this", "->", "with_where", "=", "true", ";", "return", "$", "this", ";", "}" ]
Add a condition to the initial query @param string $field column name @param mixed $value value to filter @param bool $not negation flag @return CsvGenerator
[ "Add", "a", "condition", "to", "the", "initial", "query" ]
88e67a035e2eaf3a617b0595309fe680bb62a6cb
https://github.com/JuniorZavaleta/MySqlCsvExporter/blob/88e67a035e2eaf3a617b0595309fe680bb62a6cb/src/CsvExport.php#L170-L178
train
JuniorZavaleta/MySqlCsvExporter
src/CsvExport.php
CsvGenerator.execute
public function execute() { $this->columns = $this->columns ?: '*'; $query = "SELECT {$this->columns} FROM $this->table "; if ($this->joins) { $query .= $this->joins; } $query .= $this->query; if (is_null($this->filename)) { $this->filename = '/tmp/file.csv'; } $query .= " INTO OUTFILE '{$this->filename}' CHARACTER SET utf8 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' "; $statement = $this->db->prepare($query); $r = $statement->execute(); if ($this->titles) { $file = file_get_contents($this->filename); file_put_contents($this->filename, $this->titles . "\n" . $file); } return $this->filename; }
php
public function execute() { $this->columns = $this->columns ?: '*'; $query = "SELECT {$this->columns} FROM $this->table "; if ($this->joins) { $query .= $this->joins; } $query .= $this->query; if (is_null($this->filename)) { $this->filename = '/tmp/file.csv'; } $query .= " INTO OUTFILE '{$this->filename}' CHARACTER SET utf8 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' "; $statement = $this->db->prepare($query); $r = $statement->execute(); if ($this->titles) { $file = file_get_contents($this->filename); file_put_contents($this->filename, $this->titles . "\n" . $file); } return $this->filename; }
[ "public", "function", "execute", "(", ")", "{", "$", "this", "->", "columns", "=", "$", "this", "->", "columns", "?", ":", "'*'", ";", "$", "query", "=", "\"SELECT {$this->columns} FROM $this->table \"", ";", "if", "(", "$", "this", "->", "joins", ")", "{", "$", "query", ".=", "$", "this", "->", "joins", ";", "}", "$", "query", ".=", "$", "this", "->", "query", ";", "if", "(", "is_null", "(", "$", "this", "->", "filename", ")", ")", "{", "$", "this", "->", "filename", "=", "'/tmp/file.csv'", ";", "}", "$", "query", ".=", "\"\n INTO OUTFILE '{$this->filename}'\n CHARACTER SET utf8\n FIELDS TERMINATED BY ','\n ENCLOSED BY '\\\"'\n LINES TERMINATED BY '\\n'\n \"", ";", "$", "statement", "=", "$", "this", "->", "db", "->", "prepare", "(", "$", "query", ")", ";", "$", "r", "=", "$", "statement", "->", "execute", "(", ")", ";", "if", "(", "$", "this", "->", "titles", ")", "{", "$", "file", "=", "file_get_contents", "(", "$", "this", "->", "filename", ")", ";", "file_put_contents", "(", "$", "this", "->", "filename", ",", "$", "this", "->", "titles", ".", "\"\\n\"", ".", "$", "file", ")", ";", "}", "return", "$", "this", "->", "filename", ";", "}" ]
Function for generate csv and return the filename @return string filename of csv generated
[ "Function", "for", "generate", "csv", "and", "return", "the", "filename" ]
88e67a035e2eaf3a617b0595309fe680bb62a6cb
https://github.com/JuniorZavaleta/MySqlCsvExporter/blob/88e67a035e2eaf3a617b0595309fe680bb62a6cb/src/CsvExport.php#L217-L249
train
geoffadams/bedrest-core
library/BedRest/Rest/Dispatcher.php
Dispatcher.dispatch
public function dispatch(Request $request) { // determine resource $resourceParts = explode('/', $request->getResource()); $resourceName = $resourceParts[0]; $subResourceName = false; if (count($resourceParts) > 1) { $subResourceName = $resourceParts[1]; } try { $resourceMetadata = $this->resourceMetadataFactory->getMetadataByResourceName($resourceName); } catch (ResourceMappingException $e) { throw Exception::resourceNotFound($resourceName, 404, $e); } // determine service if ($subResourceName) { if (!$resourceMetadata->hasSubResource($subResourceName)) { throw Exception::resourceNotFound($request->getResource()); } $subResourceMapping = $resourceMetadata->getSubResource($subResourceName); $service = $this->serviceLocator->get($subResourceMapping['service']); } else { $service = $this->serviceLocator->get($resourceMetadata->getService()); } $this->registerListeners($service); $event = new RequestEvent(); $event->setRequest($request); $this->eventManager->dispatch($request->getMethod(), $event); return $event->getData(); }
php
public function dispatch(Request $request) { // determine resource $resourceParts = explode('/', $request->getResource()); $resourceName = $resourceParts[0]; $subResourceName = false; if (count($resourceParts) > 1) { $subResourceName = $resourceParts[1]; } try { $resourceMetadata = $this->resourceMetadataFactory->getMetadataByResourceName($resourceName); } catch (ResourceMappingException $e) { throw Exception::resourceNotFound($resourceName, 404, $e); } // determine service if ($subResourceName) { if (!$resourceMetadata->hasSubResource($subResourceName)) { throw Exception::resourceNotFound($request->getResource()); } $subResourceMapping = $resourceMetadata->getSubResource($subResourceName); $service = $this->serviceLocator->get($subResourceMapping['service']); } else { $service = $this->serviceLocator->get($resourceMetadata->getService()); } $this->registerListeners($service); $event = new RequestEvent(); $event->setRequest($request); $this->eventManager->dispatch($request->getMethod(), $event); return $event->getData(); }
[ "public", "function", "dispatch", "(", "Request", "$", "request", ")", "{", "// determine resource", "$", "resourceParts", "=", "explode", "(", "'/'", ",", "$", "request", "->", "getResource", "(", ")", ")", ";", "$", "resourceName", "=", "$", "resourceParts", "[", "0", "]", ";", "$", "subResourceName", "=", "false", ";", "if", "(", "count", "(", "$", "resourceParts", ")", ">", "1", ")", "{", "$", "subResourceName", "=", "$", "resourceParts", "[", "1", "]", ";", "}", "try", "{", "$", "resourceMetadata", "=", "$", "this", "->", "resourceMetadataFactory", "->", "getMetadataByResourceName", "(", "$", "resourceName", ")", ";", "}", "catch", "(", "ResourceMappingException", "$", "e", ")", "{", "throw", "Exception", "::", "resourceNotFound", "(", "$", "resourceName", ",", "404", ",", "$", "e", ")", ";", "}", "// determine service", "if", "(", "$", "subResourceName", ")", "{", "if", "(", "!", "$", "resourceMetadata", "->", "hasSubResource", "(", "$", "subResourceName", ")", ")", "{", "throw", "Exception", "::", "resourceNotFound", "(", "$", "request", "->", "getResource", "(", ")", ")", ";", "}", "$", "subResourceMapping", "=", "$", "resourceMetadata", "->", "getSubResource", "(", "$", "subResourceName", ")", ";", "$", "service", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "$", "subResourceMapping", "[", "'service'", "]", ")", ";", "}", "else", "{", "$", "service", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "$", "resourceMetadata", "->", "getService", "(", ")", ")", ";", "}", "$", "this", "->", "registerListeners", "(", "$", "service", ")", ";", "$", "event", "=", "new", "RequestEvent", "(", ")", ";", "$", "event", "->", "setRequest", "(", "$", "request", ")", ";", "$", "this", "->", "eventManager", "->", "dispatch", "(", "$", "request", "->", "getMethod", "(", ")", ",", "$", "event", ")", ";", "return", "$", "event", "->", "getData", "(", ")", ";", "}" ]
Processes a REST request, returning a Response object. @param \BedRest\Rest\Request\Request $request @throws \BedRest\Rest\Exception @return \BedRest\Rest\Response\Response
[ "Processes", "a", "REST", "request", "returning", "a", "Response", "object", "." ]
a77bf8b7492dfbfb720b201f7ec91a4f03417b5c
https://github.com/geoffadams/bedrest-core/blob/a77bf8b7492dfbfb720b201f7ec91a4f03417b5c/library/BedRest/Rest/Dispatcher.php#L149-L185
train
geoffadams/bedrest-core
library/BedRest/Rest/Dispatcher.php
Dispatcher.registerListeners
protected function registerListeners($service) { $serviceMetadata = $this->serviceMetadataFactory->getMetadataFor(get_class($service)); foreach ($serviceMetadata->getAllListeners() as $event => $listeners) { foreach ($listeners as $listener) { $this->eventManager->addListener($event, array($service, $listener)); } } }
php
protected function registerListeners($service) { $serviceMetadata = $this->serviceMetadataFactory->getMetadataFor(get_class($service)); foreach ($serviceMetadata->getAllListeners() as $event => $listeners) { foreach ($listeners as $listener) { $this->eventManager->addListener($event, array($service, $listener)); } } }
[ "protected", "function", "registerListeners", "(", "$", "service", ")", "{", "$", "serviceMetadata", "=", "$", "this", "->", "serviceMetadataFactory", "->", "getMetadataFor", "(", "get_class", "(", "$", "service", ")", ")", ";", "foreach", "(", "$", "serviceMetadata", "->", "getAllListeners", "(", ")", "as", "$", "event", "=>", "$", "listeners", ")", "{", "foreach", "(", "$", "listeners", "as", "$", "listener", ")", "{", "$", "this", "->", "eventManager", "->", "addListener", "(", "$", "event", ",", "array", "(", "$", "service", ",", "$", "listener", ")", ")", ";", "}", "}", "}" ]
Registers listeners for the supplied service instance. Listeners are obtained from ServiceMetadata for the class of the instance. @param object $service
[ "Registers", "listeners", "for", "the", "supplied", "service", "instance", ".", "Listeners", "are", "obtained", "from", "ServiceMetadata", "for", "the", "class", "of", "the", "instance", "." ]
a77bf8b7492dfbfb720b201f7ec91a4f03417b5c
https://github.com/geoffadams/bedrest-core/blob/a77bf8b7492dfbfb720b201f7ec91a4f03417b5c/library/BedRest/Rest/Dispatcher.php#L193-L202
train
ARCANESOFT/Auth
src/Seeds/Foundation/PermissionTableSeeder.php
PermissionTableSeeder.getUsersPermissions
private function getUsersPermissions() { return [ [ 'name' => 'Users - List all users', 'description' => 'Allow to list all users.', 'slug' => UsersPolicy::PERMISSION_LIST, ], [ 'name' => 'Users - View a user', 'description' => 'Allow to view a user\'s details.', 'slug' => UsersPolicy::PERMISSION_SHOW, ], [ 'name' => 'Users - Add/Create a user', 'description' => 'Allow to create a new user.', 'slug' => UsersPolicy::PERMISSION_CREATE, ], [ 'name' => 'Users - Edit/Update a user', 'description' => 'Allow to update a user.', 'slug' => UsersPolicy::PERMISSION_UPDATE, ], [ 'name' => 'Users - Delete a user', 'description' => 'Allow to delete a user.', 'slug' => UsersPolicy::PERMISSION_DELETE, ], ]; }
php
private function getUsersPermissions() { return [ [ 'name' => 'Users - List all users', 'description' => 'Allow to list all users.', 'slug' => UsersPolicy::PERMISSION_LIST, ], [ 'name' => 'Users - View a user', 'description' => 'Allow to view a user\'s details.', 'slug' => UsersPolicy::PERMISSION_SHOW, ], [ 'name' => 'Users - Add/Create a user', 'description' => 'Allow to create a new user.', 'slug' => UsersPolicy::PERMISSION_CREATE, ], [ 'name' => 'Users - Edit/Update a user', 'description' => 'Allow to update a user.', 'slug' => UsersPolicy::PERMISSION_UPDATE, ], [ 'name' => 'Users - Delete a user', 'description' => 'Allow to delete a user.', 'slug' => UsersPolicy::PERMISSION_DELETE, ], ]; }
[ "private", "function", "getUsersPermissions", "(", ")", "{", "return", "[", "[", "'name'", "=>", "'Users - List all users'", ",", "'description'", "=>", "'Allow to list all users.'", ",", "'slug'", "=>", "UsersPolicy", "::", "PERMISSION_LIST", ",", "]", ",", "[", "'name'", "=>", "'Users - View a user'", ",", "'description'", "=>", "'Allow to view a user\\'s details.'", ",", "'slug'", "=>", "UsersPolicy", "::", "PERMISSION_SHOW", ",", "]", ",", "[", "'name'", "=>", "'Users - Add/Create a user'", ",", "'description'", "=>", "'Allow to create a new user.'", ",", "'slug'", "=>", "UsersPolicy", "::", "PERMISSION_CREATE", ",", "]", ",", "[", "'name'", "=>", "'Users - Edit/Update a user'", ",", "'description'", "=>", "'Allow to update a user.'", ",", "'slug'", "=>", "UsersPolicy", "::", "PERMISSION_UPDATE", ",", "]", ",", "[", "'name'", "=>", "'Users - Delete a user'", ",", "'description'", "=>", "'Allow to delete a user.'", ",", "'slug'", "=>", "UsersPolicy", "::", "PERMISSION_DELETE", ",", "]", ",", "]", ";", "}" ]
Get user's permissions seeds. @return array
[ "Get", "user", "s", "permissions", "seeds", "." ]
b33ca82597a76b1e395071f71ae3e51f1ec67e62
https://github.com/ARCANESOFT/Auth/blob/b33ca82597a76b1e395071f71ae3e51f1ec67e62/src/Seeds/Foundation/PermissionTableSeeder.php#L72-L101
train
ARCANESOFT/Auth
src/Seeds/Foundation/PermissionTableSeeder.php
PermissionTableSeeder.getRolesPermissions
private function getRolesPermissions() { return [ [ 'name' => 'Roles - List all roles', 'description' => 'Allow to list all roles.', 'slug' => RolesPolicy::PERMISSION_LIST, ], [ 'name' => 'Roles - View a role', 'description' => 'Allow to view the role\'s details.', 'slug' => RolesPolicy::PERMISSION_SHOW, ], [ 'name' => 'Roles - Add/Create a role', 'description' => 'Allow to create a new role.', 'slug' => RolesPolicy::PERMISSION_CREATE, ], [ 'name' => 'Roles - Edit/Update a role', 'description' => 'Allow to update a role.', 'slug' => RolesPolicy::PERMISSION_UPDATE, ], [ 'name' => 'Roles - Delete a role', 'description' => 'Allow to delete a role.', 'slug' => RolesPolicy::PERMISSION_DELETE, ], ]; }
php
private function getRolesPermissions() { return [ [ 'name' => 'Roles - List all roles', 'description' => 'Allow to list all roles.', 'slug' => RolesPolicy::PERMISSION_LIST, ], [ 'name' => 'Roles - View a role', 'description' => 'Allow to view the role\'s details.', 'slug' => RolesPolicy::PERMISSION_SHOW, ], [ 'name' => 'Roles - Add/Create a role', 'description' => 'Allow to create a new role.', 'slug' => RolesPolicy::PERMISSION_CREATE, ], [ 'name' => 'Roles - Edit/Update a role', 'description' => 'Allow to update a role.', 'slug' => RolesPolicy::PERMISSION_UPDATE, ], [ 'name' => 'Roles - Delete a role', 'description' => 'Allow to delete a role.', 'slug' => RolesPolicy::PERMISSION_DELETE, ], ]; }
[ "private", "function", "getRolesPermissions", "(", ")", "{", "return", "[", "[", "'name'", "=>", "'Roles - List all roles'", ",", "'description'", "=>", "'Allow to list all roles.'", ",", "'slug'", "=>", "RolesPolicy", "::", "PERMISSION_LIST", ",", "]", ",", "[", "'name'", "=>", "'Roles - View a role'", ",", "'description'", "=>", "'Allow to view the role\\'s details.'", ",", "'slug'", "=>", "RolesPolicy", "::", "PERMISSION_SHOW", ",", "]", ",", "[", "'name'", "=>", "'Roles - Add/Create a role'", ",", "'description'", "=>", "'Allow to create a new role.'", ",", "'slug'", "=>", "RolesPolicy", "::", "PERMISSION_CREATE", ",", "]", ",", "[", "'name'", "=>", "'Roles - Edit/Update a role'", ",", "'description'", "=>", "'Allow to update a role.'", ",", "'slug'", "=>", "RolesPolicy", "::", "PERMISSION_UPDATE", ",", "]", ",", "[", "'name'", "=>", "'Roles - Delete a role'", ",", "'description'", "=>", "'Allow to delete a role.'", ",", "'slug'", "=>", "RolesPolicy", "::", "PERMISSION_DELETE", ",", "]", ",", "]", ";", "}" ]
Get role's permissions seeds. @return array
[ "Get", "role", "s", "permissions", "seeds", "." ]
b33ca82597a76b1e395071f71ae3e51f1ec67e62
https://github.com/ARCANESOFT/Auth/blob/b33ca82597a76b1e395071f71ae3e51f1ec67e62/src/Seeds/Foundation/PermissionTableSeeder.php#L108-L137
train
stevenliebregt/crispysystem
src/Routing/Router.php
Router.getRouteByName
public static function getRouteByName(string $name) : Route { foreach (static::$routes as $routes) { /** @var Route $route */ foreach ($routes as $route) { if ($route->getName() === $name) { return $route; } } } return null; }
php
public static function getRouteByName(string $name) : Route { foreach (static::$routes as $routes) { /** @var Route $route */ foreach ($routes as $route) { if ($route->getName() === $name) { return $route; } } } return null; }
[ "public", "static", "function", "getRouteByName", "(", "string", "$", "name", ")", ":", "Route", "{", "foreach", "(", "static", "::", "$", "routes", "as", "$", "routes", ")", "{", "/** @var Route $route */", "foreach", "(", "$", "routes", "as", "$", "route", ")", "{", "if", "(", "$", "route", "->", "getName", "(", ")", "===", "$", "name", ")", "{", "return", "$", "route", ";", "}", "}", "}", "return", "null", ";", "}" ]
Tries to fetch a route by name, returns null if it doesn't exist @param string $name @return null|Route @since 1.0.0
[ "Tries", "to", "fetch", "a", "route", "by", "name", "returns", "null", "if", "it", "doesn", "t", "exist" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Routing/Router.php#L178-L190
train
siriusSupreme/sirius-container
src/Container.php
Container.getAlias
public function getAlias($abstract) { if (! isset($this->aliases[$abstract])) { return $abstract; } if ($this->aliases[$abstract] === $abstract) { throw new LogicException("[{$abstract}] is aliased to itself."); } return $this->getAlias($this->aliases[$abstract]); }
php
public function getAlias($abstract) { if (! isset($this->aliases[$abstract])) { return $abstract; } if ($this->aliases[$abstract] === $abstract) { throw new LogicException("[{$abstract}] is aliased to itself."); } return $this->getAlias($this->aliases[$abstract]); }
[ "public", "function", "getAlias", "(", "$", "abstract", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "aliases", "[", "$", "abstract", "]", ")", ")", "{", "return", "$", "abstract", ";", "}", "if", "(", "$", "this", "->", "aliases", "[", "$", "abstract", "]", "===", "$", "abstract", ")", "{", "throw", "new", "LogicException", "(", "\"[{$abstract}] is aliased to itself.\"", ")", ";", "}", "return", "$", "this", "->", "getAlias", "(", "$", "this", "->", "aliases", "[", "$", "abstract", "]", ")", ";", "}" ]
Get the alias for an abstract if available. @param string $abstract @return string @throws \LogicException
[ "Get", "the", "alias", "for", "an", "abstract", "if", "available", "." ]
a9ca7770c5ddfca7b109bc87bac40f00bea3ef0a
https://github.com/siriusSupreme/sirius-container/blob/a9ca7770c5ddfca7b109bc87bac40f00bea3ef0a/src/Container.php#L1071-L1082
train
ezra-obiwale/dSCore
src/Core/Request.php
Request.initServer
private function initServer() { $this->http = new Object(); $this->server = new Object(); foreach ($_SERVER as $key => $val) { $key = str_replace('request_', '', strtolower($key)); if (substr($key, 0, 5) === 'http_') { $this->http->{Util::_toCamel(substr($key, 5))} = $val; } elseif (substr($key, 0, 7) === 'server_') { $this->server->{Util::_toCamel(substr($key, 7))} = $val; } else { $this->{Util::_toCamel($key)} = $val; } } }
php
private function initServer() { $this->http = new Object(); $this->server = new Object(); foreach ($_SERVER as $key => $val) { $key = str_replace('request_', '', strtolower($key)); if (substr($key, 0, 5) === 'http_') { $this->http->{Util::_toCamel(substr($key, 5))} = $val; } elseif (substr($key, 0, 7) === 'server_') { $this->server->{Util::_toCamel(substr($key, 7))} = $val; } else { $this->{Util::_toCamel($key)} = $val; } } }
[ "private", "function", "initServer", "(", ")", "{", "$", "this", "->", "http", "=", "new", "Object", "(", ")", ";", "$", "this", "->", "server", "=", "new", "Object", "(", ")", ";", "foreach", "(", "$", "_SERVER", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "key", "=", "str_replace", "(", "'request_'", ",", "''", ",", "strtolower", "(", "$", "key", ")", ")", ";", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "5", ")", "===", "'http_'", ")", "{", "$", "this", "->", "http", "->", "{", "Util", "::", "_toCamel", "(", "substr", "(", "$", "key", ",", "5", ")", ")", "}", "=", "$", "val", ";", "}", "elseif", "(", "substr", "(", "$", "key", ",", "0", ",", "7", ")", "===", "'server_'", ")", "{", "$", "this", "->", "server", "->", "{", "Util", "::", "_toCamel", "(", "substr", "(", "$", "key", ",", "7", ")", ")", "}", "=", "$", "val", ";", "}", "else", "{", "$", "this", "->", "{", "Util", "::", "_toCamel", "(", "$", "key", ")", "}", "=", "$", "val", ";", "}", "}", "}" ]
initializes server values
[ "initializes", "server", "values" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Request.php#L76-L92
train
ezra-obiwale/dSCore
src/Core/Request.php
Request.isAjax
public function isAjax() { return (isset($this->http->xRequestedWith) && $this->http->xRequestedWith = 'XMLHttpRequest' || isset($this->http->requestedWith) && $this->http->requestedWith = 'XMLHttpRequest'); }
php
public function isAjax() { return (isset($this->http->xRequestedWith) && $this->http->xRequestedWith = 'XMLHttpRequest' || isset($this->http->requestedWith) && $this->http->requestedWith = 'XMLHttpRequest'); }
[ "public", "function", "isAjax", "(", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "http", "->", "xRequestedWith", ")", "&&", "$", "this", "->", "http", "->", "xRequestedWith", "=", "'XMLHttpRequest'", "||", "isset", "(", "$", "this", "->", "http", "->", "requestedWith", ")", "&&", "$", "this", "->", "http", "->", "requestedWith", "=", "'XMLHttpRequest'", ")", ";", "}" ]
Checks if the request is an ajax @return boolean
[ "Checks", "if", "the", "request", "is", "an", "ajax" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Request.php#L106-L109
train
Tapakan/Path
src/Path.php
Path.getInstance
public static function getInstance($id = 'default') { if (!isset(static::$instances[$id])) { static::$instances[$id] = new self(); } return static::$instances[$id]; }
php
public static function getInstance($id = 'default') { if (!isset(static::$instances[$id])) { static::$instances[$id] = new self(); } return static::$instances[$id]; }
[ "public", "static", "function", "getInstance", "(", "$", "id", "=", "'default'", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "instances", "[", "$", "id", "]", ")", ")", "{", "static", "::", "$", "instances", "[", "$", "id", "]", "=", "new", "self", "(", ")", ";", "}", "return", "static", "::", "$", "instances", "[", "$", "id", "]", ";", "}" ]
If identifier exists it will be return instance, if not new instance will create. @param mixed $id Identifier of instance. @return Path
[ "If", "identifier", "exists", "it", "will", "be", "return", "instance", "if", "not", "new", "instance", "will", "create", "." ]
07e39d605de3f4b81a3e9314c3b211371a0a3fda
https://github.com/Tapakan/Path/blob/07e39d605de3f4b81a3e9314c3b211371a0a3fda/src/Path.php#L48-L55
train
Tapakan/Path
src/Path.php
Path.path
public function path($path) { $path = strtolower(trim($path)); $first = substr($path, 0, 1); if ($first == '@' && isset($this->aliases[$path])) { $path = $this->aliases[$path]; } elseif ($first == '/') { $path = preg_replace('/\\//', $this->root() . '/', $path, 1); } if ($path = realpath($path)) { $path = static::clean($path); } return $path; }
php
public function path($path) { $path = strtolower(trim($path)); $first = substr($path, 0, 1); if ($first == '@' && isset($this->aliases[$path])) { $path = $this->aliases[$path]; } elseif ($first == '/') { $path = preg_replace('/\\//', $this->root() . '/', $path, 1); } if ($path = realpath($path)) { $path = static::clean($path); } return $path; }
[ "public", "function", "path", "(", "$", "path", ")", "{", "$", "path", "=", "strtolower", "(", "trim", "(", "$", "path", ")", ")", ";", "$", "first", "=", "substr", "(", "$", "path", ",", "0", ",", "1", ")", ";", "if", "(", "$", "first", "==", "'@'", "&&", "isset", "(", "$", "this", "->", "aliases", "[", "$", "path", "]", ")", ")", "{", "$", "path", "=", "$", "this", "->", "aliases", "[", "$", "path", "]", ";", "}", "elseif", "(", "$", "first", "==", "'/'", ")", "{", "$", "path", "=", "preg_replace", "(", "'/\\\\//'", ",", "$", "this", "->", "root", "(", ")", ".", "'/'", ",", "$", "path", ",", "1", ")", ";", "}", "if", "(", "$", "path", "=", "realpath", "(", "$", "path", ")", ")", "{", "$", "path", "=", "static", "::", "clean", "(", "$", "path", ")", ";", "}", "return", "$", "path", ";", "}" ]
Translate path alias into a actual path or build path. Return absolute path. @param string $path Path to the file @return mixed|string
[ "Translate", "path", "alias", "into", "a", "actual", "path", "or", "build", "path", ".", "Return", "absolute", "path", "." ]
07e39d605de3f4b81a3e9314c3b211371a0a3fda
https://github.com/Tapakan/Path/blob/07e39d605de3f4b81a3e9314c3b211371a0a3fda/src/Path.php#L96-L113
train
Kris-Kuiper/sFire-Framework
src/Utils/NameConvert.php
NameConvert.toCamelcase
public static function toCamelcase($string, $capitalizeFirstCharacter = false) { if(false === is_string($string)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($string)), E_USER_ERROR); } if(false === is_bool($capitalizeFirstCharacter)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type boolean, "%s" given', __METHOD__, gettype($capitalizeFirstCharacter)), E_USER_ERROR); } $str = str_replace(' ', '', ucwords(str_replace('_', ' ', $string))); if(false === $capitalizeFirstCharacter) { $str[0] = strtolower($str[0]); } return $str; }
php
public static function toCamelcase($string, $capitalizeFirstCharacter = false) { if(false === is_string($string)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($string)), E_USER_ERROR); } if(false === is_bool($capitalizeFirstCharacter)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type boolean, "%s" given', __METHOD__, gettype($capitalizeFirstCharacter)), E_USER_ERROR); } $str = str_replace(' ', '', ucwords(str_replace('_', ' ', $string))); if(false === $capitalizeFirstCharacter) { $str[0] = strtolower($str[0]); } return $str; }
[ "public", "static", "function", "toCamelcase", "(", "$", "string", ",", "$", "capitalizeFirstCharacter", "=", "false", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "string", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "string", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "false", "===", "is_bool", "(", "$", "capitalizeFirstCharacter", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type boolean, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "capitalizeFirstCharacter", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "str", "=", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "str_replace", "(", "'_'", ",", "' '", ",", "$", "string", ")", ")", ")", ";", "if", "(", "false", "===", "$", "capitalizeFirstCharacter", ")", "{", "$", "str", "[", "0", "]", "=", "strtolower", "(", "$", "str", "[", "0", "]", ")", ";", "}", "return", "$", "str", ";", "}" ]
Converts string underscores to camelCase @param string $string @param boolean $capitalizeFirstCharacter @return string
[ "Converts", "string", "underscores", "to", "camelCase" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Utils/NameConvert.php#L20-L37
train
Kris-Kuiper/sFire-Framework
src/Utils/NameConvert.php
NameConvert.toSnakecase
public static function toSnakecase($string) { if(false === is_string($string)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($string)), E_USER_ERROR); } return ltrim(strtolower(preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '_$0', $string)), '_'); }
php
public static function toSnakecase($string) { if(false === is_string($string)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($string)), E_USER_ERROR); } return ltrim(strtolower(preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '_$0', $string)), '_'); }
[ "public", "static", "function", "toSnakecase", "(", "$", "string", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "string", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "string", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "return", "ltrim", "(", "strtolower", "(", "preg_replace", "(", "'/[A-Z]([A-Z](?![a-z]))*/'", ",", "'_$0'", ",", "$", "string", ")", ")", ",", "'_'", ")", ";", "}" ]
Converts string camelcase to snakecase @param string $string @return string
[ "Converts", "string", "camelcase", "to", "snakecase" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Utils/NameConvert.php#L45-L52
train
codeblanche/Web
src/Web/Request/Request.php
Request.resolveValue
protected function resolveValue($name, &$source = null, $sanitize = true, $array = false) { $result = $array ? array() : null; if (empty($name)) { $result = $source; } elseif (isset($source[$name])) { $result = $source[$name]; } if (!$sanitize) { return $result; } if (is_array($result)) { foreach ($result as $key => $value) { $result[$key] = $this->resolveValue('', $value, $sanitize); } } else { $filter = 0; $flags = FILTER_FLAG_EMPTY_STRING_NULL | FILTER_NULL_ON_FAILURE; if ($sanitize) { $filter = $filter | FILTER_SANITIZE_STRING; $flags = $flags | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH; } if ($array) { $flags = $flags | FILTER_FORCE_ARRAY; } $result = filter_var($result, $filter, array('flags' => $flags)); } return $result; }
php
protected function resolveValue($name, &$source = null, $sanitize = true, $array = false) { $result = $array ? array() : null; if (empty($name)) { $result = $source; } elseif (isset($source[$name])) { $result = $source[$name]; } if (!$sanitize) { return $result; } if (is_array($result)) { foreach ($result as $key => $value) { $result[$key] = $this->resolveValue('', $value, $sanitize); } } else { $filter = 0; $flags = FILTER_FLAG_EMPTY_STRING_NULL | FILTER_NULL_ON_FAILURE; if ($sanitize) { $filter = $filter | FILTER_SANITIZE_STRING; $flags = $flags | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH; } if ($array) { $flags = $flags | FILTER_FORCE_ARRAY; } $result = filter_var($result, $filter, array('flags' => $flags)); } return $result; }
[ "protected", "function", "resolveValue", "(", "$", "name", ",", "&", "$", "source", "=", "null", ",", "$", "sanitize", "=", "true", ",", "$", "array", "=", "false", ")", "{", "$", "result", "=", "$", "array", "?", "array", "(", ")", ":", "null", ";", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "result", "=", "$", "source", ";", "}", "elseif", "(", "isset", "(", "$", "source", "[", "$", "name", "]", ")", ")", "{", "$", "result", "=", "$", "source", "[", "$", "name", "]", ";", "}", "if", "(", "!", "$", "sanitize", ")", "{", "return", "$", "result", ";", "}", "if", "(", "is_array", "(", "$", "result", ")", ")", "{", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "this", "->", "resolveValue", "(", "''", ",", "$", "value", ",", "$", "sanitize", ")", ";", "}", "}", "else", "{", "$", "filter", "=", "0", ";", "$", "flags", "=", "FILTER_FLAG_EMPTY_STRING_NULL", "|", "FILTER_NULL_ON_FAILURE", ";", "if", "(", "$", "sanitize", ")", "{", "$", "filter", "=", "$", "filter", "|", "FILTER_SANITIZE_STRING", ";", "$", "flags", "=", "$", "flags", "|", "FILTER_FLAG_STRIP_LOW", "|", "FILTER_FLAG_STRIP_HIGH", ";", "}", "if", "(", "$", "array", ")", "{", "$", "flags", "=", "$", "flags", "|", "FILTER_FORCE_ARRAY", ";", "}", "$", "result", "=", "filter_var", "(", "$", "result", ",", "$", "filter", ",", "array", "(", "'flags'", "=>", "$", "flags", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Resolve a value from the given collection. @param string $name @param array $source @param bool $sanitize @param bool $array @return mixed
[ "Resolve", "a", "value", "from", "the", "given", "collection", "." ]
3e9ebf1943d3ea468f619ba99f7cc10714cb16e9
https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Request/Request.php#L79-L116
train
codeblanche/Web
src/Web/Request/Request.php
Request.setRequestOrder
public function setRequestOrder($requestOrder) { if (!is_string($requestOrder)) { throw new InvalidArgumentException('Expected requestOrder to be a string'); } if (empty($requestOrder)) { throw new InvalidArgumentException('An empty string is not a valid requestOrder value'); } $this->requestOrder = array_unique(str_split(strtoupper($requestOrder), 1)); }
php
public function setRequestOrder($requestOrder) { if (!is_string($requestOrder)) { throw new InvalidArgumentException('Expected requestOrder to be a string'); } if (empty($requestOrder)) { throw new InvalidArgumentException('An empty string is not a valid requestOrder value'); } $this->requestOrder = array_unique(str_split(strtoupper($requestOrder), 1)); }
[ "public", "function", "setRequestOrder", "(", "$", "requestOrder", ")", "{", "if", "(", "!", "is_string", "(", "$", "requestOrder", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Expected requestOrder to be a string'", ")", ";", "}", "if", "(", "empty", "(", "$", "requestOrder", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'An empty string is not a valid requestOrder value'", ")", ";", "}", "$", "this", "->", "requestOrder", "=", "array_unique", "(", "str_split", "(", "strtoupper", "(", "$", "requestOrder", ")", ",", "1", ")", ")", ";", "}" ]
Set the request order. @param string $requestOrder The order in which to check request collections for a value. [G = GET, P = POST, C = COOKIE, S = SESSION, E = ENV, H = SERVER] @throws InvalidArgumentException
[ "Set", "the", "request", "order", "." ]
3e9ebf1943d3ea468f619ba99f7cc10714cb16e9
https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Request/Request.php#L125-L136
train