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
sonata-project/SonataClassificationBundle
src/Model/Category.php
Category.removeChild
public function removeChild(CategoryInterface $childToDelete) { foreach ($this->getChildren() as $pos => $child) { if ($childToDelete->getId() && $child->getId() === $childToDelete->getId()) { unset($this->children[$pos]); return; } if (!$childToDelete->getId() && $child === $childToDelete) { unset($this->children[$pos]); return; } } }
php
public function removeChild(CategoryInterface $childToDelete) { foreach ($this->getChildren() as $pos => $child) { if ($childToDelete->getId() && $child->getId() === $childToDelete->getId()) { unset($this->children[$pos]); return; } if (!$childToDelete->getId() && $child === $childToDelete) { unset($this->children[$pos]); return; } } }
[ "public", "function", "removeChild", "(", "CategoryInterface", "$", "childToDelete", ")", "{", "foreach", "(", "$", "this", "->", "getChildren", "(", ")", "as", "$", "pos", "=>", "$", "child", ")", "{", "if", "(", "$", "childToDelete", "->", "getId", "("...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Model/Category.php#L244-L259
sonata-project/SonataClassificationBundle
src/Model/Category.php
Category.setChildren
public function setChildren($children) { $this->children = new ArrayCollection(); foreach ($children as $category) { $this->addChild($category); } }
php
public function setChildren($children) { $this->children = new ArrayCollection(); foreach ($children as $category) { $this->addChild($category); } }
[ "public", "function", "setChildren", "(", "$", "children", ")", "{", "$", "this", "->", "children", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "category", ")", "{", "$", "this", "->", "addChild", "(", "$",...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Model/Category.php#L272-L279
sonata-project/SonataClassificationBundle
src/Model/Category.php
Category.setParent
public function setParent(CategoryInterface $parent = null, $nested = false) { $this->parent = $parent; if (!$nested && $parent) { $parent->addChild($this, true); } }
php
public function setParent(CategoryInterface $parent = null, $nested = false) { $this->parent = $parent; if (!$nested && $parent) { $parent->addChild($this, true); } }
[ "public", "function", "setParent", "(", "CategoryInterface", "$", "parent", "=", "null", ",", "$", "nested", "=", "false", ")", "{", "$", "this", "->", "parent", "=", "$", "parent", ";", "if", "(", "!", "$", "nested", "&&", "$", "parent", ")", "{", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Model/Category.php#L292-L299
sonata-project/SonataClassificationBundle
src/Form/ChoiceList/CategoryChoiceLoader.php
CategoryChoiceLoader.loadChoiceList
public function loadChoiceList($value = null) { if (null !== $this->choiceList) { return $this->choiceList; } return $this->choiceList = new ArrayChoiceList($this->choices, $value); }
php
public function loadChoiceList($value = null) { if (null !== $this->choiceList) { return $this->choiceList; } return $this->choiceList = new ArrayChoiceList($this->choices, $value); }
[ "public", "function", "loadChoiceList", "(", "$", "value", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "choiceList", ")", "{", "return", "$", "this", "->", "choiceList", ";", "}", "return", "$", "this", "->", "choiceList", "=", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Form/ChoiceList/CategoryChoiceLoader.php#L44-L51
sonata-project/SonataClassificationBundle
src/Controller/Api/ContextController.php
ContextController.getContextsAction
public function getContextsAction(ParamFetcherInterface $paramFetcher) { $page = $paramFetcher->get('page'); $count = $paramFetcher->get('count'); /** @var PagerInterface $contextsPager */ $contextsPager = $this->contextManager->getPager($this->filterCriteria($paramFetcher), $page, $count); return $contextsPager; }
php
public function getContextsAction(ParamFetcherInterface $paramFetcher) { $page = $paramFetcher->get('page'); $count = $paramFetcher->get('count'); /** @var PagerInterface $contextsPager */ $contextsPager = $this->contextManager->getPager($this->filterCriteria($paramFetcher), $page, $count); return $contextsPager; }
[ "public", "function", "getContextsAction", "(", "ParamFetcherInterface", "$", "paramFetcher", ")", "{", "$", "page", "=", "$", "paramFetcher", "->", "get", "(", "'page'", ")", ";", "$", "count", "=", "$", "paramFetcher", "->", "get", "(", "'count'", ")", "...
Retrieves the list of contexts (paginated) based on criteria. @ApiDoc( resource=true, output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} ) @QueryParam(name="page", requirements="\d+", default="1", description="Page for context list pagination") @QueryParam(name="count", requirements="\d+", default="10", description="Number of contexts by page") @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled contexts filter") @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) @param ParamFetcherInterface $paramFetcher @return PagerInterface
[ "Retrieves", "the", "list", "of", "contexts", "(", "paginated", ")", "based", "on", "criteria", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/Api/ContextController.php#L74-L83
sonata-project/SonataClassificationBundle
src/Controller/Api/ContextController.php
ContextController.deleteContextAction
public function deleteContextAction($id) { $context = $this->getContext($id); $this->contextManager->delete($context); return ['deleted' => true]; }
php
public function deleteContextAction($id) { $context = $this->getContext($id); $this->contextManager->delete($context); return ['deleted' => true]; }
[ "public", "function", "deleteContextAction", "(", "$", "id", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", "$", "id", ")", ";", "$", "this", "->", "contextManager", "->", "delete", "(", "$", "context", ")", ";", "return", "[", ...
Deletes a context. @ApiDoc( requirements={ {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="context identifier"} }, statusCodes={ 200="Returned when context is successfully deleted", 400="Returned when an error has occurred while context deletion", 404="Returned when unable to find context" } ) @param int $id A Context identifier @throws NotFoundHttpException @return View
[ "Deletes", "a", "context", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/Api/ContextController.php#L182-L189
sonata-project/SonataClassificationBundle
src/Controller/Api/ContextController.php
ContextController.getContext
protected function getContext($id) { $context = $this->contextManager->find($id); if (null === $context) { throw new NotFoundHttpException(sprintf('Context (%d) not found', $id)); } return $context; }
php
protected function getContext($id) { $context = $this->contextManager->find($id); if (null === $context) { throw new NotFoundHttpException(sprintf('Context (%d) not found', $id)); } return $context; }
[ "protected", "function", "getContext", "(", "$", "id", ")", "{", "$", "context", "=", "$", "this", "->", "contextManager", "->", "find", "(", "$", "id", ")", ";", "if", "(", "null", "===", "$", "context", ")", "{", "throw", "new", "NotFoundHttpExceptio...
Retrieves context with id $id or throws an exception if it doesn't exist. @param int $id A Context identifier @throws NotFoundHttpException @return ContextInterface
[ "Retrieves", "context", "with", "id", "$id", "or", "throws", "an", "exception", "if", "it", "doesn", "t", "exist", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/Api/ContextController.php#L222-L231
sonata-project/SonataClassificationBundle
src/Controller/Api/ContextController.php
ContextController.handleWriteContext
protected function handleWriteContext($request, $id = null) { $context = $id ? $this->getContext($id) : null; $form = $this->formFactory->createNamed(null, 'sonata_classification_api_form_context', $context, [ 'csrf_protection' => false, ]); FormHelper::removeFields($request->request->all(), $form); $form->handleRequest($request); if ($form->isValid()) { $context = $form->getData(); $this->contextManager->save($context); $context = new Context(); $context->setGroups(['sonata_api_read']); $view = FOSRestView::create($context); $view->setContext($context); return $view; } return $form; }
php
protected function handleWriteContext($request, $id = null) { $context = $id ? $this->getContext($id) : null; $form = $this->formFactory->createNamed(null, 'sonata_classification_api_form_context', $context, [ 'csrf_protection' => false, ]); FormHelper::removeFields($request->request->all(), $form); $form->handleRequest($request); if ($form->isValid()) { $context = $form->getData(); $this->contextManager->save($context); $context = new Context(); $context->setGroups(['sonata_api_read']); $view = FOSRestView::create($context); $view->setContext($context); return $view; } return $form; }
[ "protected", "function", "handleWriteContext", "(", "$", "request", ",", "$", "id", "=", "null", ")", "{", "$", "context", "=", "$", "id", "?", "$", "this", "->", "getContext", "(", "$", "id", ")", ":", "null", ";", "$", "form", "=", "$", "this", ...
Write a context, this method is used by both POST and PUT action methods. @param Request $request Symfony request @param int|null $id A context identifier @return FormInterface
[ "Write", "a", "context", "this", "method", "is", "used", "by", "both", "POST", "and", "PUT", "action", "methods", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/Api/ContextController.php#L241-L267
sonata-project/SonataClassificationBundle
src/Block/Service/AbstractTagsBlockService.php
AbstractTagsBlockService.execute
public function execute(BlockContextInterface $blockContext, Response $response = null) { $tag = $this->getTag($blockContext->getSetting('tagId'), $blockContext->getSetting('tag')); $tags = $this->tagManager->findBy([ 'enabled' => true, 'context' => $blockContext->getSetting('context'), ]); return $this->renderResponse($blockContext->getTemplate(), [ 'context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'tag' => $tag, 'tags' => $tags, ], $response); }
php
public function execute(BlockContextInterface $blockContext, Response $response = null) { $tag = $this->getTag($blockContext->getSetting('tagId'), $blockContext->getSetting('tag')); $tags = $this->tagManager->findBy([ 'enabled' => true, 'context' => $blockContext->getSetting('context'), ]); return $this->renderResponse($blockContext->getTemplate(), [ 'context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'tag' => $tag, 'tags' => $tags, ], $response); }
[ "public", "function", "execute", "(", "BlockContextInterface", "$", "blockContext", ",", "Response", "$", "response", "=", "null", ")", "{", "$", "tag", "=", "$", "this", "->", "getTag", "(", "$", "blockContext", "->", "getSetting", "(", "'tagId'", ")", ",...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Block/Service/AbstractTagsBlockService.php#L64-L79
sonata-project/SonataClassificationBundle
src/Block/Service/AbstractTagsBlockService.php
AbstractTagsBlockService.buildEditForm
public function buildEditForm(FormMapper $formMapper, BlockInterface $block) { $adminField = $this->getFormAdminType($formMapper, $this->tagAdmin, 'tagId', 'tag', [ 'label' => 'form.label_tag', ], [ 'translation_domain' => 'SonataClassificationBundle', 'link_parameters' => [ [ 'context' => $block->getSetting('context'), ], ], ]); $formMapper->add('settings', ImmutableArrayType::class, [ 'keys' => [ ['title', TextType::class, [ 'required' => false, 'label' => 'form.label_title', ]], ['translation_domain', TextType::class, [ 'label' => 'form.label_translation_domain', 'required' => false, ]], ['icon', TextType::class, [ 'label' => 'form.label_icon', 'required' => false, ]], ['class', TextType::class, [ 'label' => 'form.label_class', 'required' => false, ]], ['context', ChoiceType::class, [ 'label' => 'form.label_context', 'required' => false, 'choices' => $this->getContextChoices(), ]], [$adminField, null, []], ], 'translation_domain' => 'SonataClassificationBundle', ] ); }
php
public function buildEditForm(FormMapper $formMapper, BlockInterface $block) { $adminField = $this->getFormAdminType($formMapper, $this->tagAdmin, 'tagId', 'tag', [ 'label' => 'form.label_tag', ], [ 'translation_domain' => 'SonataClassificationBundle', 'link_parameters' => [ [ 'context' => $block->getSetting('context'), ], ], ]); $formMapper->add('settings', ImmutableArrayType::class, [ 'keys' => [ ['title', TextType::class, [ 'required' => false, 'label' => 'form.label_title', ]], ['translation_domain', TextType::class, [ 'label' => 'form.label_translation_domain', 'required' => false, ]], ['icon', TextType::class, [ 'label' => 'form.label_icon', 'required' => false, ]], ['class', TextType::class, [ 'label' => 'form.label_class', 'required' => false, ]], ['context', ChoiceType::class, [ 'label' => 'form.label_context', 'required' => false, 'choices' => $this->getContextChoices(), ]], [$adminField, null, []], ], 'translation_domain' => 'SonataClassificationBundle', ] ); }
[ "public", "function", "buildEditForm", "(", "FormMapper", "$", "formMapper", ",", "BlockInterface", "$", "block", ")", "{", "$", "adminField", "=", "$", "this", "->", "getFormAdminType", "(", "$", "formMapper", ",", "$", "this", "->", "tagAdmin", ",", "'tagI...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Block/Service/AbstractTagsBlockService.php#L84-L125
sonata-project/SonataClassificationBundle
src/Block/Service/AbstractTagsBlockService.php
AbstractTagsBlockService.configureSettings
public function configureSettings(OptionsResolver $resolver) { $resolver->setDefaults([ 'title' => null, 'translation_domain' => null, 'icon' => 'fa fa-tags', 'class' => null, 'tag' => false, 'tagId' => null, 'context' => null, 'template' => '@SonataClassification/Block/base_block_tags.html.twig', ]); }
php
public function configureSettings(OptionsResolver $resolver) { $resolver->setDefaults([ 'title' => null, 'translation_domain' => null, 'icon' => 'fa fa-tags', 'class' => null, 'tag' => false, 'tagId' => null, 'context' => null, 'template' => '@SonataClassification/Block/base_block_tags.html.twig', ]); }
[ "public", "function", "configureSettings", "(", "OptionsResolver", "$", "resolver", ")", "{", "$", "resolver", "->", "setDefaults", "(", "[", "'title'", "=>", "null", ",", "'translation_domain'", "=>", "null", ",", "'icon'", "=>", "'fa fa-tags'", ",", "'class'",...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Block/Service/AbstractTagsBlockService.php#L130-L142
sonata-project/SonataClassificationBundle
src/Block/Service/AbstractTagsBlockService.php
AbstractTagsBlockService.load
public function load(BlockInterface $block) { if (is_numeric($block->getSetting('tagId'))) { $block->setSetting('tagId', $this->getTag($block->getSetting('tagId'))); } }
php
public function load(BlockInterface $block) { if (is_numeric($block->getSetting('tagId'))) { $block->setSetting('tagId', $this->getTag($block->getSetting('tagId'))); } }
[ "public", "function", "load", "(", "BlockInterface", "$", "block", ")", "{", "if", "(", "is_numeric", "(", "$", "block", "->", "getSetting", "(", "'tagId'", ")", ")", ")", "{", "$", "block", "->", "setSetting", "(", "'tagId'", ",", "$", "this", "->", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Block/Service/AbstractTagsBlockService.php#L147-L152
sonata-project/SonataClassificationBundle
src/Block/Service/AbstractTagsBlockService.php
AbstractTagsBlockService.getTag
final protected function getTag($id, $default = null) { if ($id instanceof TagInterface) { return $id; } if (is_numeric($id)) { return $this->tagManager->find($id); } if ($default instanceof TagInterface) { return $default; } return null; }
php
final protected function getTag($id, $default = null) { if ($id instanceof TagInterface) { return $id; } if (is_numeric($id)) { return $this->tagManager->find($id); } if ($default instanceof TagInterface) { return $default; } return null; }
[ "final", "protected", "function", "getTag", "(", "$", "id", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "id", "instanceof", "TagInterface", ")", "{", "return", "$", "id", ";", "}", "if", "(", "is_numeric", "(", "$", "id", ")", ")", ...
@param TagInterface|int $id @param mixed $default @return TagInterface|null
[ "@param", "TagInterface|int", "$id", "@param", "mixed", "$default" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Block/Service/AbstractTagsBlockService.php#L188-L203
sonata-project/SonataClassificationBundle
src/Controller/CategoryAdminController.php
CategoryAdminController.listAction
public function listAction(Request $request = null) { if (!$request->get('filter') && !$request->get('filters')) { return new RedirectResponse($this->admin->generateUrl('tree', $request->query->all())); } if ($listMode = $request->get('_list_mode')) { $this->admin->setListMode($listMode); } $datagrid = $this->admin->getDatagrid(); $datagridValues = $datagrid->getValues(); $datagridContextIsSet = isset($datagridValues['context']['value']) && !empty($datagridValues['context']['value']); //ignore `context` persistent parameter if datagrid `context` value is set if ($this->admin->getPersistentParameter('context') && !$datagridContextIsSet) { $datagrid->setValue('context', null, $this->admin->getPersistentParameter('context')); } $formView = $datagrid->getForm()->createView(); // set the theme for the current Admin Form $this->setFormTheme($formView, $this->admin->getFilterTheme()); return $this->renderWithExtraParams($this->admin->getTemplate('list'), [ 'action' => 'list', 'form' => $formView, 'datagrid' => $datagrid, 'csrf_token' => $this->getCsrfToken('sonata.batch'), ]); }
php
public function listAction(Request $request = null) { if (!$request->get('filter') && !$request->get('filters')) { return new RedirectResponse($this->admin->generateUrl('tree', $request->query->all())); } if ($listMode = $request->get('_list_mode')) { $this->admin->setListMode($listMode); } $datagrid = $this->admin->getDatagrid(); $datagridValues = $datagrid->getValues(); $datagridContextIsSet = isset($datagridValues['context']['value']) && !empty($datagridValues['context']['value']); //ignore `context` persistent parameter if datagrid `context` value is set if ($this->admin->getPersistentParameter('context') && !$datagridContextIsSet) { $datagrid->setValue('context', null, $this->admin->getPersistentParameter('context')); } $formView = $datagrid->getForm()->createView(); // set the theme for the current Admin Form $this->setFormTheme($formView, $this->admin->getFilterTheme()); return $this->renderWithExtraParams($this->admin->getTemplate('list'), [ 'action' => 'list', 'form' => $formView, 'datagrid' => $datagrid, 'csrf_token' => $this->getCsrfToken('sonata.batch'), ]); }
[ "public", "function", "listAction", "(", "Request", "$", "request", "=", "null", ")", "{", "if", "(", "!", "$", "request", "->", "get", "(", "'filter'", ")", "&&", "!", "$", "request", "->", "get", "(", "'filters'", ")", ")", "{", "return", "new", ...
@param Request $request @return Response
[ "@param", "Request", "$request" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/CategoryAdminController.php#L39-L70
sonata-project/SonataClassificationBundle
src/Controller/CategoryAdminController.php
CategoryAdminController.treeAction
public function treeAction(Request $request) { $categoryManager = $this->get('sonata.classification.manager.category'); $currentContext = false; if ($context = $request->get('context')) { $currentContext = $this->get('sonata.classification.manager.context')->find($context); } // all root categories. $rootCategoriesSplitByContexts = $categoryManager->getRootCategoriesSplitByContexts(false); // root categories inside the current context $currentCategories = []; if (!$currentContext && !empty($rootCategoriesSplitByContexts)) { $currentCategories = current($rootCategoriesSplitByContexts); $currentContext = current($currentCategories)->getContext(); } else { foreach ($rootCategoriesSplitByContexts as $contextId => $contextCategories) { if ($currentContext->getId() !== $contextId) { continue; } foreach ($contextCategories as $category) { if ($currentContext->getId() !== $category->getContext()->getId()) { continue; } $currentCategories[] = $category; } } } $datagrid = $this->admin->getDatagrid(); if ($this->admin->getPersistentParameter('context')) { $datagrid->setValue('context', null, $this->admin->getPersistentParameter('context')); } $formView = $datagrid->getForm()->createView(); $this->setFormTheme($formView, $this->admin->getFilterTheme()); return $this->renderWithExtraParams($this->admin->getTemplate('tree'), [ 'action' => 'tree', 'current_categories' => $currentCategories, 'root_categories' => $rootCategoriesSplitByContexts, 'current_context' => $currentContext, 'form' => $formView, 'csrf_token' => $this->getCsrfToken('sonata.batch'), ]); }
php
public function treeAction(Request $request) { $categoryManager = $this->get('sonata.classification.manager.category'); $currentContext = false; if ($context = $request->get('context')) { $currentContext = $this->get('sonata.classification.manager.context')->find($context); } // all root categories. $rootCategoriesSplitByContexts = $categoryManager->getRootCategoriesSplitByContexts(false); // root categories inside the current context $currentCategories = []; if (!$currentContext && !empty($rootCategoriesSplitByContexts)) { $currentCategories = current($rootCategoriesSplitByContexts); $currentContext = current($currentCategories)->getContext(); } else { foreach ($rootCategoriesSplitByContexts as $contextId => $contextCategories) { if ($currentContext->getId() !== $contextId) { continue; } foreach ($contextCategories as $category) { if ($currentContext->getId() !== $category->getContext()->getId()) { continue; } $currentCategories[] = $category; } } } $datagrid = $this->admin->getDatagrid(); if ($this->admin->getPersistentParameter('context')) { $datagrid->setValue('context', null, $this->admin->getPersistentParameter('context')); } $formView = $datagrid->getForm()->createView(); $this->setFormTheme($formView, $this->admin->getFilterTheme()); return $this->renderWithExtraParams($this->admin->getTemplate('tree'), [ 'action' => 'tree', 'current_categories' => $currentCategories, 'root_categories' => $rootCategoriesSplitByContexts, 'current_context' => $currentContext, 'form' => $formView, 'csrf_token' => $this->getCsrfToken('sonata.batch'), ]); }
[ "public", "function", "treeAction", "(", "Request", "$", "request", ")", "{", "$", "categoryManager", "=", "$", "this", "->", "get", "(", "'sonata.classification.manager.category'", ")", ";", "$", "currentContext", "=", "false", ";", "if", "(", "$", "context",...
@param Request $request @return Response
[ "@param", "Request", "$request" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/CategoryAdminController.php#L77-L128
sonata-project/SonataClassificationBundle
src/Controller/Api/CollectionController.php
CollectionController.getCollectionsAction
public function getCollectionsAction(ParamFetcherInterface $paramFetcher) { $page = $paramFetcher->get('page'); $count = $paramFetcher->get('count'); /** @var PagerInterface $collectionsPager */ $collectionsPager = $this->collectionManager->getPager($this->filterCriteria($paramFetcher), $page, $count); return $collectionsPager; }
php
public function getCollectionsAction(ParamFetcherInterface $paramFetcher) { $page = $paramFetcher->get('page'); $count = $paramFetcher->get('count'); /** @var PagerInterface $collectionsPager */ $collectionsPager = $this->collectionManager->getPager($this->filterCriteria($paramFetcher), $page, $count); return $collectionsPager; }
[ "public", "function", "getCollectionsAction", "(", "ParamFetcherInterface", "$", "paramFetcher", ")", "{", "$", "page", "=", "$", "paramFetcher", "->", "get", "(", "'page'", ")", ";", "$", "count", "=", "$", "paramFetcher", "->", "get", "(", "'count'", ")", ...
Retrieves the list of collections (paginated) based on criteria. @ApiDoc( resource=true, output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} ) @QueryParam(name="page", requirements="\d+", default="1", description="Page for collection list pagination") @QueryParam(name="count", requirements="\d+", default="10", description="Number of collections by page") @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled collections filter") @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) @param ParamFetcherInterface $paramFetcher @return PagerInterface
[ "Retrieves", "the", "list", "of", "collections", "(", "paginated", ")", "based", "on", "criteria", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/Api/CollectionController.php#L74-L83
sonata-project/SonataClassificationBundle
src/Controller/Api/CollectionController.php
CollectionController.deleteCollectionAction
public function deleteCollectionAction($id) { $collection = $this->getCollection($id); $this->collectionManager->delete($collection); return ['deleted' => true]; }
php
public function deleteCollectionAction($id) { $collection = $this->getCollection($id); $this->collectionManager->delete($collection); return ['deleted' => true]; }
[ "public", "function", "deleteCollectionAction", "(", "$", "id", ")", "{", "$", "collection", "=", "$", "this", "->", "getCollection", "(", "$", "id", ")", ";", "$", "this", "->", "collectionManager", "->", "delete", "(", "$", "collection", ")", ";", "ret...
Deletes a collection. @ApiDoc( requirements={ {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="collection identifier"} }, statusCodes={ 200="Returned when collection is successfully deleted", 400="Returned when an error has occurred while collection deletion", 404="Returned when unable to find collection" } ) @param int $id A Collection identifier @throws NotFoundHttpException @return View
[ "Deletes", "a", "collection", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/Api/CollectionController.php#L182-L189
sonata-project/SonataClassificationBundle
src/Controller/Api/CollectionController.php
CollectionController.getCollection
protected function getCollection($id) { $collection = $this->collectionManager->find($id); if (null === $collection) { throw new NotFoundHttpException(sprintf('Collection (%d) not found', $id)); } return $collection; }
php
protected function getCollection($id) { $collection = $this->collectionManager->find($id); if (null === $collection) { throw new NotFoundHttpException(sprintf('Collection (%d) not found', $id)); } return $collection; }
[ "protected", "function", "getCollection", "(", "$", "id", ")", "{", "$", "collection", "=", "$", "this", "->", "collectionManager", "->", "find", "(", "$", "id", ")", ";", "if", "(", "null", "===", "$", "collection", ")", "{", "throw", "new", "NotFound...
Retrieves collection with id $id or throws an exception if it doesn't exist. @param int $id A Collection identifier @throws NotFoundHttpException @return CollectionInterface
[ "Retrieves", "collection", "with", "id", "$id", "or", "throws", "an", "exception", "if", "it", "doesn", "t", "exist", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/Api/CollectionController.php#L222-L231
sonata-project/SonataClassificationBundle
src/Controller/Api/CollectionController.php
CollectionController.handleWriteCollection
protected function handleWriteCollection($request, $id = null) { $collection = $id ? $this->getCollection($id) : null; $form = $this->formFactory->createNamed(null, 'sonata_classification_api_form_collection', $collection, [ 'csrf_protection' => false, ]); FormHelper::removeFields($request->request->all(), $form); $form->handleRequest($request); if ($form->isValid()) { $collection = $form->getData(); $this->collectionManager->save($collection); $context = new Context(); $context->setGroups(['sonata_api_read']); $view = FOSRestView::create($collection); $view->setContext($context); return $view; } return $form; }
php
protected function handleWriteCollection($request, $id = null) { $collection = $id ? $this->getCollection($id) : null; $form = $this->formFactory->createNamed(null, 'sonata_classification_api_form_collection', $collection, [ 'csrf_protection' => false, ]); FormHelper::removeFields($request->request->all(), $form); $form->handleRequest($request); if ($form->isValid()) { $collection = $form->getData(); $this->collectionManager->save($collection); $context = new Context(); $context->setGroups(['sonata_api_read']); $view = FOSRestView::create($collection); $view->setContext($context); return $view; } return $form; }
[ "protected", "function", "handleWriteCollection", "(", "$", "request", ",", "$", "id", "=", "null", ")", "{", "$", "collection", "=", "$", "id", "?", "$", "this", "->", "getCollection", "(", "$", "id", ")", ":", "null", ";", "$", "form", "=", "$", ...
Write a collection, this method is used by both POST and PUT action methods. @param Request $request Symfony request @param int|null $id A collection identifier @return View|FormInterface
[ "Write", "a", "collection", "this", "method", "is", "used", "by", "both", "POST", "and", "PUT", "action", "methods", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Controller/Api/CollectionController.php#L241-L267
sonata-project/SonataClassificationBundle
src/Admin/CollectionAdmin.php
CollectionAdmin.configureFormFields
protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('name') ->add('description', TextareaType::class, [ 'required' => false, ]) ->add('context') ->add('enabled', CheckboxType::class, [ 'required' => false, ]) ; if (interface_exists(MediaInterface::class)) { $formMapper->add('media', ModelListType::class, [ 'required' => false, ], [ 'link_parameters' => [ 'provider' => 'sonata.media.provider.image', 'context' => 'sonata_collection', ], ]); } }
php
protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('name') ->add('description', TextareaType::class, [ 'required' => false, ]) ->add('context') ->add('enabled', CheckboxType::class, [ 'required' => false, ]) ; if (interface_exists(MediaInterface::class)) { $formMapper->add('media', ModelListType::class, [ 'required' => false, ], [ 'link_parameters' => [ 'provider' => 'sonata.media.provider.image', 'context' => 'sonata_collection', ], ]); } }
[ "protected", "function", "configureFormFields", "(", "FormMapper", "$", "formMapper", ")", "{", "$", "formMapper", "->", "add", "(", "'name'", ")", "->", "add", "(", "'description'", ",", "TextareaType", "::", "class", ",", "[", "'required'", "=>", "false", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Admin/CollectionAdmin.php#L57-L80
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getRootCategoriesPager
public function getRootCategoriesPager($page = 1, $limit = 25, $criteria = []) { $page = 0 === (int) $page ? 1 : (int) $page; $queryBuilder = $this->getObjectManager()->createQueryBuilder() ->select('c') ->from($this->class, 'c') ->andWhere('c.parent IS NULL'); $pager = new Pager($limit); $pager->setQuery(new ProxyQuery($queryBuilder)); $pager->setPage($page); $pager->init(); return $pager; }
php
public function getRootCategoriesPager($page = 1, $limit = 25, $criteria = []) { $page = 0 === (int) $page ? 1 : (int) $page; $queryBuilder = $this->getObjectManager()->createQueryBuilder() ->select('c') ->from($this->class, 'c') ->andWhere('c.parent IS NULL'); $pager = new Pager($limit); $pager->setQuery(new ProxyQuery($queryBuilder)); $pager->setPage($page); $pager->init(); return $pager; }
[ "public", "function", "getRootCategoriesPager", "(", "$", "page", "=", "1", ",", "$", "limit", "=", "25", ",", "$", "criteria", "=", "[", "]", ")", "{", "$", "page", "=", "0", "===", "(", "int", ")", "$", "page", "?", "1", ":", "(", "int", ")",...
Returns a pager to iterate over the root category. @param int $page @param int $limit @param array $criteria @return mixed
[ "Returns", "a", "pager", "to", "iterate", "over", "the", "root", "category", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L60-L75
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getSubCategoriesPager
public function getSubCategoriesPager($categoryId, $page = 1, $limit = 25, $criteria = []) { $queryBuilder = $this->getObjectManager()->createQueryBuilder() ->select('c') ->from($this->class, 'c') ->where('c.parent = :categoryId') ->setParameter('categoryId', $categoryId); $pager = new Pager($limit); $pager->setQuery(new ProxyQuery($queryBuilder)); $pager->setPage($page); $pager->init(); return $pager; }
php
public function getSubCategoriesPager($categoryId, $page = 1, $limit = 25, $criteria = []) { $queryBuilder = $this->getObjectManager()->createQueryBuilder() ->select('c') ->from($this->class, 'c') ->where('c.parent = :categoryId') ->setParameter('categoryId', $categoryId); $pager = new Pager($limit); $pager->setQuery(new ProxyQuery($queryBuilder)); $pager->setPage($page); $pager->init(); return $pager; }
[ "public", "function", "getSubCategoriesPager", "(", "$", "categoryId", ",", "$", "page", "=", "1", ",", "$", "limit", "=", "25", ",", "$", "criteria", "=", "[", "]", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "getObjectManager", "(", ")", ...
@param int $categoryId @param int $page @param int $limit @param array $criteria @return PagerInterface
[ "@param", "int", "$categoryId", "@param", "int", "$page", "@param", "int", "$limit", "@param", "array", "$criteria" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L85-L99
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getRootCategoryWithChildren
public function getRootCategoryWithChildren(CategoryInterface $category) { if (null === $category->getContext()) { throw new \RuntimeException('Context cannot be null'); } if (null !== $category->getParent()) { throw new \RuntimeException('Method can be called only for root categories'); } $context = $this->getContext($category->getContext()); $this->loadCategories($context); foreach ($this->categories[$context->getId()] as $contextRootCategory) { if ($category->getId() === $contextRootCategory->getId()) { return $contextRootCategory; } } throw new \RuntimeException('Category does not exist'); }
php
public function getRootCategoryWithChildren(CategoryInterface $category) { if (null === $category->getContext()) { throw new \RuntimeException('Context cannot be null'); } if (null !== $category->getParent()) { throw new \RuntimeException('Method can be called only for root categories'); } $context = $this->getContext($category->getContext()); $this->loadCategories($context); foreach ($this->categories[$context->getId()] as $contextRootCategory) { if ($category->getId() === $contextRootCategory->getId()) { return $contextRootCategory; } } throw new \RuntimeException('Category does not exist'); }
[ "public", "function", "getRootCategoryWithChildren", "(", "CategoryInterface", "$", "category", ")", "{", "if", "(", "null", "===", "$", "category", "->", "getContext", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Context cannot be null'", ...
NEXT_MAJOR: add this method to the interface. @param CategoryInterface $category @return CategoryInterface
[ "NEXT_MAJOR", ":", "add", "this", "method", "to", "the", "interface", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L108-L127
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getRootCategory
public function getRootCategory($context = null) { $context = $this->getContext($context); $this->loadCategories($context); return $this->categories[$context->getId()][0]; }
php
public function getRootCategory($context = null) { $context = $this->getContext($context); $this->loadCategories($context); return $this->categories[$context->getId()][0]; }
[ "public", "function", "getRootCategory", "(", "$", "context", "=", "null", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", "$", "context", ")", ";", "$", "this", "->", "loadCategories", "(", "$", "context", ")", ";", "return", "$",...
@todo NEXT_MAJOR: remove this method. @param ContextInterface $context @return CategoryInterface
[ "@todo", "NEXT_MAJOR", ":", "remove", "this", "method", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L136-L143
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getRootCategoriesForContext
public function getRootCategoriesForContext(ContextInterface $context = null) { $context = $this->getContext($context); $this->loadCategories($context); return $this->categories[$context->getId()]; }
php
public function getRootCategoriesForContext(ContextInterface $context = null) { $context = $this->getContext($context); $this->loadCategories($context); return $this->categories[$context->getId()]; }
[ "public", "function", "getRootCategoriesForContext", "(", "ContextInterface", "$", "context", "=", "null", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", "$", "context", ")", ";", "$", "this", "->", "loadCategories", "(", "$", "context"...
NEXT_MAJOR: add this method to the interface. @param ContextInterface $context @return CategoryInterface[]
[ "NEXT_MAJOR", ":", "add", "this", "method", "to", "the", "interface", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L152-L159
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getAllRootCategories
public function getAllRootCategories($loadChildren = true) { $class = $this->getClass(); $rootCategories = $this->getObjectManager()->createQuery(sprintf('SELECT c FROM %s c WHERE c.parent IS NULL', $class)) ->execute(); $categories = []; foreach ($rootCategories as $category) { if (null === $category->getContext()) { throw new \RuntimeException('Context cannot be null'); } $categories[] = $loadChildren ? $this->getRootCategoryWithChildren($category) : $category; } return $categories; }
php
public function getAllRootCategories($loadChildren = true) { $class = $this->getClass(); $rootCategories = $this->getObjectManager()->createQuery(sprintf('SELECT c FROM %s c WHERE c.parent IS NULL', $class)) ->execute(); $categories = []; foreach ($rootCategories as $category) { if (null === $category->getContext()) { throw new \RuntimeException('Context cannot be null'); } $categories[] = $loadChildren ? $this->getRootCategoryWithChildren($category) : $category; } return $categories; }
[ "public", "function", "getAllRootCategories", "(", "$", "loadChildren", "=", "true", ")", "{", "$", "class", "=", "$", "this", "->", "getClass", "(", ")", ";", "$", "rootCategories", "=", "$", "this", "->", "getObjectManager", "(", ")", "->", "createQuery"...
NEXT_MAJOR: add this method to the interface. @param bool|true $loadChildren @return CategoryInterface[]
[ "NEXT_MAJOR", ":", "add", "this", "method", "to", "the", "interface", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L195-L213
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getRootCategoriesSplitByContexts
public function getRootCategoriesSplitByContexts($loadChildren = true) { $rootCategories = $this->getAllRootCategories($loadChildren); $splitCategories = []; foreach ($rootCategories as $category) { $splitCategories[$category->getContext()->getId()][] = $category; } return $splitCategories; }
php
public function getRootCategoriesSplitByContexts($loadChildren = true) { $rootCategories = $this->getAllRootCategories($loadChildren); $splitCategories = []; foreach ($rootCategories as $category) { $splitCategories[$category->getContext()->getId()][] = $category; } return $splitCategories; }
[ "public", "function", "getRootCategoriesSplitByContexts", "(", "$", "loadChildren", "=", "true", ")", "{", "$", "rootCategories", "=", "$", "this", "->", "getAllRootCategories", "(", "$", "loadChildren", ")", ";", "$", "splitCategories", "=", "[", "]", ";", "f...
NEXT_MAJOR: add this method to the interface. @param bool|true $loadChildren @return array
[ "NEXT_MAJOR", ":", "add", "this", "method", "to", "the", "interface", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L222-L233
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getCategories
public function getCategories($context = null) { $context = $this->getContext($context); $this->loadCategories($context); return $this->categories[$context->getId()]; }
php
public function getCategories($context = null) { $context = $this->getContext($context); $this->loadCategories($context); return $this->categories[$context->getId()]; }
[ "public", "function", "getCategories", "(", "$", "context", "=", "null", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", "$", "context", ")", ";", "$", "this", "->", "loadCategories", "(", "$", "context", ")", ";", "return", "$", ...
@param ContextInterface|null $context @return array
[ "@param", "ContextInterface|null", "$context" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L240-L247
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.loadCategories
protected function loadCategories(ContextInterface $context) { if (\array_key_exists($context->getId(), $this->categories)) { return; } $class = $this->getClass(); $categories = $this->getObjectManager()->createQuery(sprintf('SELECT c FROM %s c WHERE c.context = :context ORDER BY c.parent ASC', $class)) ->setParameter('context', $context->getId()) ->execute(); if (0 === \count($categories)) { // no category, create one for the provided context $category = $this->create(); $category->setName($context->getName()); $category->setEnabled(true); $category->setContext($context); $category->setDescription($context->getName()); $this->save($category); $categories = [$category]; } $rootCategories = []; foreach ($categories as $pos => $category) { if (null === $category->getParent()) { $rootCategories[] = $category; } $this->categories[$context->getId()][$category->getId()] = $category; $parent = $category->getParent(); $category->disableChildrenLazyLoading(); if ($parent) { $parent->addChild($category); } } $this->categories[$context->getId()] = $rootCategories; }
php
protected function loadCategories(ContextInterface $context) { if (\array_key_exists($context->getId(), $this->categories)) { return; } $class = $this->getClass(); $categories = $this->getObjectManager()->createQuery(sprintf('SELECT c FROM %s c WHERE c.context = :context ORDER BY c.parent ASC', $class)) ->setParameter('context', $context->getId()) ->execute(); if (0 === \count($categories)) { // no category, create one for the provided context $category = $this->create(); $category->setName($context->getName()); $category->setEnabled(true); $category->setContext($context); $category->setDescription($context->getName()); $this->save($category); $categories = [$category]; } $rootCategories = []; foreach ($categories as $pos => $category) { if (null === $category->getParent()) { $rootCategories[] = $category; } $this->categories[$context->getId()][$category->getId()] = $category; $parent = $category->getParent(); $category->disableChildrenLazyLoading(); if ($parent) { $parent->addChild($category); } } $this->categories[$context->getId()] = $rootCategories; }
[ "protected", "function", "loadCategories", "(", "ContextInterface", "$", "context", ")", "{", "if", "(", "\\", "array_key_exists", "(", "$", "context", "->", "getId", "(", ")", ",", "$", "this", "->", "categories", ")", ")", "{", "return", ";", "}", "$",...
Load all categories from the database, the current method is very efficient for < 256 categories. @param ContextInterface $context
[ "Load", "all", "categories", "from", "the", "database", "the", "current", "method", "is", "very", "efficient", "for", "<", "256", "categories", "." ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L286-L329
sonata-project/SonataClassificationBundle
src/Entity/CategoryManager.php
CategoryManager.getContext
private function getContext($contextCode) { if (empty($contextCode)) { $contextCode = ContextInterface::DEFAULT_CONTEXT; } if ($contextCode instanceof ContextInterface) { return $contextCode; } $context = $this->contextManager->find($contextCode); if (!$context instanceof ContextInterface) { $context = $this->contextManager->create(); $context->setId($contextCode); $context->setName($contextCode); $context->setEnabled(true); $this->contextManager->save($context); } return $context; }
php
private function getContext($contextCode) { if (empty($contextCode)) { $contextCode = ContextInterface::DEFAULT_CONTEXT; } if ($contextCode instanceof ContextInterface) { return $contextCode; } $context = $this->contextManager->find($contextCode); if (!$context instanceof ContextInterface) { $context = $this->contextManager->create(); $context->setId($contextCode); $context->setName($contextCode); $context->setEnabled(true); $this->contextManager->save($context); } return $context; }
[ "private", "function", "getContext", "(", "$", "contextCode", ")", "{", "if", "(", "empty", "(", "$", "contextCode", ")", ")", "{", "$", "contextCode", "=", "ContextInterface", "::", "DEFAULT_CONTEXT", ";", "}", "if", "(", "$", "contextCode", "instanceof", ...
@param $contextCode @return ContextInterface
[ "@param", "$contextCode" ]
train
https://github.com/sonata-project/SonataClassificationBundle/blob/f75add739dc0f79e02933fb87aca0ea8355a1a4b/src/Entity/CategoryManager.php#L336-L359
slimphp/Slim-HttpCache
src/CacheProvider.php
CacheProvider.allowCache
public function allowCache(ResponseInterface $response, $type = 'private', $maxAge = null, $mustRevalidate = false) { if (!in_array($type, ['private', 'public'])) { throw new InvalidArgumentException('Invalid Cache-Control type. Must be "public" or "private".'); } $headerValue = $type; if ($maxAge || is_integer($maxAge)) { if (!is_integer($maxAge)) { $maxAge = strtotime($maxAge); } $headerValue = $headerValue . ', max-age=' . $maxAge; } if ($mustRevalidate) { $headerValue = $headerValue . ", must-revalidate"; } return $response->withHeader('Cache-Control', $headerValue); }
php
public function allowCache(ResponseInterface $response, $type = 'private', $maxAge = null, $mustRevalidate = false) { if (!in_array($type, ['private', 'public'])) { throw new InvalidArgumentException('Invalid Cache-Control type. Must be "public" or "private".'); } $headerValue = $type; if ($maxAge || is_integer($maxAge)) { if (!is_integer($maxAge)) { $maxAge = strtotime($maxAge); } $headerValue = $headerValue . ', max-age=' . $maxAge; } if ($mustRevalidate) { $headerValue = $headerValue . ", must-revalidate"; } return $response->withHeader('Cache-Control', $headerValue); }
[ "public", "function", "allowCache", "(", "ResponseInterface", "$", "response", ",", "$", "type", "=", "'private'", ",", "$", "maxAge", "=", "null", ",", "$", "mustRevalidate", "=", "false", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "...
Enable client-side HTTP caching @param ResponseInterface $response PSR7 response object @param string $type Cache-Control type: "private" or "public" @param null|int|string $maxAge Maximum cache age (integer timestamp or datetime string) @param bool $mustRevalidate add option "must-revalidate" to Cache-Control @return ResponseInterface A new PSR7 response object with `Cache-Control` header @throws InvalidArgumentException if the cache-control type is invalid
[ "Enable", "client", "-", "side", "HTTP", "caching" ]
train
https://github.com/slimphp/Slim-HttpCache/blob/9b9e6c62cffebc986aeaa1f55fb8d16ec1d0bf7e/src/CacheProvider.php#L20-L38
slimphp/Slim-HttpCache
src/CacheProvider.php
CacheProvider.withExpires
public function withExpires(ResponseInterface $response, $time) { if (!is_integer($time)) { $time = strtotime($time); if ($time === false) { throw new InvalidArgumentException('Expiration value could not be parsed with `strtotime()`.'); } } return $response->withHeader('Expires', gmdate('D, d M Y H:i:s T', $time)); }
php
public function withExpires(ResponseInterface $response, $time) { if (!is_integer($time)) { $time = strtotime($time); if ($time === false) { throw new InvalidArgumentException('Expiration value could not be parsed with `strtotime()`.'); } } return $response->withHeader('Expires', gmdate('D, d M Y H:i:s T', $time)); }
[ "public", "function", "withExpires", "(", "ResponseInterface", "$", "response", ",", "$", "time", ")", "{", "if", "(", "!", "is_integer", "(", "$", "time", ")", ")", "{", "$", "time", "=", "strtotime", "(", "$", "time", ")", ";", "if", "(", "$", "t...
Add `Expires` header to PSR7 response object @param ResponseInterface $response A PSR7 response object @param int|string $time A UNIX timestamp or a valid `strtotime()` string @return ResponseInterface A new PSR7 response object with `Expires` header @throws InvalidArgumentException if the expiration date cannot be parsed
[ "Add", "Expires", "header", "to", "PSR7", "response", "object" ]
train
https://github.com/slimphp/Slim-HttpCache/blob/9b9e6c62cffebc986aeaa1f55fb8d16ec1d0bf7e/src/CacheProvider.php#L61-L71
slimphp/Slim-HttpCache
src/CacheProvider.php
CacheProvider.withEtag
public function withEtag(ResponseInterface $response, $value, $type = 'strong') { if (!in_array($type, ['strong', 'weak'])) { throw new InvalidArgumentException('Invalid etag type. Must be "strong" or "weak".'); } $value = '"' . $value . '"'; if ($type === 'weak') { $value = 'W/' . $value; } return $response->withHeader('ETag', $value); }
php
public function withEtag(ResponseInterface $response, $value, $type = 'strong') { if (!in_array($type, ['strong', 'weak'])) { throw new InvalidArgumentException('Invalid etag type. Must be "strong" or "weak".'); } $value = '"' . $value . '"'; if ($type === 'weak') { $value = 'W/' . $value; } return $response->withHeader('ETag', $value); }
[ "public", "function", "withEtag", "(", "ResponseInterface", "$", "response", ",", "$", "value", ",", "$", "type", "=", "'strong'", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "[", "'strong'", ",", "'weak'", "]", ")", ")", "{", "throw...
Add `ETag` header to PSR7 response object @param ResponseInterface $response A PSR7 response object @param string $value The ETag value @param string $type ETag type: "strong" or "weak" @return ResponseInterface A new PSR7 response object with `ETag` header @throws InvalidArgumentException if the etag type is invalid
[ "Add", "ETag", "header", "to", "PSR7", "response", "object" ]
train
https://github.com/slimphp/Slim-HttpCache/blob/9b9e6c62cffebc986aeaa1f55fb8d16ec1d0bf7e/src/CacheProvider.php#L83-L94
nicklaw5/twitch-api-php
src/TwitchApi.php
TwitchApi.setApiVersion
public function setApiVersion($apiVersion) { if (!in_array($apiVersion = intval($apiVersion), $this->getSupportedApiVersions())) { throw new UnsupportedApiVersionException(); } $this->apiVersion = $apiVersion; }
php
public function setApiVersion($apiVersion) { if (!in_array($apiVersion = intval($apiVersion), $this->getSupportedApiVersions())) { throw new UnsupportedApiVersionException(); } $this->apiVersion = $apiVersion; }
[ "public", "function", "setApiVersion", "(", "$", "apiVersion", ")", "{", "if", "(", "!", "in_array", "(", "$", "apiVersion", "=", "intval", "(", "$", "apiVersion", ")", ",", "$", "this", "->", "getSupportedApiVersions", "(", ")", ")", ")", "{", "throw", ...
Set API version @param string|int $apiVersion @throws UnsupportedApiVersionException
[ "Set", "API", "version" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchApi.php#L173-L180
nicklaw5/twitch-api-php
src/TwitchApi.php
TwitchApi.setScope
public function setScope($scope) { if (!is_array($scope)) { throw new InvalidTypeException('Scope', 'array', gettype($scope)); } $this->scope = $scope; }
php
public function setScope($scope) { if (!is_array($scope)) { throw new InvalidTypeException('Scope', 'array', gettype($scope)); } $this->scope = $scope; }
[ "public", "function", "setScope", "(", "$", "scope", ")", "{", "if", "(", "!", "is_array", "(", "$", "scope", ")", ")", "{", "throw", "new", "InvalidTypeException", "(", "'Scope'", ",", "'array'", ",", "gettype", "(", "$", "scope", ")", ")", ";", "}"...
Set scope @param array $scope @throws InvalidTypeException
[ "Set", "scope" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchApi.php#L218-L225
nicklaw5/twitch-api-php
src/TwitchApi.php
TwitchApi.isValidBroadcastType
protected function isValidBroadcastType($broadcastType) { $validBroadcastTypes = ['archive', 'highlight', 'upload']; $broadcastTypeArray = explode(',', $broadcastType); foreach ($broadcastTypeArray as $type) { if (!in_array($type, $validBroadcastTypes)) { return false; } } return true; }
php
protected function isValidBroadcastType($broadcastType) { $validBroadcastTypes = ['archive', 'highlight', 'upload']; $broadcastTypeArray = explode(',', $broadcastType); foreach ($broadcastTypeArray as $type) { if (!in_array($type, $validBroadcastTypes)) { return false; } } return true; }
[ "protected", "function", "isValidBroadcastType", "(", "$", "broadcastType", ")", "{", "$", "validBroadcastTypes", "=", "[", "'archive'", ",", "'highlight'", ",", "'upload'", "]", ";", "$", "broadcastTypeArray", "=", "explode", "(", "','", ",", "$", "broadcastTyp...
Return true if the provided broadcast type is valid @param string $broadcastType @return bool
[ "Return", "true", "if", "the", "provided", "broadcast", "type", "is", "valid" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchApi.php#L286-L298
nicklaw5/twitch-api-php
src/Api/Chat.php
Chat.getChannelChatBadges
public function getChannelChatBadges($channelIdentifier) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('chat/%s/badges', $channelIdentifier)); }
php
public function getChannelChatBadges($channelIdentifier) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('chat/%s/badges', $channelIdentifier)); }
[ "public", "function", "getChannelChatBadges", "(", "$", "channelIdentifier", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "channelIdentifier", ")", ")", "{", "throw", "new", "InvalidIdentifierE...
Get chat badges by channel @param string|int $channelIdentifier @throws InvalidIdentifierException @return array|json
[ "Get", "chat", "badges", "by", "channel" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Chat.php#L17-L24
nicklaw5/twitch-api-php
src/Api/Chat.php
Chat.getChatEmoticonSets
public function getChatEmoticonSets($emotesets = null) { if ($emotesets && !is_string($emotesets)) { throw new InvalidTypeException('emotesets', 'string', gettype($emotesets)); } $emotesets = trim($emotesets, ', '); return $this->get('chat/emoticon_images', ['emotesets' => $emotesets]); }
php
public function getChatEmoticonSets($emotesets = null) { if ($emotesets && !is_string($emotesets)) { throw new InvalidTypeException('emotesets', 'string', gettype($emotesets)); } $emotesets = trim($emotesets, ', '); return $this->get('chat/emoticon_images', ['emotesets' => $emotesets]); }
[ "public", "function", "getChatEmoticonSets", "(", "$", "emotesets", "=", "null", ")", "{", "if", "(", "$", "emotesets", "&&", "!", "is_string", "(", "$", "emotesets", ")", ")", "{", "throw", "new", "InvalidTypeException", "(", "'emotesets'", ",", "'string'",...
Get chat emoticons by set @param string $emotesets (comma-seperated list) @throws InvalidTypeException @return array|json
[ "Get", "chat", "emoticons", "by", "set" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Chat.php#L33-L42
nicklaw5/twitch-api-php
src/Api/Authentication.php
Authentication.getAuthenticationUrl
public function getAuthenticationUrl($state = null, $forceVerify = false) { return implode('', [ sprintf('%soauth2/authorize', $this->baseUri), '?response_type=code', sprintf('&client_id=%s', $this->getClientId()), sprintf('&redirect_uri=%s', $this->getRedirectUri()), sprintf('&scope=%s', implode('+', $this->getScope())), sprintf('&state=%s', $state), sprintf('&force_verify=%s', $forceVerify ? 'true' : 'false'), ]); }
php
public function getAuthenticationUrl($state = null, $forceVerify = false) { return implode('', [ sprintf('%soauth2/authorize', $this->baseUri), '?response_type=code', sprintf('&client_id=%s', $this->getClientId()), sprintf('&redirect_uri=%s', $this->getRedirectUri()), sprintf('&scope=%s', implode('+', $this->getScope())), sprintf('&state=%s', $state), sprintf('&force_verify=%s', $forceVerify ? 'true' : 'false'), ]); }
[ "public", "function", "getAuthenticationUrl", "(", "$", "state", "=", "null", ",", "$", "forceVerify", "=", "false", ")", "{", "return", "implode", "(", "''", ",", "[", "sprintf", "(", "'%soauth2/authorize'", ",", "$", "this", "->", "baseUri", ")", ",", ...
Get the Twitch OAuth URL @param string $state @param bool $forceVerify @return string
[ "Get", "the", "Twitch", "OAuth", "URL" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Authentication.php#L14-L25
nicklaw5/twitch-api-php
src/Api/Authentication.php
Authentication.getAccessCredentials
public function getAccessCredentials($code, $state = null) { return $this->post('oauth2/token', [ 'client_id' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), 'grant_type' => 'authorization_code', 'redirect_uri' => $this->getRedirectUri(), 'code' => $code, 'state' => $state, ]); }
php
public function getAccessCredentials($code, $state = null) { return $this->post('oauth2/token', [ 'client_id' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), 'grant_type' => 'authorization_code', 'redirect_uri' => $this->getRedirectUri(), 'code' => $code, 'state' => $state, ]); }
[ "public", "function", "getAccessCredentials", "(", "$", "code", ",", "$", "state", "=", "null", ")", "{", "return", "$", "this", "->", "post", "(", "'oauth2/token'", ",", "[", "'client_id'", "=>", "$", "this", "->", "getClientId", "(", ")", ",", "'client...
Get a user's access credentials, which includes the access token @param string $code @param string $state @return array|json
[ "Get", "a", "user", "s", "access", "credentials", "which", "includes", "the", "access", "token" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Authentication.php#L34-L44
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.getMultipleFeedPosts
public function getMultipleFeedPosts($channelIdentifier, $accessToken, $limit = 10, $cursor = null, $comments = 5) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } if (!is_int($comments)) { throw new InvalidTypeException('Comments', 'integer', gettype($comments)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, 'comments' => $comments, ]; return $this->get(sprintf('feed/%s/posts', $channelIdentifier), $params, $accessToken); }
php
public function getMultipleFeedPosts($channelIdentifier, $accessToken, $limit = 10, $cursor = null, $comments = 5) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } if (!is_int($comments)) { throw new InvalidTypeException('Comments', 'integer', gettype($comments)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, 'comments' => $comments, ]; return $this->get(sprintf('feed/%s/posts', $channelIdentifier), $params, $accessToken); }
[ "public", "function", "getMultipleFeedPosts", "(", "$", "channelIdentifier", ",", "$", "accessToken", ",", "$", "limit", "=", "10", ",", "$", "cursor", "=", "null", ",", "$", "comments", "=", "5", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGrea...
Get multiple feed posts @param string|int $channelIdentifier @param string $accessToken @param int $limit @param string $cursor @param int $comments @throws InvalidIdentifierException @throws InvalidLimitException @throws InvalidTypeException @return array|json
[ "Get", "multiple", "feed", "posts" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L24-L49
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.getFeedPost
public function getFeedPost($channelIdentifier, $postId, $accessToken, $comments = 5) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } if (!is_int($comments)) { throw new InvalidTypeException('Comments', 'integer', gettype($comments)); } $params = [ 'comments' => $comments, ]; return $this->get(sprintf('feed/%s/posts/%s', $channelIdentifier, $postId), $params, $accessToken); }
php
public function getFeedPost($channelIdentifier, $postId, $accessToken, $comments = 5) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } if (!is_int($comments)) { throw new InvalidTypeException('Comments', 'integer', gettype($comments)); } $params = [ 'comments' => $comments, ]; return $this->get(sprintf('feed/%s/posts/%s', $channelIdentifier, $postId), $params, $accessToken); }
[ "public", "function", "getFeedPost", "(", "$", "channelIdentifier", ",", "$", "postId", ",", "$", "accessToken", ",", "$", "comments", "=", "5", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", ...
Get a feed post @param string|int $channelIdentifier @param string $postId @param string $accessToken @param int $comments @throws InvalidIdentifierException @throws InvalidTypeException @return array|json
[ "Get", "a", "feed", "post" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L62-L81
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.createFeedPost
public function createFeedPost($channelIdentifier, $accessToken, $content, $share = false) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($content)) { throw new InvalidTypeException('Content', 'string', gettype($content)); } if (!is_bool($share)) { throw new InvalidTypeException('Share', 'boolean', gettype($share)); } $params = [ 'share' => $share, 'content' => $content, ]; return $this->post(sprintf('feed/%s/posts', $channelIdentifier), $params, $accessToken); }
php
public function createFeedPost($channelIdentifier, $accessToken, $content, $share = false) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($content)) { throw new InvalidTypeException('Content', 'string', gettype($content)); } if (!is_bool($share)) { throw new InvalidTypeException('Share', 'boolean', gettype($share)); } $params = [ 'share' => $share, 'content' => $content, ]; return $this->post(sprintf('feed/%s/posts', $channelIdentifier), $params, $accessToken); }
[ "public", "function", "createFeedPost", "(", "$", "channelIdentifier", ",", "$", "accessToken", ",", "$", "content", ",", "$", "share", "=", "false", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(...
Create a fedd post @param string|int $channelIdentifier @param string $accessToken @param string $content @param boolean $share @throws InvalidIdentifierException @throws InvalidTypeException @return array|json
[ "Create", "a", "fedd", "post" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L94-L114
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.deleteFeedPost
public function deleteFeedPost($channelIdentifier, $postId, $accessToken) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } return $this->delete(sprintf('feed/%s/posts/%s', $channelIdentifier, $postId), [], $accessToken); }
php
public function deleteFeedPost($channelIdentifier, $postId, $accessToken) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } return $this->delete(sprintf('feed/%s/posts/%s', $channelIdentifier, $postId), [], $accessToken); }
[ "public", "function", "deleteFeedPost", "(", "$", "channelIdentifier", ",", "$", "postId", ",", "$", "accessToken", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "channelIdentifier", ")", ")...
Delete a feed post @param string|int $channelIdentifier @param string $postId @param string $accessToken @throws InvalidIdentifierException @throws InvalidTypeException @return array|json
[ "Delete", "a", "feed", "post" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L126-L137
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.getFeedComments
public function getFeedComments($channelIdentifier, $postId, $accessToken, $limit = 10, $cursor = null) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, ]; return $this->get(sprintf('feed/%s/posts/%s/comments', $channelIdentifier, $postId), $params, $accessToken); }
php
public function getFeedComments($channelIdentifier, $postId, $accessToken, $limit = 10, $cursor = null) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, ]; return $this->get(sprintf('feed/%s/posts/%s/comments', $channelIdentifier, $postId), $params, $accessToken); }
[ "public", "function", "getFeedComments", "(", "$", "channelIdentifier", ",", "$", "postId", ",", "$", "accessToken", ",", "$", "limit", "=", "10", ",", "$", "cursor", "=", "null", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ...
Get comments from a feed post @param string|int $channelIdentifier @param string $postId @param string $accessToken @param int $limit @param string $cursor @throws InvalidIdentifierException @throws InvalidTypeException @throws InvalidLimitException @return array|json
[ "Get", "comments", "from", "a", "feed", "post" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L216-L240
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.createFeedComment
public function createFeedComment($channelIdentifier, $postId, $accessToken, $comment) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($comment)) { throw new InvalidTypeException('Comment', 'string', gettype($comment)); } $params = [ 'content' => $comment, ]; return $this->post(sprintf('feed/%s/posts/%s/comments', $channelIdentifier, $postId), $params, $accessToken); }
php
public function createFeedComment($channelIdentifier, $postId, $accessToken, $comment) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($comment)) { throw new InvalidTypeException('Comment', 'string', gettype($comment)); } $params = [ 'content' => $comment, ]; return $this->post(sprintf('feed/%s/posts/%s/comments', $channelIdentifier, $postId), $params, $accessToken); }
[ "public", "function", "createFeedComment", "(", "$", "channelIdentifier", ",", "$", "postId", ",", "$", "accessToken", ",", "$", "comment", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "c...
Create a feed post comment @param string|int $channelIdentifier @param string $postId @param string $accessToken @param string $comment @throws InvalidIdentifierException @throws InvalidTypeException @return array|json
[ "Create", "a", "feed", "post", "comment" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L253-L268
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.deleteFeedComment
public function deleteFeedComment($channelIdentifier, $postId, $commentId, $accessToken) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->delete(sprintf('feed/%s/posts/%s/comments/%s', $channelIdentifier, $postId, $commentId), [], $accessToken); }
php
public function deleteFeedComment($channelIdentifier, $postId, $commentId, $accessToken) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->delete(sprintf('feed/%s/posts/%s/comments/%s', $channelIdentifier, $postId, $commentId), [], $accessToken); }
[ "public", "function", "deleteFeedComment", "(", "$", "channelIdentifier", ",", "$", "postId", ",", "$", "commentId", ",", "$", "accessToken", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", ...
Delete a feed post comment @param string|int $channelIdentifier @param string $postId @param string $accessToken @param string|int $commentId @throws InvalidIdentifierException @throws InvalidTypeException @return array|json
[ "Delete", "a", "feed", "post", "comment" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L281-L288
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.createFeedCommentReaction
public function createFeedCommentReaction($channelIdentifier, $postId, $commentId, $accessToken, $emoteId) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } if (!is_string($emoteId)) { throw new InvalidTypeException('Reaction', 'string', gettype($emoteId)); } $params = [ 'emote_id' => $emoteId, ]; return $this->post(sprintf('feed/%s/posts/%s/comments/%s/reactions', $channelIdentifier, $postId, $commentId), $params, $accessToken); }
php
public function createFeedCommentReaction($channelIdentifier, $postId, $commentId, $accessToken, $emoteId) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } if (!is_string($emoteId)) { throw new InvalidTypeException('Reaction', 'string', gettype($emoteId)); } $params = [ 'emote_id' => $emoteId, ]; return $this->post(sprintf('feed/%s/posts/%s/comments/%s/reactions', $channelIdentifier, $postId, $commentId), $params, $accessToken); }
[ "public", "function", "createFeedCommentReaction", "(", "$", "channelIdentifier", ",", "$", "postId", ",", "$", "commentId", ",", "$", "accessToken", ",", "$", "emoteId", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!...
Create a reaction to a feed comment @param string|int $channelIdentifier @param string $postId @param string|int $commentId @param string $accessToken @param string $emoteId @throws InvalidIdentifierException @throws InvalidTypeException @return array|json
[ "Create", "a", "reaction", "to", "a", "feed", "comment" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L302-L321
nicklaw5/twitch-api-php
src/Api/ChannelFeed.php
ChannelFeed.deleteFeedCommentReaction
public function deleteFeedCommentReaction($channelIdentifier, $postId, $commentId, $accessToken, $emoteId) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } if (!is_string($emoteId)) { throw new InvalidTypeException('Reaction', 'string', gettype($emoteId)); } $params = [ 'emote_id' => $emoteId, ]; return $this->delete(sprintf('feed/%s/posts/%s/comments/%s/reactions', $channelIdentifier, $postId, $commentId), $params, $accessToken); }
php
public function deleteFeedCommentReaction($channelIdentifier, $postId, $commentId, $accessToken, $emoteId) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($postId)) { throw new InvalidTypeException('Post ID', 'string', gettype($postId)); } if (!is_string($emoteId)) { throw new InvalidTypeException('Reaction', 'string', gettype($emoteId)); } $params = [ 'emote_id' => $emoteId, ]; return $this->delete(sprintf('feed/%s/posts/%s/comments/%s/reactions', $channelIdentifier, $postId, $commentId), $params, $accessToken); }
[ "public", "function", "deleteFeedCommentReaction", "(", "$", "channelIdentifier", ",", "$", "postId", ",", "$", "commentId", ",", "$", "accessToken", ",", "$", "emoteId", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!...
Delete a reaction to a feed comment @param string|int $channelIdentifier @param string $postId @param string|int $commentId @param string $accessToken @param string $emoteId @throws InvalidIdentifierException @throws InvalidTypeException @return array|json
[ "Delete", "a", "reaction", "to", "a", "feed", "comment" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/ChannelFeed.php#L335-L354
nicklaw5/twitch-api-php
src/Api/Games.php
Games.getTopGames
public function getTopGames($limit = 10, $offset = 0) { if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $params = [ 'limit' => $limit, 'offset' => $offset, ]; return $this->get('games/top', $params); }
php
public function getTopGames($limit = 10, $offset = 0) { if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $params = [ 'limit' => $limit, 'offset' => $offset, ]; return $this->get('games/top', $params); }
[ "public", "function", "getTopGames", "(", "$", "limit", "=", "10", ",", "$", "offset", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "isValidLimit", "(", "$", "limit", ")", ")", "{", "throw", "new", "InvalidLimitException", "(", ")", ";", ...
Get top games @param int $limit @param int $offset @throws InvalidLimitException @throws InvalidOffsetException @return array|json
[ "Get", "top", "games" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Games.php#L19-L35
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.getCommunityByName
public function getCommunityByName($name) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($name)) { throw new InvalidTypeException('Name', 'string', gettype($name)); } return $this->get('communities', ['name' => $name]); }
php
public function getCommunityByName($name) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($name)) { throw new InvalidTypeException('Name', 'string', gettype($name)); } return $this->get('communities', ['name' => $name]); }
[ "public", "function", "getCommunityByName", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "(", ")", ";", "}", "if", "(", "!", "is_s...
Get community by name @param string $name @throws InvalidTypeException @throws EndpointNotSupportedByApiVersionException @return array|json
[ "Get", "community", "by", "name" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L21-L32
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.getCommunityById
public function getCommunityById($communityId) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($communityId)) { throw new InvalidTypeException('Community ID', 'string', gettype($communityId)); } return $this->get(sprintf('communities/%s', $communityId)); }
php
public function getCommunityById($communityId) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($communityId)) { throw new InvalidTypeException('Community ID', 'string', gettype($communityId)); } return $this->get(sprintf('communities/%s', $communityId)); }
[ "public", "function", "getCommunityById", "(", "$", "communityId", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "(", ")", ";", "}", "if", "(", "!", ...
Get community by ID @param string $communityId @throws InvalidTypeException @throws EndpointNotSupportedByApiVersionException @return array|json
[ "Get", "community", "by", "ID" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L42-L53
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.createCommunity
public function createCommunity($name, $summary, $description, $rules, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (strlen($name) < 3 || strlen($name) > 25) { throw new InvalidParameterLengthException('name'); } if (strlen($summary) > 160) { throw new InvalidParameterLengthException('summary'); } if (strlen($description) > 1572864) { // 1.5MB throw new InvalidParameterLengthException('description'); } if (strlen($rules) > 1572864) { // 1.5MB throw new InvalidParameterLengthException('rules'); } $params = [ 'name' => $name, 'summary' => $summary, 'description' => $description, 'rules' => $rules, ]; return $this->post('communities', $params, $accessToken); }
php
public function createCommunity($name, $summary, $description, $rules, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (strlen($name) < 3 || strlen($name) > 25) { throw new InvalidParameterLengthException('name'); } if (strlen($summary) > 160) { throw new InvalidParameterLengthException('summary'); } if (strlen($description) > 1572864) { // 1.5MB throw new InvalidParameterLengthException('description'); } if (strlen($rules) > 1572864) { // 1.5MB throw new InvalidParameterLengthException('rules'); } $params = [ 'name' => $name, 'summary' => $summary, 'description' => $description, 'rules' => $rules, ]; return $this->post('communities', $params, $accessToken); }
[ "public", "function", "createCommunity", "(", "$", "name", ",", "$", "summary", ",", "$", "description", ",", "$", "rules", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", ...
Create a community @param string $name @param string $summary @param string $description @param string $rules @param string $accessToken @throws InvalidParameterLengthException @throws EndpointNotSupportedByApiVersionException @return array|json
[ "Create", "a", "community" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L67-L97
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.updateCommunity
public function updateCommunity($communityId, $accessToken, $summary = null, $description = null, $rules = null, $email = null) { $params = []; if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if ($summary) { if (strlen($summary) > 160) { throw new InvalidParameterLengthException('summary'); } $params['summary'] = $summary; } if ($description) { if (strlen($description) > 1572864) { // 1.5MB throw new InvalidParameterLengthException('description'); } $params['description'] = $description; } if ($rules) { if (strlen($rules) > 1572864) { // 1.5MB throw new InvalidParameterLengthException('rules'); } $params['rules'] = $rules; } if ($email) { if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { throw new InvalidEmailAddressException(); } $params['email'] = $email; } return $this->put(sprintf('communities/%s', $communityId), $params, $accessToken); }
php
public function updateCommunity($communityId, $accessToken, $summary = null, $description = null, $rules = null, $email = null) { $params = []; if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if ($summary) { if (strlen($summary) > 160) { throw new InvalidParameterLengthException('summary'); } $params['summary'] = $summary; } if ($description) { if (strlen($description) > 1572864) { // 1.5MB throw new InvalidParameterLengthException('description'); } $params['description'] = $description; } if ($rules) { if (strlen($rules) > 1572864) { // 1.5MB throw new InvalidParameterLengthException('rules'); } $params['rules'] = $rules; } if ($email) { if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { throw new InvalidEmailAddressException(); } $params['email'] = $email; } return $this->put(sprintf('communities/%s', $communityId), $params, $accessToken); }
[ "public", "function", "updateCommunity", "(", "$", "communityId", ",", "$", "accessToken", ",", "$", "summary", "=", "null", ",", "$", "description", "=", "null", ",", "$", "rules", "=", "null", ",", "$", "email", "=", "null", ")", "{", "$", "params", ...
Update a community @param string $communityId @param string $accessToken @param string $summary @param string $description @param string $rules @param string $email @throws InvalidParameterLengthException @throws EndpointNotSupportedByApiVersionException @throws InvalidEmailAddressException @return array|json
[ "Update", "a", "community" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L113-L150
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.getTopCommunities
public function getTopCommunities($limit = 10, $cursor = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, ]; return $this->get('communities/top', $params); }
php
public function getTopCommunities($limit = 10, $cursor = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, ]; return $this->get('communities/top', $params); }
[ "public", "function", "getTopCommunities", "(", "$", "limit", "=", "10", ",", "$", "cursor", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException",...
Get top communities @param int $limit @param string $cursor @throws InvalidLimitException @throws InvalidTypeException @throws EndpointNotSupportedByApiVersionException @return array|json
[ "Get", "top", "communities" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L162-L182
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.getBannedCommunityUsers
public function getBannedCommunityUsers($communityId, $accessToken, $limit = 10, $cursor = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, ]; return $this->get(sprintf('communities/%s/bans', $communityId), $params, $accessToken); }
php
public function getBannedCommunityUsers($communityId, $accessToken, $limit = 10, $cursor = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, ]; return $this->get(sprintf('communities/%s/bans', $communityId), $params, $accessToken); }
[ "public", "function", "getBannedCommunityUsers", "(", "$", "communityId", ",", "$", "accessToken", ",", "$", "limit", "=", "10", ",", "$", "cursor", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{"...
Get banned community users @param string $communityId @param string $accessToken @param int $limit @param string $cursor @throws InvalidLimitException @throws InvalidTypeException @throws EndpointNotSupportedByApiVersionException @return array|json
[ "Get", "banned", "community", "users" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L196-L216
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.createCommunityAvatar
public function createCommunityAvatar($communityId, $avatar, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($avatar)) { throw new InvalidTypeException('Avatar', 'string', gettype($avatar)); } return $this->post(sprintf('communities/%s/images/avatar', $communityId), ['avatar_image' => $avatar], $accessToken); }
php
public function createCommunityAvatar($communityId, $avatar, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($avatar)) { throw new InvalidTypeException('Avatar', 'string', gettype($avatar)); } return $this->post(sprintf('communities/%s/images/avatar', $communityId), ['avatar_image' => $avatar], $accessToken); }
[ "public", "function", "createCommunityAvatar", "(", "$", "communityId", ",", "$", "avatar", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionEx...
Upload a community avatar image (600x800px) @param string $communityId @param string $avatar (base64 encoded) @param string $accessToken @throws InvalidTypeException @throws EndpointNotSupportedByApiVersionException @return null|array|json
[ "Upload", "a", "community", "avatar", "image", "(", "600x800px", ")" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L274-L285
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.deleteCommunityAvatar
public function deleteCommunityAvatar($communityId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } return $this->delete(sprintf('communities/%s/images/avatar', $communityId), [], $accessToken); }
php
public function deleteCommunityAvatar($communityId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } return $this->delete(sprintf('communities/%s/images/avatar', $communityId), [], $accessToken); }
[ "public", "function", "deleteCommunityAvatar", "(", "$", "communityId", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "(", ")", ...
Delete a community avatar image @param string $communityId @param string $accessToken @throws EndpointNotSupportedByApiVersionException @return null|array|json
[ "Delete", "a", "community", "avatar", "image" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L295-L302
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.createCommunityCoverImage
public function createCommunityCoverImage($communityId, $image, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($image)) { throw new InvalidTypeException('Cover image', 'string', gettype($image)); } return $this->post(sprintf('communities/%s/images/cover', $communityId), ['cover_image' => $image], $accessToken); }
php
public function createCommunityCoverImage($communityId, $image, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($image)) { throw new InvalidTypeException('Cover image', 'string', gettype($image)); } return $this->post(sprintf('communities/%s/images/cover', $communityId), ['cover_image' => $image], $accessToken); }
[ "public", "function", "createCommunityCoverImage", "(", "$", "communityId", ",", "$", "image", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersio...
Upload a community cover image (1200x180px) @param string $communityId @param string $image (base64 encoded) @param string $accessToken @throws InvalidTypeException @throws EndpointNotSupportedByApiVersionException @return null|array|json
[ "Upload", "a", "community", "cover", "image", "(", "1200x180px", ")" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L314-L325
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.deleteCommunityCoverImage
public function deleteCommunityCoverImage($communityId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } return $this->delete(sprintf('communities/%s/images/cover', $communityId), [], $accessToken); }
php
public function deleteCommunityCoverImage($communityId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } return $this->delete(sprintf('communities/%s/images/cover', $communityId), [], $accessToken); }
[ "public", "function", "deleteCommunityCoverImage", "(", "$", "communityId", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "(", ")"...
Delete a community cover image @param string $communityId @param string $accessToken @throws EndpointNotSupportedByApiVersionException @return null|array|json
[ "Delete", "a", "community", "cover", "image" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L335-L342
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.addCommunityModerator
public function addCommunityModerator($communityId, $userId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($userId)) { throw new InvalidIdentifierException('user'); } return $this->put(sprintf('communities/%s/moderators/%s', $communityId, $userId), [], $accessToken); }
php
public function addCommunityModerator($communityId, $userId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($userId)) { throw new InvalidIdentifierException('user'); } return $this->put(sprintf('communities/%s/moderators/%s', $communityId, $userId), [], $accessToken); }
[ "public", "function", "addCommunityModerator", "(", "$", "communityId", ",", "$", "userId", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionEx...
Give a community user moderator permissions @param string $communityId @param int $userId @param string $accessToken @throws EndpointNotSupportedByApiVersionException @throws InvalidIdentifierException @return null|array|json
[ "Give", "a", "community", "user", "moderator", "permissions" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L370-L381
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.removeCommunityModerator
public function removeCommunityModerator($communityId, $userId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($userId)) { throw new InvalidIdentifierException('user'); } return $this->delete(sprintf('communities/%s/moderators/%s', $communityId, $userId), [], $accessToken); }
php
public function removeCommunityModerator($communityId, $userId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($userId)) { throw new InvalidIdentifierException('user'); } return $this->delete(sprintf('communities/%s/moderators/%s', $communityId, $userId), [], $accessToken); }
[ "public", "function", "removeCommunityModerator", "(", "$", "communityId", ",", "$", "userId", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersio...
Remove moderator permission from a community user @param string $communityId @param int $userId @param string $accessToken @throws EndpointNotSupportedByApiVersionException @throws InvalidIdentifierException @return null|array|json
[ "Remove", "moderator", "permission", "from", "a", "community", "user" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L393-L404
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.getCommunityPermissions
public function getCommunityPermissions($communityId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } return $this->get(sprintf('communities/%s/permissions', $communityId), [], $accessToken); }
php
public function getCommunityPermissions($communityId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } return $this->get(sprintf('communities/%s/permissions', $communityId), [], $accessToken); }
[ "public", "function", "getCommunityPermissions", "(", "$", "communityId", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "(", ")", ...
Get community permissions @param string $communityId @param string $accessToken @throws EndpointNotSupportedByApiVersionException @return array|json
[ "Get", "community", "permissions" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L414-L421
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.reportCommunityViolation
public function reportCommunityViolation($communityId, $channelId) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelId)) { throw new InvalidIdentifierException('channel'); } return $this->post(sprintf('communities/%s/report_channel', $communityId), ['channel_id' => $channelId]); }
php
public function reportCommunityViolation($communityId, $channelId) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelId)) { throw new InvalidIdentifierException('channel'); } return $this->post(sprintf('communities/%s/report_channel', $communityId), ['channel_id' => $channelId]); }
[ "public", "function", "reportCommunityViolation", "(", "$", "communityId", ",", "$", "channelId", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "(", ")", ...
Report a community channel violation @param string $communityId @param int $channelId @throws EndpointNotSupportedByApiVersionException @throws InvalidIdentifierException @return null|array|json
[ "Report", "a", "community", "channel", "violation" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L432-L443
nicklaw5/twitch-api-php
src/Api/Communities.php
Communities.timeoutCommunityUser
public function timeoutCommunityUser($communityId, $userId, $accessToken, $duration, $reason = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($userId)) { throw new InvalidIdentifierException('user'); } if (!is_numeric($duration)) { throw new InvalidTypeException('Duration', 'integer', gettype($duration)); } if ($reason && !is_string($reason)) { throw new InvalidTypeException('Reason', 'string', gettype($reason)); } $params = [ 'duration' => intval($duration), 'reason' => $reason, ]; return $this->put(sprintf('communities/%s/timeouts/%s', $communityId, $userId), $params, $accessToken); }
php
public function timeoutCommunityUser($communityId, $userId, $accessToken, $duration, $reason = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($userId)) { throw new InvalidIdentifierException('user'); } if (!is_numeric($duration)) { throw new InvalidTypeException('Duration', 'integer', gettype($duration)); } if ($reason && !is_string($reason)) { throw new InvalidTypeException('Reason', 'string', gettype($reason)); } $params = [ 'duration' => intval($duration), 'reason' => $reason, ]; return $this->put(sprintf('communities/%s/timeouts/%s', $communityId, $userId), $params, $accessToken); }
[ "public", "function", "timeoutCommunityUser", "(", "$", "communityId", ",", "$", "userId", ",", "$", "accessToken", ",", "$", "duration", ",", "$", "reason", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ...
Timeout a community user @param string $communityId @param int $userId @param string $accessToken @param int $duration @param string $reason @throws EndpointNotSupportedByApiVersionException @throws InvalidTypeException @return null|array|json
[ "Timeout", "a", "community", "user" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Communities.php#L489-L513
nicklaw5/twitch-api-php
src/Api/Videos.php
Videos.getVideo
public function getVideo($videoIdentifier) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($videoIdentifier)) { throw new InvalidIdentifierException('video'); } return $this->get(sprintf('videos/%s', $videoIdentifier)); }
php
public function getVideo($videoIdentifier) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($videoIdentifier)) { throw new InvalidIdentifierException('video'); } return $this->get(sprintf('videos/%s', $videoIdentifier)); }
[ "public", "function", "getVideo", "(", "$", "videoIdentifier", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "videoIdentifier", ")", ")", "{", "throw", "new", "InvalidIdentifierException", "("...
Get a video @param int|string $videoIdentifier @return array|json
[ "Get", "a", "video" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Videos.php#L19-L26
nicklaw5/twitch-api-php
src/Api/Videos.php
Videos.getTopVideos
public function getTopVideos($limit = 10, $offset = 0, $game = null, $period = 'week', $broadcastType = 'highlight') { $validPeriods = ['week', 'month', 'all']; if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } if ($game && !is_string($game)) { throw new InvalidTypeException('game', 'string', gettype($game)); } if (!in_array($period = strtolower($period), $validPeriods)) { throw new UnsupportedOptionException('period', $validPeriods); } $broadcastType = trim($broadcastType, ', '); if (!$this->isValidBroadcastType($broadcastType)) { throw new UnsupportedOptionException('broadcastType', $validBroadcastTypes); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'game' => $game, 'period' => $period, 'broadcast_type' => $broadcastType, ]; return $this->get('videos/top', $params); }
php
public function getTopVideos($limit = 10, $offset = 0, $game = null, $period = 'week', $broadcastType = 'highlight') { $validPeriods = ['week', 'month', 'all']; if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } if ($game && !is_string($game)) { throw new InvalidTypeException('game', 'string', gettype($game)); } if (!in_array($period = strtolower($period), $validPeriods)) { throw new UnsupportedOptionException('period', $validPeriods); } $broadcastType = trim($broadcastType, ', '); if (!$this->isValidBroadcastType($broadcastType)) { throw new UnsupportedOptionException('broadcastType', $validBroadcastTypes); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'game' => $game, 'period' => $period, 'broadcast_type' => $broadcastType, ]; return $this->get('videos/top', $params); }
[ "public", "function", "getTopVideos", "(", "$", "limit", "=", "10", ",", "$", "offset", "=", "0", ",", "$", "game", "=", "null", ",", "$", "period", "=", "'week'", ",", "$", "broadcastType", "=", "'highlight'", ")", "{", "$", "validPeriods", "=", "["...
Get top videos @param int $limit @param int $offset @param string $gamme @param string $period @param string $broadcastType (comma-seperated list) @throws InvalidLimitException @throws InvalidOffsetException @throws InvalidTypeException @throws UnsupportedOptionException @return array|json
[ "Get", "top", "videos" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Videos.php#L42-L76
nicklaw5/twitch-api-php
src/Api/Videos.php
Videos.getFollowedChannelsVideos
public function getFollowedChannelsVideos($accessToken, $limit = 10, $offset = 0, $broadcastType = 'highlight') { if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $broadcastType = trim($broadcastType, ', '); if (!$this->isValidBroadcastType($broadcastType)) { throw new UnsupportedOptionException('broadcastType', $validBroadcastTypes); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'broadcast_type' => $broadcastType, ]; return $this->get('videos/followed', $params, $accessToken); }
php
public function getFollowedChannelsVideos($accessToken, $limit = 10, $offset = 0, $broadcastType = 'highlight') { if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $broadcastType = trim($broadcastType, ', '); if (!$this->isValidBroadcastType($broadcastType)) { throw new UnsupportedOptionException('broadcastType', $validBroadcastTypes); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'broadcast_type' => $broadcastType, ]; return $this->get('videos/followed', $params, $accessToken); }
[ "public", "function", "getFollowedChannelsVideos", "(", "$", "accessToken", ",", "$", "limit", "=", "10", ",", "$", "offset", "=", "0", ",", "$", "broadcastType", "=", "'highlight'", ")", "{", "if", "(", "!", "$", "this", "->", "isValidLimit", "(", "$", ...
Get the videos from channels followed by the authenticated user @param string $accessToken @param int $limit @param int $offset @param string $broadcastType (comma-seperated list) @throws InvalidLimitException @throws InvalidOffsetException @throws UnsupportedOptionException @return array|json
[ "Get", "the", "videos", "from", "channels", "followed", "by", "the", "authenticated", "user" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Videos.php#L90-L112
nicklaw5/twitch-api-php
src/Api/Clips.php
Clips.getClip
public function getClip($slug) { if (!is_string($slug)) { throw new InvalidTypeException('Slug', 'string', gettype($slug)); } return $this->get(sprintf('clips/%s', $slug)); }
php
public function getClip($slug) { if (!is_string($slug)) { throw new InvalidTypeException('Slug', 'string', gettype($slug)); } return $this->get(sprintf('clips/%s', $slug)); }
[ "public", "function", "getClip", "(", "$", "slug", ")", "{", "if", "(", "!", "is_string", "(", "$", "slug", ")", ")", "{", "throw", "new", "InvalidTypeException", "(", "'Slug'", ",", "'string'", ",", "gettype", "(", "$", "slug", ")", ")", ";", "}", ...
Get a clip @param string $slug @throws InvalidTypeException @return array|json
[ "Get", "a", "clip" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Clips.php#L19-L26
nicklaw5/twitch-api-php
src/Api/Clips.php
Clips.getTopClips
public function getTopClips($channel = null, $cursor = null, $game = null, $limit = 10, $period = 'day', $trending = false, $language = null) { $validPeriods = ['day', 'week', 'month', 'all']; if ($channel) { if (!is_string($channel)) { throw new InvalidTypeException('channel', 'string', gettype($channel)); } $channel = trim($channel, ', '); if (($count = substr_count($channel, ',') + 1) > 10) { throw new TwitchApiException(sprintf('Only a maximum of 10 channels can be queried. %d requested.', $count)); } } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('cursor', 'string', gettype($cursor)); } if ($game) { if (!is_string($game)) { throw new InvalidTypeException('game', 'string', gettype($game)); } $game = trim($game, ', '); if (($count = substr_count($game, ',') + 1) > 10) { throw new TwitchApiException(sprintf('Only a maximum of 10 games can be queried. %d requested.', $count)); } } if ($language) { if (!is_string($language)) { throw new InvalidTypeException('language', 'string', gettype($language)); } $language = trim($language, ', '); if (($count = substr_count($language, ',') + 1) > 28) { throw new TwitchApiException(sprintf('Only a maximum of 28 languages can be queried. %d requested.', $count)); } } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!in_array($period = strtolower($period), $validPeriods)) { throw new UnsupportedOptionException('period', $validPeriods); } if (!is_bool($trending)) { throw new InvalidTypeException('trending', 'boolean', gettype($trending)); } $params = [ 'channel' => $channel, 'cursor' => $cursor, 'game' => $game, 'language' => $language, 'limit' => (int)$limit, 'period' => $period, 'trending' => $trending ? 'true' : 'false', ]; return $this->get('clips/top', $params); }
php
public function getTopClips($channel = null, $cursor = null, $game = null, $limit = 10, $period = 'day', $trending = false, $language = null) { $validPeriods = ['day', 'week', 'month', 'all']; if ($channel) { if (!is_string($channel)) { throw new InvalidTypeException('channel', 'string', gettype($channel)); } $channel = trim($channel, ', '); if (($count = substr_count($channel, ',') + 1) > 10) { throw new TwitchApiException(sprintf('Only a maximum of 10 channels can be queried. %d requested.', $count)); } } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('cursor', 'string', gettype($cursor)); } if ($game) { if (!is_string($game)) { throw new InvalidTypeException('game', 'string', gettype($game)); } $game = trim($game, ', '); if (($count = substr_count($game, ',') + 1) > 10) { throw new TwitchApiException(sprintf('Only a maximum of 10 games can be queried. %d requested.', $count)); } } if ($language) { if (!is_string($language)) { throw new InvalidTypeException('language', 'string', gettype($language)); } $language = trim($language, ', '); if (($count = substr_count($language, ',') + 1) > 28) { throw new TwitchApiException(sprintf('Only a maximum of 28 languages can be queried. %d requested.', $count)); } } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!in_array($period = strtolower($period), $validPeriods)) { throw new UnsupportedOptionException('period', $validPeriods); } if (!is_bool($trending)) { throw new InvalidTypeException('trending', 'boolean', gettype($trending)); } $params = [ 'channel' => $channel, 'cursor' => $cursor, 'game' => $game, 'language' => $language, 'limit' => (int)$limit, 'period' => $period, 'trending' => $trending ? 'true' : 'false', ]; return $this->get('clips/top', $params); }
[ "public", "function", "getTopClips", "(", "$", "channel", "=", "null", ",", "$", "cursor", "=", "null", ",", "$", "game", "=", "null", ",", "$", "limit", "=", "10", ",", "$", "period", "=", "'day'", ",", "$", "trending", "=", "false", ",", "$", "...
Get top clips @param string $channel (comma-seperated list - 10 max) @param string $cursor @param string $game (comma-seperated list - 10 max) @param int $limit @param string $period @param boolean $trending @param string $language comma-seperated list - 28 max) @throws InvalidTypeException @throws TwitchApiException @throws InvalidLimitException @throws UnsupportedOptionException @return array|json
[ "Get", "top", "clips" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Clips.php#L44-L108
nicklaw5/twitch-api-php
src/Api/Clips.php
Clips.getFollowedClips
public function getFollowedClips($accessToken, $limit = 10, $cursor = null, $trending = false) { if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('cursor', 'string', gettype($cursor)); } if (!is_bool($trending)) { throw new InvalidTypeException('trending', 'boolean', gettype($trending)); } $params = [ 'limit' => (int)$limit, 'cursor' => $cursor, 'trending' => $trending ? 'true' : 'false', ]; return $this->get('clips/followed', $params, $accessToken); }
php
public function getFollowedClips($accessToken, $limit = 10, $cursor = null, $trending = false) { if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('cursor', 'string', gettype($cursor)); } if (!is_bool($trending)) { throw new InvalidTypeException('trending', 'boolean', gettype($trending)); } $params = [ 'limit' => (int)$limit, 'cursor' => $cursor, 'trending' => $trending ? 'true' : 'false', ]; return $this->get('clips/followed', $params, $accessToken); }
[ "public", "function", "getFollowedClips", "(", "$", "accessToken", ",", "$", "limit", "=", "10", ",", "$", "cursor", "=", "null", ",", "$", "trending", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "isValidLimit", "(", "$", "limit", ")",...
Get clips from channels followed @param string $accessToken @param int $limit @param string $cursor @param boolean $trending @throws InvalidTypeException @throws InvalidLimitException @return array|json
[ "Get", "clips", "from", "channels", "followed" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Clips.php#L121-L142
nicklaw5/twitch-api-php
src/TwitchRequest.php
TwitchRequest.sendRequest
protected function sendRequest($method, $endpoint, $params = [], $accessToken = null) { $client = $this->getNewHttpClient($method, $params, $accessToken); $response = $client->request($method, $endpoint); $responseBody = $response->getBody()->getContents(); return $this->getReturnJson() ? $responseBody : json_decode($responseBody, true); }
php
protected function sendRequest($method, $endpoint, $params = [], $accessToken = null) { $client = $this->getNewHttpClient($method, $params, $accessToken); $response = $client->request($method, $endpoint); $responseBody = $response->getBody()->getContents(); return $this->getReturnJson() ? $responseBody : json_decode($responseBody, true); }
[ "protected", "function", "sendRequest", "(", "$", "method", ",", "$", "endpoint", ",", "$", "params", "=", "[", "]", ",", "$", "accessToken", "=", "null", ")", "{", "$", "client", "=", "$", "this", "->", "getNewHttpClient", "(", "$", "method", ",", "...
Send the request @param string $method @param string $endpoint @param array $params @param bool $accessToken @return mixed
[ "Send", "the", "request" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchRequest.php#L48-L55
nicklaw5/twitch-api-php
src/TwitchRequest.php
TwitchRequest.getNewHttpClient
protected function getNewHttpClient($method, $params, $accessToken = null) { $config = [ 'http_errors' => $this->getHttpErrors(), 'base_uri' => $this->baseUri, 'timeout' => $this->getTimeout(), 'headers' => [ 'Client-ID' => $this->getClientId(), 'Accept' => sprintf('application/vnd.twitchtv.v%d+json', $this->getApiVersion()), 'User-Agent' => ($this->getUserAgent() !== null) ? $this->getUserAgent() : GuzzleHttp\default_user_agent(), ], ]; if ($accessToken) { $config['headers']['Authorization'] = sprintf('OAuth %s', $accessToken); } if (!empty($params)) { $config[($method == self::GET_METHOD) ? 'query' : 'json'] = $params; } return new GuzzleHttp\Client($config); }
php
protected function getNewHttpClient($method, $params, $accessToken = null) { $config = [ 'http_errors' => $this->getHttpErrors(), 'base_uri' => $this->baseUri, 'timeout' => $this->getTimeout(), 'headers' => [ 'Client-ID' => $this->getClientId(), 'Accept' => sprintf('application/vnd.twitchtv.v%d+json', $this->getApiVersion()), 'User-Agent' => ($this->getUserAgent() !== null) ? $this->getUserAgent() : GuzzleHttp\default_user_agent(), ], ]; if ($accessToken) { $config['headers']['Authorization'] = sprintf('OAuth %s', $accessToken); } if (!empty($params)) { $config[($method == self::GET_METHOD) ? 'query' : 'json'] = $params; } return new GuzzleHttp\Client($config); }
[ "protected", "function", "getNewHttpClient", "(", "$", "method", ",", "$", "params", ",", "$", "accessToken", "=", "null", ")", "{", "$", "config", "=", "[", "'http_errors'", "=>", "$", "this", "->", "getHttpErrors", "(", ")", ",", "'base_uri'", "=>", "$...
Get a new HTTP Client @param strring $method @param array $params @param string $accessToken @return Client
[ "Get", "a", "new", "HTTP", "Client" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchRequest.php#L65-L87
nicklaw5/twitch-api-php
src/TwitchRequest.php
TwitchRequest.get
protected function get($endpoint, $params = [], $accessToken = null) { return $this->sendRequest(self::GET_METHOD, $endpoint, $params, $accessToken); }
php
protected function get($endpoint, $params = [], $accessToken = null) { return $this->sendRequest(self::GET_METHOD, $endpoint, $params, $accessToken); }
[ "protected", "function", "get", "(", "$", "endpoint", ",", "$", "params", "=", "[", "]", ",", "$", "accessToken", "=", "null", ")", "{", "return", "$", "this", "->", "sendRequest", "(", "self", "::", "GET_METHOD", ",", "$", "endpoint", ",", "$", "par...
Send a GET request @param string $endpoint @param array $params @param bool $accessToken @return array|json
[ "Send", "a", "GET", "request" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchRequest.php#L97-L100
nicklaw5/twitch-api-php
src/TwitchRequest.php
TwitchRequest.post
protected function post($endpoint, $params = [], $accessToken = null) { return $this->sendRequest(self::POST_METHOD, $endpoint, $params, $accessToken); }
php
protected function post($endpoint, $params = [], $accessToken = null) { return $this->sendRequest(self::POST_METHOD, $endpoint, $params, $accessToken); }
[ "protected", "function", "post", "(", "$", "endpoint", ",", "$", "params", "=", "[", "]", ",", "$", "accessToken", "=", "null", ")", "{", "return", "$", "this", "->", "sendRequest", "(", "self", "::", "POST_METHOD", ",", "$", "endpoint", ",", "$", "p...
Send a POST request @param string $endpoint @param array $params @param bool $accessToken @return array|json
[ "Send", "a", "POST", "request" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchRequest.php#L110-L113
nicklaw5/twitch-api-php
src/TwitchRequest.php
TwitchRequest.put
protected function put($endpoint, $params = [], $accessToken = null) { return $this->sendRequest(self::PUT_METHOD, $endpoint, $params, $accessToken); }
php
protected function put($endpoint, $params = [], $accessToken = null) { return $this->sendRequest(self::PUT_METHOD, $endpoint, $params, $accessToken); }
[ "protected", "function", "put", "(", "$", "endpoint", ",", "$", "params", "=", "[", "]", ",", "$", "accessToken", "=", "null", ")", "{", "return", "$", "this", "->", "sendRequest", "(", "self", "::", "PUT_METHOD", ",", "$", "endpoint", ",", "$", "par...
Send a PUT request @param string $endpoint @param array $params @param bool $accessToken @return array|json
[ "Send", "a", "PUT", "request" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchRequest.php#L123-L126
nicklaw5/twitch-api-php
src/TwitchRequest.php
TwitchRequest.delete
protected function delete($endpoint, $params = [], $accessToken = null) { return $this->sendRequest(self::DELETE_METHOD, $endpoint, $params, $accessToken); }
php
protected function delete($endpoint, $params = [], $accessToken = null) { return $this->sendRequest(self::DELETE_METHOD, $endpoint, $params, $accessToken); }
[ "protected", "function", "delete", "(", "$", "endpoint", ",", "$", "params", "=", "[", "]", ",", "$", "accessToken", "=", "null", ")", "{", "return", "$", "this", "->", "sendRequest", "(", "self", "::", "DELETE_METHOD", ",", "$", "endpoint", ",", "$", ...
Send a DELETE request @param string $endpoint @param array $params @param bool $accessToken @return null|array|json
[ "Send", "a", "DELETE", "request" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/TwitchRequest.php#L136-L139
nicklaw5/twitch-api-php
src/Api/Streams.php
Streams.getStreamByUser
public function getStreamByUser($userIdendifier, $streamType = 'live') { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($userIdendifier)) { throw new InvalidIdentifierException('user'); } if (!$this->isValidStreamType($streamType)) { throw new InvalidStreamTypeException(); } return $this->get(sprintf('streams/%s', $userIdendifier), ['stream_type' => $streamType]); }
php
public function getStreamByUser($userIdendifier, $streamType = 'live') { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($userIdendifier)) { throw new InvalidIdentifierException('user'); } if (!$this->isValidStreamType($streamType)) { throw new InvalidStreamTypeException(); } return $this->get(sprintf('streams/%s', $userIdendifier), ['stream_type' => $streamType]); }
[ "public", "function", "getStreamByUser", "(", "$", "userIdendifier", ",", "$", "streamType", "=", "'live'", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "userIdendifier", ")", ")", "{", "...
Get the stream information for a user @param int|string $userIdentifier @param string $streamType @throws InvalidIdentifierException @throws InvalidStreamTypeException @return array|json
[ "Get", "the", "stream", "information", "for", "a", "user" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Streams.php#L22-L33
nicklaw5/twitch-api-php
src/Api/Streams.php
Streams.getLiveStreams
public function getLiveStreams($channel = null, $game = null, $language = null, $streamType = 'live', $limit = 25, $offset = 0, $broadcaster_language = null) { if ($channel) { if (!is_string($channel)) { throw new InvalidTypeException('channel', 'string', gettype($channel)); } $channel = trim($channel, ', '); if ($this->apiVersionIsGreaterThanV3()) { foreach (explode(',', $channel) as $chan) { if (!is_numeric($chan)) { throw new InvalidIdentifierException('channel'); } } } } if ($game && !is_string($game)) { throw new InvalidTypeException('game', 'string', gettype($game)); } if ($language && !is_string($language)) { throw new InvalidTypeException('language', 'string', gettype($language)); } if ($broadcaster_language && !is_string($broadcaster_language)) { throw new InvalidTypeException('broadcaster_language', 'string', gettype($broadcaster_language)); } if (!$this->isValidStreamType($streamType)) { throw new InvalidStreamTypeException(); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $params = [ 'channel' => $channel, 'game' => $game, 'language' => $language, 'broadcaster_language' => $broadcaster_language, 'stream_type' => $streamType, 'limit' => intval($limit), 'offset' => intval($offset), ]; return $this->get('streams', $params); }
php
public function getLiveStreams($channel = null, $game = null, $language = null, $streamType = 'live', $limit = 25, $offset = 0, $broadcaster_language = null) { if ($channel) { if (!is_string($channel)) { throw new InvalidTypeException('channel', 'string', gettype($channel)); } $channel = trim($channel, ', '); if ($this->apiVersionIsGreaterThanV3()) { foreach (explode(',', $channel) as $chan) { if (!is_numeric($chan)) { throw new InvalidIdentifierException('channel'); } } } } if ($game && !is_string($game)) { throw new InvalidTypeException('game', 'string', gettype($game)); } if ($language && !is_string($language)) { throw new InvalidTypeException('language', 'string', gettype($language)); } if ($broadcaster_language && !is_string($broadcaster_language)) { throw new InvalidTypeException('broadcaster_language', 'string', gettype($broadcaster_language)); } if (!$this->isValidStreamType($streamType)) { throw new InvalidStreamTypeException(); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $params = [ 'channel' => $channel, 'game' => $game, 'language' => $language, 'broadcaster_language' => $broadcaster_language, 'stream_type' => $streamType, 'limit' => intval($limit), 'offset' => intval($offset), ]; return $this->get('streams', $params); }
[ "public", "function", "getLiveStreams", "(", "$", "channel", "=", "null", ",", "$", "game", "=", "null", ",", "$", "language", "=", "null", ",", "$", "streamType", "=", "'live'", ",", "$", "limit", "=", "25", ",", "$", "offset", "=", "0", ",", "$",...
Get live streams @param string $channel (comma-seperated list) @param string $game @param string $language @param string $streamType @param int $limit @param int $offset @param string $broadcaster_language @throws InvalidTypeException @throws InvalidIdentifierException @throws InvalidStreamTypeException @throws InvalidLimitException @throws InvalidOffsetException @return array|json
[ "Get", "live", "streams" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Streams.php#L52-L104
nicklaw5/twitch-api-php
src/Api/Streams.php
Streams.getStreamsSummary
public function getStreamsSummary($game = null) { if ($game && !is_string($game)) { throw new InvalidTypeException('game', 'string', gettype($game)); } return $this->get('streams/summary', ['game' => $game]); }
php
public function getStreamsSummary($game = null) { if ($game && !is_string($game)) { throw new InvalidTypeException('game', 'string', gettype($game)); } return $this->get('streams/summary', ['game' => $game]); }
[ "public", "function", "getStreamsSummary", "(", "$", "game", "=", "null", ")", "{", "if", "(", "$", "game", "&&", "!", "is_string", "(", "$", "game", ")", ")", "{", "throw", "new", "InvalidTypeException", "(", "'game'", ",", "'string'", ",", "gettype", ...
Gets a summary of live streams @param string $game @throws InvalidTypeException @return array|json
[ "Gets", "a", "summary", "of", "live", "streams" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Streams.php#L113-L120
nicklaw5/twitch-api-php
src/Api/Streams.php
Streams.getFeaturedStreams
public function getFeaturedStreams($limit = 25, $offset = 0) { if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), ]; return $this->get('streams/featured', $params); }
php
public function getFeaturedStreams($limit = 25, $offset = 0) { if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), ]; return $this->get('streams/featured', $params); }
[ "public", "function", "getFeaturedStreams", "(", "$", "limit", "=", "25", ",", "$", "offset", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "isValidLimit", "(", "$", "limit", ")", ")", "{", "throw", "new", "InvalidLimitException", "(", ")", ...
Get a list of all featured live streams @param int $limit @param int $offset @throws InvalidLimitException @throws InvalidOffsetException @return array|json
[ "Get", "a", "list", "of", "all", "featured", "live", "streams" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Streams.php#L131-L147
nicklaw5/twitch-api-php
src/Api/Streams.php
Streams.getFollowedStreams
public function getFollowedStreams($asccessToken, $streamType = 'live', $limit = 25, $offset = 0) { if (!$this->isValidStreamType($streamType)) { throw new InvalidStreamTypeException(); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $params = [ 'stream_type' => $streamType, 'limit' => intval($limit), 'offset' => intval($offset), ]; return $this->get('streams/followed', $params, $asccessToken); }
php
public function getFollowedStreams($asccessToken, $streamType = 'live', $limit = 25, $offset = 0) { if (!$this->isValidStreamType($streamType)) { throw new InvalidStreamTypeException(); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $params = [ 'stream_type' => $streamType, 'limit' => intval($limit), 'offset' => intval($offset), ]; return $this->get('streams/followed', $params, $asccessToken); }
[ "public", "function", "getFollowedStreams", "(", "$", "asccessToken", ",", "$", "streamType", "=", "'live'", ",", "$", "limit", "=", "25", ",", "$", "offset", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "isValidStreamType", "(", "$", "stream...
Get followed streams @param string $streamType @param int $limit @param int $offset @throws InvalidStreamTypeException @throws InvalidLimitException @throws InvalidOffsetException @return array|json
[ "Get", "followed", "streams" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Streams.php#L160-L181
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.getChannel
public function getChannel($channelIdentifier) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('channels/%s', $channelIdentifier)); }
php
public function getChannel($channelIdentifier) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('channels/%s', $channelIdentifier)); }
[ "public", "function", "getChannel", "(", "$", "channelIdentifier", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "channelIdentifier", ")", ")", "{", "throw", "new", "InvalidIdentifierException",...
Get a channel @param string|int $channelIdentifier @throws InvalidIdentifierException @return array|json
[ "Get", "a", "channel" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L34-L41
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.updateChannel
public function updateChannel($channelIdentifier, $accessToken, $status = null, $game = null, $delay = null, $channelFeedEnabled = null) { $params = []; $params['channel'] = []; if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if ($status) { if (!is_string($status)) { throw new InvalidTypeException('Status', 'string', gettype($status)); } $params['channel']['status'] = $status; } if ($game) { if (!is_string($game)) { throw new InvalidTypeException('Game', 'string', gettype($game)); } $params['channel']['game'] = $game; } if ($delay) { if (!is_numeric($delay)) { throw new InvalidTypeException('Delay', 'integer', gettype($delay)); } $params['channel']['delay'] = intval($delay); } if ($channelFeedEnabled !== null) { if (!is_bool($channelFeedEnabled)) { throw new InvalidTypeException('ChannelFeedEnabled', 'boolean', gettype($channelFeedEnabled)); } $params['channel']['channel_feed_enabled'] = $channelFeedEnabled; } if (empty($params['channel'])) { throw new TwitchApiException('At least one of the following parameters must be set: status, game, delay or channelFeedEnabled.'); } return $this->put(sprintf('channels/%s', $channelIdentifier), $params, $accessToken); }
php
public function updateChannel($channelIdentifier, $accessToken, $status = null, $game = null, $delay = null, $channelFeedEnabled = null) { $params = []; $params['channel'] = []; if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if ($status) { if (!is_string($status)) { throw new InvalidTypeException('Status', 'string', gettype($status)); } $params['channel']['status'] = $status; } if ($game) { if (!is_string($game)) { throw new InvalidTypeException('Game', 'string', gettype($game)); } $params['channel']['game'] = $game; } if ($delay) { if (!is_numeric($delay)) { throw new InvalidTypeException('Delay', 'integer', gettype($delay)); } $params['channel']['delay'] = intval($delay); } if ($channelFeedEnabled !== null) { if (!is_bool($channelFeedEnabled)) { throw new InvalidTypeException('ChannelFeedEnabled', 'boolean', gettype($channelFeedEnabled)); } $params['channel']['channel_feed_enabled'] = $channelFeedEnabled; } if (empty($params['channel'])) { throw new TwitchApiException('At least one of the following parameters must be set: status, game, delay or channelFeedEnabled.'); } return $this->put(sprintf('channels/%s', $channelIdentifier), $params, $accessToken); }
[ "public", "function", "updateChannel", "(", "$", "channelIdentifier", ",", "$", "accessToken", ",", "$", "status", "=", "null", ",", "$", "game", "=", "null", ",", "$", "delay", "=", "null", ",", "$", "channelFeedEnabled", "=", "null", ")", "{", "$", "...
Update a user's channel @param string|int $channelIdentifier @param string $accessToken @param string $status @param string $game @param int $delay @param bool $channelFeedEnabled @throws InvalidIdentifierException @throws InvalidTypeException @throws TwitchApiException @return array|json
[ "Update", "a", "user", "s", "channel" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L57-L99
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.getChannelEditors
public function getChannelEditors($channelIdentifier, $accessToken) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('channels/%s/editors', $channelIdentifier), [], $accessToken); }
php
public function getChannelEditors($channelIdentifier, $accessToken) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('channels/%s/editors', $channelIdentifier), [], $accessToken); }
[ "public", "function", "getChannelEditors", "(", "$", "channelIdentifier", ",", "$", "accessToken", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "channelIdentifier", ")", ")", "{", "throw", ...
Get channel editors @param string|int $channelIdentifier @param string $accessToken @throws InvalidIdentifierException @return array|json
[ "Get", "channel", "editors" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L109-L116
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.getChannelFollowers
public function getChannelFollowers($channelIdentifier, $limit = 25, $offset = 0, $cursor = null, $direction = 'desc') { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } if (!$this->isValidDirection($direction)) { throw new InvalidDirectionException(); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'cursor' => $cursor, 'direction' => $direction, ]; return $this->get(sprintf('channels/%s/follows', $channelIdentifier), $params); }
php
public function getChannelFollowers($channelIdentifier, $limit = 25, $offset = 0, $cursor = null, $direction = 'desc') { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } if (!$this->isValidDirection($direction)) { throw new InvalidDirectionException(); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'cursor' => $cursor, 'direction' => $direction, ]; return $this->get(sprintf('channels/%s/follows', $channelIdentifier), $params); }
[ "public", "function", "getChannelFollowers", "(", "$", "channelIdentifier", ",", "$", "limit", "=", "25", ",", "$", "offset", "=", "0", ",", "$", "cursor", "=", "null", ",", "$", "direction", "=", "'desc'", ")", "{", "if", "(", "$", "this", "->", "ap...
Get channel followers @param string|int $channelIdentifier @param int $limit @param int $offset @param string $cursor @param string $direction @throws InvalidIdentifierException @throws InvalidLimitException @throws InvalidOffsetException @throws InvalidTypeException @throws InvalidDirectionException @return array|json
[ "Get", "channel", "followers" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L133-L163
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.getChannelTeams
public function getChannelTeams($channelIdentifier) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('channels/%s/teams', $channelIdentifier)); }
php
public function getChannelTeams($channelIdentifier) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('channels/%s/teams', $channelIdentifier)); }
[ "public", "function", "getChannelTeams", "(", "$", "channelIdentifier", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "channelIdentifier", ")", ")", "{", "throw", "new", "InvalidIdentifierExcept...
Get channel teams @param string|int $channelIdentifier @throws InvalidIdentifierException @return array|json
[ "Get", "channel", "teams" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L172-L179
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.getChannelSubscribers
public function getChannelSubscribers($channelIdentifier, $accessToken, $limit = 25, $offset = 0, $direction = 'desc') { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } if (!$this->isValidDirection($direction)) { throw new InvalidDirectionException(); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'direction' => $direction, ]; return $this->get(sprintf('channels/%s/subscriptions', $channelIdentifier), $params, $accessToken); }
php
public function getChannelSubscribers($channelIdentifier, $accessToken, $limit = 25, $offset = 0, $direction = 'desc') { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } if (!$this->isValidDirection($direction)) { throw new InvalidDirectionException(); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'direction' => $direction, ]; return $this->get(sprintf('channels/%s/subscriptions', $channelIdentifier), $params, $accessToken); }
[ "public", "function", "getChannelSubscribers", "(", "$", "channelIdentifier", ",", "$", "accessToken", ",", "$", "limit", "=", "25", ",", "$", "offset", "=", "0", ",", "$", "direction", "=", "'desc'", ")", "{", "if", "(", "$", "this", "->", "apiVersionIs...
Get channel subscribers @param string|int $channelIdentifier @param string $accessToken @param int $limit @param int $offset @param string $direction @throws InvalidIdentifierException @throws InvalidLimitException @throws InvalidOffsetException @throws InvalidDirectionException @return array|json
[ "Get", "channel", "subscribers" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L195-L220
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.getChannelVideos
public function getChannelVideos($channelIdentifier, $limit = 10, $offset = 0, $broadcastType = 'highlight', $language = null, $sort = 'time') { $validSort = ['views', 'time']; if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $broadcastType = trim($broadcastType, ', '); if (!$this->isValidBroadcastType($broadcastType)) { throw new UnsupportedOptionException('broadcastType', $validBroadcastTypes); } if ($language && !is_string($language)) { throw new InvalidTypeException('language', 'string', gettype($language)); } if (!in_array($sort = strtolower($sort), $validSort)) { throw new UnsupportedOptionException('sort', $validSort); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'broadcast_type' => $broadcastType, 'language' => $language, 'sort' => $sort, ]; return $this->get(sprintf('channels/%s/videos', $channelIdentifier), $params); }
php
public function getChannelVideos($channelIdentifier, $limit = 10, $offset = 0, $broadcastType = 'highlight', $language = null, $sort = 'time') { $validSort = ['views', 'time']; if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if (!$this->isValidOffset($offset)) { throw new InvalidOffsetException(); } $broadcastType = trim($broadcastType, ', '); if (!$this->isValidBroadcastType($broadcastType)) { throw new UnsupportedOptionException('broadcastType', $validBroadcastTypes); } if ($language && !is_string($language)) { throw new InvalidTypeException('language', 'string', gettype($language)); } if (!in_array($sort = strtolower($sort), $validSort)) { throw new UnsupportedOptionException('sort', $validSort); } $params = [ 'limit' => intval($limit), 'offset' => intval($offset), 'broadcast_type' => $broadcastType, 'language' => $language, 'sort' => $sort, ]; return $this->get(sprintf('channels/%s/videos', $channelIdentifier), $params); }
[ "public", "function", "getChannelVideos", "(", "$", "channelIdentifier", ",", "$", "limit", "=", "10", ",", "$", "offset", "=", "0", ",", "$", "broadcastType", "=", "'highlight'", ",", "$", "language", "=", "null", ",", "$", "sort", "=", "'time'", ")", ...
Get channel videos @param string|int $channelIdentifier @param int $limit @param int $offset @param string $broadcastType (comma-seperated list) @param string $language (comma-seperated list) @param string $sort @throws InvalidIdentifierException @throws InvalidLimitException @throws InvalidOffsetException @throws UnsupportedOptionException @throws InvalidTypeException @return array|json
[ "Get", "channel", "videos" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L262-L300
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.startChannelCommercial
public function startChannelCommercial($channelIdentifier, $accessToken, $length = 30) { $validLengths = [30, 60, 90, 120, 150, 180]; if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!in_array($length = intval($length), $validLengths)) { throw new UnsupportedOptionException('length', $validLengths); } return $this->post(sprintf('channels/%s/commercial', $channelIdentifier), ['length' => $length], $accessToken); }
php
public function startChannelCommercial($channelIdentifier, $accessToken, $length = 30) { $validLengths = [30, 60, 90, 120, 150, 180]; if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!in_array($length = intval($length), $validLengths)) { throw new UnsupportedOptionException('length', $validLengths); } return $this->post(sprintf('channels/%s/commercial', $channelIdentifier), ['length' => $length], $accessToken); }
[ "public", "function", "startChannelCommercial", "(", "$", "channelIdentifier", ",", "$", "accessToken", ",", "$", "length", "=", "30", ")", "{", "$", "validLengths", "=", "[", "30", ",", "60", ",", "90", ",", "120", ",", "150", ",", "180", "]", ";", ...
Run a channel commercial @param string|int $channelIdentifier @param string $accessToken @param int $length @throws InvalidIdentifierException @throws UnsupportedOptionException @return array|json
[ "Run", "a", "channel", "commercial" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L312-L325
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.resetChannelStreamKey
public function resetChannelStreamKey($channelIdentifier, $accessToken) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->delete(sprintf('channels/%s/stream_key', $channelIdentifier), [], $accessToken); }
php
public function resetChannelStreamKey($channelIdentifier, $accessToken) { if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->delete(sprintf('channels/%s/stream_key', $channelIdentifier), [], $accessToken); }
[ "public", "function", "resetChannelStreamKey", "(", "$", "channelIdentifier", ",", "$", "accessToken", ")", "{", "if", "(", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", "&&", "!", "is_numeric", "(", "$", "channelIdentifier", ")", ")", "{", "throw"...
Reset a channel's stream key @param string|int $channelIdentifier @param string $accessToken @throws InvalidIdentifierException @return array|json
[ "Reset", "a", "channel", "s", "stream", "key" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L335-L342
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.getChannelCommunity
public function getChannelCommunity($channelIdentifier) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('channels/%s/community', $channelIdentifier)); }
php
public function getChannelCommunity($channelIdentifier) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->get(sprintf('channels/%s/community', $channelIdentifier)); }
[ "public", "function", "getChannelCommunity", "(", "$", "channelIdentifier", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "(", ")", ";", "}", "if", "(", ...
Get the community for a channel @param string|int $channelIdentifier @throws InvalidIdentifierException @throws EndpointNotSupportedByApiVersionException @return null|array|json
[ "Get", "the", "community", "for", "a", "channel" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L352-L363
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.setChannelCommunity
public function setChannelCommunity($channelIdentifier, $communityId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->put(sprintf('channels/%s/community/%s', $channelIdentifier, $communityId), [], $accessToken); }
php
public function setChannelCommunity($channelIdentifier, $communityId, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->put(sprintf('channels/%s/community/%s', $channelIdentifier, $communityId), [], $accessToken); }
[ "public", "function", "setChannelCommunity", "(", "$", "channelIdentifier", ",", "$", "communityId", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApi...
Set the community for a channel @param string|int $channelIdentifier @param string $communityId @param string $accessToken @throws InvalidIdentifierException @throws EndpointNotSupportedByApiVersionException @return null
[ "Set", "the", "community", "for", "a", "channel" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L375-L386
nicklaw5/twitch-api-php
src/Api/Channels.php
Channels.deleteChannelFromCommunity
public function deleteChannelFromCommunity($channelIdentifier, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->delete(sprintf('channels/%s/community', $channelIdentifier), [], $accessToken); }
php
public function deleteChannelFromCommunity($channelIdentifier, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } return $this->delete(sprintf('channels/%s/community', $channelIdentifier), [], $accessToken); }
[ "public", "function", "deleteChannelFromCommunity", "(", "$", "channelIdentifier", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "("...
Remove a channel form a community @param string|int $channelIdentifier @param string $accessToken @throws InvalidIdentifierException @throws EndpointNotSupportedByApiVersionException @return null
[ "Remove", "a", "channel", "form", "a", "community" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Channels.php#L397-L408
nicklaw5/twitch-api-php
src/Api/Teams.php
Teams.getTeam
public function getTeam($name) { if (!is_string($name)) { throw new InvalidTypeException('Name', 'string', gettype($name)); } return $this->get(sprintf('teams/%s', $name)); }
php
public function getTeam($name) { if (!is_string($name)) { throw new InvalidTypeException('Name', 'string', gettype($name)); } return $this->get(sprintf('teams/%s', $name)); }
[ "public", "function", "getTeam", "(", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidTypeException", "(", "'Name'", ",", "'string'", ",", "gettype", "(", "$", "name", ")", ")", ";", "}", ...
Get a team by name @param string $name @throws InvalidTypeException @return array|json
[ "Get", "a", "team", "by", "name" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Teams.php#L18-L25
nicklaw5/twitch-api-php
src/Api/Bits.php
Bits.getCheermotes
public function getCheermotes($channelIdentifier = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if ($channelIdentifier && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } $params = [ 'channel_id' => $channelIdentifier, ]; return $this->get('bits/actions', $params); }
php
public function getCheermotes($channelIdentifier = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if ($channelIdentifier && !is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } $params = [ 'channel_id' => $channelIdentifier, ]; return $this->get('bits/actions', $params); }
[ "public", "function", "getCheermotes", "(", "$", "channelIdentifier", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", "(", ")", ";", "}", "i...
Get a list of cheermotes @param string|int $channelIdentifier @throws InvalidIdentifierException @throws EndpointNotSupportedByApiVersionException @return array|json
[ "Get", "a", "list", "of", "cheermotes" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Bits.php#L18-L33
nicklaw5/twitch-api-php
src/Api/Collections.php
Collections.getCollection
public function getCollection($collectionId, $includeAllItems = false) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_bool($includeAllItems)) { throw new InvalidTypeException('Include All Items', 'boolean', gettype($includeAllItems)); } $params = [ 'includeAllItems' => $includeAllItems, ]; return $this->get(sprintf('collections/%s/items', $collectionId), $params); }
php
public function getCollection($collectionId, $includeAllItems = false) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_bool($includeAllItems)) { throw new InvalidTypeException('Include All Items', 'boolean', gettype($includeAllItems)); } $params = [ 'includeAllItems' => $includeAllItems, ]; return $this->get(sprintf('collections/%s/items', $collectionId), $params); }
[ "public", "function", "getCollection", "(", "$", "collectionId", ",", "$", "includeAllItems", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionException", ...
Gets all items (videos) in specified collection @param string $collectionId @param bool $includeAllItems @throws EndpointNotSupportedByApiVersionException @throws InvalidTypeException @return array|json
[ "Gets", "all", "items", "(", "videos", ")", "in", "specified", "collection" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Collections.php#L38-L53
nicklaw5/twitch-api-php
src/Api/Collections.php
Collections.getChannelCollection
public function getChannelCollection($channelIdentifier, $limit = 10, $cursor = null, $containingItem = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } if ($containingItem && !is_string($containingItem)) { throw new InvalidTypeException('Containing Item', 'string', gettype($containingItem)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, 'containingItem' => $containingItem, ]; return $this->get(sprintf('channels/%s/collections', $channelIdentifier), $params); }
php
public function getChannelCollection($channelIdentifier, $limit = 10, $cursor = null, $containingItem = null) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!$this->isValidLimit($limit)) { throw new InvalidLimitException(); } if ($cursor && !is_string($cursor)) { throw new InvalidTypeException('Cursor', 'string', gettype($cursor)); } if ($containingItem && !is_string($containingItem)) { throw new InvalidTypeException('Containing Item', 'string', gettype($containingItem)); } $params = [ 'limit' => intval($limit), 'cursor' => $cursor, 'containingItem' => $containingItem, ]; return $this->get(sprintf('channels/%s/collections', $channelIdentifier), $params); }
[ "public", "function", "getChannelCollection", "(", "$", "channelIdentifier", ",", "$", "limit", "=", "10", ",", "$", "cursor", "=", "null", ",", "$", "containingItem", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "...
Get all collections owned by a channel @param int|string $channelIdentifier @param int $limit @param string $cursor @param string $containingItem @throws EndpointNotSupportedByApiVersionException @throws InvalidIdentifierException @throws InvalidLimitException @throws InvalidTypeException @return array|json
[ "Get", "all", "collections", "owned", "by", "a", "channel" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Collections.php#L68-L97
nicklaw5/twitch-api-php
src/Api/Collections.php
Collections.createCollection
public function createCollection($channelIdentifier, $title, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($title)) { throw new InvalidTypeException('Title', 'string', gettype($title)); } $params = [ 'title' => $title, ]; return $this->post(sprintf('channels/%s/collections', $channelIdentifier), $params, $accessToken); }
php
public function createCollection($channelIdentifier, $title, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_numeric($channelIdentifier)) { throw new InvalidIdentifierException('channel'); } if (!is_string($title)) { throw new InvalidTypeException('Title', 'string', gettype($title)); } $params = [ 'title' => $title, ]; return $this->post(sprintf('channels/%s/collections', $channelIdentifier), $params, $accessToken); }
[ "public", "function", "createCollection", "(", "$", "channelIdentifier", ",", "$", "title", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionEx...
Create a new collection owned a channel @param int|string $channelIdentifier @param string $title @param string $accessToken @throws EndpointNotSupportedByApiVersionException @throws InvalidIdentifierException @throws InvalidTypeException @return array|json
[ "Create", "a", "new", "collection", "owned", "a", "channel" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Collections.php#L110-L129
nicklaw5/twitch-api-php
src/Api/Collections.php
Collections.updateCollection
public function updateCollection($collectionId, $title, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($title)) { throw new InvalidTypeException('Title', 'string', gettype($title)); } $params = [ 'title' => $title, ]; return $this->put(sprintf('collections/%s', $collectionId), $params, $accessToken); }
php
public function updateCollection($collectionId, $title, $accessToken) { if (!$this->apiVersionIsGreaterThanV3()) { throw new EndpointNotSupportedByApiVersionException(); } if (!is_string($title)) { throw new InvalidTypeException('Title', 'string', gettype($title)); } $params = [ 'title' => $title, ]; return $this->put(sprintf('collections/%s', $collectionId), $params, $accessToken); }
[ "public", "function", "updateCollection", "(", "$", "collectionId", ",", "$", "title", ",", "$", "accessToken", ")", "{", "if", "(", "!", "$", "this", "->", "apiVersionIsGreaterThanV3", "(", ")", ")", "{", "throw", "new", "EndpointNotSupportedByApiVersionExcepti...
Update a collection @param string $collectionId @param string $title @param string $accessToken @throws EndpointNotSupportedByApiVersionException @throws InvalidTypeException @return null
[ "Update", "a", "collection" ]
train
https://github.com/nicklaw5/twitch-api-php/blob/171ef0e43662ea186ec5a6b7a452b3bd3822f3a3/src/Api/Collections.php#L141-L156