repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php
DOMIterator.registerNodes
protected function registerNodes($nodeList) { // If the node list is invalid if (!is_array($nodeList) && !($nodeList instanceof \DOMNodeList)) { throw new RuntimeException(RuntimeException::INVALID_NODE_LIST_STR, RuntimeException::INVALID_NODE_LIST); } $nodes = []; // Run through and register all nodes /** @var \DOMNode $node */ foreach ($nodeList as $node) { $nodes[$node->getNodePath()] = $this->registerNode($node); } return $nodes; }
php
protected function registerNodes($nodeList) { // If the node list is invalid if (!is_array($nodeList) && !($nodeList instanceof \DOMNodeList)) { throw new RuntimeException(RuntimeException::INVALID_NODE_LIST_STR, RuntimeException::INVALID_NODE_LIST); } $nodes = []; // Run through and register all nodes /** @var \DOMNode $node */ foreach ($nodeList as $node) { $nodes[$node->getNodePath()] = $this->registerNode($node); } return $nodes; }
[ "protected", "function", "registerNodes", "(", "$", "nodeList", ")", "{", "// If the node list is invalid", "if", "(", "!", "is_array", "(", "$", "nodeList", ")", "&&", "!", "(", "$", "nodeList", "instanceof", "\\", "DOMNodeList", ")", ")", "{", "throw", "ne...
Recursive DOM node iterator constructor @param \DOMNodeList|array $nodeList Node list @throws RuntimeException If the node list is invalid @return array Nodes
[ "Recursive", "DOM", "node", "iterator", "constructor" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php#L101-L117
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php
DOMIterator.registerNode
protected function registerNode(\DOMNode $node) { if ($node->nodeType == XML_ELEMENT_NODE) { /** @var \DOMElement $node */ $localContext = $this->elementProcessor->processElement($node, $this->initialContext); // Register the node context $localContextId = spl_object_hash($localContext); if (empty($this->contexts[$localContextId])) { $this->contexts[$localContextId] = $localContext; } $this->contextMap[$node->getNodePath()] = $localContextId; } return $node; }
php
protected function registerNode(\DOMNode $node) { if ($node->nodeType == XML_ELEMENT_NODE) { /** @var \DOMElement $node */ $localContext = $this->elementProcessor->processElement($node, $this->initialContext); // Register the node context $localContextId = spl_object_hash($localContext); if (empty($this->contexts[$localContextId])) { $this->contexts[$localContextId] = $localContext; } $this->contextMap[$node->getNodePath()] = $localContextId; } return $node; }
[ "protected", "function", "registerNode", "(", "\\", "DOMNode", "$", "node", ")", "{", "if", "(", "$", "node", "->", "nodeType", "==", "XML_ELEMENT_NODE", ")", "{", "/** @var \\DOMElement $node */", "$", "localContext", "=", "$", "this", "->", "elementProcessor",...
Register an element node @param \DOMNode $node Node @return \DOMNode Node
[ "Register", "an", "element", "node" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php#L125-L141
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php
DOMIterator.getChildren
public function getChildren() { $element = $this->current(); $childContext = $this->elementProcessor->processElementChildren( $element, $this->contexts[$this->contextMap[$this->key()]] ); return new static($element->childNodes, $childContext, $this->elementProcessor); }
php
public function getChildren() { $element = $this->current(); $childContext = $this->elementProcessor->processElementChildren( $element, $this->contexts[$this->contextMap[$this->key()]] ); return new static($element->childNodes, $childContext, $this->elementProcessor); }
[ "public", "function", "getChildren", "(", ")", "{", "$", "element", "=", "$", "this", "->", "current", "(", ")", ";", "$", "childContext", "=", "$", "this", "->", "elementProcessor", "->", "processElementChildren", "(", "$", "element", ",", "$", "this", ...
Return a child node iterator @return DOMIterator Child node iterator
[ "Return", "a", "child", "node", "iterator" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php#L172-L180
CampaignChain/core
Controller/UserController.php
UserController.indexAction
public function indexAction() { $userManager = $this->get('fos_user.user_manager'); $users = $userManager->findUsers(); return $this->render('CampaignChainCoreBundle:User:index.html.twig', array( 'users' => $users, 'page_title' => 'Users', )); }
php
public function indexAction() { $userManager = $this->get('fos_user.user_manager'); $users = $userManager->findUsers(); return $this->render('CampaignChainCoreBundle:User:index.html.twig', array( 'users' => $users, 'page_title' => 'Users', )); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "userManager", "=", "$", "this", "->", "get", "(", "'fos_user.user_manager'", ")", ";", "$", "users", "=", "$", "userManager", "->", "findUsers", "(", ")", ";", "return", "$", "this", "->", "render...
List every user from the DB @return \Symfony\Component\HttpFoundation\Response
[ "List", "every", "user", "from", "the", "DB" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/UserController.php#L38-L48
CampaignChain/core
Controller/UserController.php
UserController.editAction
public function editAction(Request $request, User $userToEdit) { $form = $this->createForm(UserType::class, $userToEdit); $form->handleRequest($request); if ($form->isValid()) { /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->get('fos_user.user_manager'); $userManager->updateUser($userToEdit); $this->addFlash( 'success', 'The user '.$userToEdit->getNameAndUsername().' was edited successfully.' ); return $this->redirectToRoute('campaignchain_core_user_edit', array('id' => $userToEdit->getId())); } return $this->render( 'CampaignChainCoreBundle:User:edit.html.twig', array( 'page_title' => 'Edit User '.$userToEdit->getNameAndUsername(), 'form' => $form->createView(), 'form_submit_label' => 'Save', 'user' => $userToEdit, )); }
php
public function editAction(Request $request, User $userToEdit) { $form = $this->createForm(UserType::class, $userToEdit); $form->handleRequest($request); if ($form->isValid()) { /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->get('fos_user.user_manager'); $userManager->updateUser($userToEdit); $this->addFlash( 'success', 'The user '.$userToEdit->getNameAndUsername().' was edited successfully.' ); return $this->redirectToRoute('campaignchain_core_user_edit', array('id' => $userToEdit->getId())); } return $this->render( 'CampaignChainCoreBundle:User:edit.html.twig', array( 'page_title' => 'Edit User '.$userToEdit->getNameAndUsername(), 'form' => $form->createView(), 'form_submit_label' => 'Save', 'user' => $userToEdit, )); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "User", "$", "userToEdit", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "UserType", "::", "class", ",", "$", "userToEdit", ")", ";", "$", "form", "->", "handl...
@param Request $request @param User $userToEdit @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response @Security("has_role('ROLE_SUPER_ADMIN')")
[ "@param", "Request", "$request", "@param", "User", "$userToEdit", "@return", "\\", "Symfony", "\\", "Component", "\\", "HttpFoundation", "\\", "RedirectResponse|", "\\", "Symfony", "\\", "Component", "\\", "HttpFoundation", "\\", "Response" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/UserController.php#L57-L85
CampaignChain/core
Controller/UserController.php
UserController.changePasswordAction
public function changePasswordAction(Request $request, User $userToEdit) { /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */ $formFactory = $this->get('fos_user.change_password.form.factory'); $form = $formFactory->createForm(); $form->setData($userToEdit); $form->remove('current_password'); $form->handleRequest($request); if ($form->isValid()) { /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->get('fos_user.user_manager'); $userManager->updateUser($userToEdit); $this->addFlash( 'success', 'The password for '.$userToEdit->getNameAndUsername().' was successfully changed!' ); return $this->redirectToRoute('campaignchain_core_user'); } return $this->render('CampaignChainCoreBundle:User:changePassword.html.twig', array( 'form' => $form->createView(), 'page_title' => 'Change Password for '.$userToEdit->getNameAndUsername(), )); }
php
public function changePasswordAction(Request $request, User $userToEdit) { /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */ $formFactory = $this->get('fos_user.change_password.form.factory'); $form = $formFactory->createForm(); $form->setData($userToEdit); $form->remove('current_password'); $form->handleRequest($request); if ($form->isValid()) { /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->get('fos_user.user_manager'); $userManager->updateUser($userToEdit); $this->addFlash( 'success', 'The password for '.$userToEdit->getNameAndUsername().' was successfully changed!' ); return $this->redirectToRoute('campaignchain_core_user'); } return $this->render('CampaignChainCoreBundle:User:changePassword.html.twig', array( 'form' => $form->createView(), 'page_title' => 'Change Password for '.$userToEdit->getNameAndUsername(), )); }
[ "public", "function", "changePasswordAction", "(", "Request", "$", "request", ",", "User", "$", "userToEdit", ")", "{", "/** @var $formFactory \\FOS\\UserBundle\\Form\\Factory\\FactoryInterface */", "$", "formFactory", "=", "$", "this", "->", "get", "(", "'fos_user.change...
@param Request $request @param User $userToEdit @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response @Security("has_role('ROLE_SUPER_ADMIN')")
[ "@param", "Request", "$request", "@param", "User", "$userToEdit", "@return", "\\", "Symfony", "\\", "Component", "\\", "HttpFoundation", "\\", "RedirectResponse|", "\\", "Symfony", "\\", "Component", "\\", "HttpFoundation", "\\", "Response" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/UserController.php#L94-L123
CampaignChain/core
Controller/UserController.php
UserController.newAction
public function newAction(Request $request) { $userManager = $this->get('fos_user.user_manager'); /** @var User $user */ $user = $userManager->createUser(); $form = $this->createForm(UserType::class, $user, ['new' => true]); $form->handleRequest($request); if ($form->isValid()) { $user->setEnabled(true); $user->setPlainPassword($form->get('password')->getData()); $userManager->updateUser($user); $this->addFlash('success', 'New user successfully created!'); return $this->redirectToRoute('campaignchain_core_user'); } return $this->render('CampaignChainCoreBundle:User:new.html.twig', array( 'form' => $form->createView(), 'page_title' => 'Create New User', )); }
php
public function newAction(Request $request) { $userManager = $this->get('fos_user.user_manager'); /** @var User $user */ $user = $userManager->createUser(); $form = $this->createForm(UserType::class, $user, ['new' => true]); $form->handleRequest($request); if ($form->isValid()) { $user->setEnabled(true); $user->setPlainPassword($form->get('password')->getData()); $userManager->updateUser($user); $this->addFlash('success', 'New user successfully created!'); return $this->redirectToRoute('campaignchain_core_user'); } return $this->render('CampaignChainCoreBundle:User:new.html.twig', array( 'form' => $form->createView(), 'page_title' => 'Create New User', )); }
[ "public", "function", "newAction", "(", "Request", "$", "request", ")", "{", "$", "userManager", "=", "$", "this", "->", "get", "(", "'fos_user.user_manager'", ")", ";", "/** @var User $user */", "$", "user", "=", "$", "userManager", "->", "createUser", "(", ...
Create a new user @param Request $request @return \Symfony\Component\HttpFoundation\Response @Security("has_role('ROLE_SUPER_ADMIN')")
[ "Create", "a", "new", "user" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/UserController.php#L133-L159
CampaignChain/core
Controller/UserController.php
UserController.toggleEnablingAction
public function toggleEnablingAction(User $userToEdit) { // only normal users/admins can be changed if (!$userToEdit->isSuperAdmin()) { /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->get('fos_user.user_manager'); $userToEdit->setEnabled(!$userToEdit->isEnabled()); $userManager->updateUser($userToEdit); $this->addFlash( 'info', $userToEdit->isEnabled() ? 'User '.$userToEdit->getNameAndUsername().' enabled' : 'User '.$userToEdit->getNameAndUsername().' disabled' ); } else { $this->addFlash('warning', 'Users with super admin privileges can not be disabled'); } return $this->redirectToRoute('campaignchain_core_user'); }
php
public function toggleEnablingAction(User $userToEdit) { // only normal users/admins can be changed if (!$userToEdit->isSuperAdmin()) { /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->get('fos_user.user_manager'); $userToEdit->setEnabled(!$userToEdit->isEnabled()); $userManager->updateUser($userToEdit); $this->addFlash( 'info', $userToEdit->isEnabled() ? 'User '.$userToEdit->getNameAndUsername().' enabled' : 'User '.$userToEdit->getNameAndUsername().' disabled' ); } else { $this->addFlash('warning', 'Users with super admin privileges can not be disabled'); } return $this->redirectToRoute('campaignchain_core_user'); }
[ "public", "function", "toggleEnablingAction", "(", "User", "$", "userToEdit", ")", "{", "// only normal users/admins can be changed", "if", "(", "!", "$", "userToEdit", "->", "isSuperAdmin", "(", ")", ")", "{", "/** @var $userManager \\FOS\\UserBundle\\Model\\UserManagerInt...
Toggle enabled state of a user @param User $userToEdit @return \Symfony\Component\HttpFoundation\RedirectResponse @Security("has_role('ROLE_SUPER_ADMIN')")
[ "Toggle", "enabled", "state", "of", "a", "user" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/UserController.php#L169-L192
wisp-x/hopephp
hopephp/library/hope/Log.php
Log.save
public static function save() { $path = RUNTIME_PATH . Config::get('log.path') . DS; if (!is_dir($path)) { File::createFolder($path); } if (isset($_SERVER['HTTP_HOST'])) { $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } else { $current_uri = "cmd:" . implode(' ', $_SERVER['argv']); } $runtime = round(microtime(true) - HOPE_START_TIME, 10); $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; $time_str = ' [运行时间:' . number_format($runtime, 6) . 's] [吞吐率:' . $reqs . 'req/s]'; $memory_use = number_format((memory_get_usage() - HOPE_START_MEM) / 1024, 2); $memory_str = ' [内存消耗:' . $memory_use . 'kb]'; $file_load = ' [文件加载:' . count(get_included_files()) . ']'; $message = '[ info ] [Url:' . $current_uri . ']' . $time_str . $memory_str . $file_load; self::record($message); $files = File::getFolder($path)['file']; if (count($files)) { foreach ($files as $file) { if ((filemtime($path . $file) + 3600 * 24 * (Config::get('log.time'))) <= time()) { @unlink($path . $file); } } } $name = date('Y-m-d') . '.log'; foreach (self::$log as $value) { file_put_contents($path . $name, '[' . date('Y-m-d h:i:s') . '] ' . $value . "\r\n", FILE_APPEND); } return true; }
php
public static function save() { $path = RUNTIME_PATH . Config::get('log.path') . DS; if (!is_dir($path)) { File::createFolder($path); } if (isset($_SERVER['HTTP_HOST'])) { $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } else { $current_uri = "cmd:" . implode(' ', $_SERVER['argv']); } $runtime = round(microtime(true) - HOPE_START_TIME, 10); $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; $time_str = ' [运行时间:' . number_format($runtime, 6) . 's] [吞吐率:' . $reqs . 'req/s]'; $memory_use = number_format((memory_get_usage() - HOPE_START_MEM) / 1024, 2); $memory_str = ' [内存消耗:' . $memory_use . 'kb]'; $file_load = ' [文件加载:' . count(get_included_files()) . ']'; $message = '[ info ] [Url:' . $current_uri . ']' . $time_str . $memory_str . $file_load; self::record($message); $files = File::getFolder($path)['file']; if (count($files)) { foreach ($files as $file) { if ((filemtime($path . $file) + 3600 * 24 * (Config::get('log.time'))) <= time()) { @unlink($path . $file); } } } $name = date('Y-m-d') . '.log'; foreach (self::$log as $value) { file_put_contents($path . $name, '[' . date('Y-m-d h:i:s') . '] ' . $value . "\r\n", FILE_APPEND); } return true; }
[ "public", "static", "function", "save", "(", ")", "{", "$", "path", "=", "RUNTIME_PATH", ".", "Config", "::", "get", "(", "'log.path'", ")", ".", "DS", ";", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "File", "::", "createFolder", "(...
保存日志信息 @return bool
[ "保存日志信息" ]
train
https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/hope/Log.php#L55-L94
CampaignChain/core
Controller/REST/RootController.php
RootController.getPackagesAction
public function getPackagesAction() { $qb = $this->getQueryBuilder(); $qb->select(PackageController::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b'); $qb->orderBy('b.name'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
php
public function getPackagesAction() { $qb = $this->getQueryBuilder(); $qb->select(PackageController::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b'); $qb->orderBy('b.name'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
[ "public", "function", "getPackagesAction", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "PackageController", "::", "SELECT_STATEMENT", ")", ";", "$", "qb", "->", "from", "(", "'Campai...
Get a list of all installed Composer packages containing CampaignChain modules. Example Request =============== GET /api/v1/packages Example Response ================ [ { "id": 22, "packageType": "campaignchain-activity", "composerPackage": "campaignchain/activity-facebook", "description": "Collection of various Facebook activities, such as post or share a message.", "license": "Apache-2.0", "authors": { "name": "CampaignChain, Inc.", "email": "info@campaignchain.com\"" }, "homepage": "http://www.campaignchain.com", "version": "dev-master", "createdDate": "2015-11-26T11:08:29+0000" }, { "id": 25, "packageType": "campaignchain-activity", "composerPackage": "campaignchain/activity-gotowebinar", "description": "Include a Webinar into a campaign.", "license": "Apache-2.0", "authors": { "name": "CampaignChain, Inc.", "email": "info@campaignchain.com\"" }, "homepage": "http://www.campaignchain.com", "version": "dev-master", "createdDate": "2015-11-26T11:08:29+0000" }, { "id": 24, "packageType": "campaignchain-activity", "composerPackage": "campaignchain/activity-linkedin", "description": "Collection of various LinkedIn activities, such as tweeting and re-tweeting.", "license": "Apache-2.0", "authors": { "name": "CampaignChain, Inc.", "email": "info@campaignchain.com\"" }, "homepage": "http://www.campaignchain.com", "version": "dev-master", "createdDate": "2015-11-26T11:08:29+0000" } ] @ApiDoc( section="Core" )
[ "Get", "a", "list", "of", "all", "installed", "Composer", "packages", "containing", "CampaignChain", "modules", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L174-L185
CampaignChain/core
Controller/REST/RootController.php
RootController.getCampaignsAction
public function getCampaignsAction(ParamFetcher $paramFetcher) { try { $params = $paramFetcher->all(); $qb = $this->getQueryBuilder(); $qb->select('c'); $qb->from('CampaignChain\CoreBundle\Entity\Campaign', 'c'); if($params['moduleUri']){ $qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b'); $qb->from('CampaignChain\CoreBundle\Entity\Module', 'm'); $qb->andWhere('b.id = m.bundle'); $qb->andWhere('c.campaignModule = m.id'); foreach($params['moduleUri'] as $key => $moduleUri) { $moduleUriParts = explode('/', $moduleUri); $vendor = $moduleUriParts[0]; $project = $moduleUriParts[1]; $identifier = $moduleUriParts[2]; $moduleUriQuery[] = '(b.name = :package'.$key.' AND '.'m.identifier = :identifier'.$key.')'; $qb->setParameter('package'.$key, $vendor . '/' . $project); $qb->setParameter('identifier'.$key, $identifier); } $qb->andWhere(implode(' OR ', $moduleUriQuery)); } if($params['fromNow']){ foreach($params['fromNow'] as $fromNow) { switch($fromNow){ case 'done': $fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate < CURRENT_TIMESTAMP())'; break; case 'ongoing': $fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())'; break; case 'upcoming': $fromNowQuery[] = '(c.startDate > CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())'; break; } } $qb->andWhere(implode(' OR ', $fromNowQuery)); } if($params['status']){ foreach($params['status'] as $key => $status) { $statusQuery[] = 'c.status = :status' . $key; $qb->setParameter('status' . $key, $status); } $qb->andWhere(implode(' OR ', $statusQuery)); } $qb->orderBy('c.name'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); } catch (\Exception $e) { return $this->errorResponse($e->getMessage(), $e->getCode()); } }
php
public function getCampaignsAction(ParamFetcher $paramFetcher) { try { $params = $paramFetcher->all(); $qb = $this->getQueryBuilder(); $qb->select('c'); $qb->from('CampaignChain\CoreBundle\Entity\Campaign', 'c'); if($params['moduleUri']){ $qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b'); $qb->from('CampaignChain\CoreBundle\Entity\Module', 'm'); $qb->andWhere('b.id = m.bundle'); $qb->andWhere('c.campaignModule = m.id'); foreach($params['moduleUri'] as $key => $moduleUri) { $moduleUriParts = explode('/', $moduleUri); $vendor = $moduleUriParts[0]; $project = $moduleUriParts[1]; $identifier = $moduleUriParts[2]; $moduleUriQuery[] = '(b.name = :package'.$key.' AND '.'m.identifier = :identifier'.$key.')'; $qb->setParameter('package'.$key, $vendor . '/' . $project); $qb->setParameter('identifier'.$key, $identifier); } $qb->andWhere(implode(' OR ', $moduleUriQuery)); } if($params['fromNow']){ foreach($params['fromNow'] as $fromNow) { switch($fromNow){ case 'done': $fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate < CURRENT_TIMESTAMP())'; break; case 'ongoing': $fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())'; break; case 'upcoming': $fromNowQuery[] = '(c.startDate > CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())'; break; } } $qb->andWhere(implode(' OR ', $fromNowQuery)); } if($params['status']){ foreach($params['status'] as $key => $status) { $statusQuery[] = 'c.status = :status' . $key; $qb->setParameter('status' . $key, $status); } $qb->andWhere(implode(' OR ', $statusQuery)); } $qb->orderBy('c.name'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); } catch (\Exception $e) { return $this->errorResponse($e->getMessage(), $e->getCode()); } }
[ "public", "function", "getCampaignsAction", "(", "ParamFetcher", "$", "paramFetcher", ")", "{", "try", "{", "$", "params", "=", "$", "paramFetcher", "->", "all", "(", ")", ";", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "...
Get a list of Campaigns. Example Request =============== GET /api/v1/campaigns?fromNow[]=ongoing&moduleUri[]=campaignchain/campaign-scheduled/campaignchain-scheduled&status[]=open Example Response ================ [ { "id": 2, "timezone": "America/Paramaribo", "hasRelativeDates": false, "name": "Company Anniversary", "startDate": "2015-06-10T22:01:32+0000", "endDate": "2015-12-21T05:04:27+0000", "status": "open", "createdDate": "2015-11-26T11:08:29+0000" }, { "id": 3, "timezone": "Asia/Tashkent", "hasRelativeDates": false, "name": "Customer Win Story", "startDate": "2015-09-28T07:02:39+0000", "endDate": "2016-04-18T01:44:23+0000", "status": "open", "createdDate": "2015-11-26T11:08:29+0000" } ] @ApiDoc( section="Core" ) @REST\QueryParam( name="fromNow", map=true, requirements="(done|ongoing|upcoming)", description="Filters per start and end date, options: 'upcoming' (start date is after now), 'ongoing' (start date is before and end date after now), 'done' (end date is before now)." ) @REST\QueryParam( name="status", map=true, requirements="(open|closed|paused|background process|interaction required)", description="Workflow status of a campaign." ) @REST\QueryParam( name="moduleUri", map=true, requirements="[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*", description="The module URI of a campaign module, e.g. campaignchain/campaign-scheduled/campaignchain-scheduled." )
[ "Get", "a", "list", "of", "Campaigns", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L244-L309
CampaignChain/core
Controller/REST/RootController.php
RootController.getChannelsAction
public function getChannelsAction() { $qb = $this->getQueryBuilder(); $qb->select(ModuleController::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\ChannelModule', 'm'); $qb->join('m.bundle', 'b'); $qb->where('b.id = m.bundle'); $qb->orderBy('m.identifier'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
php
public function getChannelsAction() { $qb = $this->getQueryBuilder(); $qb->select(ModuleController::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\ChannelModule', 'm'); $qb->join('m.bundle', 'b'); $qb->where('b.id = m.bundle'); $qb->orderBy('m.identifier'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
[ "public", "function", "getChannelsAction", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "ModuleController", "::", "SELECT_STATEMENT", ")", ";", "$", "qb", "->", "from", "(", "'Campaig...
Get a list of all installed Channels. Example Request =============== GET /api/v1/channels Example Response ================ [ { "composerPackage": "campaignchain/channel-facebook", "moduleIdentifier": "campaignchain-facebook", "displayName": "Facebook", "routes": { "new": "campaignchain_channel_facebook_create" }, "hooks": { "default": { "campaignchain-assignee": true } }, "createdDate": "2015-11-26T11:08:29+0000" }, { "composerPackage": "campaignchain/channel-linkedin", "moduleIdentifier": "campaignchain-linkedin", "displayName": "LinkedIn", "routes": { "new": "campaignchain_channel_linkedin_create" }, "hooks": { "default": { "campaignchain-assignee": true } }, "createdDate": "2015-11-26T11:08:29+0000" }, { "composerPackage": "campaignchain/channel-twitter", "moduleIdentifier": "campaignchain-twitter", "displayName": "Twitter", "routes": { "new": "campaignchain_channel_twitter_create" }, "hooks": { "default": { "campaignchain-assignee": true } }, "createdDate": "2015-11-26T11:08:29+0000" } ] @ApiDoc( section="Core" )
[ "Get", "a", "list", "of", "all", "installed", "Channels", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L371-L384
CampaignChain/core
Controller/REST/RootController.php
RootController.getRoutesAction
public function getRoutesAction() { $response = array(); $schemeAndHost = $this->get('request_stack')->getCurrentRequest()->getSchemeAndHttpHost(); // Get rid of dev environment (app_dev.php). $baseUrl = $this->get('router')->getContext()->getBaseUrl(); $this->get('router')->getContext()->setBaseUrl(''); $routeCollection = $this->get('router')->getRouteCollection(); foreach ($routeCollection->all() as $name => $route) { $options = $route->getOptions(); if( isset($options['campaignchain']) && isset($options['campaignchain']['rest']) && isset($options['campaignchain']['rest']['expose']) && $options['campaignchain']['rest']['expose'] ){ $routeData = array( 'url' => $schemeAndHost.$this->generateUrl($name), 'name' => $name, ); if(isset($options['campaignchain']['description'])){ $routeData['description'] = $options['campaignchain']['description']; } $response[] = $routeData; } } // Reset to previous environment. $this->get('router')->getContext()->setBaseUrl($baseUrl); return $this->response( $response ); }
php
public function getRoutesAction() { $response = array(); $schemeAndHost = $this->get('request_stack')->getCurrentRequest()->getSchemeAndHttpHost(); // Get rid of dev environment (app_dev.php). $baseUrl = $this->get('router')->getContext()->getBaseUrl(); $this->get('router')->getContext()->setBaseUrl(''); $routeCollection = $this->get('router')->getRouteCollection(); foreach ($routeCollection->all() as $name => $route) { $options = $route->getOptions(); if( isset($options['campaignchain']) && isset($options['campaignchain']['rest']) && isset($options['campaignchain']['rest']['expose']) && $options['campaignchain']['rest']['expose'] ){ $routeData = array( 'url' => $schemeAndHost.$this->generateUrl($name), 'name' => $name, ); if(isset($options['campaignchain']['description'])){ $routeData['description'] = $options['campaignchain']['description']; } $response[] = $routeData; } } // Reset to previous environment. $this->get('router')->getContext()->setBaseUrl($baseUrl); return $this->response( $response ); }
[ "public", "function", "getRoutesAction", "(", ")", "{", "$", "response", "=", "array", "(", ")", ";", "$", "schemeAndHost", "=", "$", "this", "->", "get", "(", "'request_stack'", ")", "->", "getCurrentRequest", "(", ")", "->", "getSchemeAndHttpHost", "(", ...
Get a list of system URLs, so-called routes. Example Request =============== GET /api/v1/routes Example Response ================ [ { "url": "https://www.example.com/", "name": "campaignchain_core_homepage", "description": "The start page" }, { "url": "https://www.example.com/about/", "name": "campaignchain_core_about", "description": "Read about CampaignChain" }, { "url": "https://www.example.com/plan", "name": "campaignchain_core_plan", "description": "Plan campaigns" }, { "url": "https://www.example.com/execute/", "name": "campaignchain_core_execute", "description": "View upcoming actions" }, { "url": "https://www.example.com/campaign/new/", "name": "campaignchain_core_campaign_new", "description": "Create a new campaign" } ] @ApiDoc( section="Core" )
[ "Get", "a", "list", "of", "system", "URLs", "so", "-", "called", "routes", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L429-L468
CampaignChain/core
Controller/REST/RootController.php
RootController.getUsersAction
public function getUsersAction() { $qb = $this->getQueryBuilder(); $qb->select(UserController::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\User', 'u'); $qb->orderBy('u.username'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
php
public function getUsersAction() { $qb = $this->getQueryBuilder(); $qb->select(UserController::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\User', 'u'); $qb->orderBy('u.username'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
[ "public", "function", "getUsersAction", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "UserController", "::", "SELECT_STATEMENT", ")", ";", "$", "qb", "->", "from", "(", "'CampaignChai...
Get a list of all users. Example Request =============== GET /api/v1/users Example Response ================ [ { "id": 1, "username": "admin", "firstName": "Sandro", "lastName": "Groganz", "email": "admin@example.com", "roles": [ "ROLE_SUPER_ADMIN" ], "language": "en_US", "locale": "en_US", "timezone": "UTC", "currency": "USD", "dateFormat": "yyyy-MM-dd", "timeFormat": "HH:mm", "profileImage": "avatar/4d6e7d832be2ab4c.jpg" }, { "id": 2, "username": "hipolito_marks", "firstName": "Danial", "lastName": "Smith", "email": "user1@example.com", "roles": [ "ROLE_ADMIN" ], "language": "en_US", "locale": "en_US", "timezone": "Antarctica/Mawson", "currency": "USD", "dateFormat": "yyyy-MM-dd", "timeFormat": "HH:mm", "profileImage": "avatar/c44d95581d3b5df4.jpg" } ] @ApiDoc( section="Core" )
[ "Get", "a", "list", "of", "all", "users", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L522-L533
canis-io/lumen-jwt-auth
src/Adapters/Lcobucci/Processor.php
Processor.validateToken
private function validateToken(JwtToken $token, $isRefresh = false) { $data = new ValidationData(); if (isset($this->config['issuer'])) { $data->setIssuer($this->config['issuer']); } if (isset($this->config['audience'])) { $data->setAudience($this->config['audience']); } if ($isRefresh) { $data->setExpiration(time() - $this->config['refreshOffsetAllowance']); } if (!$token->validate($data)) { return false; } return true; }
php
private function validateToken(JwtToken $token, $isRefresh = false) { $data = new ValidationData(); if (isset($this->config['issuer'])) { $data->setIssuer($this->config['issuer']); } if (isset($this->config['audience'])) { $data->setAudience($this->config['audience']); } if ($isRefresh) { $data->setExpiration(time() - $this->config['refreshOffsetAllowance']); } if (!$token->validate($data)) { return false; } return true; }
[ "private", "function", "validateToken", "(", "JwtToken", "$", "token", ",", "$", "isRefresh", "=", "false", ")", "{", "$", "data", "=", "new", "ValidationData", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'issuer'", "]", ...
Validate token with validation data @param JwtToken $token @param boolean $isRefresh Is a token refresh happening @return boolean
[ "Validate", "token", "with", "validation", "data" ]
train
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/Adapters/Lcobucci/Processor.php#L47-L63
cornernote/yii-email-module
email/commands/EmailSpoolCommand.php
EmailSpoolCommand.actionLoop
public function actionLoop($loopLimit = 1000, $spoolLimit = 10) { for ($i = 0; $i < $loopLimit; $i++) { $done = Yii::app()->emailManager->spool($spoolLimit); if ($done) { for ($i = 0; $i < $done; $i++) { echo '.'; } } sleep(1); } }
php
public function actionLoop($loopLimit = 1000, $spoolLimit = 10) { for ($i = 0; $i < $loopLimit; $i++) { $done = Yii::app()->emailManager->spool($spoolLimit); if ($done) { for ($i = 0; $i < $done; $i++) { echo '.'; } } sleep(1); } }
[ "public", "function", "actionLoop", "(", "$", "loopLimit", "=", "1000", ",", "$", "spoolLimit", "=", "10", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "loopLimit", ";", "$", "i", "++", ")", "{", "$", "done", "=", "Yii", ...
Sends emails in a continuous loop
[ "Sends", "emails", "in", "a", "continuous", "loop" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/commands/EmailSpoolCommand.php#L36-L47
CampaignChain/core
EntityService/MilestoneService.php
MilestoneService.getIcons
public function getIcons($milestone) { // Compose the channel icon path $bundlePath = $milestone->getMilestoneModule()->getBundle()->getWebAssetsPath(); $bundleName = $milestone->getMilestoneModule()->getBundle()->getName(); $iconName = str_replace('campaignchain/', '', str_replace('-', '_', $bundleName)).'.png'; $icon['16px'] = '/'.$bundlePath.'/images/icons/16x16/'.$iconName; $icon['24px'] = '/'.$bundlePath.'/images/icons/24x24/'.$iconName; return $icon; }
php
public function getIcons($milestone) { // Compose the channel icon path $bundlePath = $milestone->getMilestoneModule()->getBundle()->getWebAssetsPath(); $bundleName = $milestone->getMilestoneModule()->getBundle()->getName(); $iconName = str_replace('campaignchain/', '', str_replace('-', '_', $bundleName)).'.png'; $icon['16px'] = '/'.$bundlePath.'/images/icons/16x16/'.$iconName; $icon['24px'] = '/'.$bundlePath.'/images/icons/24x24/'.$iconName; return $icon; }
[ "public", "function", "getIcons", "(", "$", "milestone", ")", "{", "// Compose the channel icon path", "$", "bundlePath", "=", "$", "milestone", "->", "getMilestoneModule", "(", ")", "->", "getBundle", "(", ")", "->", "getWebAssetsPath", "(", ")", ";", "$", "b...
Compose the milestone icon path @param $channel @return mixed
[ "Compose", "the", "milestone", "icon", "path" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/MilestoneService.php#L123-L133
prooph/link-process-manager
src/Controller/Factory/ProcessManagerControllerFactory.php
ProcessManagerControllerFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $con = new ProcessManagerController(); $con->setScriptLocation(ScriptLocation::fromPath(Definition::getScriptsDir())); $con->setLocationTranslator($serviceLocator->getServiceLocator()->get('prooph.link.app.location_translator')); $con->setWorkflowFinder($serviceLocator->getServiceLocator()->get(\Prooph\Link\ProcessManager\Projection\Workflow\WorkflowFinder::class)); return $con; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $con = new ProcessManagerController(); $con->setScriptLocation(ScriptLocation::fromPath(Definition::getScriptsDir())); $con->setLocationTranslator($serviceLocator->getServiceLocator()->get('prooph.link.app.location_translator')); $con->setWorkflowFinder($serviceLocator->getServiceLocator()->get(\Prooph\Link\ProcessManager\Projection\Workflow\WorkflowFinder::class)); return $con; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "con", "=", "new", "ProcessManagerController", "(", ")", ";", "$", "con", "->", "setScriptLocation", "(", "ScriptLocation", "::", "fromPath", "(", "Definit...
Create service @param ServiceLocatorInterface $serviceLocator @return ProcessManagerController
[ "Create", "service" ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Controller/Factory/ProcessManagerControllerFactory.php#L35-L45
JustBlackBird/handlebars.php-helpers
src/Collection/FirstHelper.php
FirstHelper.execute
public function execute(Template $template, Context $context, $args, $source) { $parsed_args = $template->parseArguments($args); if (count($parsed_args) != 1) { throw new \InvalidArgumentException( '"first" helper expects exactly one argument.' ); } $collection = $context->get($parsed_args[0]); if (!is_array($collection) && !($collection instanceof \Traversable)) { throw new \InvalidArgumentException('Wrong type of the argument in the "first" helper.'); } if (is_array($collection)) { return reset($collection); } // "reset" function does not work with \Traversable in HHVM. Thus we // need to get the element manually. while ($collection instanceof \IteratorAggregate) { $collection = $collection->getIterator(); } $collection->rewind(); return $collection->valid() ? $collection->current() : false; }
php
public function execute(Template $template, Context $context, $args, $source) { $parsed_args = $template->parseArguments($args); if (count($parsed_args) != 1) { throw new \InvalidArgumentException( '"first" helper expects exactly one argument.' ); } $collection = $context->get($parsed_args[0]); if (!is_array($collection) && !($collection instanceof \Traversable)) { throw new \InvalidArgumentException('Wrong type of the argument in the "first" helper.'); } if (is_array($collection)) { return reset($collection); } // "reset" function does not work with \Traversable in HHVM. Thus we // need to get the element manually. while ($collection instanceof \IteratorAggregate) { $collection = $collection->getIterator(); } $collection->rewind(); return $collection->valid() ? $collection->current() : false; }
[ "public", "function", "execute", "(", "Template", "$", "template", ",", "Context", "$", "context", ",", "$", "args", ",", "$", "source", ")", "{", "$", "parsed_args", "=", "$", "template", "->", "parseArguments", "(", "$", "args", ")", ";", "if", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Collection/FirstHelper.php#L38-L64
tableau-mkt/elomentary
src/Api/Data/Contact/Subscription.php
Subscription.search
public function search($search, array $options = array()) { return $this->get('data/contact/' . rawurlencode($this->contactId) . '/email/groups/subscription', array_merge(array( 'search' => $search, ), $options)); }
php
public function search($search, array $options = array()) { return $this->get('data/contact/' . rawurlencode($this->contactId) . '/email/groups/subscription', array_merge(array( 'search' => $search, ), $options)); }
[ "public", "function", "search", "(", "$", "search", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "get", "(", "'data/contact/'", ".", "rawurlencode", "(", "$", "this", "->", "contactId", ")", ".", "'/email...
{@inheritdoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Data/Contact/Subscription.php#L45-L49
tableau-mkt/elomentary
src/Api/Data/Contact/Subscription.php
Subscription.update
public function update($id, $subscription_data) { return $this->put('data/contact/' . rawurlencode($this->contactId) . '/email/group/' . rawurlencode($id) . '/subscription', $subscription_data); }
php
public function update($id, $subscription_data) { return $this->put('data/contact/' . rawurlencode($this->contactId) . '/email/group/' . rawurlencode($id) . '/subscription', $subscription_data); }
[ "public", "function", "update", "(", "$", "id", ",", "$", "subscription_data", ")", "{", "return", "$", "this", "->", "put", "(", "'data/contact/'", ".", "rawurlencode", "(", "$", "this", "->", "contactId", ")", ".", "'/email/group/'", ".", "rawurlencode", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Data/Contact/Subscription.php#L64-L66
joomla-framework/twitter-api
src/Directmessages.php
Directmessages.getDirectMessages
public function getDirectMessages($sinceId = 0, $maxId = 0, $count = 20, $entities = null, $skipStatus = null) { // Check the rate limit for remaining hits $this->checkRateLimit('direct_messages'); // Set the API path $path = '/direct_messages.json'; $data = array(); // Check if since_id is specified. if ($sinceId) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId) { $data['max_id'] = $maxId; } // Check if count is specified. if ($count) { $data['count'] = $count; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is specified. if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
php
public function getDirectMessages($sinceId = 0, $maxId = 0, $count = 20, $entities = null, $skipStatus = null) { // Check the rate limit for remaining hits $this->checkRateLimit('direct_messages'); // Set the API path $path = '/direct_messages.json'; $data = array(); // Check if since_id is specified. if ($sinceId) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId) { $data['max_id'] = $maxId; } // Check if count is specified. if ($count) { $data['count'] = $count; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is specified. if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
[ "public", "function", "getDirectMessages", "(", "$", "sinceId", "=", "0", ",", "$", "maxId", "=", "0", ",", "$", "count", "=", "20", ",", "$", "entities", "=", "null", ",", "$", "skipStatus", "=", "null", ")", "{", "// Check the rate limit for remaining hi...
Method to get the most recent direct messages sent to the authenticating user. @param integer $sinceId Returns results with an ID greater than (that is, more recent than) the specified ID. @param integer $maxId Returns results with an ID less than (that is, older than) or equal to the specified ID. @param integer $count Specifies the number of direct messages to try and retrieve, up to a maximum of 200. @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. @param boolean $skipStatus When set to either true, t or 1 statuses will not be included in the returned user objects. @return array The decoded JSON response @since 1.0
[ "Method", "to", "get", "the", "most", "recent", "direct", "messages", "sent", "to", "the", "authenticating", "user", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Directmessages.php#L33-L75
joomla-framework/twitter-api
src/Directmessages.php
Directmessages.getSentDirectMessages
public function getSentDirectMessages($sinceId = 0, $maxId = 0, $count = 20, $page = 0, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('direct_messages', 'sent'); // Set the API path $path = '/direct_messages/sent.json'; $data = array(); // Check if since_id is specified. if ($sinceId) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId) { $data['max_id'] = $maxId; } // Check if count is specified. if ($count) { $data['count'] = $count; } // Check if page is specified. if ($page) { $data['page'] = $page; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
php
public function getSentDirectMessages($sinceId = 0, $maxId = 0, $count = 20, $page = 0, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('direct_messages', 'sent'); // Set the API path $path = '/direct_messages/sent.json'; $data = array(); // Check if since_id is specified. if ($sinceId) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId) { $data['max_id'] = $maxId; } // Check if count is specified. if ($count) { $data['count'] = $count; } // Check if page is specified. if ($page) { $data['page'] = $page; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
[ "public", "function", "getSentDirectMessages", "(", "$", "sinceId", "=", "0", ",", "$", "maxId", "=", "0", ",", "$", "count", "=", "20", ",", "$", "page", "=", "0", ",", "$", "entities", "=", "null", ")", "{", "// Check the rate limit for remaining hits", ...
Method to get the most recent direct messages sent by the authenticating user. @param integer $sinceId Returns results with an ID greater than (that is, more recent than) the specified ID. @param integer $maxId Returns results with an ID less than (that is, older than) or equal to the specified ID. @param integer $count Specifies the number of direct messages to try and retrieve, up to a maximum of 200. @param integer $page Specifies the page of results to retrieve. @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. @return array The decoded JSON response @since 1.0
[ "Method", "to", "get", "the", "most", "recent", "direct", "messages", "sent", "by", "the", "authenticating", "user", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Directmessages.php#L91-L133
joomla-framework/twitter-api
src/Directmessages.php
Directmessages.sendDirectMessages
public function sendDirectMessages($user, $text) { // Set the API path $path = '/direct_messages/new.json'; // Determine which type of data was passed for $user if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } $data['text'] = $text; // Send the request. return $this->sendRequest($path, 'POST', $data); }
php
public function sendDirectMessages($user, $text) { // Set the API path $path = '/direct_messages/new.json'; // Determine which type of data was passed for $user if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } $data['text'] = $text; // Send the request. return $this->sendRequest($path, 'POST', $data); }
[ "public", "function", "sendDirectMessages", "(", "$", "user", ",", "$", "text", ")", "{", "// Set the API path", "$", "path", "=", "'/direct_messages/new.json'", ";", "// Determine which type of data was passed for $user", "if", "(", "is_numeric", "(", "$", "user", ")...
Method to send a new direct message to the specified user from the authenticating user. @param mixed $user Either an integer containing the user ID or a string containing the screen name. @param string $text The text of your direct message. Be sure to keep the message under 140 characters. @return array The decoded JSON response @since 1.0 @throws \RuntimeException
[ "Method", "to", "send", "a", "new", "direct", "message", "to", "the", "specified", "user", "from", "the", "authenticating", "user", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Directmessages.php#L146-L170
cornernote/yii-email-module
email/controllers/EmailSpoolController.php
EmailSpoolController.actionIndex
public function actionIndex() { $emailSpool = new EmailSpool('search'); if (!empty($_GET['EmailSpool'])) $emailSpool->attributes = $_GET['EmailSpool']; $this->render('index', array( 'emailSpool' => $emailSpool, )); }
php
public function actionIndex() { $emailSpool = new EmailSpool('search'); if (!empty($_GET['EmailSpool'])) $emailSpool->attributes = $_GET['EmailSpool']; $this->render('index', array( 'emailSpool' => $emailSpool, )); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "emailSpool", "=", "new", "EmailSpool", "(", "'search'", ")", ";", "if", "(", "!", "empty", "(", "$", "_GET", "[", "'EmailSpool'", "]", ")", ")", "$", "emailSpool", "->", "attributes", "=", "$", ...
Index
[ "Index" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/controllers/EmailSpoolController.php#L36-L45
cornernote/yii-email-module
email/controllers/EmailSpoolController.php
EmailSpoolController.actionPreview
public function actionPreview($id) { $emailSpool = $this->loadModel($id); echo CHtml::tag('div', array('style' => 'font-family: Arial; font-weight: bold;'), $emailSpool->subject) . '<hr/>'; echo $emailSpool->swiftMessage->getBody(); }
php
public function actionPreview($id) { $emailSpool = $this->loadModel($id); echo CHtml::tag('div', array('style' => 'font-family: Arial; font-weight: bold;'), $emailSpool->subject) . '<hr/>'; echo $emailSpool->swiftMessage->getBody(); }
[ "public", "function", "actionPreview", "(", "$", "id", ")", "{", "$", "emailSpool", "=", "$", "this", "->", "loadModel", "(", "$", "id", ")", ";", "echo", "CHtml", "::", "tag", "(", "'div'", ",", "array", "(", "'style'", "=>", "'font-family: Arial; font-...
Preview @param $id
[ "Preview" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/controllers/EmailSpoolController.php#L64-L69
CampaignChain/core
Util/DateTimeUtil.php
DateTimeUtil.modifyTimezoneOffset
public function modifyTimezoneOffset(\DateTime $dateTime){ $userTimezone = new \DateTimeZone($this->container->get('session')->get('campaignchain.timezone')); $offset = $userTimezone->getOffset($dateTime); return $dateTime->modify('-'.$offset.' sec'); }
php
public function modifyTimezoneOffset(\DateTime $dateTime){ $userTimezone = new \DateTimeZone($this->container->get('session')->get('campaignchain.timezone')); $offset = $userTimezone->getOffset($dateTime); return $dateTime->modify('-'.$offset.' sec'); }
[ "public", "function", "modifyTimezoneOffset", "(", "\\", "DateTime", "$", "dateTime", ")", "{", "$", "userTimezone", "=", "new", "\\", "DateTimeZone", "(", "$", "this", "->", "container", "->", "get", "(", "'session'", ")", "->", "get", "(", "'campaignchain....
/* A Symfony form sends datetime back in UTC timezone, because no timezone string has been provided with the posted data.
[ "/", "*", "A", "Symfony", "form", "sends", "datetime", "back", "in", "UTC", "timezone", "because", "no", "timezone", "string", "has", "been", "provided", "with", "the", "posted", "data", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/DateTimeUtil.php#L60-L64
swoft-cloud/swoft-console
src/Router/HandlerAdapter.php
HandlerAdapter.getBindParams
private function getBindParams(string $className, string $methodName): array { $reflectClass = new \ReflectionClass($className); $reflectMethod = $reflectClass->getMethod($methodName); $reflectParams = $reflectMethod->getParameters(); // binding params $bindParams = []; foreach ($reflectParams as $key => $reflectParam) { $reflectType = $reflectParam->getType(); // undefined type of the param if ($reflectType === null) { $bindParams[$key] = null; continue; } /** * defined type of the param * @notice \ReflectType::getName() is not supported in PHP 7.0, that is why use __toString() */ $type = $reflectType->__toString(); if ($type === Output::class) { $bindParams[$key] = \output(); } elseif ($type === Input::class) { $bindParams[$key] = \input(); } else { $bindParams[$key] = null; } } return $bindParams; }
php
private function getBindParams(string $className, string $methodName): array { $reflectClass = new \ReflectionClass($className); $reflectMethod = $reflectClass->getMethod($methodName); $reflectParams = $reflectMethod->getParameters(); // binding params $bindParams = []; foreach ($reflectParams as $key => $reflectParam) { $reflectType = $reflectParam->getType(); // undefined type of the param if ($reflectType === null) { $bindParams[$key] = null; continue; } /** * defined type of the param * @notice \ReflectType::getName() is not supported in PHP 7.0, that is why use __toString() */ $type = $reflectType->__toString(); if ($type === Output::class) { $bindParams[$key] = \output(); } elseif ($type === Input::class) { $bindParams[$key] = \input(); } else { $bindParams[$key] = null; } } return $bindParams; }
[ "private", "function", "getBindParams", "(", "string", "$", "className", ",", "string", "$", "methodName", ")", ":", "array", "{", "$", "reflectClass", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "$", "reflectMethod", "=", "$", "r...
get binded params @param string $className @param string $methodName @return array @throws \ReflectionException
[ "get", "binded", "params" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Router/HandlerAdapter.php#L50-L82
swoft-cloud/swoft-console
src/Router/HandlerAdapter.php
HandlerAdapter.executeCommandByCoroutine
private function executeCommandByCoroutine($class, string $method, bool $server, $bindParams) { Coroutine::create(function () use ($class, $method, $server, $bindParams) { $this->beforeCommand(\get_parent_class($class), $method, $server); PhpHelper::call([$class, $method], $bindParams); $this->afterCommand($method, $server); }); }
php
private function executeCommandByCoroutine($class, string $method, bool $server, $bindParams) { Coroutine::create(function () use ($class, $method, $server, $bindParams) { $this->beforeCommand(\get_parent_class($class), $method, $server); PhpHelper::call([$class, $method], $bindParams); $this->afterCommand($method, $server); }); }
[ "private", "function", "executeCommandByCoroutine", "(", "$", "class", ",", "string", "$", "method", ",", "bool", "$", "server", ",", "$", "bindParams", ")", "{", "Coroutine", "::", "create", "(", "function", "(", ")", "use", "(", "$", "class", ",", "$",...
execute command by coroutine @param mixed $class @param string $method @param bool $server @param array $bindParams
[ "execute", "command", "by", "coroutine" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Router/HandlerAdapter.php#L92-L99
swoft-cloud/swoft-console
src/Router/HandlerAdapter.php
HandlerAdapter.executeCommand
private function executeCommand($class, string $method, bool $server, $bindParams) { $this->beforeCommand(\get_parent_class($class), $method, $server); PhpHelper::call([$class, $method], $bindParams); $this->afterCommand($method, $server); }
php
private function executeCommand($class, string $method, bool $server, $bindParams) { $this->beforeCommand(\get_parent_class($class), $method, $server); PhpHelper::call([$class, $method], $bindParams); $this->afterCommand($method, $server); }
[ "private", "function", "executeCommand", "(", "$", "class", ",", "string", "$", "method", ",", "bool", "$", "server", ",", "$", "bindParams", ")", "{", "$", "this", "->", "beforeCommand", "(", "\\", "get_parent_class", "(", "$", "class", ")", ",", "$", ...
execute command @param mixed $class @param string $method @param bool $server @param array $bindParams @throws \ReflectionException
[ "execute", "command" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Router/HandlerAdapter.php#L110-L115
swoft-cloud/swoft-console
src/Router/HandlerAdapter.php
HandlerAdapter.beforeCommand
private function beforeCommand(string $class, string $command, bool $server) { if ($server) { return; } $this->bootstrap(); BeanFactory::reload(); // 初始化 $spanId = 0; $logId = uniqid(); $uri = $class . '->' . $command; $contextData = [ 'logid' => $logId, 'spanid' => $spanId, 'uri' => $uri, 'requestTime' => microtime(true), ]; RequestContext::setContextData($contextData); }
php
private function beforeCommand(string $class, string $command, bool $server) { if ($server) { return; } $this->bootstrap(); BeanFactory::reload(); // 初始化 $spanId = 0; $logId = uniqid(); $uri = $class . '->' . $command; $contextData = [ 'logid' => $logId, 'spanid' => $spanId, 'uri' => $uri, 'requestTime' => microtime(true), ]; RequestContext::setContextData($contextData); }
[ "private", "function", "beforeCommand", "(", "string", "$", "class", ",", "string", "$", "command", ",", "bool", "$", "server", ")", "{", "if", "(", "$", "server", ")", "{", "return", ";", "}", "$", "this", "->", "bootstrap", "(", ")", ";", "BeanFact...
before command @param string $class @param string $command @param bool $server @throws \ReflectionException
[ "before", "command" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Router/HandlerAdapter.php#L125-L146
swoft-cloud/swoft-console
src/Router/HandlerAdapter.php
HandlerAdapter.afterCommand
private function afterCommand(string $command, bool $server) { if ($server) { return; } App::getLogger()->appendNoticeLog(true); }
php
private function afterCommand(string $command, bool $server) { if ($server) { return; } App::getLogger()->appendNoticeLog(true); }
[ "private", "function", "afterCommand", "(", "string", "$", "command", ",", "bool", "$", "server", ")", "{", "if", "(", "$", "server", ")", "{", "return", ";", "}", "App", "::", "getLogger", "(", ")", "->", "appendNoticeLog", "(", "true", ")", ";", "}...
after command @param string $command @param bool $server
[ "after", "command" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Router/HandlerAdapter.php#L154-L161
swoft-cloud/swoft-console
src/Router/HandlerAdapter.php
HandlerAdapter.bootstrap
private function bootstrap() { $defaultItems = [ LoadEnv::class, InitPhpEnv::class, LoadInitConfiguration::class, ]; foreach ($defaultItems as $bootstrapItem) { if (\class_exists($bootstrapItem)) { $itemInstance = new $bootstrapItem(); if ($itemInstance instanceof Bootable) { $itemInstance->bootstrap(); } } } }
php
private function bootstrap() { $defaultItems = [ LoadEnv::class, InitPhpEnv::class, LoadInitConfiguration::class, ]; foreach ($defaultItems as $bootstrapItem) { if (\class_exists($bootstrapItem)) { $itemInstance = new $bootstrapItem(); if ($itemInstance instanceof Bootable) { $itemInstance->bootstrap(); } } } }
[ "private", "function", "bootstrap", "(", ")", "{", "$", "defaultItems", "=", "[", "LoadEnv", "::", "class", ",", "InitPhpEnv", "::", "class", ",", "LoadInitConfiguration", "::", "class", ",", "]", ";", "foreach", "(", "$", "defaultItems", "as", "$", "boots...
bootstrap
[ "bootstrap" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Router/HandlerAdapter.php#L166-L181
opus-online/yii2-payment
lib/adapters/Estcard.php
Estcard.getLanguageCode
public function getLanguageCode($language) { switch ($language) { case PaymentHandlerBase::LANGUAGE_EN: case PaymentHandlerBase::LANGUAGE_ET: return $language; default: return PaymentHandlerBase::LANGUAGE_EN; } }
php
public function getLanguageCode($language) { switch ($language) { case PaymentHandlerBase::LANGUAGE_EN: case PaymentHandlerBase::LANGUAGE_ET: return $language; default: return PaymentHandlerBase::LANGUAGE_EN; } }
[ "public", "function", "getLanguageCode", "(", "$", "language", ")", "{", "switch", "(", "$", "language", ")", "{", "case", "PaymentHandlerBase", "::", "LANGUAGE_EN", ":", "case", "PaymentHandlerBase", "::", "LANGUAGE_ET", ":", "return", "$", "language", ";", "...
Estcard supports et, en, fi, de. Our system supports en, ru, et. @param string $language @return string
[ "Estcard", "supports", "et", "en", "fi", "de", ".", "Our", "system", "supports", "en", "ru", "et", "." ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/Estcard.php#L85-L94
opus-online/yii2-payment
lib/adapters/Estcard.php
Estcard.addMacSignature
private function addMacSignature(Dataset $dataset) { $macSource = $this->getMacSource($dataset, 'payment'); $keyPath = $this->getPkcKeyPath(); $signature = $this->signWithPrivateKey($keyPath, $macSource); $mac = bin2hex($signature); $dataset->setParam('mac', $mac); // Yes, the ID value in the form and the value in MAC are different $dataset->setParam('id', trim($dataset->getParam('id'))); $dataset->setParam('feedBackUrl', trim($this->getReturnUrl())); }
php
private function addMacSignature(Dataset $dataset) { $macSource = $this->getMacSource($dataset, 'payment'); $keyPath = $this->getPkcKeyPath(); $signature = $this->signWithPrivateKey($keyPath, $macSource); $mac = bin2hex($signature); $dataset->setParam('mac', $mac); // Yes, the ID value in the form and the value in MAC are different $dataset->setParam('id', trim($dataset->getParam('id'))); $dataset->setParam('feedBackUrl', trim($this->getReturnUrl())); }
[ "private", "function", "addMacSignature", "(", "Dataset", "$", "dataset", ")", "{", "$", "macSource", "=", "$", "this", "->", "getMacSource", "(", "$", "dataset", ",", "'payment'", ")", ";", "$", "keyPath", "=", "$", "this", "->", "getPkcKeyPath", "(", "...
Generates a MAC key that corresponds to the parameter set specified by the first parameter and adds it to the dataset (parameter 'mac') @param \opus\payment\services\payment\Dataset $dataset @return string
[ "Generates", "a", "MAC", "key", "that", "corresponds", "to", "the", "parameter", "set", "specified", "by", "the", "first", "parameter", "and", "adds", "it", "to", "the", "dataset", "(", "parameter", "mac", ")" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/Estcard.php#L103-L116
opus-online/yii2-payment
lib/adapters/Estcard.php
Estcard.getMacSource
private function getMacSource(Dataset $dataset, $requestType) { $this->formatParams($dataset); $macParams = $this->getNormalizedMacParams($dataset, $requestType); $source = implode($macParams); return $source; }
php
private function getMacSource(Dataset $dataset, $requestType) { $this->formatParams($dataset); $macParams = $this->getNormalizedMacParams($dataset, $requestType); $source = implode($macParams); return $source; }
[ "private", "function", "getMacSource", "(", "Dataset", "$", "dataset", ",", "$", "requestType", ")", "{", "$", "this", "->", "formatParams", "(", "$", "dataset", ")", ";", "$", "macParams", "=", "$", "this", "->", "getNormalizedMacParams", "(", "$", "datas...
Calculates MAC source for Estcard adapter (basic implode) @param \opus\payment\services\payment\Dataset $dataset @param string $requestType @return string
[ "Calculates", "MAC", "source", "for", "Estcard", "adapter", "(", "basic", "implode", ")" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/Estcard.php#L125-L132
joomla-framework/twitter-api
src/Followers.php
Followers.getFollowers
public function getFollowers($user, $cursor = null, $count = 0, $skipStatus = null, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('followers', 'ids'); // Determine which type of data was passed for $user if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } // Set the API path $path = '/followers/list.json'; // Check if cursor is specified if ($cursor !== null) { $data['cursor'] = $cursor; } // Check if count is specified if ($count !== null) { $data['count'] = $count; } // Check if skip_status is specified if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Check if entities is specified if ($entities !== null) { $data['entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
php
public function getFollowers($user, $cursor = null, $count = 0, $skipStatus = null, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('followers', 'ids'); // Determine which type of data was passed for $user if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } // Set the API path $path = '/followers/list.json'; // Check if cursor is specified if ($cursor !== null) { $data['cursor'] = $cursor; } // Check if count is specified if ($count !== null) { $data['count'] = $count; } // Check if skip_status is specified if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Check if entities is specified if ($entities !== null) { $data['entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
[ "public", "function", "getFollowers", "(", "$", "user", ",", "$", "cursor", "=", "null", ",", "$", "count", "=", "0", ",", "$", "skipStatus", "=", "null", ",", "$", "entities", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "$", "this...
Method to get an array of users the specified user is followed by. @param mixed $user Either an integer containing the user ID or a string containing the screen name. @param integer $cursor Causes the list of IDs to be broken into pages of no more than 5000 IDs at a time. The number of IDs returned is not guaranteed to be 5000 as suspended users are filtered out after connections are queried. If no cursor is provided, a value of -1 will be assumed, which is the first "page." @param integer $count Specifies the number of IDs attempt retrieval of, up to a maximum of 5,000 per distinct request. @param boolean $skipStatus When set to either true, t or 1, statuses will not be included in returned user objects. @param boolean $entities When set to either true, t or 1, each user will include a node called "entities,". This node offers a variety of metadata about the user in a discrete structure. @return array The decoded JSON response @since 1.2.0 @throws \RuntimeException
[ "Method", "to", "get", "an", "array", "of", "users", "the", "specified", "user", "is", "followed", "by", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Followers.php#L36-L85
CampaignChain/core
Entity/Scheduler.php
Scheduler.addJob
public function addJob(\CampaignChain\CoreBundle\Entity\Job $jobs) { $this->jobs[] = $jobs; return $this; }
php
public function addJob(\CampaignChain\CoreBundle\Entity\Job $jobs) { $this->jobs[] = $jobs; return $this; }
[ "public", "function", "addJob", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Job", "$", "jobs", ")", "{", "$", "this", "->", "jobs", "[", "]", "=", "$", "jobs", ";", "return", "$", "this", ";", "}" ]
Add jobs @param \CampaignChain\CoreBundle\Entity\Job $jobs @return Scheduler
[ "Add", "jobs" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/Scheduler.php#L108-L113
CampaignChain/core
Entity/Scheduler.php
Scheduler.removeJob
public function removeJob(\CampaignChain\CoreBundle\Entity\Job $jobs) { $this->jobs->removeElement($jobs); }
php
public function removeJob(\CampaignChain\CoreBundle\Entity\Job $jobs) { $this->jobs->removeElement($jobs); }
[ "public", "function", "removeJob", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Job", "$", "jobs", ")", "{", "$", "this", "->", "jobs", "->", "removeElement", "(", "$", "jobs", ")", ";", "}" ]
Remove jobs @param \CampaignChain\CoreBundle\Entity\Job $jobs
[ "Remove", "jobs" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/Scheduler.php#L120-L123
lokhman/silex-config
src/Silex/Provider/ConfigServiceProvider.php
ConfigServiceProvider.replaceTokens
public static function replaceTokens($data, $tokens) { if (is_string($data)) { return preg_replace_callback('/%(\w+)%/', function ($matches) use ($tokens) { $token = strtoupper($matches[1]); if (isset($tokens[$token])) { return $tokens[$token]; } return getenv($token) ?: $matches[0]; }, $data); } if (is_array($data)) { array_walk($data, function (&$value) use ($tokens) { $value = static::replaceTokens($value, $tokens); }); } return $data; }
php
public static function replaceTokens($data, $tokens) { if (is_string($data)) { return preg_replace_callback('/%(\w+)%/', function ($matches) use ($tokens) { $token = strtoupper($matches[1]); if (isset($tokens[$token])) { return $tokens[$token]; } return getenv($token) ?: $matches[0]; }, $data); } if (is_array($data)) { array_walk($data, function (&$value) use ($tokens) { $value = static::replaceTokens($value, $tokens); }); } return $data; }
[ "public", "static", "function", "replaceTokens", "(", "$", "data", ",", "$", "tokens", ")", "{", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "return", "preg_replace_callback", "(", "'/%(\\w+)%/'", ",", "function", "(", "$", "matches", ")", "...
Replaces tokens in the configuration. @param mixed $data Configuration @param array $tokens Tokens to replace @return mixed
[ "Replaces", "tokens", "in", "the", "configuration", "." ]
train
https://github.com/lokhman/silex-config/blob/72dfedefc3079d1b8498aa466e1afdcf25473e4a/src/Silex/Provider/ConfigServiceProvider.php#L54-L74
lokhman/silex-config
src/Silex/Provider/ConfigServiceProvider.php
ConfigServiceProvider.readFile
public static function readFile($dir, $path) { if (!pathinfo($path, PATHINFO_EXTENSION)) { $path .= '.json'; } if ($path[0] != '/') { $path = $dir.DIRECTORY_SEPARATOR.$path; } if (!is_file($path) || !is_readable($path)) { throw new \RuntimeException(sprintf('Unable to load configuration from "%s".', $path)); } $data = json_decode(file_get_contents($path), true); if (json_last_error() !== JSON_ERROR_NONE) { throw new \RuntimeException('Configuration JSON format is invalid.'); } if (isset($data['$extends']) && is_string($data['$extends'])) { $extends = static::readFile($dir, $data['$extends']); $data = array_replace_recursive($extends, $data); unset($data['$extends']); } return $data; }
php
public static function readFile($dir, $path) { if (!pathinfo($path, PATHINFO_EXTENSION)) { $path .= '.json'; } if ($path[0] != '/') { $path = $dir.DIRECTORY_SEPARATOR.$path; } if (!is_file($path) || !is_readable($path)) { throw new \RuntimeException(sprintf('Unable to load configuration from "%s".', $path)); } $data = json_decode(file_get_contents($path), true); if (json_last_error() !== JSON_ERROR_NONE) { throw new \RuntimeException('Configuration JSON format is invalid.'); } if (isset($data['$extends']) && is_string($data['$extends'])) { $extends = static::readFile($dir, $data['$extends']); $data = array_replace_recursive($extends, $data); unset($data['$extends']); } return $data; }
[ "public", "static", "function", "readFile", "(", "$", "dir", ",", "$", "path", ")", "{", "if", "(", "!", "pathinfo", "(", "$", "path", ",", "PATHINFO_EXTENSION", ")", ")", "{", "$", "path", ".=", "'.json'", ";", "}", "if", "(", "$", "path", "[", ...
Reads configuration file. @param string $dir Configuration directory @param string $path Configuration file path @throws \RuntimeException @return mixed
[ "Reads", "configuration", "file", "." ]
train
https://github.com/lokhman/silex-config/blob/72dfedefc3079d1b8498aa466e1afdcf25473e4a/src/Silex/Provider/ConfigServiceProvider.php#L86-L112
lokhman/silex-config
src/Silex/Provider/ConfigServiceProvider.php
ConfigServiceProvider.register
public function register(Container $app) { $app['config.dir'] = null; $app['config.params'] = []; $app['config.env.default'] = 'local'; $app['config.varname.default'] = 'SILEX_ENV'; $app['config'] = function (Container $app) { if (false === $app['config.dir'] = realpath($app['config.dir'])) { throw new \RuntimeException('Parameter "config.dir" should contain a valid path.'); } if (!isset($app['config.env'])) { $varname = $app['config.varname.default']; if (isset($app['config.varname'])) { $varname = $app['config.varname']; } $app['config.env'] = getenv($varname) ?: $app['config.env.default']; } $data = static::readFile($app['config.dir'], $app['config.env']); if (isset($data['$params']) && is_array($data['$params'])) { $app['config.params'] += $data['$params']; unset($data['$params']); } $params = ['__DIR__' => $app['config.dir'], '__ENV__' => $app['config.env']]; $params += array_change_key_case($app['config.params'], CASE_UPPER); $app['config.params'] = static::replaceTokens($params, $params); return $data; }; }
php
public function register(Container $app) { $app['config.dir'] = null; $app['config.params'] = []; $app['config.env.default'] = 'local'; $app['config.varname.default'] = 'SILEX_ENV'; $app['config'] = function (Container $app) { if (false === $app['config.dir'] = realpath($app['config.dir'])) { throw new \RuntimeException('Parameter "config.dir" should contain a valid path.'); } if (!isset($app['config.env'])) { $varname = $app['config.varname.default']; if (isset($app['config.varname'])) { $varname = $app['config.varname']; } $app['config.env'] = getenv($varname) ?: $app['config.env.default']; } $data = static::readFile($app['config.dir'], $app['config.env']); if (isset($data['$params']) && is_array($data['$params'])) { $app['config.params'] += $data['$params']; unset($data['$params']); } $params = ['__DIR__' => $app['config.dir'], '__ENV__' => $app['config.env']]; $params += array_change_key_case($app['config.params'], CASE_UPPER); $app['config.params'] = static::replaceTokens($params, $params); return $data; }; }
[ "public", "function", "register", "(", "Container", "$", "app", ")", "{", "$", "app", "[", "'config.dir'", "]", "=", "null", ";", "$", "app", "[", "'config.params'", "]", "=", "[", "]", ";", "$", "app", "[", "'config.env.default'", "]", "=", "'local'",...
{@inheritdoc}
[ "{" ]
train
https://github.com/lokhman/silex-config/blob/72dfedefc3079d1b8498aa466e1afdcf25473e4a/src/Silex/Provider/ConfigServiceProvider.php#L117-L150
lokhman/silex-config
src/Silex/Provider/ConfigServiceProvider.php
ConfigServiceProvider.boot
public function boot(Application $app) { foreach ($app['config'] as $key => $value) { $app[$key] = static::replaceTokens($value, $app['config.params']); } }
php
public function boot(Application $app) { foreach ($app['config'] as $key => $value) { $app[$key] = static::replaceTokens($value, $app['config.params']); } }
[ "public", "function", "boot", "(", "Application", "$", "app", ")", "{", "foreach", "(", "$", "app", "[", "'config'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "app", "[", "$", "key", "]", "=", "static", "::", "replaceTokens", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/lokhman/silex-config/blob/72dfedefc3079d1b8498aa466e1afdcf25473e4a/src/Silex/Provider/ConfigServiceProvider.php#L155-L160
corycollier/markdown-blogger
src/Application.php
Application.get
public function get($key) { $config = $this->getConfig(); if (! array_key_exists($key, $config)) { throw new \OutOfRangeException(sprintf(self::ERR_INVALID_CONFIG_KEY, $key)); } return $config[$key]; }
php
public function get($key) { $config = $this->getConfig(); if (! array_key_exists($key, $config)) { throw new \OutOfRangeException(sprintf(self::ERR_INVALID_CONFIG_KEY, $key)); } return $config[$key]; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "config", ")", ")", "{", "throw", "new", "\\", "OutOfRangeExce...
Gets a config value by key @param string $key The key to get. @return mixed Could be anything.
[ "Gets", "a", "config", "value", "by", "key" ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/Application.php#L91-L98
corycollier/markdown-blogger
src/Application.php
Application.bootstrap
public function bootstrap($config = []) { $config = $this->setConfig($config)->getConfig(); $this->request = $this->getNewRequest(array_merge($_SERVER, $_GET)); $this->iterator = new BlogIterator(realpath($config['data_dir'])); $this->factory = new BlogFactory; return $this; }
php
public function bootstrap($config = []) { $config = $this->setConfig($config)->getConfig(); $this->request = $this->getNewRequest(array_merge($_SERVER, $_GET)); $this->iterator = new BlogIterator(realpath($config['data_dir'])); $this->factory = new BlogFactory; return $this; }
[ "public", "function", "bootstrap", "(", "$", "config", "=", "[", "]", ")", "{", "$", "config", "=", "$", "this", "->", "setConfig", "(", "$", "config", ")", "->", "getConfig", "(", ")", ";", "$", "this", "->", "request", "=", "$", "this", "->", "...
Gets all of the things ready. @param array $config Configuration parameters. @return Application Return self, for object-chaining
[ "Gets", "all", "of", "the", "things", "ready", "." ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/Application.php#L105-L113
corycollier/markdown-blogger
src/Application.php
Application.run
public function run() { $request = $this->getRequest(); $factory = $this->getFactory(); $iterator = $this->getIterator(); $latest = $iterator->getLatest(); try { $blog = $factory->factory($request->getData()); } catch (\InvalidArgumentException $exception) { $request = $this->getNewRequest(['q' => '404']); $blog = $factory->factory($request->getData()); } $vars = [ 'content' => $blog->getContent(), 'title' => $blog->getTitle(), 'keywords' => $blog->getKeywords(), 'description' => $blog->getDescription(), 'latest' => $factory->massFactory($latest), 'blog_title' => $this->get('blog_title'), 'time' => $blog->getTime(), ]; include __DIR__ . '/../web/layout.php'; return $this; }
php
public function run() { $request = $this->getRequest(); $factory = $this->getFactory(); $iterator = $this->getIterator(); $latest = $iterator->getLatest(); try { $blog = $factory->factory($request->getData()); } catch (\InvalidArgumentException $exception) { $request = $this->getNewRequest(['q' => '404']); $blog = $factory->factory($request->getData()); } $vars = [ 'content' => $blog->getContent(), 'title' => $blog->getTitle(), 'keywords' => $blog->getKeywords(), 'description' => $blog->getDescription(), 'latest' => $factory->massFactory($latest), 'blog_title' => $this->get('blog_title'), 'time' => $blog->getTime(), ]; include __DIR__ . '/../web/layout.php'; return $this; }
[ "public", "function", "run", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "factory", "=", "$", "this", "->", "getFactory", "(", ")", ";", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", ")", ...
Run the application. @return Application Return self, for object-chaining.
[ "Run", "the", "application", "." ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/Application.php#L119-L145
tableau-mkt/elomentary
src/HttpClient/Listener/ErrorListener.php
ErrorListener.onRequestError
public function onRequestError(Event $event) { /** @var $request \Guzzle\Http\Message\Request */ $request = $event['request']; $response = $request->getResponse(); if ($response->isClientError() || $response->isServerError()) { $content = ResponseMediator::getContent($response); if (is_array($content)) { $error = $content[0]; if (400 == $response->getStatusCode()) { if (isset($error['property']) && isset($error['requirement'])) { throw new ErrorException(sprintf('%s - %s (%s)', $error['type'], $error['property'], $error['requirement']['type']), 400); } else { throw new ErrorException(sprintf('%s - %s', $error['type'], $error['message'] ? $error['message'] : json_encode($content)), 400); } } } else { throw new RuntimeException(json_encode($content), $response->getStatusCode()); } } }
php
public function onRequestError(Event $event) { /** @var $request \Guzzle\Http\Message\Request */ $request = $event['request']; $response = $request->getResponse(); if ($response->isClientError() || $response->isServerError()) { $content = ResponseMediator::getContent($response); if (is_array($content)) { $error = $content[0]; if (400 == $response->getStatusCode()) { if (isset($error['property']) && isset($error['requirement'])) { throw new ErrorException(sprintf('%s - %s (%s)', $error['type'], $error['property'], $error['requirement']['type']), 400); } else { throw new ErrorException(sprintf('%s - %s', $error['type'], $error['message'] ? $error['message'] : json_encode($content)), 400); } } } else { throw new RuntimeException(json_encode($content), $response->getStatusCode()); } } }
[ "public", "function", "onRequestError", "(", "Event", "$", "event", ")", "{", "/** @var $request \\Guzzle\\Http\\Message\\Request */", "$", "request", "=", "$", "event", "[", "'request'", "]", ";", "$", "response", "=", "$", "request", "->", "getResponse", "(", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/HttpClient/Listener/ErrorListener.php#L33-L56
diemuzi/mp3
src/Mp3/Service/Factory/SearchFactory.php
SearchFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { /** * @var array $config */ $config = $serviceLocator->get('config'); /** * @var \Zend\View\HelperPluginManager $serverUrl */ $serverUrl = $serviceLocator->get('ViewHelperManager'); /** * @var \Zend\Mvc\I18n\Translator $translator */ $translator = $serviceLocator->get('translator'); return new Search( $config, $serverUrl, $translator ); }
php
public function createService(ServiceLocatorInterface $serviceLocator) { /** * @var array $config */ $config = $serviceLocator->get('config'); /** * @var \Zend\View\HelperPluginManager $serverUrl */ $serverUrl = $serviceLocator->get('ViewHelperManager'); /** * @var \Zend\Mvc\I18n\Translator $translator */ $translator = $serviceLocator->get('translator'); return new Search( $config, $serverUrl, $translator ); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "/**\n * @var array $config\n */", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'config'", ")", ";", "/**\n * @var \\Zend\\View\\...
@param ServiceLocatorInterface $serviceLocator @return Search
[ "@param", "ServiceLocatorInterface", "$serviceLocator" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/Factory/SearchFactory.php#L29-L51
cornernote/yii-email-module
email/controllers/EmailTemplateController.php
EmailTemplateController.actionIndex
public function actionIndex() { $emailTemplate = new EmailTemplate('search'); if (!empty($_GET['EmailTemplate'])) $emailTemplate->attributes = $_GET['EmailTemplate']; $this->render('index', array( 'emailTemplate' => $emailTemplate, )); }
php
public function actionIndex() { $emailTemplate = new EmailTemplate('search'); if (!empty($_GET['EmailTemplate'])) $emailTemplate->attributes = $_GET['EmailTemplate']; $this->render('index', array( 'emailTemplate' => $emailTemplate, )); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "emailTemplate", "=", "new", "EmailTemplate", "(", "'search'", ")", ";", "if", "(", "!", "empty", "(", "$", "_GET", "[", "'EmailTemplate'", "]", ")", ")", "$", "emailTemplate", "->", "attributes", ...
Index
[ "Index" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/controllers/EmailTemplateController.php#L36-L45
cornernote/yii-email-module
email/controllers/EmailTemplateController.php
EmailTemplateController.actionPreview
public function actionPreview($id) { $emailTemplate = $this->loadModel($id); echo CHtml::tag('div', array('style' => 'font-family: Arial; font-weight: bold;'), $emailTemplate->subject) . '<hr/>'; echo $emailTemplate->message; }
php
public function actionPreview($id) { $emailTemplate = $this->loadModel($id); echo CHtml::tag('div', array('style' => 'font-family: Arial; font-weight: bold;'), $emailTemplate->subject) . '<hr/>'; echo $emailTemplate->message; }
[ "public", "function", "actionPreview", "(", "$", "id", ")", "{", "$", "emailTemplate", "=", "$", "this", "->", "loadModel", "(", "$", "id", ")", ";", "echo", "CHtml", "::", "tag", "(", "'div'", ",", "array", "(", "'style'", "=>", "'font-family: Arial; fo...
Preview @param $id
[ "Preview" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/controllers/EmailTemplateController.php#L64-L69
cornernote/yii-email-module
email/controllers/EmailTemplateController.php
EmailTemplateController.actionCreate
public function actionCreate() { $emailTemplate = new EmailTemplate('create'); if (isset($_POST['EmailTemplate'])) { $emailTemplate->attributes = $_POST['EmailTemplate']; if ($emailTemplate->save()) { $this->redirect(array('template/view', 'id' => $emailTemplate->id)); } } $this->render('create', array( 'emailTemplate' => $emailTemplate, )); }
php
public function actionCreate() { $emailTemplate = new EmailTemplate('create'); if (isset($_POST['EmailTemplate'])) { $emailTemplate->attributes = $_POST['EmailTemplate']; if ($emailTemplate->save()) { $this->redirect(array('template/view', 'id' => $emailTemplate->id)); } } $this->render('create', array( 'emailTemplate' => $emailTemplate, )); }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "emailTemplate", "=", "new", "EmailTemplate", "(", "'create'", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'EmailTemplate'", "]", ")", ")", "{", "$", "emailTemplate", "->", "attributes", ...
Create
[ "Create" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/controllers/EmailTemplateController.php#L74-L88
cornernote/yii-email-module
email/controllers/EmailTemplateController.php
EmailTemplateController.actionUpdate
public function actionUpdate($id) { $emailTemplate = $this->loadModel($id); if (isset($_POST['EmailTemplate'])) { $emailTemplate->attributes = $_POST['EmailTemplate']; if ($emailTemplate->save()) { $this->redirect(array('template/view', 'id' => $emailTemplate->id)); } } $this->render('update', array( 'emailTemplate' => $emailTemplate, )); }
php
public function actionUpdate($id) { $emailTemplate = $this->loadModel($id); if (isset($_POST['EmailTemplate'])) { $emailTemplate->attributes = $_POST['EmailTemplate']; if ($emailTemplate->save()) { $this->redirect(array('template/view', 'id' => $emailTemplate->id)); } } $this->render('update', array( 'emailTemplate' => $emailTemplate, )); }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "emailTemplate", "=", "$", "this", "->", "loadModel", "(", "$", "id", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'EmailTemplate'", "]", ")", ")", "{", "$", "emailTemplat...
Update @param $id
[ "Update" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/controllers/EmailTemplateController.php#L94-L108
cornernote/yii-email-module
email/controllers/EmailTemplateController.php
EmailTemplateController.actionDelete
public function actionDelete($id) { $emailTemplate = $this->loadModel($id); $emailTemplate->delete(); $this->redirect(Yii::app()->user->getState('index.emailTemplate', array('template/index'))); }
php
public function actionDelete($id) { $emailTemplate = $this->loadModel($id); $emailTemplate->delete(); $this->redirect(Yii::app()->user->getState('index.emailTemplate', array('template/index'))); }
[ "public", "function", "actionDelete", "(", "$", "id", ")", "{", "$", "emailTemplate", "=", "$", "this", "->", "loadModel", "(", "$", "id", ")", ";", "$", "emailTemplate", "->", "delete", "(", ")", ";", "$", "this", "->", "redirect", "(", "Yii", "::",...
Delete @param $id
[ "Delete" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/controllers/EmailTemplateController.php#L114-L119
templado/engine
src/viewmodel/ViewModelRenderer.php
ViewModelRenderer.processBoolean
private function processBoolean(DOMElement $context, bool $model) { if ($model === true) { return $context; } if ($context->isSameNode($context->ownerDocument->documentElement)) { throw new ViewModelRendererException('Cannot remove root element'); } $this->removeNodeFromCurrentSnapshotList($context); $context->parentNode->removeChild($context); return $context->ownerDocument->createDocumentFragment(); }
php
private function processBoolean(DOMElement $context, bool $model) { if ($model === true) { return $context; } if ($context->isSameNode($context->ownerDocument->documentElement)) { throw new ViewModelRendererException('Cannot remove root element'); } $this->removeNodeFromCurrentSnapshotList($context); $context->parentNode->removeChild($context); return $context->ownerDocument->createDocumentFragment(); }
[ "private", "function", "processBoolean", "(", "DOMElement", "$", "context", ",", "bool", "$", "model", ")", "{", "if", "(", "$", "model", "===", "true", ")", "{", "return", "$", "context", ";", "}", "if", "(", "$", "context", "->", "isSameNode", "(", ...
@return DOMDocumentFragment|DOMElement @throws ViewModelRendererException
[ "@return", "DOMDocumentFragment|DOMElement" ]
train
https://github.com/templado/engine/blob/3a1fb9d7a4595d7d49b6b45dd697d6cd9bcf2fbd/src/viewmodel/ViewModelRenderer.php#L167-L180
tableau-mkt/elomentary
src/Api/Data/Contact/Filter.php
Filter.search
public function search($search, array $options = array()) { return $this->get('data/contacts/filter/' . rawurlencode($this->contactFilterId), array_merge(array( 'search' => $search, ), $options)); }
php
public function search($search, array $options = array()) { return $this->get('data/contacts/filter/' . rawurlencode($this->contactFilterId), array_merge(array( 'search' => $search, ), $options)); }
[ "public", "function", "search", "(", "$", "search", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "get", "(", "'data/contacts/filter/'", ".", "rawurlencode", "(", "$", "this", "->", "contactFilterId", ")", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Data/Contact/Filter.php#L43-L47
CampaignChain/core
Form/Type/OperationType.php
OperationType.buildView
public function buildView(FormView $view, FormInterface $form, array $options) { $this->setOptions($options); if($this->location){ $view->vars['location'] = $this->location; } elseif(isset($options['data'])) { $view->vars['location'] = $options['data']->getOperation()->getActivity()->getLocation(); } if(!isset($options['data']) || !$view->vars['location']){ $view->vars['activity_module'] = $this->activityModule; } }
php
public function buildView(FormView $view, FormInterface $form, array $options) { $this->setOptions($options); if($this->location){ $view->vars['location'] = $this->location; } elseif(isset($options['data'])) { $view->vars['location'] = $options['data']->getOperation()->getActivity()->getLocation(); } if(!isset($options['data']) || !$view->vars['location']){ $view->vars['activity_module'] = $this->activityModule; } }
[ "public", "function", "buildView", "(", "FormView", "$", "view", ",", "FormInterface", "$", "form", ",", "array", "$", "options", ")", "{", "$", "this", "->", "setOptions", "(", "$", "options", ")", ";", "if", "(", "$", "this", "->", "location", ")", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Form/Type/OperationType.php#L58-L70
kgilden/php-digidoc
src/Ocsp/Responder.php
Responder.handle
public function handle(Request $request) { $response = $this->makeRequest($request); if (!$response->isSignedBy(new Cert(file_get_contents($this->pathToCert)))) { throw new \RuntimeException('The signature does not match.'); } return $response; }
php
public function handle(Request $request) { $response = $this->makeRequest($request); if (!$response->isSignedBy(new Cert(file_get_contents($this->pathToCert)))) { throw new \RuntimeException('The signature does not match.'); } return $response; }
[ "public", "function", "handle", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "makeRequest", "(", "$", "request", ")", ";", "if", "(", "!", "$", "response", "->", "isSignedBy", "(", "new", "Cert", "(", "file_get_con...
@param Request $request @return Response
[ "@param", "Request", "$request" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Ocsp/Responder.php#L68-L77
kgilden/php-digidoc
src/Ocsp/Responder.php
Responder.makeRequest
private function makeRequest(Request $request) { $pathToResponse = tempnam($this->tempDir, 'php-digidoc'); $process = $this->createProcess($request, $pathToResponse); $process->run(); if (!$process->isSuccessful()) { throw new OcspRequestException('OCSP Verification failed: ' . $process->getErrorOutput()); } return new Response(file_get_contents($pathToResponse)); }
php
private function makeRequest(Request $request) { $pathToResponse = tempnam($this->tempDir, 'php-digidoc'); $process = $this->createProcess($request, $pathToResponse); $process->run(); if (!$process->isSuccessful()) { throw new OcspRequestException('OCSP Verification failed: ' . $process->getErrorOutput()); } return new Response(file_get_contents($pathToResponse)); }
[ "private", "function", "makeRequest", "(", "Request", "$", "request", ")", "{", "$", "pathToResponse", "=", "tempnam", "(", "$", "this", "->", "tempDir", ",", "'php-digidoc'", ")", ";", "$", "process", "=", "$", "this", "->", "createProcess", "(", "$", "...
@param Request $request @return Response
[ "@param", "Request", "$request" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Ocsp/Responder.php#L84-L96
kgilden/php-digidoc
src/Ocsp/Responder.php
Responder.createProcess
private function createProcess(Request $request, $pathToResponse) { $commandLine = sprintf( 'openssl ocsp -issuer %s -cert %s -url %s -VAfile %s -respout %s', escapeshellarg($request->getPathToIssuerCert()), escapeshellarg($request->getPathToClientCert()), escapeshellarg($this->url), escapeshellarg($this->pathToCert), escapeshellarg($pathToResponse) ); $process = $this->process; $process->setCommandLine($commandLine); return $process; }
php
private function createProcess(Request $request, $pathToResponse) { $commandLine = sprintf( 'openssl ocsp -issuer %s -cert %s -url %s -VAfile %s -respout %s', escapeshellarg($request->getPathToIssuerCert()), escapeshellarg($request->getPathToClientCert()), escapeshellarg($this->url), escapeshellarg($this->pathToCert), escapeshellarg($pathToResponse) ); $process = $this->process; $process->setCommandLine($commandLine); return $process; }
[ "private", "function", "createProcess", "(", "Request", "$", "request", ",", "$", "pathToResponse", ")", "{", "$", "commandLine", "=", "sprintf", "(", "'openssl ocsp -issuer %s -cert %s -url %s -VAfile %s -respout %s'", ",", "escapeshellarg", "(", "$", "request", "->", ...
@param Request $request @param string $pathToResponse @return Process
[ "@param", "Request", "$request", "@param", "string", "$pathToResponse" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Ocsp/Responder.php#L104-L119
notthatbad/silverstripe-rest-api
code/serializers/HtmlSerializer.php
HtmlSerializer.serialize
public function serialize($data) { $list = $this->recursive($data, 1); return $this->renderWith(['Result', 'Controller'], ['Data' => \ArrayList::create($list)]); }
php
public function serialize($data) { $list = $this->recursive($data, 1); return $this->renderWith(['Result', 'Controller'], ['Data' => \ArrayList::create($list)]); }
[ "public", "function", "serialize", "(", "$", "data", ")", "{", "$", "list", "=", "$", "this", "->", "recursive", "(", "$", "data", ",", "1", ")", ";", "return", "$", "this", "->", "renderWith", "(", "[", "'Result'", ",", "'Controller'", "]", ",", "...
The given data will be serialized into an html string using a Silverstripe template. @param array $data @return string an html string
[ "The", "given", "data", "will", "be", "serialized", "into", "an", "html", "string", "using", "a", "Silverstripe", "template", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/serializers/HtmlSerializer.php#L28-L31
CampaignChain/core
EventListener/PasswordResetListener.php
PasswordResetListener.onPasswordResettingSuccess
public function onPasswordResettingSuccess(FormEvent $event) { $url = $this->router->generate('campaignchain_core_homepage'); $event->setResponse(new RedirectResponse($url)); }
php
public function onPasswordResettingSuccess(FormEvent $event) { $url = $this->router->generate('campaignchain_core_homepage'); $event->setResponse(new RedirectResponse($url)); }
[ "public", "function", "onPasswordResettingSuccess", "(", "FormEvent", "$", "event", ")", "{", "$", "url", "=", "$", "this", "->", "router", "->", "generate", "(", "'campaignchain_core_homepage'", ")", ";", "$", "event", "->", "setResponse", "(", "new", "Redire...
Redirect to home after successfully resetting the password @param FormEvent $event
[ "Redirect", "to", "home", "after", "successfully", "resetting", "the", "password" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/PasswordResetListener.php#L65-L70
corycollier/markdown-blogger
src/BlogFactory.php
BlogFactory.factory
public function factory($data) { $content = ''; $file = ''; $parser = $this->getParser(); $filename = $this->getFilename($data); if ($filename) { $content = $this->getFileContent($filename); $file = new \SplFileInfo($filename); } return new Blog([ 'content' => $parser->text($content), 'data' => $file, 'filename' => $filename, ]); }
php
public function factory($data) { $content = ''; $file = ''; $parser = $this->getParser(); $filename = $this->getFilename($data); if ($filename) { $content = $this->getFileContent($filename); $file = new \SplFileInfo($filename); } return new Blog([ 'content' => $parser->text($content), 'data' => $file, 'filename' => $filename, ]); }
[ "public", "function", "factory", "(", "$", "data", ")", "{", "$", "content", "=", "''", ";", "$", "file", "=", "''", ";", "$", "parser", "=", "$", "this", "->", "getParser", "(", ")", ";", "$", "filename", "=", "$", "this", "->", "getFilename", "...
Main public entry point. Returns a Blog value for the given array. @param array $data An array of data. @return Blog The subsequent blog instance.
[ "Main", "public", "entry", "point", ".", "Returns", "a", "Blog", "value", "for", "the", "given", "array", "." ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L24-L41
corycollier/markdown-blogger
src/BlogFactory.php
BlogFactory.massFactory
public function massFactory($data) { $results = []; foreach ($data as $post) { $results[] = $this->factory($post); } return $results; }
php
public function massFactory($data) { $results = []; foreach ($data as $post) { $results[] = $this->factory($post); } return $results; }
[ "public", "function", "massFactory", "(", "$", "data", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "post", ")", "{", "$", "results", "[", "]", "=", "$", "this", "->", "factory", "(", "$", "post", ")", "...
Factory for multiple items @param array $data An array of items @return array An array of Blogs
[ "Factory", "for", "multiple", "items" ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L48-L55
corycollier/markdown-blogger
src/BlogFactory.php
BlogFactory.getFileContent
protected function getFileContent($filename) { if (!file_exists($filename)) { throw new \InvalidArgumentException(sprintf(self::ERR_NO_SUCH_BLOG, $filename)); } return file_get_contents($filename); }
php
protected function getFileContent($filename) { if (!file_exists($filename)) { throw new \InvalidArgumentException(sprintf(self::ERR_NO_SUCH_BLOG, $filename)); } return file_get_contents($filename); }
[ "protected", "function", "getFileContent", "(", "$", "filename", ")", "{", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "self", "::", "ERR_NO_SUCH_BLOG", ",", "$", ...
Utility method to wrap the file_get_contents PHP function. @param string $filename The path to get content from. @return string The contents of the file.
[ "Utility", "method", "to", "wrap", "the", "file_get_contents", "PHP", "function", "." ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L71-L77
corycollier/markdown-blogger
src/BlogFactory.php
BlogFactory.translateName
protected function translateName($name) { if ($name === '/index.php') { return ''; } $name = ltrim($name, '/'); $name = rtrim($name, '/'); return preg_replace('/[^A-Za-z0-9\-_]/', '', strtr($name, [ '/' => '_', '.md' => '', ])); }
php
protected function translateName($name) { if ($name === '/index.php') { return ''; } $name = ltrim($name, '/'); $name = rtrim($name, '/'); return preg_replace('/[^A-Za-z0-9\-_]/', '', strtr($name, [ '/' => '_', '.md' => '', ])); }
[ "protected", "function", "translateName", "(", "$", "name", ")", "{", "if", "(", "$", "name", "===", "'/index.php'", ")", "{", "return", "''", ";", "}", "$", "name", "=", "ltrim", "(", "$", "name", ",", "'/'", ")", ";", "$", "name", "=", "rtrim", ...
Translates a request value, to a blog file name @param string $name The url value given @return string the file name
[ "Translates", "a", "request", "value", "to", "a", "blog", "file", "name" ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L84-L97
corycollier/markdown-blogger
src/BlogFactory.php
BlogFactory.getFilename
protected function getFilename($data) { $options = [ 'q', 'query_string', 'path_info', 'php_self', ]; $root = $data['data_dir']; foreach ($options as $option) { if (!array_key_exists($option, $data)) { continue; } $name = $this->translateName($data[$option]); if ($name) { return $root . '/' . $name . '.md'; } } }
php
protected function getFilename($data) { $options = [ 'q', 'query_string', 'path_info', 'php_self', ]; $root = $data['data_dir']; foreach ($options as $option) { if (!array_key_exists($option, $data)) { continue; } $name = $this->translateName($data[$option]); if ($name) { return $root . '/' . $name . '.md'; } } }
[ "protected", "function", "getFilename", "(", "$", "data", ")", "{", "$", "options", "=", "[", "'q'", ",", "'query_string'", ",", "'path_info'", ",", "'php_self'", ",", "]", ";", "$", "root", "=", "$", "data", "[", "'data_dir'", "]", ";", "foreach", "("...
Gets a filename from the given request url. @param array $data The array of parameters. @return string The corresponding filepath value.
[ "Gets", "a", "filename", "from", "the", "given", "request", "url", "." ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L104-L120
tableau-mkt/elomentary
src/Api/Assets/Email/Deployment.php
Deployment.show
public function show($id, $depth = 'complete', $extensions = null) { return $this->get('assets/email/deployment/' . rawurlencode($id), array( 'depth' => $depth, 'extensions' => $extensions, )); }
php
public function show($id, $depth = 'complete', $extensions = null) { return $this->get('assets/email/deployment/' . rawurlencode($id), array( 'depth' => $depth, 'extensions' => $extensions, )); }
[ "public", "function", "show", "(", "$", "id", ",", "$", "depth", "=", "'complete'", ",", "$", "extensions", "=", "null", ")", "{", "return", "$", "this", "->", "get", "(", "'assets/email/deployment/'", ".", "rawurlencode", "(", "$", "id", ")", ",", "ar...
{@inheritdoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/Email/Deployment.php#L33-L38
tableau-mkt/elomentary
src/Api/Assets/Email/Deployment.php
Deployment.create
public function create($data) { // Validate the request before sending it. $required = array('name', 'email', 'type'); foreach ($required as $key) { $this->validateExists($data, $key); } if ($data['type'] == 'EmailTestDeployment') { $this->validateExists($data, 'contactId'); } // @codeCoverageIgnore elseif ($data['type'] == 'EmailInlineDeployment') { $this->validateExists($data, 'contacts'); } return $this->post('assets/email/deployment', $data); }
php
public function create($data) { // Validate the request before sending it. $required = array('name', 'email', 'type'); foreach ($required as $key) { $this->validateExists($data, $key); } if ($data['type'] == 'EmailTestDeployment') { $this->validateExists($data, 'contactId'); } // @codeCoverageIgnore elseif ($data['type'] == 'EmailInlineDeployment') { $this->validateExists($data, 'contacts'); } return $this->post('assets/email/deployment', $data); }
[ "public", "function", "create", "(", "$", "data", ")", "{", "// Validate the request before sending it.", "$", "required", "=", "array", "(", "'name'", ",", "'email'", ",", "'type'", ")", ";", "foreach", "(", "$", "required", "as", "$", "key", ")", "{", "$...
{@inheritdoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/Email/Deployment.php#L43-L59
joomla-framework/twitter-api
src/Users.php
Users.getUsersLookup
public function getUsersLookup($screenName = null, $id = null, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('users', 'lookup'); $data = array(); // Set user IDs and screen names. if ($id) { $data['user_id'] = $id; } if ($screenName) { $data['screen_name'] = $screenName; } if ($id == null && $screenName == null) { // We don't have a valid entry throw new \RuntimeException('You must specify either a comma separated list of screen names, user IDs, or a combination of the two'); } // Set the API path $path = '/users/lookup.json'; // Check if string_ids is specified if ($entities !== null) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'POST', $data); }
php
public function getUsersLookup($screenName = null, $id = null, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('users', 'lookup'); $data = array(); // Set user IDs and screen names. if ($id) { $data['user_id'] = $id; } if ($screenName) { $data['screen_name'] = $screenName; } if ($id == null && $screenName == null) { // We don't have a valid entry throw new \RuntimeException('You must specify either a comma separated list of screen names, user IDs, or a combination of the two'); } // Set the API path $path = '/users/lookup.json'; // Check if string_ids is specified if ($entities !== null) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'POST', $data); }
[ "public", "function", "getUsersLookup", "(", "$", "screenName", "=", "null", ",", "$", "id", "=", "null", ",", "$", "entities", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "$", "this", "->", "checkRateLimit", "(", "'users'", ",", "'loo...
Method to get up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. @param string $screenName A comma separated list of screen names, up to 100 are allowed in a single request. @param string $id A comma separated list of user IDs, up to 100 are allowed in a single request. @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. @return array The decoded JSON response @since 1.0 @throws \RuntimeException
[ "Method", "to", "get", "up", "to", "100", "users", "worth", "of", "extended", "information", "specified", "by", "either", "ID", "screen", "name", "or", "combination", "of", "the", "two", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Users.php#L32-L67
joomla-framework/twitter-api
src/Users.php
Users.getUserProfileBanner
public function getUserProfileBanner($user) { // Check the rate limit for remaining hits $this->checkRateLimit('users', 'profile_banner'); // Set the API path $path = '/users/profile_banner.json'; // Determine which type of data was passed for $user if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } // Send the request. return $this->sendRequest($path, 'GET', $data); }
php
public function getUserProfileBanner($user) { // Check the rate limit for remaining hits $this->checkRateLimit('users', 'profile_banner'); // Set the API path $path = '/users/profile_banner.json'; // Determine which type of data was passed for $user if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } // Send the request. return $this->sendRequest($path, 'GET', $data); }
[ "public", "function", "getUserProfileBanner", "(", "$", "user", ")", "{", "// Check the rate limit for remaining hits", "$", "this", "->", "checkRateLimit", "(", "'users'", ",", "'profile_banner'", ")", ";", "// Set the API path", "$", "path", "=", "'/users/profile_bann...
Method to access the profile banner in various sizes for the user with the indicated screen_name. @param mixed $user Either an integer containing the user ID or a string containing the screen name. @return array The decoded JSON response @since 1.0 @throws \RuntimeException
[ "Method", "to", "access", "the", "profile", "banner", "in", "various", "sizes", "for", "the", "user", "with", "the", "indicated", "screen_name", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Users.php#L79-L104
CampaignChain/core
Controller/REST/ActivityController.php
ActivityController.getActivitiesAction
public function getActivitiesAction($id) { $qb = $this->getQueryBuilder(); $qb->select('a AS activity, c AS campaign, o AS operations, l AS location'); $qb->from('CampaignChain\CoreBundle\Entity\Activity', 'a'); $qb->from('CampaignChain\CoreBundle\Entity\Campaign', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->from('CampaignChain\CoreBundle\Entity\Operation', 'o'); $qb->where('a.id = :activity'); $qb->andWhere('a.id = o.activity'); $qb->andWhere('a.location = l.id'); $qb->andWhere('a.campaign = c.id'); $qb->setParameter('activity', $id); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
php
public function getActivitiesAction($id) { $qb = $this->getQueryBuilder(); $qb->select('a AS activity, c AS campaign, o AS operations, l AS location'); $qb->from('CampaignChain\CoreBundle\Entity\Activity', 'a'); $qb->from('CampaignChain\CoreBundle\Entity\Campaign', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->from('CampaignChain\CoreBundle\Entity\Operation', 'o'); $qb->where('a.id = :activity'); $qb->andWhere('a.id = o.activity'); $qb->andWhere('a.location = l.id'); $qb->andWhere('a.campaign = c.id'); $qb->setParameter('activity', $id); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
[ "public", "function", "getActivitiesAction", "(", "$", "id", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "'a AS activity, c AS campaign, o AS operations, l AS location'", ")", ";", "$", "qb", "...
Get one specific Activity. Example Request =============== GET /api/v1/activities/42 Example Response ================ [ { "activity": { "id": 42, "equalsOperation": true, "name": "Announcement 11 on LinkedIn", "startDate": "2015-12-18T14:44:54+0000", "status": "open", "createdDate": "2015-12-14T11:02:23+0000" } }, { "campaign": { "id": 3, "timezone": "Africa/Sao_Tome", "hasRelativeDates": false, "name": "Campaign 3", "startDate": "2015-10-30T23:09:57+0000", "endDate": "2016-04-23T14:18:03+0000", "status": "open", "createdDate": "2015-12-14T11:02:23+0000" } }, { "location": { "id": 101, "identifier": "idW8ynCjb7", "image": "/bundles/campaignchainchannellinkedin/ghost_person.png", "url": "https://www.linkedin.com/pub/amariki-software/a1/455/616", "name": "Amariki Software", "status": "active", "createdDate": "2015-12-14T11:02:23+0000" } }, { "operations": { "id": 72, "name": "Announcement 11 on LinkedIn", "startDate": "2015-12-18T14:44:54+0000", "status": "open", "createdDate": "2015-12-14T11:02:23+0000" } } ] @ApiDoc( section="Core", requirements={ { "name"="id", "requirement"="\d+" } } ) @REST\NoRoute() // We have specified a route manually. @param string $id The ID of an Activity, e.g. '42'. @return CampaignChain\CoreBundle\Entity\Bundle
[ "Get", "one", "specific", "Activity", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ActivityController.php#L107-L125
anderl1/cleverreach
Restclient.php
Restclient.setAuthMode
public function setAuthMode($mode = "none", $value = false) { switch ($mode) { case 'jwt': $this->authMode = "jwt"; $this->authModeSettings->token = $value; break; case 'bearer': $this->authMode = "bearer"; $this->authModeSettings->token = $value; break; case 'webauth': $this->authMode = "webauth"; $this->authModeSettings->login = $value->login; $this->authModeSettings->password = $value->password; break; default: # code... break; } }
php
public function setAuthMode($mode = "none", $value = false) { switch ($mode) { case 'jwt': $this->authMode = "jwt"; $this->authModeSettings->token = $value; break; case 'bearer': $this->authMode = "bearer"; $this->authModeSettings->token = $value; break; case 'webauth': $this->authMode = "webauth"; $this->authModeSettings->login = $value->login; $this->authModeSettings->password = $value->password; break; default: # code... break; } }
[ "public", "function", "setAuthMode", "(", "$", "mode", "=", "\"none\"", ",", "$", "value", "=", "false", ")", "{", "switch", "(", "$", "mode", ")", "{", "case", "'jwt'", ":", "$", "this", "->", "authMode", "=", "\"jwt\"", ";", "$", "this", "->", "a...
sets AuthMode (jwt, webauth, etc) @param string jwt, webauth,none @param mixed
[ "sets", "AuthMode", "(", "jwt", "webauth", "etc", ")" ]
train
https://github.com/anderl1/cleverreach/blob/850d4051468d60c42247e36086f7359465fdefbd/Restclient.php#L37-L62
anderl1/cleverreach
Restclient.php
Restclient.get
public function get($path, $data = false, $mode = "get") { $this->resetDebug(); if (is_string($data)) { if (!$data = json_decode($data)) { throw new \Exception("data is string but no JSON"); } } $url = sprintf("%s?%s", $this->url . $path, ($data ? http_build_query($data) : "")); $this->debug("url", $url); $curl = curl_init($url); $this->setupCurl($curl); switch ($mode) { case 'delete': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($mode)); $this->debug("mode", strtoupper($mode)); break; default: $this->debug("mode", "GET"); break; } // use for loaclahost curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $curl_response = curl_exec($curl); $headers = curl_getinfo($curl); curl_close($curl); $this->debugEndTimer(); return $this->returnResult($curl_response, $headers); }
php
public function get($path, $data = false, $mode = "get") { $this->resetDebug(); if (is_string($data)) { if (!$data = json_decode($data)) { throw new \Exception("data is string but no JSON"); } } $url = sprintf("%s?%s", $this->url . $path, ($data ? http_build_query($data) : "")); $this->debug("url", $url); $curl = curl_init($url); $this->setupCurl($curl); switch ($mode) { case 'delete': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($mode)); $this->debug("mode", strtoupper($mode)); break; default: $this->debug("mode", "GET"); break; } // use for loaclahost curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $curl_response = curl_exec($curl); $headers = curl_getinfo($curl); curl_close($curl); $this->debugEndTimer(); return $this->returnResult($curl_response, $headers); }
[ "public", "function", "get", "(", "$", "path", ",", "$", "data", "=", "false", ",", "$", "mode", "=", "\"get\"", ")", "{", "$", "this", "->", "resetDebug", "(", ")", ";", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "if", "(", "!", ...
makes a GET call @param array @param string get/put/delete @return mixed
[ "makes", "a", "GET", "call" ]
train
https://github.com/anderl1/cleverreach/blob/850d4051468d60c42247e36086f7359465fdefbd/Restclient.php#L72-L115
anderl1/cleverreach
Restclient.php
Restclient.post
public function post($path, $data, $mode = "post") { $this->resetDebug(); $this->debug("url", $this->url . $path); if (is_string($data)) { if (!$data = json_decode($data)) { throw new \Exception("data is string but no JSON"); } } $curl_post_data = $data; $curl = curl_init($this->url . $path); // echo "authmode=" . $this->authMode; $this->setupCurl($curl); // use for loaclahost curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); switch ($mode) { case 'put': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); break; default: curl_setopt($curl, CURLOPT_POST, true); break; } $this->debug("mode", strtoupper($mode)); if ($this->postFormat == "json") { $curl_post_data = json_encode($curl_post_data); } curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); // use for loaclahost curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false); $curl_response = curl_exec($curl); $headers = curl_getinfo($curl); curl_close($curl); $this->debugEndTimer(); return $this->returnResult($curl_response, $headers); }
php
public function post($path, $data, $mode = "post") { $this->resetDebug(); $this->debug("url", $this->url . $path); if (is_string($data)) { if (!$data = json_decode($data)) { throw new \Exception("data is string but no JSON"); } } $curl_post_data = $data; $curl = curl_init($this->url . $path); // echo "authmode=" . $this->authMode; $this->setupCurl($curl); // use for loaclahost curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); switch ($mode) { case 'put': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); break; default: curl_setopt($curl, CURLOPT_POST, true); break; } $this->debug("mode", strtoupper($mode)); if ($this->postFormat == "json") { $curl_post_data = json_encode($curl_post_data); } curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); // use for loaclahost curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false); $curl_response = curl_exec($curl); $headers = curl_getinfo($curl); curl_close($curl); $this->debugEndTimer(); return $this->returnResult($curl_response, $headers); }
[ "public", "function", "post", "(", "$", "path", ",", "$", "data", ",", "$", "mode", "=", "\"post\"", ")", "{", "$", "this", "->", "resetDebug", "(", ")", ";", "$", "this", "->", "debug", "(", "\"url\"", ",", "$", "this", "->", "url", ".", "$", ...
does POST @param [type] @return [type]
[ "does", "POST" ]
train
https://github.com/anderl1/cleverreach/blob/850d4051468d60c42247e36086f7359465fdefbd/Restclient.php#L142-L208
anderl1/cleverreach
Restclient.php
Restclient.setupCurl
private function setupCurl(&$curl) { $header = array(); switch ($this->postFormat) { case 'json': $header['content'] = 'Content-Type: application/json'; break; default: $header['content'] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'; break; } switch ($this->authMode) { case 'webauth': curl_setopt($curl, CURLOPT_USERPWD, $this->authModeSettings->login . ":" . $this->authModeSettings->password); break; case 'jwt': $header['token'] = 'X-ACCESS-TOKEN: ' . $this->authModeSettings->token; // $header['token'] = 'Authorization: Bearer ' . $this->authModeSettings->token; break; case 'bearer': $header['token'] = 'Authorization: Bearer ' . $this->authModeSettings->token; break; default: # code... break; } $this->debugValues->header = $header; curl_setopt($curl, CURLOPT_HTTPHEADER, $header); }
php
private function setupCurl(&$curl) { $header = array(); switch ($this->postFormat) { case 'json': $header['content'] = 'Content-Type: application/json'; break; default: $header['content'] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'; break; } switch ($this->authMode) { case 'webauth': curl_setopt($curl, CURLOPT_USERPWD, $this->authModeSettings->login . ":" . $this->authModeSettings->password); break; case 'jwt': $header['token'] = 'X-ACCESS-TOKEN: ' . $this->authModeSettings->token; // $header['token'] = 'Authorization: Bearer ' . $this->authModeSettings->token; break; case 'bearer': $header['token'] = 'Authorization: Bearer ' . $this->authModeSettings->token; break; default: # code... break; } $this->debugValues->header = $header; curl_setopt($curl, CURLOPT_HTTPHEADER, $header); }
[ "private", "function", "setupCurl", "(", "&", "$", "curl", ")", "{", "$", "header", "=", "array", "(", ")", ";", "switch", "(", "$", "this", "->", "postFormat", ")", "{", "case", "'json'", ":", "$", "header", "[", "'content'", "]", "=", "'Content-Typ...
prepapres curl with settings amd ein object @param pointer_curl
[ "prepapres", "curl", "with", "settings", "amd", "ein", "object" ]
train
https://github.com/anderl1/cleverreach/blob/850d4051468d60c42247e36086f7359465fdefbd/Restclient.php#L248-L285
anderl1/cleverreach
Restclient.php
Restclient.returnResult
private function returnResult($in, $header = false) { $this->header = $header; if ($this->checkHeader && isset($header["http_code"])) { if ($header["http_code"] < 200 || $header["http_code"] >= 300) { //error!? $this->error = $in; $message = var_export($in, true); if ($tmp = json_decode($in)) { if (isset($tmp->error->message)) { $message = $tmp->error->message; } } if ($this->throwExceptions) { throw new \Exception('' . $header["http_code"] . ';' . $message); } $in = null; } } switch ($this->returnFormat) { case 'json': return json_decode($in); break; default: return $in; break; } return $in; }
php
private function returnResult($in, $header = false) { $this->header = $header; if ($this->checkHeader && isset($header["http_code"])) { if ($header["http_code"] < 200 || $header["http_code"] >= 300) { //error!? $this->error = $in; $message = var_export($in, true); if ($tmp = json_decode($in)) { if (isset($tmp->error->message)) { $message = $tmp->error->message; } } if ($this->throwExceptions) { throw new \Exception('' . $header["http_code"] . ';' . $message); } $in = null; } } switch ($this->returnFormat) { case 'json': return json_decode($in); break; default: return $in; break; } return $in; }
[ "private", "function", "returnResult", "(", "$", "in", ",", "$", "header", "=", "false", ")", "{", "$", "this", "->", "header", "=", "$", "header", ";", "if", "(", "$", "this", "->", "checkHeader", "&&", "isset", "(", "$", "header", "[", "\"http_code...
returls formated based on given obj settings @param string @return mixed
[ "returls", "formated", "based", "on", "given", "obj", "settings" ]
train
https://github.com/anderl1/cleverreach/blob/850d4051468d60c42247e36086f7359465fdefbd/Restclient.php#L292-L325
czukowski/I18n_Plural
classes/I18n/Model/ModelBase.php
ModelBase.context
public function context($context = NULL) { if ( ! func_num_args()) { return $this->_context; } $this->_context = $context; return $this; }
php
public function context($context = NULL) { if ( ! func_num_args()) { return $this->_context; } $this->_context = $context; return $this; }
[ "public", "function", "context", "(", "$", "context", "=", "NULL", ")", "{", "if", "(", "!", "func_num_args", "(", ")", ")", "{", "return", "$", "this", "->", "_context", ";", "}", "$", "this", "->", "_context", "=", "$", "context", ";", "return", ...
Translation context getter and setter. @param mixed $context @return $this|mixed
[ "Translation", "context", "getter", "and", "setter", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L47-L55
czukowski/I18n_Plural
classes/I18n/Model/ModelBase.php
ModelBase.i18n
public function i18n(I18n\Core $i18n = NULL) { if (func_num_args() > 0) { $this->_i18n = $i18n; return $this; } elseif ($this->_i18n instanceof I18n\Core) { return $this->_i18n; } throw new \LogicException('I18n Core object not set.'); }
php
public function i18n(I18n\Core $i18n = NULL) { if (func_num_args() > 0) { $this->_i18n = $i18n; return $this; } elseif ($this->_i18n instanceof I18n\Core) { return $this->_i18n; } throw new \LogicException('I18n Core object not set.'); }
[ "public", "function", "i18n", "(", "I18n", "\\", "Core", "$", "i18n", "=", "NULL", ")", "{", "if", "(", "func_num_args", "(", ")", ">", "0", ")", "{", "$", "this", "->", "_i18n", "=", "$", "i18n", ";", "return", "$", "this", ";", "}", "elseif", ...
Translation 'core' object getter and setter. @param I18n\Core $i18n @return $this|I18n\Core @throws \LogicException
[ "Translation", "core", "object", "getter", "and", "setter", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L64-L76
czukowski/I18n_Plural
classes/I18n/Model/ModelBase.php
ModelBase.lang
public function lang($lang = NULL) { if ( ! func_num_args()) { return $this->_lang; } $this->_lang = $lang; return $this; }
php
public function lang($lang = NULL) { if ( ! func_num_args()) { return $this->_lang; } $this->_lang = $lang; return $this; }
[ "public", "function", "lang", "(", "$", "lang", "=", "NULL", ")", "{", "if", "(", "!", "func_num_args", "(", ")", ")", "{", "return", "$", "this", "->", "_lang", ";", "}", "$", "this", "->", "_lang", "=", "$", "lang", ";", "return", "$", "this", ...
Translation destination language getter and setter. @param string $lang @return $this|string
[ "Translation", "destination", "language", "getter", "and", "setter", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L84-L92
czukowski/I18n_Plural
classes/I18n/Model/ModelBase.php
ModelBase.parameter
public function parameter($key, $value = NULL) { if (func_num_args() === 1) { if ( ! array_key_exists($key, $this->_parameters)) { throw new \InvalidArgumentException('Parameter not set: '.$key); } return $this->_parameters[$key]; } $this->_parameters[$key] = $value; return $this; }
php
public function parameter($key, $value = NULL) { if (func_num_args() === 1) { if ( ! array_key_exists($key, $this->_parameters)) { throw new \InvalidArgumentException('Parameter not set: '.$key); } return $this->_parameters[$key]; } $this->_parameters[$key] = $value; return $this; }
[ "public", "function", "parameter", "(", "$", "key", ",", "$", "value", "=", "NULL", ")", "{", "if", "(", "func_num_args", "(", ")", "===", "1", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_parameters", ")...
Specific parameter getter and setter. @param string $key @param mixed $value @return $this|mixed
[ "Specific", "parameter", "getter", "and", "setter", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L101-L113
czukowski/I18n_Plural
classes/I18n/Model/ModelBase.php
ModelBase._parameter_default
protected function _parameter_default($key, $default = NULL) { if ( ! array_key_exists($key, $this->_parameters)) { return $default; } return $this->_parameters[$key]; }
php
protected function _parameter_default($key, $default = NULL) { if ( ! array_key_exists($key, $this->_parameters)) { return $default; } return $this->_parameters[$key]; }
[ "protected", "function", "_parameter_default", "(", "$", "key", ",", "$", "default", "=", "NULL", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_parameters", ")", ")", "{", "return", "$", "default", ";", "}", ...
Parameter getter with the default value fallback.
[ "Parameter", "getter", "with", "the", "default", "value", "fallback", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L134-L141
JustBlackBird/handlebars.php-helpers
src/Layout/BlockHelper.php
BlockHelper.execute
public function execute(Template $template, Context $context, $args, $source) { // Get block name $parsed_args = $template->parseArguments($args); if (count($parsed_args) != 1) { throw new \InvalidArgumentException( '"block" helper expects exactly one argument.' ); } $block_name = $context->get(array_shift($parsed_args)); // If the block is not overridden render and show the default value if (!$this->blocksStorage->has($block_name)) { return $template->render($context); } $content = $this->blocksStorage->get($block_name); // Show overridden content return $content; }
php
public function execute(Template $template, Context $context, $args, $source) { // Get block name $parsed_args = $template->parseArguments($args); if (count($parsed_args) != 1) { throw new \InvalidArgumentException( '"block" helper expects exactly one argument.' ); } $block_name = $context->get(array_shift($parsed_args)); // If the block is not overridden render and show the default value if (!$this->blocksStorage->has($block_name)) { return $template->render($context); } $content = $this->blocksStorage->get($block_name); // Show overridden content return $content; }
[ "public", "function", "execute", "(", "Template", "$", "template", ",", "Context", "$", "context", ",", "$", "args", ",", "$", "source", ")", "{", "// Get block name", "$", "parsed_args", "=", "$", "template", "->", "parseArguments", "(", "$", "args", ")",...
{@inheritdoc}
[ "{" ]
train
https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Layout/BlockHelper.php#L37-L57
JustBlackBird/handlebars.php-helpers
src/Text/RepeatHelper.php
RepeatHelper.execute
public function execute(Template $template, Context $context, $args, $source) { $parsed_args = $template->parseArguments($args); if (count($parsed_args) != 1) { throw new \InvalidArgumentException( '"repeat" helper expects exactly one argument.' ); } $times = intval($context->get($parsed_args[0])); if ($times < 0) { throw new \InvalidArgumentException( 'The first argument of "repeat" helper has to be greater than or equal to 0.' ); } $string = $template->render($context); return str_repeat($string, $times); }
php
public function execute(Template $template, Context $context, $args, $source) { $parsed_args = $template->parseArguments($args); if (count($parsed_args) != 1) { throw new \InvalidArgumentException( '"repeat" helper expects exactly one argument.' ); } $times = intval($context->get($parsed_args[0])); if ($times < 0) { throw new \InvalidArgumentException( 'The first argument of "repeat" helper has to be greater than or equal to 0.' ); } $string = $template->render($context); return str_repeat($string, $times); }
[ "public", "function", "execute", "(", "Template", "$", "template", ",", "Context", "$", "context", ",", "$", "args", ",", "$", "source", ")", "{", "$", "parsed_args", "=", "$", "template", "->", "parseArguments", "(", "$", "args", ")", ";", "if", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Text/RepeatHelper.php#L36-L54
joomla-framework/twitter-api
src/Block.php
Block.getBlocking
public function getBlocking($stringifyIds = null, $cursor = null, $full = null) { // Check the rate limit for remaining hits if ($full !== null) { $this->checkRateLimit('blocks', 'ids'); } else { $this->checkRateLimit('blocks', 'list'); } $data = array(); // Check if stringify_ids is specified if ($stringifyIds !== null) { $data['stringify_ids'] = $stringifyIds; } // Check if cursor is specified if ($stringifyIds !== null) { $data['cursor'] = $cursor; } // Set the API path $path = ($full === null) ? '/blocks/ids.json' : '/blocks/list.json'; // Send the request. return $this->sendRequest($path, 'GET', $data); }
php
public function getBlocking($stringifyIds = null, $cursor = null, $full = null) { // Check the rate limit for remaining hits if ($full !== null) { $this->checkRateLimit('blocks', 'ids'); } else { $this->checkRateLimit('blocks', 'list'); } $data = array(); // Check if stringify_ids is specified if ($stringifyIds !== null) { $data['stringify_ids'] = $stringifyIds; } // Check if cursor is specified if ($stringifyIds !== null) { $data['cursor'] = $cursor; } // Set the API path $path = ($full === null) ? '/blocks/ids.json' : '/blocks/list.json'; // Send the request. return $this->sendRequest($path, 'GET', $data); }
[ "public", "function", "getBlocking", "(", "$", "stringifyIds", "=", "null", ",", "$", "cursor", "=", "null", ",", "$", "full", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "if", "(", "$", "full", "!==", "null", ")", "{", "$", "this"...
Method to get the user ids the authenticating user is blocking. @param boolean $stringifyIds Provide this option to have ids returned as strings instead. @param integer $cursor Causes the list of IDs to be broken into pages of no more than 5000 IDs at a time. The number of IDs returned is not guaranteed to be 5000 as suspended users are filtered out after connections are queried. If no cursor is provided, a value of -1 will be assumed, which is the first "page." @param boolean $full Causes the list returned to contain full details of all blocks, instead of just the IDs. @return array The decoded JSON response @since 1.0
[ "Method", "to", "get", "the", "user", "ids", "the", "authenticating", "user", "is", "blocking", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Block.php#L32-L63
JustBlackBird/handlebars.php-helpers
src/Text/TruncateHelper.php
TruncateHelper.execute
public function execute(Template $template, Context $context, $args, $source) { $parsed_args = $template->parseArguments($args); if (count($parsed_args) < 2 || count($parsed_args) > 3) { throw new \InvalidArgumentException( '"truncate" helper expects two or three arguments.' ); } $string = (string)$context->get($parsed_args[0]); $length = intval($context->get($parsed_args[1])); $append = isset($parsed_args[2]) ? (string)$context->get($parsed_args[2]) : ''; if ($length < 0) { throw new \InvalidArgumentException( 'The second argument of "truncate" helper has to be greater than or equal to 0.' ); } if ($append && strlen($append) > $length) { throw new \InvalidArgumentException( 'Cannot truncate string. Length of append value is greater than target length.' ); } if (strlen($string) > $length) { return substr($string, 0, $length - strlen($append)) . $append; } else { return $string; } }
php
public function execute(Template $template, Context $context, $args, $source) { $parsed_args = $template->parseArguments($args); if (count($parsed_args) < 2 || count($parsed_args) > 3) { throw new \InvalidArgumentException( '"truncate" helper expects two or three arguments.' ); } $string = (string)$context->get($parsed_args[0]); $length = intval($context->get($parsed_args[1])); $append = isset($parsed_args[2]) ? (string)$context->get($parsed_args[2]) : ''; if ($length < 0) { throw new \InvalidArgumentException( 'The second argument of "truncate" helper has to be greater than or equal to 0.' ); } if ($append && strlen($append) > $length) { throw new \InvalidArgumentException( 'Cannot truncate string. Length of append value is greater than target length.' ); } if (strlen($string) > $length) { return substr($string, 0, $length - strlen($append)) . $append; } else { return $string; } }
[ "public", "function", "execute", "(", "Template", "$", "template", ",", "Context", "$", "context", ",", "$", "args", ",", "$", "source", ")", "{", "$", "parsed_args", "=", "$", "template", "->", "parseArguments", "(", "$", "args", ")", ";", "if", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Text/TruncateHelper.php#L38-L68
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Domain/Property/PropertyList.php
PropertyList.toArray
public function toArray() { $values = $this->values; return array_map( function ($cursor) use ($values) { return $values[$cursor]; }, $this->nameToCursor ); }
php
public function toArray() { $values = $this->values; return array_map( function ($cursor) use ($values) { return $values[$cursor]; }, $this->nameToCursor ); }
[ "public", "function", "toArray", "(", ")", "{", "$", "values", "=", "$", "this", "->", "values", ";", "return", "array_map", "(", "function", "(", "$", "cursor", ")", "use", "(", "$", "values", ")", "{", "return", "$", "values", "[", "$", "cursor", ...
Return an array form @return array Array form
[ "Return", "an", "array", "form" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Property/PropertyList.php#L111-L120
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Domain/Property/PropertyList.php
PropertyList.add
public function add(PropertyInterface $property) { $iri = $property->toIri(); // Create the property values list if necessary if (!$this->offsetExists($iri)) { $this->offsetSet($iri, [$property]); return; } $propertyStore =& $this->offsetGet($iri); $propertyStore[] = $property; }
php
public function add(PropertyInterface $property) { $iri = $property->toIri(); // Create the property values list if necessary if (!$this->offsetExists($iri)) { $this->offsetSet($iri, [$property]); return; } $propertyStore =& $this->offsetGet($iri); $propertyStore[] = $property; }
[ "public", "function", "add", "(", "PropertyInterface", "$", "property", ")", "{", "$", "iri", "=", "$", "property", "->", "toIri", "(", ")", ";", "// Create the property values list if necessary", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "$", ...
Add a property @param PropertyInterface $property Property
[ "Add", "a", "property" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Property/PropertyList.php#L127-L139
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Domain/Property/PropertyList.php
PropertyList.offsetSet
public function offsetSet($iri, $value) { $iriStr = strval($iri); $cursor = array_key_exists($iriStr, $this->nameToCursor) ? $this->nameToCursor[$iriStr] : ($this->nameToCursor[$iriStr] = count($this->nameToCursor)); $this->names[$cursor] = $iri; $this->values[$cursor] = $value; }
php
public function offsetSet($iri, $value) { $iriStr = strval($iri); $cursor = array_key_exists($iriStr, $this->nameToCursor) ? $this->nameToCursor[$iriStr] : ($this->nameToCursor[$iriStr] = count($this->nameToCursor)); $this->names[$cursor] = $iri; $this->values[$cursor] = $value; }
[ "public", "function", "offsetSet", "(", "$", "iri", ",", "$", "value", ")", "{", "$", "iriStr", "=", "strval", "(", "$", "iri", ")", ";", "$", "cursor", "=", "array_key_exists", "(", "$", "iriStr", ",", "$", "this", "->", "nameToCursor", ")", "?", ...
Set a particular property @param IriInterface|string $iri IRI @param array $value Property values
[ "Set", "a", "particular", "property" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Property/PropertyList.php#L158-L165
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Domain/Property/PropertyList.php
PropertyList.&
public function &offsetGet($iri) { $iriStr = strval($iri); // If the property name is unknown if (!isset($this->nameToCursor[$iriStr])) { throw new OutOfBoundsException( sprintf(OutOfBoundsException::UNKNOWN_PROPERTY_NAME_STR, $iriStr), OutOfBoundsException::UNKNOWN_PROPERTY_NAME ); } $cursor = $this->nameToCursor[strval($iri)]; return $this->values[$cursor]; }
php
public function &offsetGet($iri) { $iriStr = strval($iri); // If the property name is unknown if (!isset($this->nameToCursor[$iriStr])) { throw new OutOfBoundsException( sprintf(OutOfBoundsException::UNKNOWN_PROPERTY_NAME_STR, $iriStr), OutOfBoundsException::UNKNOWN_PROPERTY_NAME ); } $cursor = $this->nameToCursor[strval($iri)]; return $this->values[$cursor]; }
[ "public", "function", "&", "offsetGet", "(", "$", "iri", ")", "{", "$", "iriStr", "=", "strval", "(", "$", "iri", ")", ";", "// If the property name is unknown", "if", "(", "!", "isset", "(", "$", "this", "->", "nameToCursor", "[", "$", "iriStr", "]", ...
Get a particular property @param IriInterface|string $iri IRI @return array Property values
[ "Get", "a", "particular", "property" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Property/PropertyList.php#L173-L187
cornernote/yii-email-module
email/components/EEmailManager.php
EEmailManager.email
public function email($to, $subject, $message, $from = null, $attachments = array(), $transport = null, $spool = true, $priority = 10) { // get the message $swiftMessage = Swift_Message::newInstance($subject); $swiftMessage->setTo(is_array($to) ? $to : array($to)); $swiftMessage->setBody($message, 'text/html'); // set the from if (!$from) $swiftMessage->setFrom($this->fromEmail, $this->fromName); else $swiftMessage->setFrom(is_array($from) ? $from : array($from)); // attach files if ($attachments) { if (is_array($attachments)) foreach ($attachments as $attachment) $swiftMessage->attach(Swift_Attachment::fromPath($attachment)); else $swiftMessage->attach(Swift_Attachment::fromPath($attachments)); } // set the transport $transport = $transport ? $transport : $this->defaultTransport; // send the email if (!$spool) return $this->deliver($swiftMessage, $transport); // or spool the email $emailSpool = $this->getEmailSpool($swiftMessage); $emailSpool->transport = $transport; $emailSpool->priority = $priority; return $emailSpool->save(false); }
php
public function email($to, $subject, $message, $from = null, $attachments = array(), $transport = null, $spool = true, $priority = 10) { // get the message $swiftMessage = Swift_Message::newInstance($subject); $swiftMessage->setTo(is_array($to) ? $to : array($to)); $swiftMessage->setBody($message, 'text/html'); // set the from if (!$from) $swiftMessage->setFrom($this->fromEmail, $this->fromName); else $swiftMessage->setFrom(is_array($from) ? $from : array($from)); // attach files if ($attachments) { if (is_array($attachments)) foreach ($attachments as $attachment) $swiftMessage->attach(Swift_Attachment::fromPath($attachment)); else $swiftMessage->attach(Swift_Attachment::fromPath($attachments)); } // set the transport $transport = $transport ? $transport : $this->defaultTransport; // send the email if (!$spool) return $this->deliver($swiftMessage, $transport); // or spool the email $emailSpool = $this->getEmailSpool($swiftMessage); $emailSpool->transport = $transport; $emailSpool->priority = $priority; return $emailSpool->save(false); }
[ "public", "function", "email", "(", "$", "to", ",", "$", "subject", ",", "$", "message", ",", "$", "from", "=", "null", ",", "$", "attachments", "=", "array", "(", ")", ",", "$", "transport", "=", "null", ",", "$", "spool", "=", "true", ",", "$",...
Send an email. Email addresses can be formatted as a string 'user@dom.ain' or as an array('user@dom.ain'=>'User name'). Eg: Yii::app()->emailManager->email('user@dom.ain', 'test email', '<b>Hello</b> <i>World<i>!'); @param string|array $to @param string $subject @param string $message @param string|array $from @param array $attachments @param string $transport @param bool $spool @param int $priority @return bool
[ "Send", "an", "email", ".", "Email", "addresses", "can", "be", "formatted", "as", "a", "string", "user@dom", ".", "ain", "or", "as", "an", "array", "(", "user@dom", ".", "ain", "=", ">", "User", "name", ")", "." ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L139-L173
cornernote/yii-email-module
email/components/EEmailManager.php
EEmailManager.deliver
public function deliver($swiftMessage, $transport = null) { // get the transport if (!$transport) $transport = $this->defaultTransport; if (!isset($this->transports[$transport])) throw new CException(Yii::t('email', 'Transport :transport is not configured.', array(':transport' => $transport))); // get transport options $options = $this->transports[$transport]; // get transport class if (isset($options['class'])) { $class = $options['class']; unset($options['class']); } else { throw new CException(Yii::t('email', 'Transport :transport does not have a class.', array(':transport' => $transport))); } // get transport setters if (isset($options['setters'])) { $setters = $options['setters']; unset($options['setters']); } else { $setters = array(); } // create a new transport using class, options and setters $swiftTransport = call_user_func_array($class . '::newInstance', $options); foreach ($setters as $k => $v) { call_user_func_array(array($swiftTransport, 'set' . ucfirst($k)), array($v)); } // send the message using the transport return Swift_Mailer::newInstance($swiftTransport)->send($swiftMessage); }
php
public function deliver($swiftMessage, $transport = null) { // get the transport if (!$transport) $transport = $this->defaultTransport; if (!isset($this->transports[$transport])) throw new CException(Yii::t('email', 'Transport :transport is not configured.', array(':transport' => $transport))); // get transport options $options = $this->transports[$transport]; // get transport class if (isset($options['class'])) { $class = $options['class']; unset($options['class']); } else { throw new CException(Yii::t('email', 'Transport :transport does not have a class.', array(':transport' => $transport))); } // get transport setters if (isset($options['setters'])) { $setters = $options['setters']; unset($options['setters']); } else { $setters = array(); } // create a new transport using class, options and setters $swiftTransport = call_user_func_array($class . '::newInstance', $options); foreach ($setters as $k => $v) { call_user_func_array(array($swiftTransport, 'set' . ucfirst($k)), array($v)); } // send the message using the transport return Swift_Mailer::newInstance($swiftTransport)->send($swiftMessage); }
[ "public", "function", "deliver", "(", "$", "swiftMessage", ",", "$", "transport", "=", "null", ")", "{", "// get the transport", "if", "(", "!", "$", "transport", ")", "$", "transport", "=", "$", "this", "->", "defaultTransport", ";", "if", "(", "!", "is...
Deliver a message using a Swift_Transport class. Eg: Yii::app()->emailManager->deliver($swiftMessage); @param $swiftMessage @param string $transport @throws CException @return bool
[ "Deliver", "a", "message", "using", "a", "Swift_Transport", "class", "." ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L186-L221
cornernote/yii-email-module
email/components/EEmailManager.php
EEmailManager.spool
public function spool($limit = 10) { $done = 0; // find all the spooled emails $emailSpools = EmailSpool::model()->findAll(array( 'condition' => 't.status=:status', 'params' => array(':status' => 'pending'), 'order' => 't.priority DESC, t.created ASC', 'limit' => $limit, )); foreach ($emailSpools as $emailSpool) { // update status to processing $emailSpool->status = 'processing'; $emailSpool->save(false); // build the message $swiftMessage = $emailSpool->unpack($emailSpool->message); // send the email $sent = $this->deliver($swiftMessage, $emailSpool->transport); // update status and save $emailSpool->status = $sent ? 'emailed' : 'error'; $emailSpool->sent = time(); $emailSpool->save(false); $done++; } return $done; }
php
public function spool($limit = 10) { $done = 0; // find all the spooled emails $emailSpools = EmailSpool::model()->findAll(array( 'condition' => 't.status=:status', 'params' => array(':status' => 'pending'), 'order' => 't.priority DESC, t.created ASC', 'limit' => $limit, )); foreach ($emailSpools as $emailSpool) { // update status to processing $emailSpool->status = 'processing'; $emailSpool->save(false); // build the message $swiftMessage = $emailSpool->unpack($emailSpool->message); // send the email $sent = $this->deliver($swiftMessage, $emailSpool->transport); // update status and save $emailSpool->status = $sent ? 'emailed' : 'error'; $emailSpool->sent = time(); $emailSpool->save(false); $done++; } return $done; }
[ "public", "function", "spool", "(", "$", "limit", "=", "10", ")", "{", "$", "done", "=", "0", ";", "// find all the spooled emails", "$", "emailSpools", "=", "EmailSpool", "::", "model", "(", ")", "->", "findAll", "(", "array", "(", "'condition'", "=>", ...
Deliver pending EmailSpool records.
[ "Deliver", "pending", "EmailSpool", "records", "." ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L226-L255
cornernote/yii-email-module
email/components/EEmailManager.php
EEmailManager.getEmailSpool
public function getEmailSpool($swiftMessage, $model = null) { $emailSpool = new EmailSpool; $emailSpool->created = time(); $emailSpool->status = 'pending'; $emailSpool->subject = $swiftMessage->getSubject(); $emailSpool->message = $emailSpool->pack($swiftMessage); $emailSpool->to_address = json_encode($swiftMessage->getTo()); $emailSpool->from_address = json_encode($swiftMessage->getFrom()); if ($model) { $emailSpool->model_name = get_class($model); $emailSpool->model_id = is_array($model->getPrimaryKey()) ? implode('-', $model->getPrimaryKey()) : $model->getPrimaryKey(); } return $emailSpool; }
php
public function getEmailSpool($swiftMessage, $model = null) { $emailSpool = new EmailSpool; $emailSpool->created = time(); $emailSpool->status = 'pending'; $emailSpool->subject = $swiftMessage->getSubject(); $emailSpool->message = $emailSpool->pack($swiftMessage); $emailSpool->to_address = json_encode($swiftMessage->getTo()); $emailSpool->from_address = json_encode($swiftMessage->getFrom()); if ($model) { $emailSpool->model_name = get_class($model); $emailSpool->model_id = is_array($model->getPrimaryKey()) ? implode('-', $model->getPrimaryKey()) : $model->getPrimaryKey(); } return $emailSpool; }
[ "public", "function", "getEmailSpool", "(", "$", "swiftMessage", ",", "$", "model", "=", "null", ")", "{", "$", "emailSpool", "=", "new", "EmailSpool", ";", "$", "emailSpool", "->", "created", "=", "time", "(", ")", ";", "$", "emailSpool", "->", "status"...
Creates an EmailSpool based on a Swift_Message. Can optionally relate the EmailSpool to a model_id and model_name by passing an CActiveRecord into $model. @param Swift_Message $swiftMessage @param CActiveRecord|null $model @return EmailSpool
[ "Creates", "an", "EmailSpool", "based", "on", "a", "Swift_Message", ".", "Can", "optionally", "relate", "the", "EmailSpool", "to", "a", "model_id", "and", "model_name", "by", "passing", "an", "CActiveRecord", "into", "$model", "." ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L264-L278
cornernote/yii-email-module
email/components/EEmailManager.php
EEmailManager.buildTemplateMessage
public function buildTemplateMessage($template, $viewParams = array(), $layout = null) { if ($layout === null) $layout = $this->defaultLayout; $method = 'buildTemplateMessage_' . $this->templateType; if (!method_exists($this, $method)) $this->templateType = 'php'; return call_user_func_array(array($this, $method), array($template, $viewParams, $layout)); }
php
public function buildTemplateMessage($template, $viewParams = array(), $layout = null) { if ($layout === null) $layout = $this->defaultLayout; $method = 'buildTemplateMessage_' . $this->templateType; if (!method_exists($this, $method)) $this->templateType = 'php'; return call_user_func_array(array($this, $method), array($template, $viewParams, $layout)); }
[ "public", "function", "buildTemplateMessage", "(", "$", "template", ",", "$", "viewParams", "=", "array", "(", ")", ",", "$", "layout", "=", "null", ")", "{", "if", "(", "$", "layout", "===", "null", ")", "$", "layout", "=", "$", "this", "->", "defau...
Builds a template using the selected build method. @param $template string @param $viewParams array @param string $layout @return array
[ "Builds", "a", "template", "using", "the", "selected", "build", "method", "." ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L287-L295
cornernote/yii-email-module
email/components/EEmailManager.php
EEmailManager.registerSwiftMailerAutoloader
private function registerSwiftMailerAutoloader() { if ($this->swiftMailerPath === null) $this->swiftMailerPath = Yii::getPathOfAlias('vendor.swiftmailer.swiftmailer.lib'); $path = realpath($this->swiftMailerPath); if (!$this->swiftMailerPath || !$path) throw new CException('The EmailManager.swiftMailerPath is invalid.'); require_once($path . '/classes/Swift.php'); Yii::registerAutoloader(array('Swift', 'autoload'), true); require_once($path . '/swift_init.php'); }
php
private function registerSwiftMailerAutoloader() { if ($this->swiftMailerPath === null) $this->swiftMailerPath = Yii::getPathOfAlias('vendor.swiftmailer.swiftmailer.lib'); $path = realpath($this->swiftMailerPath); if (!$this->swiftMailerPath || !$path) throw new CException('The EmailManager.swiftMailerPath is invalid.'); require_once($path . '/classes/Swift.php'); Yii::registerAutoloader(array('Swift', 'autoload'), true); require_once($path . '/swift_init.php'); }
[ "private", "function", "registerSwiftMailerAutoloader", "(", ")", "{", "if", "(", "$", "this", "->", "swiftMailerPath", "===", "null", ")", "$", "this", "->", "swiftMailerPath", "=", "Yii", "::", "getPathOfAlias", "(", "'vendor.swiftmailer.swiftmailer.lib'", ")", ...
Registers the SwiftMailer autoloader
[ "Registers", "the", "SwiftMailer", "autoloader" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L356-L366
cornernote/yii-email-module
email/components/EEmailManager.php
EEmailManager.registerMustacheAutoloader
private function registerMustacheAutoloader() { if ($this->templateType != 'db') return; if ($this->mustachePath === null) $this->mustachePath = Yii::getPathOfAlias('vendor.mustache.mustache.src'); $path = realpath($this->mustachePath); if (!$this->mustachePath || !$path) throw new CException('The EmailManager.mustachePath is invalid.'); require_once($path . '/Mustache/Autoloader.php'); $autoloader = new Mustache_Autoloader; Yii::registerAutoloader(array($autoloader, 'autoload'), true); }
php
private function registerMustacheAutoloader() { if ($this->templateType != 'db') return; if ($this->mustachePath === null) $this->mustachePath = Yii::getPathOfAlias('vendor.mustache.mustache.src'); $path = realpath($this->mustachePath); if (!$this->mustachePath || !$path) throw new CException('The EmailManager.mustachePath is invalid.'); require_once($path . '/Mustache/Autoloader.php'); $autoloader = new Mustache_Autoloader; Yii::registerAutoloader(array($autoloader, 'autoload'), true); }
[ "private", "function", "registerMustacheAutoloader", "(", ")", "{", "if", "(", "$", "this", "->", "templateType", "!=", "'db'", ")", "return", ";", "if", "(", "$", "this", "->", "mustachePath", "===", "null", ")", "$", "this", "->", "mustachePath", "=", ...
Registers the Mustache autoloader
[ "Registers", "the", "Mustache", "autoloader" ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L371-L383
swoft-cloud/swoft-console
src/Helper/CommandHelper.php
CommandHelper.parse
public static function parse(array $params, array $config = []): array { $config = array_merge([ // List of parameters without values(bool option keys) 'noValues' => [], // ['debug', 'h'] // Whether merge short-opts and long-opts 'mergeOpts' => false, // list of params allow array. 'arrayValues' => [], // ['names', 'status'] ], $config); $args = $sOpts = $lOpts = []; $noValues = array_flip((array)$config['noValues']); $arrayValues = array_flip((array)$config['arrayValues']); // each() will deprecated at 7.2. so,there use current and next instead it. // while (list(,$p) = each($params)) { while (false !== ($p = current($params))) { next($params); // is options if ($p{0} === '-') { $val = true; $opt = substr($p, 1); $isLong = false; // long-opt: (--<opt>) if ($opt{0} === '-') { $opt = substr($opt, 1); $isLong = true; // long-opt: value specified inline (--<opt>=<value>) if (strpos($opt, '=') !== false) { list($opt, $val) = explode('=', $opt, 2); } // short-opt: value specified inline (-<opt>=<value>) } elseif (isset($opt{1}) && $opt{1} === '=') { list($opt, $val) = explode('=', $opt, 2); } // check if next parameter is a descriptor or a value $nxt = current($params); // next elem is value. fix: allow empty string '' if ($val === true && !isset($noValues[$opt]) && self::nextIsValue($nxt)) { // list(,$val) = each($params); $val = $nxt; next($params); // short-opt: bool opts. like -e -abc } elseif (!$isLong && $val === true) { foreach (str_split($opt) as $char) { $sOpts[$char] = true; } continue; } $val = self::filterBool($val); $isArray = isset($arrayValues[$opt]); if ($isLong) { if ($isArray) { $lOpts[$opt][] = $val; } else { $lOpts[$opt] = $val; } } else { if ($isArray) { $sOpts[$opt][] = $val; } else { $sOpts[$opt] = $val; } } // arguments: param doesn't belong to any option, define it is args } else { // value specified inline (<arg>=<value>) if (strpos($p, '=') !== false) { list($name, $val) = explode('=', $p, 2); $args[$name] = self::filterBool($val); } else { $args[] = $p; } } } if ($config['mergeOpts']) { return [$args, array_merge($sOpts, $lOpts)]; } return [$args, $sOpts, $lOpts]; }
php
public static function parse(array $params, array $config = []): array { $config = array_merge([ // List of parameters without values(bool option keys) 'noValues' => [], // ['debug', 'h'] // Whether merge short-opts and long-opts 'mergeOpts' => false, // list of params allow array. 'arrayValues' => [], // ['names', 'status'] ], $config); $args = $sOpts = $lOpts = []; $noValues = array_flip((array)$config['noValues']); $arrayValues = array_flip((array)$config['arrayValues']); // each() will deprecated at 7.2. so,there use current and next instead it. // while (list(,$p) = each($params)) { while (false !== ($p = current($params))) { next($params); // is options if ($p{0} === '-') { $val = true; $opt = substr($p, 1); $isLong = false; // long-opt: (--<opt>) if ($opt{0} === '-') { $opt = substr($opt, 1); $isLong = true; // long-opt: value specified inline (--<opt>=<value>) if (strpos($opt, '=') !== false) { list($opt, $val) = explode('=', $opt, 2); } // short-opt: value specified inline (-<opt>=<value>) } elseif (isset($opt{1}) && $opt{1} === '=') { list($opt, $val) = explode('=', $opt, 2); } // check if next parameter is a descriptor or a value $nxt = current($params); // next elem is value. fix: allow empty string '' if ($val === true && !isset($noValues[$opt]) && self::nextIsValue($nxt)) { // list(,$val) = each($params); $val = $nxt; next($params); // short-opt: bool opts. like -e -abc } elseif (!$isLong && $val === true) { foreach (str_split($opt) as $char) { $sOpts[$char] = true; } continue; } $val = self::filterBool($val); $isArray = isset($arrayValues[$opt]); if ($isLong) { if ($isArray) { $lOpts[$opt][] = $val; } else { $lOpts[$opt] = $val; } } else { if ($isArray) { $sOpts[$opt][] = $val; } else { $sOpts[$opt] = $val; } } // arguments: param doesn't belong to any option, define it is args } else { // value specified inline (<arg>=<value>) if (strpos($p, '=') !== false) { list($name, $val) = explode('=', $p, 2); $args[$name] = self::filterBool($val); } else { $args[] = $p; } } } if ($config['mergeOpts']) { return [$args, array_merge($sOpts, $lOpts)]; } return [$args, $sOpts, $lOpts]; }
[ "public", "static", "function", "parse", "(", "array", "$", "params", ",", "array", "$", "config", "=", "[", "]", ")", ":", "array", "{", "$", "config", "=", "array_merge", "(", "[", "// List of parameters without values(bool option keys)", "'noValues'", "=>", ...
Parses $GLOBALS['argv'] for parameters and assigns them to an array. eg: ``` php cli.php server start name=john city=chengdu -s=test --page=23 -d -rf --debug --task=off -y=false -D -e dev -v vvv ``` ```php $result = InputParser::fromArgv($_SERVER['argv']); ``` Supports args: <value> arg=<value> Supports opts: -e -e <value> -e=<value> --long-opt --long-opt <value> --long-opt=<value> @link http://php.net/manual/zh/function.getopt.php#83414 @from inhere/console @param array $params @param array $config @return array
[ "Parses", "$GLOBALS", "[", "argv", "]", "for", "parameters", "and", "assigns", "them", "to", "an", "array", ".", "eg", ":", "php", "cli", ".", "php", "server", "start", "name", "=", "john", "city", "=", "chengdu", "-", "s", "=", "test", "--", "page",...
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Helper/CommandHelper.php#L42-L135
Deathnerd/php-wtforms
src/validators/AnyOf.php
AnyOf.formatter
protected function formatter(array $values) { if (!is_null($this->user_formatter) && is_callable($this->user_formatter)) { return $this->user_formatter->__invoke($values); } return implode(", ", $values); }
php
protected function formatter(array $values) { if (!is_null($this->user_formatter) && is_callable($this->user_formatter)) { return $this->user_formatter->__invoke($values); } return implode(", ", $values); }
[ "protected", "function", "formatter", "(", "array", "$", "values", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "user_formatter", ")", "&&", "is_callable", "(", "$", "this", "->", "user_formatter", ")", ")", "{", "return", "$", "this", ...
If a callable was passed into the ``$options['formatter']`` in the constructor, this will call that to format the values to a string. Otherwise calls a default formatter: ``implode`` @param array $values The values to format @return string The formatted string
[ "If", "a", "callable", "was", "passed", "into", "the", "$options", "[", "formatter", "]", "in", "the", "constructor", "this", "will", "call", "that", "to", "format", "the", "values", "to", "a", "string", ".", "Otherwise", "calls", "a", "default", "formatte...
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/validators/AnyOf.php#L97-L104
JustBlackBird/handlebars.php-helpers
src/Text/Helpers.php
Helpers.addDefaultHelpers
protected function addDefaultHelpers() { parent::addDefaultHelpers(); $this->add('lowercase', new LowercaseHelper()); $this->add('uppercase', new UppercaseHelper()); $this->add('repeat', new RepeatHelper()); $this->add('replace', new ReplaceHelper()); $this->add('truncate', new TruncateHelper()); $this->add('ellipsis', new EllipsisHelper()); }
php
protected function addDefaultHelpers() { parent::addDefaultHelpers(); $this->add('lowercase', new LowercaseHelper()); $this->add('uppercase', new UppercaseHelper()); $this->add('repeat', new RepeatHelper()); $this->add('replace', new ReplaceHelper()); $this->add('truncate', new TruncateHelper()); $this->add('ellipsis', new EllipsisHelper()); }
[ "protected", "function", "addDefaultHelpers", "(", ")", "{", "parent", "::", "addDefaultHelpers", "(", ")", ";", "$", "this", "->", "add", "(", "'lowercase'", ",", "new", "LowercaseHelper", "(", ")", ")", ";", "$", "this", "->", "add", "(", "'uppercase'", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Text/Helpers.php#L25-L35
matfish2/eloquent-logger
src/Fish/Logger/migrations/create_mf_logs_table.php
CreateMfLogsTable.up
public function up() { if (Schema::hasTable('mf_logs')) return; Schema::create('mf_logs', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->nullable(); $table->integer('loggable_id'); $table->string('loggable_type'); $table->string('action'); $table->text('before')->nullable(); $table->text('after')->nullable(); $table->datetime('created_at'); }); }
php
public function up() { if (Schema::hasTable('mf_logs')) return; Schema::create('mf_logs', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->nullable(); $table->integer('loggable_id'); $table->string('loggable_type'); $table->string('action'); $table->text('before')->nullable(); $table->text('after')->nullable(); $table->datetime('created_at'); }); }
[ "public", "function", "up", "(", ")", "{", "if", "(", "Schema", "::", "hasTable", "(", "'mf_logs'", ")", ")", "return", ";", "Schema", "::", "create", "(", "'mf_logs'", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "i...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/matfish2/eloquent-logger/blob/37d645fc06e62d16e2c960fedd92817e8ff972f0/src/Fish/Logger/migrations/create_mf_logs_table.php#L13-L28