id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
1,400
webriq/core
module/Paragraph/src/Grid/Paragraph/Controller/ChangeLayoutController.php
ChangeLayoutController.getLayoutId
protected function getLayoutId() { $paragraph = $this->findParagraph(); if ( empty( $paragraph ) ) { /* @var $structure \Core\Model\SubDomain\Structure */ $structure = $this->getServiceLocator() ->get( 'Grid\Core\Model\SubDomain\Model' ) ->findActual(); return $structure->defaultLayoutId; } else { return $paragraph->layoutId; } }
php
protected function getLayoutId() { $paragraph = $this->findParagraph(); if ( empty( $paragraph ) ) { /* @var $structure \Core\Model\SubDomain\Structure */ $structure = $this->getServiceLocator() ->get( 'Grid\Core\Model\SubDomain\Model' ) ->findActual(); return $structure->defaultLayoutId; } else { return $paragraph->layoutId; } }
[ "protected", "function", "getLayoutId", "(", ")", "{", "$", "paragraph", "=", "$", "this", "->", "findParagraph", "(", ")", ";", "if", "(", "empty", "(", "$", "paragraph", ")", ")", "{", "/* @var $structure \\Core\\Model\\SubDomain\\Structure */", "$", "structure", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Grid\\Core\\Model\\SubDomain\\Model'", ")", "->", "findActual", "(", ")", ";", "return", "$", "structure", "->", "defaultLayoutId", ";", "}", "else", "{", "return", "$", "paragraph", "->", "layoutId", ";", "}", "}" ]
Get actual layout ID @return int
[ "Get", "actual", "layout", "ID" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Controller/ChangeLayoutController.php#L145-L162
1,401
webriq/core
module/Paragraph/src/Grid/Paragraph/Controller/ChangeLayoutController.php
ChangeLayoutController.localAction
public function localAction() { $success = null; $request = $this->getRequest(); $data = $request->getPost(); $form = $this->getServiceLocator() ->get( 'Form' ) ->create( 'Grid\Paragraph\ChangeLayout\Local', array( 'returnUri' => $request->getQuery( 'returnUri' ), ) ); $form->setAttribute( 'action', $this->url() ->fromRoute( 'Grid\Paragraph\ChangeLayout\Local', array( 'locale' => (string) $this->locale(), 'paragraphId' => $this->paragraphId, 'returnUri' => $request->getQuery( 'returnUri' ), ) ) ); if ( empty( $this->paragraphId ) ) { $form->get( 'layoutId' ) ->setEmptyOption( null ); } /* @var $form \Zend\Form\Form */ $paragraph = $this->findParagraph(); if ( ! empty( $paragraph ) ) { $form->setHydrator( $paragraph->getMapper() ) ->bind( $paragraph ); } if ( $request->isPost() ) { $form->setData( $data ); if ( $form->isValid() ) { $data = $form->getData(); $success = $this->saveLayout( $data['layoutId'] ); } else { $success = false; } } if ( true === $success ) { $this->messenger() ->add( 'paragraph.action.changeLayout.success', 'paragraph', Message::LEVEL_INFO ); } if ( false === $success ) { $this->messenger() ->add( 'paragraph.action.changeLayout.failed', 'paragraph', Message::LEVEL_ERROR ); } if ( null !== $success ) { return $this->redirect() ->toUrl( $form->get( 'returnUri' ) ->getValue() ); } $view = new ViewModel( array( 'form' => $form, ) ); return $view->setTerminal( true ); }
php
public function localAction() { $success = null; $request = $this->getRequest(); $data = $request->getPost(); $form = $this->getServiceLocator() ->get( 'Form' ) ->create( 'Grid\Paragraph\ChangeLayout\Local', array( 'returnUri' => $request->getQuery( 'returnUri' ), ) ); $form->setAttribute( 'action', $this->url() ->fromRoute( 'Grid\Paragraph\ChangeLayout\Local', array( 'locale' => (string) $this->locale(), 'paragraphId' => $this->paragraphId, 'returnUri' => $request->getQuery( 'returnUri' ), ) ) ); if ( empty( $this->paragraphId ) ) { $form->get( 'layoutId' ) ->setEmptyOption( null ); } /* @var $form \Zend\Form\Form */ $paragraph = $this->findParagraph(); if ( ! empty( $paragraph ) ) { $form->setHydrator( $paragraph->getMapper() ) ->bind( $paragraph ); } if ( $request->isPost() ) { $form->setData( $data ); if ( $form->isValid() ) { $data = $form->getData(); $success = $this->saveLayout( $data['layoutId'] ); } else { $success = false; } } if ( true === $success ) { $this->messenger() ->add( 'paragraph.action.changeLayout.success', 'paragraph', Message::LEVEL_INFO ); } if ( false === $success ) { $this->messenger() ->add( 'paragraph.action.changeLayout.failed', 'paragraph', Message::LEVEL_ERROR ); } if ( null !== $success ) { return $this->redirect() ->toUrl( $form->get( 'returnUri' ) ->getValue() ); } $view = new ViewModel( array( 'form' => $form, ) ); return $view->setTerminal( true ); }
[ "public", "function", "localAction", "(", ")", "{", "$", "success", "=", "null", ";", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "data", "=", "$", "request", "->", "getPost", "(", ")", ";", "$", "form", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Form'", ")", "->", "create", "(", "'Grid\\Paragraph\\ChangeLayout\\Local'", ",", "array", "(", "'returnUri'", "=>", "$", "request", "->", "getQuery", "(", "'returnUri'", ")", ",", ")", ")", ";", "$", "form", "->", "setAttribute", "(", "'action'", ",", "$", "this", "->", "url", "(", ")", "->", "fromRoute", "(", "'Grid\\Paragraph\\ChangeLayout\\Local'", ",", "array", "(", "'locale'", "=>", "(", "string", ")", "$", "this", "->", "locale", "(", ")", ",", "'paragraphId'", "=>", "$", "this", "->", "paragraphId", ",", "'returnUri'", "=>", "$", "request", "->", "getQuery", "(", "'returnUri'", ")", ",", ")", ")", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "paragraphId", ")", ")", "{", "$", "form", "->", "get", "(", "'layoutId'", ")", "->", "setEmptyOption", "(", "null", ")", ";", "}", "/* @var $form \\Zend\\Form\\Form */", "$", "paragraph", "=", "$", "this", "->", "findParagraph", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "paragraph", ")", ")", "{", "$", "form", "->", "setHydrator", "(", "$", "paragraph", "->", "getMapper", "(", ")", ")", "->", "bind", "(", "$", "paragraph", ")", ";", "}", "if", "(", "$", "request", "->", "isPost", "(", ")", ")", "{", "$", "form", "->", "setData", "(", "$", "data", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "data", "=", "$", "form", "->", "getData", "(", ")", ";", "$", "success", "=", "$", "this", "->", "saveLayout", "(", "$", "data", "[", "'layoutId'", "]", ")", ";", "}", "else", "{", "$", "success", "=", "false", ";", "}", "}", "if", "(", "true", "===", "$", "success", ")", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.action.changeLayout.success'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_INFO", ")", ";", "}", "if", "(", "false", "===", "$", "success", ")", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.action.changeLayout.failed'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_ERROR", ")", ";", "}", "if", "(", "null", "!==", "$", "success", ")", "{", "return", "$", "this", "->", "redirect", "(", ")", "->", "toUrl", "(", "$", "form", "->", "get", "(", "'returnUri'", ")", "->", "getValue", "(", ")", ")", ";", "}", "$", "view", "=", "new", "ViewModel", "(", "array", "(", "'form'", "=>", "$", "form", ",", ")", ")", ";", "return", "$", "view", "->", "setTerminal", "(", "true", ")", ";", "}" ]
Change to local layout
[ "Change", "to", "local", "layout" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Controller/ChangeLayoutController.php#L199-L275
1,402
webriq/core
module/Paragraph/src/Grid/Paragraph/Controller/ChangeLayoutController.php
ChangeLayoutController.importAction
public function importAction() { $success = null; $request = $this->getRequest(); $data = $request->getPost(); $form = $this->getServiceLocator() ->get( 'Form' ) ->create( 'Grid\Paragraph\ChangeLayout\Import', array( 'returnUri' => $request->getQuery( 'returnUri' ), ) ); $form->setAttribute( 'action', $this->url() ->fromRoute( 'Grid\Paragraph\ChangeLayout\Import', array( 'locale' => (string) $this->locale(), 'paragraphId' => $this->paragraphId, 'returnUri' => $request->getQuery( 'returnUri' ), ) ) ); if ( $request->isPost() ) { $form->setData( $data ); if ( $form->isValid() ) { $data = $form->getData(); $beforeId = $this->getLayoutId(); $clonedId = $this->getParagraphModel() ->cloneFrom( $data['importId'], '_central' ); $success = $this->saveLayout( $clonedId ); $this->getServiceLocator() ->get( 'Grid\Menu\Model\Menu\Model' ) ->interleaveParagraphs( $clonedId, $beforeId ); } else { $success = false; } } if ( true === $success ) { $this->messenger() ->add( 'paragraph.action.importLayout.success', 'paragraph', Message::LEVEL_INFO ); } if ( false === $success ) { $this->messenger() ->add( 'paragraph.action.importLayout.failed', 'paragraph', Message::LEVEL_ERROR ); } if ( null !== $success ) { return $this->redirect() ->toUrl( $form->get( 'returnUri' ) ->getValue() ); } $view = new ViewModel( array( 'form' => $form, ) ); return $view->setTerminal( true ); }
php
public function importAction() { $success = null; $request = $this->getRequest(); $data = $request->getPost(); $form = $this->getServiceLocator() ->get( 'Form' ) ->create( 'Grid\Paragraph\ChangeLayout\Import', array( 'returnUri' => $request->getQuery( 'returnUri' ), ) ); $form->setAttribute( 'action', $this->url() ->fromRoute( 'Grid\Paragraph\ChangeLayout\Import', array( 'locale' => (string) $this->locale(), 'paragraphId' => $this->paragraphId, 'returnUri' => $request->getQuery( 'returnUri' ), ) ) ); if ( $request->isPost() ) { $form->setData( $data ); if ( $form->isValid() ) { $data = $form->getData(); $beforeId = $this->getLayoutId(); $clonedId = $this->getParagraphModel() ->cloneFrom( $data['importId'], '_central' ); $success = $this->saveLayout( $clonedId ); $this->getServiceLocator() ->get( 'Grid\Menu\Model\Menu\Model' ) ->interleaveParagraphs( $clonedId, $beforeId ); } else { $success = false; } } if ( true === $success ) { $this->messenger() ->add( 'paragraph.action.importLayout.success', 'paragraph', Message::LEVEL_INFO ); } if ( false === $success ) { $this->messenger() ->add( 'paragraph.action.importLayout.failed', 'paragraph', Message::LEVEL_ERROR ); } if ( null !== $success ) { return $this->redirect() ->toUrl( $form->get( 'returnUri' ) ->getValue() ); } $view = new ViewModel( array( 'form' => $form, ) ); return $view->setTerminal( true ); }
[ "public", "function", "importAction", "(", ")", "{", "$", "success", "=", "null", ";", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "data", "=", "$", "request", "->", "getPost", "(", ")", ";", "$", "form", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Form'", ")", "->", "create", "(", "'Grid\\Paragraph\\ChangeLayout\\Import'", ",", "array", "(", "'returnUri'", "=>", "$", "request", "->", "getQuery", "(", "'returnUri'", ")", ",", ")", ")", ";", "$", "form", "->", "setAttribute", "(", "'action'", ",", "$", "this", "->", "url", "(", ")", "->", "fromRoute", "(", "'Grid\\Paragraph\\ChangeLayout\\Import'", ",", "array", "(", "'locale'", "=>", "(", "string", ")", "$", "this", "->", "locale", "(", ")", ",", "'paragraphId'", "=>", "$", "this", "->", "paragraphId", ",", "'returnUri'", "=>", "$", "request", "->", "getQuery", "(", "'returnUri'", ")", ",", ")", ")", ")", ";", "if", "(", "$", "request", "->", "isPost", "(", ")", ")", "{", "$", "form", "->", "setData", "(", "$", "data", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "data", "=", "$", "form", "->", "getData", "(", ")", ";", "$", "beforeId", "=", "$", "this", "->", "getLayoutId", "(", ")", ";", "$", "clonedId", "=", "$", "this", "->", "getParagraphModel", "(", ")", "->", "cloneFrom", "(", "$", "data", "[", "'importId'", "]", ",", "'_central'", ")", ";", "$", "success", "=", "$", "this", "->", "saveLayout", "(", "$", "clonedId", ")", ";", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Grid\\Menu\\Model\\Menu\\Model'", ")", "->", "interleaveParagraphs", "(", "$", "clonedId", ",", "$", "beforeId", ")", ";", "}", "else", "{", "$", "success", "=", "false", ";", "}", "}", "if", "(", "true", "===", "$", "success", ")", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.action.importLayout.success'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_INFO", ")", ";", "}", "if", "(", "false", "===", "$", "success", ")", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.action.importLayout.failed'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_ERROR", ")", ";", "}", "if", "(", "null", "!==", "$", "success", ")", "{", "return", "$", "this", "->", "redirect", "(", ")", "->", "toUrl", "(", "$", "form", "->", "get", "(", "'returnUri'", ")", "->", "getValue", "(", ")", ")", ";", "}", "$", "view", "=", "new", "ViewModel", "(", "array", "(", "'form'", "=>", "$", "form", ",", ")", ")", ";", "return", "$", "view", "->", "setTerminal", "(", "true", ")", ";", "}" ]
Import layout & change to it
[ "Import", "layout", "&", "change", "to", "it" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Controller/ChangeLayoutController.php#L280-L348
1,403
sebardo/ecommerce
EcommerceBundle/Controller/ContractController.php
ContractController.actorlistJsonAction
public function actorlistJsonAction($id) { $em = $this->getDoctrine()->getManager(); $actor = $em->getRepository('CoreBundle:Actor')->find($id); if (!$actor) { throw $this->createNotFoundException('Unable to find Actor entity.'); } /** @var \AdminBundle\Services\DataTables\JsonList $jsonList */ $jsonList = $this->get('json_list'); $jsonList->setRepository($em->getRepository('EcommerceBundle:Contract')); $jsonList->setActor($actor); $response = $jsonList->get(); return new JsonResponse($response); }
php
public function actorlistJsonAction($id) { $em = $this->getDoctrine()->getManager(); $actor = $em->getRepository('CoreBundle:Actor')->find($id); if (!$actor) { throw $this->createNotFoundException('Unable to find Actor entity.'); } /** @var \AdminBundle\Services\DataTables\JsonList $jsonList */ $jsonList = $this->get('json_list'); $jsonList->setRepository($em->getRepository('EcommerceBundle:Contract')); $jsonList->setActor($actor); $response = $jsonList->get(); return new JsonResponse($response); }
[ "public", "function", "actorlistJsonAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "actor", "=", "$", "em", "->", "getRepository", "(", "'CoreBundle:Actor'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "actor", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Actor entity.'", ")", ";", "}", "/** @var \\AdminBundle\\Services\\DataTables\\JsonList $jsonList */", "$", "jsonList", "=", "$", "this", "->", "get", "(", "'json_list'", ")", ";", "$", "jsonList", "->", "setRepository", "(", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Contract'", ")", ")", ";", "$", "jsonList", "->", "setActor", "(", "$", "actor", ")", ";", "$", "response", "=", "$", "jsonList", "->", "get", "(", ")", ";", "return", "new", "JsonResponse", "(", "$", "response", ")", ";", "}" ]
Returns a list of Brand entities in JSON format. @return JsonResponse @Route("/{id}/list.{_format}", requirements={ "_format" = "json" }, defaults={ "_format" = "json" }) @Method("GET")
[ "Returns", "a", "list", "of", "Brand", "entities", "in", "JSON", "format", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ContractController.php#L71-L88
1,404
sebardo/ecommerce
EcommerceBundle/Controller/ContractController.php
ContractController.createAction
public function createAction(Request $request) { $entity = new Contract(); $form = $this->createCreateForm($entity); $planForm = $this->createForm(new PlanType(), new Plan(), array( 'action' => $this->generateUrl('ecommerce_plan_new'), 'method' => 'POST', )); $form->handleRequest($request); if ($form->isValid()) { //check payment method $data = $form->getNormData(); print_r($data);die(); $em = $this->getDoctrine()->getManager(); $agreement = $entity->getAgreement(); $agreement->setContract($entity); $agreement->setStatus('Created'); try { $em->persist($entity); $em->persist($entity->getAgreement()); $em->flush(); } catch (\Exception $exc) { $this->get('session')->getFlashBag()->add('danger', 'contract.duplicated'); } //paypal workflow $checkoutManager = $this->get('checkout_manager'); //create agreement paypal $creditCard = $form->getNormData()->getAgreement()->getCreditCard(); $cc = array( "number" => $creditCard['cardNo'], "type" => $creditCard['cardType'], "expire_month" => $creditCard['expirationDate']->format('m'), "expire_year" => $creditCard['expirationDate']->format('Y'), "cvv2" => $creditCard['CVV'], "first_name" => $creditCard['firstname'], "last_name" => $creditCard['lastname'] ); $payPalAgreement = $checkoutManager->createPaypalAgreement($entity->getAgreement(), $cc); if($entity->getAgreement()->getPaymentMethod() == 'paypal'){ $this->get('session')->getFlashBag()->add('success', 'contract.created.approval'); $transactions = $entity->getAgreement()->getTransactions(); return $this->redirect($this->generateUrl('ecommerce_transaction_show', array('id' => $transactions->last()->getId()))); }else { $this->get('session')->getFlashBag()->add('success', 'contract.created'); } return $this->redirect($this->generateUrl('ecommerce_contract_show', array('id' => $entity->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), 'planForm' => $planForm->createView(), ); }
php
public function createAction(Request $request) { $entity = new Contract(); $form = $this->createCreateForm($entity); $planForm = $this->createForm(new PlanType(), new Plan(), array( 'action' => $this->generateUrl('ecommerce_plan_new'), 'method' => 'POST', )); $form->handleRequest($request); if ($form->isValid()) { //check payment method $data = $form->getNormData(); print_r($data);die(); $em = $this->getDoctrine()->getManager(); $agreement = $entity->getAgreement(); $agreement->setContract($entity); $agreement->setStatus('Created'); try { $em->persist($entity); $em->persist($entity->getAgreement()); $em->flush(); } catch (\Exception $exc) { $this->get('session')->getFlashBag()->add('danger', 'contract.duplicated'); } //paypal workflow $checkoutManager = $this->get('checkout_manager'); //create agreement paypal $creditCard = $form->getNormData()->getAgreement()->getCreditCard(); $cc = array( "number" => $creditCard['cardNo'], "type" => $creditCard['cardType'], "expire_month" => $creditCard['expirationDate']->format('m'), "expire_year" => $creditCard['expirationDate']->format('Y'), "cvv2" => $creditCard['CVV'], "first_name" => $creditCard['firstname'], "last_name" => $creditCard['lastname'] ); $payPalAgreement = $checkoutManager->createPaypalAgreement($entity->getAgreement(), $cc); if($entity->getAgreement()->getPaymentMethod() == 'paypal'){ $this->get('session')->getFlashBag()->add('success', 'contract.created.approval'); $transactions = $entity->getAgreement()->getTransactions(); return $this->redirect($this->generateUrl('ecommerce_transaction_show', array('id' => $transactions->last()->getId()))); }else { $this->get('session')->getFlashBag()->add('success', 'contract.created'); } return $this->redirect($this->generateUrl('ecommerce_contract_show', array('id' => $entity->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), 'planForm' => $planForm->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "entity", "=", "new", "Contract", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "entity", ")", ";", "$", "planForm", "=", "$", "this", "->", "createForm", "(", "new", "PlanType", "(", ")", ",", "new", "Plan", "(", ")", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'ecommerce_plan_new'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "//check payment method", "$", "data", "=", "$", "form", "->", "getNormData", "(", ")", ";", "print_r", "(", "$", "data", ")", ";", "die", "(", ")", ";", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "agreement", "=", "$", "entity", "->", "getAgreement", "(", ")", ";", "$", "agreement", "->", "setContract", "(", "$", "entity", ")", ";", "$", "agreement", "->", "setStatus", "(", "'Created'", ")", ";", "try", "{", "$", "em", "->", "persist", "(", "$", "entity", ")", ";", "$", "em", "->", "persist", "(", "$", "entity", "->", "getAgreement", "(", ")", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exc", ")", "{", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'danger'", ",", "'contract.duplicated'", ")", ";", "}", "//paypal workflow", "$", "checkoutManager", "=", "$", "this", "->", "get", "(", "'checkout_manager'", ")", ";", "//create agreement paypal", "$", "creditCard", "=", "$", "form", "->", "getNormData", "(", ")", "->", "getAgreement", "(", ")", "->", "getCreditCard", "(", ")", ";", "$", "cc", "=", "array", "(", "\"number\"", "=>", "$", "creditCard", "[", "'cardNo'", "]", ",", "\"type\"", "=>", "$", "creditCard", "[", "'cardType'", "]", ",", "\"expire_month\"", "=>", "$", "creditCard", "[", "'expirationDate'", "]", "->", "format", "(", "'m'", ")", ",", "\"expire_year\"", "=>", "$", "creditCard", "[", "'expirationDate'", "]", "->", "format", "(", "'Y'", ")", ",", "\"cvv2\"", "=>", "$", "creditCard", "[", "'CVV'", "]", ",", "\"first_name\"", "=>", "$", "creditCard", "[", "'firstname'", "]", ",", "\"last_name\"", "=>", "$", "creditCard", "[", "'lastname'", "]", ")", ";", "$", "payPalAgreement", "=", "$", "checkoutManager", "->", "createPaypalAgreement", "(", "$", "entity", "->", "getAgreement", "(", ")", ",", "$", "cc", ")", ";", "if", "(", "$", "entity", "->", "getAgreement", "(", ")", "->", "getPaymentMethod", "(", ")", "==", "'paypal'", ")", "{", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'contract.created.approval'", ")", ";", "$", "transactions", "=", "$", "entity", "->", "getAgreement", "(", ")", "->", "getTransactions", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_transaction_show'", ",", "array", "(", "'id'", "=>", "$", "transactions", "->", "last", "(", ")", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'contract.created'", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_contract_show'", ",", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'planForm'", "=>", "$", "planForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new Contract entity. @Route("/") @Method("POST") @Template("EcommerceBundle:Contract:new.html.twig")
[ "Creates", "a", "new", "Contract", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ContractController.php#L97-L167
1,405
sebardo/ecommerce
EcommerceBundle/Controller/ContractController.php
ContractController.createCreateForm
private function createCreateForm(Contract $entity) { $form = $this->createForm(new ContractType(), $entity, array( 'action' => $this->generateUrl('ecommerce_contract_create'), 'method' => 'POST', )); // $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(Contract $entity) { $form = $this->createForm(new ContractType(), $entity, array( 'action' => $this->generateUrl('ecommerce_contract_create'), 'method' => 'POST', )); // $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "Contract", "$", "entity", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "ContractType", "(", ")", ",", "$", "entity", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'ecommerce_contract_create'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "// $form->add('submit', 'submit', array('label' => 'Create'));", "return", "$", "form", ";", "}" ]
Creates a form to create a Contract entity. @param Contract $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "Contract", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ContractController.php#L176-L186
1,406
sebardo/ecommerce
EcommerceBundle/Controller/ContractController.php
ContractController.newAction
public function newAction() { $entity = new Contract(); $form = $this->createCreateForm($entity); $planForm = $this->createForm(new PlanType(), new Plan(), array( 'action' => $this->generateUrl('ecommerce_plan_new'), 'method' => 'POST', )); return array( 'entity' => $entity, 'form' => $form->createView(), 'planForm' => $planForm->createView(), ); }
php
public function newAction() { $entity = new Contract(); $form = $this->createCreateForm($entity); $planForm = $this->createForm(new PlanType(), new Plan(), array( 'action' => $this->generateUrl('ecommerce_plan_new'), 'method' => 'POST', )); return array( 'entity' => $entity, 'form' => $form->createView(), 'planForm' => $planForm->createView(), ); }
[ "public", "function", "newAction", "(", ")", "{", "$", "entity", "=", "new", "Contract", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "entity", ")", ";", "$", "planForm", "=", "$", "this", "->", "createForm", "(", "new", "PlanType", "(", ")", ",", "new", "Plan", "(", ")", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'ecommerce_plan_new'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'planForm'", "=>", "$", "planForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to create a new Contract entity. @Route("/new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "Contract", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ContractController.php#L195-L210
1,407
sebardo/ecommerce
EcommerceBundle/Controller/ContractController.php
ContractController.showAction
public function showAction($id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('EcommerceBundle:Contract')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Contract entity.'); } $deleteForm = $this->createDeleteForm($id); //get agreement $agreement = $entity->getAgreement(); $paypalAgreement = $this->get('checkout_manager')->getPaypalAgreement($agreement->getPaypalId()); $transactions = $this->get('checkout_manager')->searchPaypalAgreementTransactions($agreement); return array( 'entity' => $entity, 'delete_form' => $deleteForm->createView(), 'transactions' => $transactions, 'paypalAgreement' => $paypalAgreement ); }
php
public function showAction($id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('EcommerceBundle:Contract')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Contract entity.'); } $deleteForm = $this->createDeleteForm($id); //get agreement $agreement = $entity->getAgreement(); $paypalAgreement = $this->get('checkout_manager')->getPaypalAgreement($agreement->getPaypalId()); $transactions = $this->get('checkout_manager')->searchPaypalAgreementTransactions($agreement); return array( 'entity' => $entity, 'delete_form' => $deleteForm->createView(), 'transactions' => $transactions, 'paypalAgreement' => $paypalAgreement ); }
[ "public", "function", "showAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Contract'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Contract entity.'", ")", ";", "}", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "id", ")", ";", "//get agreement", "$", "agreement", "=", "$", "entity", "->", "getAgreement", "(", ")", ";", "$", "paypalAgreement", "=", "$", "this", "->", "get", "(", "'checkout_manager'", ")", "->", "getPaypalAgreement", "(", "$", "agreement", "->", "getPaypalId", "(", ")", ")", ";", "$", "transactions", "=", "$", "this", "->", "get", "(", "'checkout_manager'", ")", "->", "searchPaypalAgreementTransactions", "(", "$", "agreement", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", "'transactions'", "=>", "$", "transactions", ",", "'paypalAgreement'", "=>", "$", "paypalAgreement", ")", ";", "}" ]
Finds and displays a Contract entity. @Route("/{id}") @Method("GET") @Template()
[ "Finds", "and", "displays", "a", "Contract", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ContractController.php#L219-L243
1,408
sebardo/ecommerce
EcommerceBundle/Controller/ContractController.php
ContractController.createEditForm
private function createEditForm(Contract $entity) { $form = $this->createForm(new ContractType(), $entity, array( 'action' => $this->generateUrl('ecommerce_contract_update', array('id' => $entity->getId())), 'method' => 'PUT', )); // $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
php
private function createEditForm(Contract $entity) { $form = $this->createForm(new ContractType(), $entity, array( 'action' => $this->generateUrl('ecommerce_contract_update', array('id' => $entity->getId())), 'method' => 'PUT', )); // $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
[ "private", "function", "createEditForm", "(", "Contract", "$", "entity", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "ContractType", "(", ")", ",", "$", "entity", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'ecommerce_contract_update'", ",", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "// $form->add('submit', 'submit', array('label' => 'Update'));", "return", "$", "form", ";", "}" ]
Creates a form to edit a Contract entity. @param Contract $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "edit", "a", "Contract", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ContractController.php#L279-L289
1,409
crysalead/env
src/Env.php
Env.offsetGet
public function offsetGet($offset) { if (!array_key_exists($offset, $this->_data)) { return false; } return $this->_data[$offset]; }
php
public function offsetGet($offset) { if (!array_key_exists($offset, $this->_data)) { return false; } return $this->_data[$offset]; }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "offset", ",", "$", "this", "->", "_data", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "_data", "[", "$", "offset", "]", ";", "}" ]
Returns the value at specified offset or `false` if not exists. @param string $offset The offset to retrieve. @return mixed The value at offset.
[ "Returns", "the", "value", "at", "specified", "offset", "or", "false", "if", "not", "exists", "." ]
f81b0e10dfdc56d75e8a032297976a86ceb29110
https://github.com/crysalead/env/blob/f81b0e10dfdc56d75e8a032297976a86ceb29110/src/Env.php#L28-L34
1,410
crysalead/env
src/Env.php
Env.set
public function set($collection, $value = null) { if (func_num_args() === 1) { return parent::merge($collection, true); } $this->_data[$collection] = $value; return $this; }
php
public function set($collection, $value = null) { if (func_num_args() === 1) { return parent::merge($collection, true); } $this->_data[$collection] = $value; return $this; }
[ "public", "function", "set", "(", "$", "collection", ",", "$", "value", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "===", "1", ")", "{", "return", "parent", "::", "merge", "(", "$", "collection", ",", "true", ")", ";", "}", "$", "this", "->", "_data", "[", "$", "collection", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets an array of variables. @param string $collection The key. @param mixed $value The value. @param self
[ "Sets", "an", "array", "of", "variables", "." ]
f81b0e10dfdc56d75e8a032297976a86ceb29110
https://github.com/crysalead/env/blob/f81b0e10dfdc56d75e8a032297976a86ceb29110/src/Env.php#L43-L50
1,411
crysalead/env
src/Env.php
Env.normalize
public static function normalize($env) { $env += ['PHP_SAPI' => PHP_SAPI]; if (isset($env['SCRIPT_URI'])) { $env['HTTPS'] = strpos($env['SCRIPT_URI'], 'https://') === 0; } elseif (isset($env['HTTPS'])) { $env['HTTPS'] = (!empty($env['HTTPS']) && $env['HTTPS'] !== 'off'); } if (isset($env['HTTP_X_HTTP_METHOD_OVERRIDE'])) { $env['REQUEST_METHOD'] = $env['HTTP_X_HTTP_METHOD_OVERRIDE']; } if (isset($env['REDIRECT_HTTP_AUTHORIZATION'])) { $env['HTTP_AUTHORIZATION'] = $env['REDIRECT_HTTP_AUTHORIZATION']; } foreach (['HTTP_X_FORWARDED_FOR', 'HTTP_PC_REMOTE_ADDR', 'HTTP_X_REAL_IP'] as $key) { if (isset($env[$key])) { $addrs = explode(', ', $env[$key]); $env['REMOTE_ADDR'] = reset($addrs); break; } } if (empty($env['SERVER_ADDR']) && !empty($env['LOCAL_ADDR'])) { $env['SERVER_ADDR'] = $env['LOCAL_ADDR']; } if ($env['PHP_SAPI'] === 'isapi' && isset($env['PATH_TRANSLATED']) && isset($env['SCRIPT_NAME'])) { $env['SCRIPT_FILENAME'] = str_replace('\\\\', '\\', $env['PATH_TRANSLATED']); $env['DOCUMENT_ROOT'] = substr($env['SCRIPT_FILENAME'], 0, -strlen($env['SCRIPT_NAME'])); } return $env; }
php
public static function normalize($env) { $env += ['PHP_SAPI' => PHP_SAPI]; if (isset($env['SCRIPT_URI'])) { $env['HTTPS'] = strpos($env['SCRIPT_URI'], 'https://') === 0; } elseif (isset($env['HTTPS'])) { $env['HTTPS'] = (!empty($env['HTTPS']) && $env['HTTPS'] !== 'off'); } if (isset($env['HTTP_X_HTTP_METHOD_OVERRIDE'])) { $env['REQUEST_METHOD'] = $env['HTTP_X_HTTP_METHOD_OVERRIDE']; } if (isset($env['REDIRECT_HTTP_AUTHORIZATION'])) { $env['HTTP_AUTHORIZATION'] = $env['REDIRECT_HTTP_AUTHORIZATION']; } foreach (['HTTP_X_FORWARDED_FOR', 'HTTP_PC_REMOTE_ADDR', 'HTTP_X_REAL_IP'] as $key) { if (isset($env[$key])) { $addrs = explode(', ', $env[$key]); $env['REMOTE_ADDR'] = reset($addrs); break; } } if (empty($env['SERVER_ADDR']) && !empty($env['LOCAL_ADDR'])) { $env['SERVER_ADDR'] = $env['LOCAL_ADDR']; } if ($env['PHP_SAPI'] === 'isapi' && isset($env['PATH_TRANSLATED']) && isset($env['SCRIPT_NAME'])) { $env['SCRIPT_FILENAME'] = str_replace('\\\\', '\\', $env['PATH_TRANSLATED']); $env['DOCUMENT_ROOT'] = substr($env['SCRIPT_FILENAME'], 0, -strlen($env['SCRIPT_NAME'])); } return $env; }
[ "public", "static", "function", "normalize", "(", "$", "env", ")", "{", "$", "env", "+=", "[", "'PHP_SAPI'", "=>", "PHP_SAPI", "]", ";", "if", "(", "isset", "(", "$", "env", "[", "'SCRIPT_URI'", "]", ")", ")", "{", "$", "env", "[", "'HTTPS'", "]", "=", "strpos", "(", "$", "env", "[", "'SCRIPT_URI'", "]", ",", "'https://'", ")", "===", "0", ";", "}", "elseif", "(", "isset", "(", "$", "env", "[", "'HTTPS'", "]", ")", ")", "{", "$", "env", "[", "'HTTPS'", "]", "=", "(", "!", "empty", "(", "$", "env", "[", "'HTTPS'", "]", ")", "&&", "$", "env", "[", "'HTTPS'", "]", "!==", "'off'", ")", ";", "}", "if", "(", "isset", "(", "$", "env", "[", "'HTTP_X_HTTP_METHOD_OVERRIDE'", "]", ")", ")", "{", "$", "env", "[", "'REQUEST_METHOD'", "]", "=", "$", "env", "[", "'HTTP_X_HTTP_METHOD_OVERRIDE'", "]", ";", "}", "if", "(", "isset", "(", "$", "env", "[", "'REDIRECT_HTTP_AUTHORIZATION'", "]", ")", ")", "{", "$", "env", "[", "'HTTP_AUTHORIZATION'", "]", "=", "$", "env", "[", "'REDIRECT_HTTP_AUTHORIZATION'", "]", ";", "}", "foreach", "(", "[", "'HTTP_X_FORWARDED_FOR'", ",", "'HTTP_PC_REMOTE_ADDR'", ",", "'HTTP_X_REAL_IP'", "]", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "env", "[", "$", "key", "]", ")", ")", "{", "$", "addrs", "=", "explode", "(", "', '", ",", "$", "env", "[", "$", "key", "]", ")", ";", "$", "env", "[", "'REMOTE_ADDR'", "]", "=", "reset", "(", "$", "addrs", ")", ";", "break", ";", "}", "}", "if", "(", "empty", "(", "$", "env", "[", "'SERVER_ADDR'", "]", ")", "&&", "!", "empty", "(", "$", "env", "[", "'LOCAL_ADDR'", "]", ")", ")", "{", "$", "env", "[", "'SERVER_ADDR'", "]", "=", "$", "env", "[", "'LOCAL_ADDR'", "]", ";", "}", "if", "(", "$", "env", "[", "'PHP_SAPI'", "]", "===", "'isapi'", "&&", "isset", "(", "$", "env", "[", "'PATH_TRANSLATED'", "]", ")", "&&", "isset", "(", "$", "env", "[", "'SCRIPT_NAME'", "]", ")", ")", "{", "$", "env", "[", "'SCRIPT_FILENAME'", "]", "=", "str_replace", "(", "'\\\\\\\\'", ",", "'\\\\'", ",", "$", "env", "[", "'PATH_TRANSLATED'", "]", ")", ";", "$", "env", "[", "'DOCUMENT_ROOT'", "]", "=", "substr", "(", "$", "env", "[", "'SCRIPT_FILENAME'", "]", ",", "0", ",", "-", "strlen", "(", "$", "env", "[", "'SCRIPT_NAME'", "]", ")", ")", ";", "}", "return", "$", "env", ";", "}" ]
Normalizes a couple of well known PHP environment variables. @param array $env Some `$_SERVER` environment variables array. @return The normalized variables.
[ "Normalizes", "a", "couple", "of", "well", "known", "PHP", "environment", "variables", "." ]
f81b0e10dfdc56d75e8a032297976a86ceb29110
https://github.com/crysalead/env/blob/f81b0e10dfdc56d75e8a032297976a86ceb29110/src/Env.php#L68-L104
1,412
rseyferth/activerecord
lib/Serialization.php
Serialization.to_a
final public function to_a() { foreach ($this->attributes as &$value) { if ($value instanceof \DateTime) $value = $value->format(self::$DATETIME_FORMAT); } return $this->attributes; }
php
final public function to_a() { foreach ($this->attributes as &$value) { if ($value instanceof \DateTime) $value = $value->format(self::$DATETIME_FORMAT); } return $this->attributes; }
[ "final", "public", "function", "to_a", "(", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "&", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "$", "value", "=", "$", "value", "->", "format", "(", "self", "::", "$", "DATETIME_FORMAT", ")", ";", "}", "return", "$", "this", "->", "attributes", ";", "}" ]
Returns the attributes array. @return array
[ "Returns", "the", "attributes", "array", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Serialization.php#L215-L223
1,413
samsonos/cms_app_gallery
src/Application.php
Application.tabBuilder
public function tabBuilder(\samsoncms\app\material\form\Form & $form) { // If we have related structures if (count($form->navigationIDs)) { // Get all gallery additional field for material form structures $galleryFields = $this->query->entity(\samsoncms\api\Field::class) ->where('Type', 9) ->join('structurefield') ->where('structurefield_StructureID', $form->navigationIDs) ->exec(); // Create tab for each additional gallery field foreach ($galleryFields as $field) { $form->tabs[] = new Gallery($this, $this->query, $form->entity, $field); } } }
php
public function tabBuilder(\samsoncms\app\material\form\Form & $form) { // If we have related structures if (count($form->navigationIDs)) { // Get all gallery additional field for material form structures $galleryFields = $this->query->entity(\samsoncms\api\Field::class) ->where('Type', 9) ->join('structurefield') ->where('structurefield_StructureID', $form->navigationIDs) ->exec(); // Create tab for each additional gallery field foreach ($galleryFields as $field) { $form->tabs[] = new Gallery($this, $this->query, $form->entity, $field); } } }
[ "public", "function", "tabBuilder", "(", "\\", "samsoncms", "\\", "app", "\\", "material", "\\", "form", "\\", "Form", "&", "$", "form", ")", "{", "// If we have related structures", "if", "(", "count", "(", "$", "form", "->", "navigationIDs", ")", ")", "{", "// Get all gallery additional field for material form structures", "$", "galleryFields", "=", "$", "this", "->", "query", "->", "entity", "(", "\\", "samsoncms", "\\", "api", "\\", "Field", "::", "class", ")", "->", "where", "(", "'Type'", ",", "9", ")", "->", "join", "(", "'structurefield'", ")", "->", "where", "(", "'structurefield_StructureID'", ",", "$", "form", "->", "navigationIDs", ")", "->", "exec", "(", ")", ";", "// Create tab for each additional gallery field", "foreach", "(", "$", "galleryFields", "as", "$", "field", ")", "{", "$", "form", "->", "tabs", "[", "]", "=", "new", "Gallery", "(", "$", "this", ",", "$", "this", "->", "query", ",", "$", "form", "->", "entity", ",", "$", "field", ")", ";", "}", "}", "}" ]
Render all gallery additional fields as material form tabs @param \samsoncms\app\material\form\Form $form Material form insctance
[ "Render", "all", "gallery", "additional", "fields", "as", "material", "form", "tabs" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L57-L73
1,414
samsonos/cms_app_gallery
src/Application.php
Application.__async_getCount
public function __async_getCount($materialFieldId) { // @var array $result Result of asynchronous controller $response = array('status' => 1); // Getting quantity from DB by param materialFieldId $response['count'] = $this->query ->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY) ->where(MaterialField::F_PRIMARY, $materialFieldId) ->count(); return $response; }
php
public function __async_getCount($materialFieldId) { // @var array $result Result of asynchronous controller $response = array('status' => 1); // Getting quantity from DB by param materialFieldId $response['count'] = $this->query ->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY) ->where(MaterialField::F_PRIMARY, $materialFieldId) ->count(); return $response; }
[ "public", "function", "__async_getCount", "(", "$", "materialFieldId", ")", "{", "// @var array $result Result of asynchronous controller", "$", "response", "=", "array", "(", "'status'", "=>", "1", ")", ";", "// Getting quantity from DB by param materialFieldId", "$", "response", "[", "'count'", "]", "=", "$", "this", "->", "query", "->", "entity", "(", "CMS", "::", "MATERIAL_IMAGES_RELATION_ENTITY", ")", "->", "where", "(", "MaterialField", "::", "F_PRIMARY", ",", "$", "materialFieldId", ")", "->", "count", "(", ")", ";", "return", "$", "response", ";", "}" ]
Controller for getting quantity image in gallery. @param integer $materialFieldId identefier Table MaterialField @return array Async response array with additional param count.
[ "Controller", "for", "getting", "quantity", "image", "in", "gallery", "." ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L142-L153
1,415
samsonos/cms_app_gallery
src/Application.php
Application.__async_updateAlt
public function __async_updateAlt($imageId) { // @var array $result Result of asynchronous controller $result = array('status' => false); // @var \samson\activerecord\gallery $image Image to insert into editor $image = null; //get data from ajax $data = json_decode(file_get_contents('php://input'), true); //set input value $value = trim($data['value']); // Getting first field image if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY) ->where('PhotoID', $imageId)->first($image)) { // Update value alt $image->Description = $value; // Save result in datebase $image->save(); // Set success status $result['status'] = true; // Reduce number of characters to 25 $result['description'] = utf8_limit_string($value, 25, '...'); // Return result value $result['value'] = $value; } return $result; }
php
public function __async_updateAlt($imageId) { // @var array $result Result of asynchronous controller $result = array('status' => false); // @var \samson\activerecord\gallery $image Image to insert into editor $image = null; //get data from ajax $data = json_decode(file_get_contents('php://input'), true); //set input value $value = trim($data['value']); // Getting first field image if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY) ->where('PhotoID', $imageId)->first($image)) { // Update value alt $image->Description = $value; // Save result in datebase $image->save(); // Set success status $result['status'] = true; // Reduce number of characters to 25 $result['description'] = utf8_limit_string($value, 25, '...'); // Return result value $result['value'] = $value; } return $result; }
[ "public", "function", "__async_updateAlt", "(", "$", "imageId", ")", "{", "// @var array $result Result of asynchronous controller", "$", "result", "=", "array", "(", "'status'", "=>", "false", ")", ";", "// @var \\samson\\activerecord\\gallery $image Image to insert into editor", "$", "image", "=", "null", ";", "//get data from ajax", "$", "data", "=", "json_decode", "(", "file_get_contents", "(", "'php://input'", ")", ",", "true", ")", ";", "//set input value", "$", "value", "=", "trim", "(", "$", "data", "[", "'value'", "]", ")", ";", "// Getting first field image", "if", "(", "$", "this", "->", "query", "->", "entity", "(", "CMS", "::", "MATERIAL_IMAGES_RELATION_ENTITY", ")", "->", "where", "(", "'PhotoID'", ",", "$", "imageId", ")", "->", "first", "(", "$", "image", ")", ")", "{", "// Update value alt", "$", "image", "->", "Description", "=", "$", "value", ";", "// Save result in datebase", "$", "image", "->", "save", "(", ")", ";", "// Set success status", "$", "result", "[", "'status'", "]", "=", "true", ";", "// Reduce number of characters to 25", "$", "result", "[", "'description'", "]", "=", "utf8_limit_string", "(", "$", "value", ",", "25", ",", "'...'", ")", ";", "// Return result value", "$", "result", "[", "'value'", "]", "=", "$", "value", ";", "}", "return", "$", "result", ";", "}" ]
Controller for update material image properties alt from gallery. @param int $imageId Gallery image identifier @return array async response
[ "Controller", "for", "update", "material", "image", "properties", "alt", "from", "gallery", "." ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L161-L189
1,416
samsonos/cms_app_gallery
src/Application.php
Application.verifyExtensionFile
private function verifyExtensionFile() { $supported_image = array( 'gif', 'jpg', 'jpeg', 'png' ); $fileName = $_SERVER['HTTP_X_FILE_NAME']; $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); if (in_array($ext, $supported_image)) { return true; } return false; }
php
private function verifyExtensionFile() { $supported_image = array( 'gif', 'jpg', 'jpeg', 'png' ); $fileName = $_SERVER['HTTP_X_FILE_NAME']; $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); if (in_array($ext, $supported_image)) { return true; } return false; }
[ "private", "function", "verifyExtensionFile", "(", ")", "{", "$", "supported_image", "=", "array", "(", "'gif'", ",", "'jpg'", ",", "'jpeg'", ",", "'png'", ")", ";", "$", "fileName", "=", "$", "_SERVER", "[", "'HTTP_X_FILE_NAME'", "]", ";", "$", "ext", "=", "strtolower", "(", "pathinfo", "(", "$", "fileName", ",", "PATHINFO_EXTENSION", ")", ")", ";", "if", "(", "in_array", "(", "$", "ext", ",", "$", "supported_image", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
method for verify extension file @return boolean true - file is image, false - file not image
[ "method", "for", "verify", "extension", "file" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L251-L267
1,417
samsonos/cms_app_gallery
src/Application.php
Application.__async_priority
public function __async_priority() { $result = array('status' => true); // If we have changed priority of images if (isset($_POST['ids'])) { // For each received image id for ($i = 0; $i < count($_POST['ids']); $i++) { /** @var \samson\activerecord\gallery $photo Variable to store image info */ $photo = null; // If we have such image in database if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('PhotoID', $_POST['ids'][$i])->first($photo)) { // Reset it's priority and save it $photo->priority = $i; $photo->save(); } else { $result['status'] = false; $result['message'] = 'Can not find images with specified ids!'; } } } else { $result['status'] = false; $result['message'] = 'There are no images to sort!'; } return $result; }
php
public function __async_priority() { $result = array('status' => true); // If we have changed priority of images if (isset($_POST['ids'])) { // For each received image id for ($i = 0; $i < count($_POST['ids']); $i++) { /** @var \samson\activerecord\gallery $photo Variable to store image info */ $photo = null; // If we have such image in database if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('PhotoID', $_POST['ids'][$i])->first($photo)) { // Reset it's priority and save it $photo->priority = $i; $photo->save(); } else { $result['status'] = false; $result['message'] = 'Can not find images with specified ids!'; } } } else { $result['status'] = false; $result['message'] = 'There are no images to sort!'; } return $result; }
[ "public", "function", "__async_priority", "(", ")", "{", "$", "result", "=", "array", "(", "'status'", "=>", "true", ")", ";", "// If we have changed priority of images", "if", "(", "isset", "(", "$", "_POST", "[", "'ids'", "]", ")", ")", "{", "// For each received image id", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "_POST", "[", "'ids'", "]", ")", ";", "$", "i", "++", ")", "{", "/** @var \\samson\\activerecord\\gallery $photo Variable to store image info */", "$", "photo", "=", "null", ";", "// If we have such image in database", "if", "(", "$", "this", "->", "query", "->", "entity", "(", "CMS", "::", "MATERIAL_IMAGES_RELATION_ENTITY", ")", "->", "where", "(", "'PhotoID'", ",", "$", "_POST", "[", "'ids'", "]", "[", "$", "i", "]", ")", "->", "first", "(", "$", "photo", ")", ")", "{", "// Reset it's priority and save it", "$", "photo", "->", "priority", "=", "$", "i", ";", "$", "photo", "->", "save", "(", ")", ";", "}", "else", "{", "$", "result", "[", "'status'", "]", "=", "false", ";", "$", "result", "[", "'message'", "]", "=", "'Can not find images with specified ids!'", ";", "}", "}", "}", "else", "{", "$", "result", "[", "'status'", "]", "=", "false", ";", "$", "result", "[", "'message'", "]", "=", "'There are no images to sort!'", ";", "}", "return", "$", "result", ";", "}" ]
Function to save image priority @return array Async response array
[ "Function", "to", "save", "image", "priority" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L273-L298
1,418
samsonos/cms_app_gallery
src/Application.php
Application.__async_show_edit
public function __async_show_edit($imageId) { /** @var array $result Result of asynchronous controller */ $result = array('status' => false); /** @var \samson\activerecord\gallery $image Image to insert into editor */ $image = null; if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('PhotoID', $imageId)->first($image)) { /** @var string $path Path to image */ $path = $this->formImagePath($image->Path, $image->Src); // If there is image for this path if ($this->imageExists($path)) { $result['status'] = true; $result['html'] = $this->view('editor/index') ->set($image, 'image') ->set($path, 'path') ->output(); } } return $result; }
php
public function __async_show_edit($imageId) { /** @var array $result Result of asynchronous controller */ $result = array('status' => false); /** @var \samson\activerecord\gallery $image Image to insert into editor */ $image = null; if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('PhotoID', $imageId)->first($image)) { /** @var string $path Path to image */ $path = $this->formImagePath($image->Path, $image->Src); // If there is image for this path if ($this->imageExists($path)) { $result['status'] = true; $result['html'] = $this->view('editor/index') ->set($image, 'image') ->set($path, 'path') ->output(); } } return $result; }
[ "public", "function", "__async_show_edit", "(", "$", "imageId", ")", "{", "/** @var array $result Result of asynchronous controller */", "$", "result", "=", "array", "(", "'status'", "=>", "false", ")", ";", "/** @var \\samson\\activerecord\\gallery $image Image to insert into editor */", "$", "image", "=", "null", ";", "if", "(", "$", "this", "->", "query", "->", "entity", "(", "CMS", "::", "MATERIAL_IMAGES_RELATION_ENTITY", ")", "->", "where", "(", "'PhotoID'", ",", "$", "imageId", ")", "->", "first", "(", "$", "image", ")", ")", "{", "/** @var string $path Path to image */", "$", "path", "=", "$", "this", "->", "formImagePath", "(", "$", "image", "->", "Path", ",", "$", "image", "->", "Src", ")", ";", "// If there is image for this path", "if", "(", "$", "this", "->", "imageExists", "(", "$", "path", ")", ")", "{", "$", "result", "[", "'status'", "]", "=", "true", ";", "$", "result", "[", "'html'", "]", "=", "$", "this", "->", "view", "(", "'editor/index'", ")", "->", "set", "(", "$", "image", ",", "'image'", ")", "->", "set", "(", "$", "path", ",", "'path'", ")", "->", "output", "(", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Asynchronous function to get image editor @param int $imageId Image identifier to insert into editor @return array Result array
[ "Asynchronous", "function", "to", "get", "image", "editor" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L305-L326
1,419
samsonos/cms_app_gallery
src/Application.php
Application.__async_edit
public function __async_edit($imageId) { /** @var array $result Result of asynchronous controller */ $result = array('status' => false); /** @var \samson\activerecord\gallery $image Image to insert into editor */ $image = null; /** @var resource $imageResource Copy of edit image */ $imageResource = null; /** @var resource $croppedImage Resource of cropped image */ $croppedImage = null; // If there is such image in database if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('PhotoID', $imageId)->first($image)) { // Form proper path $path = $this->formImagePath($image->Path, $image->Src); // Check image extension switch (pathinfo($path, PATHINFO_EXTENSION)) { case 'jpeg': case 'jpg': $imageResource = imagecreatefromjpeg($path); $croppedImage = $this->cropImage($imageResource); $result['status'] = imagejpeg($croppedImage, $path); break; case 'png': $imageResource = imagecreatefrompng($path); $croppedImage = $this->cropTransparentImage($imageResource); $result['status'] = imagepng($croppedImage, $path); break; case 'gif': $imageResource = imagecreatefromgif($path); $croppedImage = $this->cropTransparentImage($imageResource); $result['status'] = imagegif($croppedImage, $path); break; } // delete temporary images imagedestroy($croppedImage); imagedestroy($imageResource); } return $result; }
php
public function __async_edit($imageId) { /** @var array $result Result of asynchronous controller */ $result = array('status' => false); /** @var \samson\activerecord\gallery $image Image to insert into editor */ $image = null; /** @var resource $imageResource Copy of edit image */ $imageResource = null; /** @var resource $croppedImage Resource of cropped image */ $croppedImage = null; // If there is such image in database if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('PhotoID', $imageId)->first($image)) { // Form proper path $path = $this->formImagePath($image->Path, $image->Src); // Check image extension switch (pathinfo($path, PATHINFO_EXTENSION)) { case 'jpeg': case 'jpg': $imageResource = imagecreatefromjpeg($path); $croppedImage = $this->cropImage($imageResource); $result['status'] = imagejpeg($croppedImage, $path); break; case 'png': $imageResource = imagecreatefrompng($path); $croppedImage = $this->cropTransparentImage($imageResource); $result['status'] = imagepng($croppedImage, $path); break; case 'gif': $imageResource = imagecreatefromgif($path); $croppedImage = $this->cropTransparentImage($imageResource); $result['status'] = imagegif($croppedImage, $path); break; } // delete temporary images imagedestroy($croppedImage); imagedestroy($imageResource); } return $result; }
[ "public", "function", "__async_edit", "(", "$", "imageId", ")", "{", "/** @var array $result Result of asynchronous controller */", "$", "result", "=", "array", "(", "'status'", "=>", "false", ")", ";", "/** @var \\samson\\activerecord\\gallery $image Image to insert into editor */", "$", "image", "=", "null", ";", "/** @var resource $imageResource Copy of edit image */", "$", "imageResource", "=", "null", ";", "/** @var resource $croppedImage Resource of cropped image */", "$", "croppedImage", "=", "null", ";", "// If there is such image in database", "if", "(", "$", "this", "->", "query", "->", "entity", "(", "CMS", "::", "MATERIAL_IMAGES_RELATION_ENTITY", ")", "->", "where", "(", "'PhotoID'", ",", "$", "imageId", ")", "->", "first", "(", "$", "image", ")", ")", "{", "// Form proper path", "$", "path", "=", "$", "this", "->", "formImagePath", "(", "$", "image", "->", "Path", ",", "$", "image", "->", "Src", ")", ";", "// Check image extension", "switch", "(", "pathinfo", "(", "$", "path", ",", "PATHINFO_EXTENSION", ")", ")", "{", "case", "'jpeg'", ":", "case", "'jpg'", ":", "$", "imageResource", "=", "imagecreatefromjpeg", "(", "$", "path", ")", ";", "$", "croppedImage", "=", "$", "this", "->", "cropImage", "(", "$", "imageResource", ")", ";", "$", "result", "[", "'status'", "]", "=", "imagejpeg", "(", "$", "croppedImage", ",", "$", "path", ")", ";", "break", ";", "case", "'png'", ":", "$", "imageResource", "=", "imagecreatefrompng", "(", "$", "path", ")", ";", "$", "croppedImage", "=", "$", "this", "->", "cropTransparentImage", "(", "$", "imageResource", ")", ";", "$", "result", "[", "'status'", "]", "=", "imagepng", "(", "$", "croppedImage", ",", "$", "path", ")", ";", "break", ";", "case", "'gif'", ":", "$", "imageResource", "=", "imagecreatefromgif", "(", "$", "path", ")", ";", "$", "croppedImage", "=", "$", "this", "->", "cropTransparentImage", "(", "$", "imageResource", ")", ";", "$", "result", "[", "'status'", "]", "=", "imagegif", "(", "$", "croppedImage", ",", "$", "path", ")", ";", "break", ";", "}", "// delete temporary images", "imagedestroy", "(", "$", "croppedImage", ")", ";", "imagedestroy", "(", "$", "imageResource", ")", ";", "}", "return", "$", "result", ";", "}" ]
Applies all changes with the image and save it @param int $imageId Edit image identifier @return array
[ "Applies", "all", "changes", "with", "the", "image", "and", "save", "it" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L333-L375
1,420
samsonos/cms_app_gallery
src/Application.php
Application.getHTML
public function getHTML($materialFieldId) { // Get all material images $items_html = ''; /** @var array $images List of gallery images */ $images = null; // there are gallery images if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('materialFieldId', $materialFieldId)->orderBy('priority')->exec($images)) { /** @var \samson\cms\CMSGallery $image */ foreach ($images as $image) { // Get image size string $size = ', '; // Get image path $path = $this->formImagePath($image->Path, $image->Src); // if file doesn't exist if (!$this->imageExists($path)) { $path = ResourceMap::find('www/img/no-img.png', $this); } // set image size string representation, if it is not 0 $size = ($image->size == 0) ? '' : $size . $this->humanFileSize($image->size); // Render gallery image tumb $items_html .= $this->view('tumbs/item') ->set($image, 'image') ->set(utf8_limit_string($image->Description, 25, '...'), 'description') ->set(utf8_limit_string($image->Name, 18, '...'), 'name') ->set($path, 'imgpath') ->set($size, 'size') ->set($materialFieldId, 'material_id') ->output(); } } // Render content into inner content html return $this->view('tumbs/index') ->set($items_html, 'images') ->set($materialFieldId, 'material_id') ->output(); }
php
public function getHTML($materialFieldId) { // Get all material images $items_html = ''; /** @var array $images List of gallery images */ $images = null; // there are gallery images if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('materialFieldId', $materialFieldId)->orderBy('priority')->exec($images)) { /** @var \samson\cms\CMSGallery $image */ foreach ($images as $image) { // Get image size string $size = ', '; // Get image path $path = $this->formImagePath($image->Path, $image->Src); // if file doesn't exist if (!$this->imageExists($path)) { $path = ResourceMap::find('www/img/no-img.png', $this); } // set image size string representation, if it is not 0 $size = ($image->size == 0) ? '' : $size . $this->humanFileSize($image->size); // Render gallery image tumb $items_html .= $this->view('tumbs/item') ->set($image, 'image') ->set(utf8_limit_string($image->Description, 25, '...'), 'description') ->set(utf8_limit_string($image->Name, 18, '...'), 'name') ->set($path, 'imgpath') ->set($size, 'size') ->set($materialFieldId, 'material_id') ->output(); } } // Render content into inner content html return $this->view('tumbs/index') ->set($items_html, 'images') ->set($materialFieldId, 'material_id') ->output(); }
[ "public", "function", "getHTML", "(", "$", "materialFieldId", ")", "{", "// Get all material images", "$", "items_html", "=", "''", ";", "/** @var array $images List of gallery images */", "$", "images", "=", "null", ";", "// there are gallery images", "if", "(", "$", "this", "->", "query", "->", "entity", "(", "CMS", "::", "MATERIAL_IMAGES_RELATION_ENTITY", ")", "->", "where", "(", "'materialFieldId'", ",", "$", "materialFieldId", ")", "->", "orderBy", "(", "'priority'", ")", "->", "exec", "(", "$", "images", ")", ")", "{", "/** @var \\samson\\cms\\CMSGallery $image */", "foreach", "(", "$", "images", "as", "$", "image", ")", "{", "// Get image size string", "$", "size", "=", "', '", ";", "// Get image path", "$", "path", "=", "$", "this", "->", "formImagePath", "(", "$", "image", "->", "Path", ",", "$", "image", "->", "Src", ")", ";", "// if file doesn't exist", "if", "(", "!", "$", "this", "->", "imageExists", "(", "$", "path", ")", ")", "{", "$", "path", "=", "ResourceMap", "::", "find", "(", "'www/img/no-img.png'", ",", "$", "this", ")", ";", "}", "// set image size string representation, if it is not 0", "$", "size", "=", "(", "$", "image", "->", "size", "==", "0", ")", "?", "''", ":", "$", "size", ".", "$", "this", "->", "humanFileSize", "(", "$", "image", "->", "size", ")", ";", "// Render gallery image tumb", "$", "items_html", ".=", "$", "this", "->", "view", "(", "'tumbs/item'", ")", "->", "set", "(", "$", "image", ",", "'image'", ")", "->", "set", "(", "utf8_limit_string", "(", "$", "image", "->", "Description", ",", "25", ",", "'...'", ")", ",", "'description'", ")", "->", "set", "(", "utf8_limit_string", "(", "$", "image", "->", "Name", ",", "18", ",", "'...'", ")", ",", "'name'", ")", "->", "set", "(", "$", "path", ",", "'imgpath'", ")", "->", "set", "(", "$", "size", ",", "'size'", ")", "->", "set", "(", "$", "materialFieldId", ",", "'material_id'", ")", "->", "output", "(", ")", ";", "}", "}", "// Render content into inner content html", "return", "$", "this", "->", "view", "(", "'tumbs/index'", ")", "->", "set", "(", "$", "items_html", ",", "'images'", ")", "->", "set", "(", "$", "materialFieldId", ",", "'material_id'", ")", "->", "output", "(", ")", ";", "}" ]
Render gallery images list @param string $materialFieldId Material identifier @return string html representation of image list
[ "Render", "gallery", "images", "list" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L382-L422
1,421
samsonos/cms_app_gallery
src/Application.php
Application.humanFileSize
public function humanFileSize($bytes, $decimals = 2) { /** @var string $sizeLetters Size shortcuts */ $sizeLetters = 'BKBMBGBTBPB'; $factor = (int)(floor((strlen($bytes) - 1) / 3)); $sizeLetter = ($factor <= 0) ? substr($sizeLetters, 0, 1) : substr($sizeLetters, $factor * 2 - 1, 2); return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . $sizeLetter; }
php
public function humanFileSize($bytes, $decimals = 2) { /** @var string $sizeLetters Size shortcuts */ $sizeLetters = 'BKBMBGBTBPB'; $factor = (int)(floor((strlen($bytes) - 1) / 3)); $sizeLetter = ($factor <= 0) ? substr($sizeLetters, 0, 1) : substr($sizeLetters, $factor * 2 - 1, 2); return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . $sizeLetter; }
[ "public", "function", "humanFileSize", "(", "$", "bytes", ",", "$", "decimals", "=", "2", ")", "{", "/** @var string $sizeLetters Size shortcuts */", "$", "sizeLetters", "=", "'BKBMBGBTBPB'", ";", "$", "factor", "=", "(", "int", ")", "(", "floor", "(", "(", "strlen", "(", "$", "bytes", ")", "-", "1", ")", "/", "3", ")", ")", ";", "$", "sizeLetter", "=", "(", "$", "factor", "<=", "0", ")", "?", "substr", "(", "$", "sizeLetters", ",", "0", ",", "1", ")", ":", "substr", "(", "$", "sizeLetters", ",", "$", "factor", "*", "2", "-", "1", ",", "2", ")", ";", "return", "sprintf", "(", "\"%.{$decimals}f\"", ",", "$", "bytes", "/", "pow", "(", "1024", ",", "$", "factor", ")", ")", ".", "$", "sizeLetter", ";", "}" ]
Function to form image size @param int $bytes Bytes count @param int $decimals Decimal part of number(count of numbers) @return string Generated image size
[ "Function", "to", "form", "image", "size" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L430-L437
1,422
samsonos/cms_app_gallery
src/Application.php
Application.imageExists
private function imageExists($imagePath, $imageSrc = null) { // If image name is sewhere parameter if (isset($imageSrc)) { // Form path to the image $imageFullPath = $this->formImagePath($imagePath, $imageSrc); } else { // Path was already set $imageFullPath = $imagePath; } // Call file service existence method return $this->fs->exists($imageFullPath); }
php
private function imageExists($imagePath, $imageSrc = null) { // If image name is sewhere parameter if (isset($imageSrc)) { // Form path to the image $imageFullPath = $this->formImagePath($imagePath, $imageSrc); } else { // Path was already set $imageFullPath = $imagePath; } // Call file service existence method return $this->fs->exists($imageFullPath); }
[ "private", "function", "imageExists", "(", "$", "imagePath", ",", "$", "imageSrc", "=", "null", ")", "{", "// If image name is sewhere parameter", "if", "(", "isset", "(", "$", "imageSrc", ")", ")", "{", "// Form path to the image", "$", "imageFullPath", "=", "$", "this", "->", "formImagePath", "(", "$", "imagePath", ",", "$", "imageSrc", ")", ";", "}", "else", "{", "// Path was already set", "$", "imageFullPath", "=", "$", "imagePath", ";", "}", "// Call file service existence method", "return", "$", "this", "->", "fs", "->", "exists", "(", "$", "imageFullPath", ")", ";", "}" ]
Checks if image exists, supports old database structure @param string $imagePath Path to image(Full or not) @param string $imageSrc Image name, if it wasn't in $imagePath @return bool
[ "Checks", "if", "image", "exists", "supports", "old", "database", "structure" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L445-L458
1,423
samsonos/cms_app_gallery
src/Application.php
Application.formImagePath
private function formImagePath($imagePath, $imageSrc) { // Get old-way image path, remove full path to check file if (empty($imagePath)) { $path = $imageSrc; } else { // Use new CORRECT way $path = $imagePath . $imageSrc; } // form relative path to the image $dir = quotemeta(__SAMSON_BASE__); // TODO: WTF? Why do we need this, need comments!!! if (strpos($path, 'http://') === false) { if ($dir == '/') { return substr($path, 1); } else { return preg_replace('/' . addcslashes($dir, '/') . '/', '', $path); } } return $path; }
php
private function formImagePath($imagePath, $imageSrc) { // Get old-way image path, remove full path to check file if (empty($imagePath)) { $path = $imageSrc; } else { // Use new CORRECT way $path = $imagePath . $imageSrc; } // form relative path to the image $dir = quotemeta(__SAMSON_BASE__); // TODO: WTF? Why do we need this, need comments!!! if (strpos($path, 'http://') === false) { if ($dir == '/') { return substr($path, 1); } else { return preg_replace('/' . addcslashes($dir, '/') . '/', '', $path); } } return $path; }
[ "private", "function", "formImagePath", "(", "$", "imagePath", ",", "$", "imageSrc", ")", "{", "// Get old-way image path, remove full path to check file", "if", "(", "empty", "(", "$", "imagePath", ")", ")", "{", "$", "path", "=", "$", "imageSrc", ";", "}", "else", "{", "// Use new CORRECT way", "$", "path", "=", "$", "imagePath", ".", "$", "imageSrc", ";", "}", "// form relative path to the image", "$", "dir", "=", "quotemeta", "(", "__SAMSON_BASE__", ")", ";", "// TODO: WTF? Why do we need this, need comments!!!", "if", "(", "strpos", "(", "$", "path", ",", "'http://'", ")", "===", "false", ")", "{", "if", "(", "$", "dir", "==", "'/'", ")", "{", "return", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "else", "{", "return", "preg_replace", "(", "'/'", ".", "addcslashes", "(", "$", "dir", ",", "'/'", ")", ".", "'/'", ",", "''", ",", "$", "path", ")", ";", "}", "}", "return", "$", "path", ";", "}" ]
Function to form image path correctly, also supports old database structure @param string $imagePath Path to the image @param string $imageSrc Image name @return string Full path to image
[ "Function", "to", "form", "image", "path", "correctly", "also", "supports", "old", "database", "structure" ]
3a2bb3a6c025640a84f9fee9156364533a127a4e
https://github.com/samsonos/cms_app_gallery/blob/3a2bb3a6c025640a84f9fee9156364533a127a4e/src/Application.php#L466-L487
1,424
php-rest-server/core
src/Core/General/Param.php
Param.get
public function get($name, $default = null) { if (isset($this->dataContainer[$name])) { return $this->dataContainer[$name]; } return $default; }
php
public function get($name, $default = null) { if (isset($this->dataContainer[$name])) { return $this->dataContainer[$name]; } return $default; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dataContainer", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "dataContainer", "[", "$", "name", "]", ";", "}", "return", "$", "default", ";", "}" ]
Get value by key. If value does not exists then return default value @param string $name @param mixed $default @return mixed|null
[ "Get", "value", "by", "key", ".", "If", "value", "does", "not", "exists", "then", "return", "default", "value" ]
4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888
https://github.com/php-rest-server/core/blob/4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888/src/Core/General/Param.php#L47-L54
1,425
ellipsephp/http
src/Handlers/SimpleHtmlExceptionRequestHandler.php
SimpleHtmlExceptionRequestHandler.handle
public function handle(ServerRequestInterface $request): ResponseInterface { $path = realpath(__DIR__ . '/../../templates'); $engine = new Engine($path); $contents = $engine->render('simple'); $response = $this->factory ->createResponse(500) ->withHeader('Content-type', 'text/html'); $response->getBody()->write($contents); return $response; }
php
public function handle(ServerRequestInterface $request): ResponseInterface { $path = realpath(__DIR__ . '/../../templates'); $engine = new Engine($path); $contents = $engine->render('simple'); $response = $this->factory ->createResponse(500) ->withHeader('Content-type', 'text/html'); $response->getBody()->write($contents); return $response; }
[ "public", "function", "handle", "(", "ServerRequestInterface", "$", "request", ")", ":", "ResponseInterface", "{", "$", "path", "=", "realpath", "(", "__DIR__", ".", "'/../../templates'", ")", ";", "$", "engine", "=", "new", "Engine", "(", "$", "path", ")", ";", "$", "contents", "=", "$", "engine", "->", "render", "(", "'simple'", ")", ";", "$", "response", "=", "$", "this", "->", "factory", "->", "createResponse", "(", "500", ")", "->", "withHeader", "(", "'Content-type'", ",", "'text/html'", ")", ";", "$", "response", "->", "getBody", "(", ")", "->", "write", "(", "$", "contents", ")", ";", "return", "$", "response", ";", "}" ]
Return a simple html response for the exception. @param \Psr\Http\Message\ServerRequestInterface $request @return \Psr\Http\Message\ResponseInterface
[ "Return", "a", "simple", "html", "response", "for", "the", "exception", "." ]
20a2b0ae1d3a149a905b93ae0993203eb7d414e1
https://github.com/ellipsephp/http/blob/20a2b0ae1d3a149a905b93ae0993203eb7d414e1/src/Handlers/SimpleHtmlExceptionRequestHandler.php#L39-L54
1,426
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/migrate.php
Migrate.version
public static function version($version = null, $name = 'default', $type = 'app', $all = false) { // get the current version from the config $all or $current = \Config::get('migrations.version.'.$type.'.'.$name); // any migrations defined? if ( ! empty($current)) { // get the timestamp of the last installed migration if (preg_match('/^(.*?)_(.*)$/', end($current), $match)) { // determine the direction $direction = (is_null($version) or $match[1] < $version) ? 'up' : 'down'; // fetch the migrations if ($direction == 'up') { $migrations = static::find_migrations($name, $type, $match[1], $version); } else { $migrations = static::find_migrations($name, $type, $version, $match[1], $direction); // we're going down, so reverse the order of mygrations $migrations = array_reverse($migrations, true); } // run migrations from current version to given version return static::run($migrations, $name, $type, $direction); } else { throw new \UnexpectedValueException('Could not determine a valid version from '.$current.'.'); } } // run migrations from the beginning to given version return static::run(static::find_migrations($name, $type, null, $version), $name, $type, 'up'); }
php
public static function version($version = null, $name = 'default', $type = 'app', $all = false) { // get the current version from the config $all or $current = \Config::get('migrations.version.'.$type.'.'.$name); // any migrations defined? if ( ! empty($current)) { // get the timestamp of the last installed migration if (preg_match('/^(.*?)_(.*)$/', end($current), $match)) { // determine the direction $direction = (is_null($version) or $match[1] < $version) ? 'up' : 'down'; // fetch the migrations if ($direction == 'up') { $migrations = static::find_migrations($name, $type, $match[1], $version); } else { $migrations = static::find_migrations($name, $type, $version, $match[1], $direction); // we're going down, so reverse the order of mygrations $migrations = array_reverse($migrations, true); } // run migrations from current version to given version return static::run($migrations, $name, $type, $direction); } else { throw new \UnexpectedValueException('Could not determine a valid version from '.$current.'.'); } } // run migrations from the beginning to given version return static::run(static::find_migrations($name, $type, null, $version), $name, $type, 'up'); }
[ "public", "static", "function", "version", "(", "$", "version", "=", "null", ",", "$", "name", "=", "'default'", ",", "$", "type", "=", "'app'", ",", "$", "all", "=", "false", ")", "{", "// get the current version from the config", "$", "all", "or", "$", "current", "=", "\\", "Config", "::", "get", "(", "'migrations.version.'", ".", "$", "type", ".", "'.'", ".", "$", "name", ")", ";", "// any migrations defined?", "if", "(", "!", "empty", "(", "$", "current", ")", ")", "{", "// get the timestamp of the last installed migration", "if", "(", "preg_match", "(", "'/^(.*?)_(.*)$/'", ",", "end", "(", "$", "current", ")", ",", "$", "match", ")", ")", "{", "// determine the direction", "$", "direction", "=", "(", "is_null", "(", "$", "version", ")", "or", "$", "match", "[", "1", "]", "<", "$", "version", ")", "?", "'up'", ":", "'down'", ";", "// fetch the migrations", "if", "(", "$", "direction", "==", "'up'", ")", "{", "$", "migrations", "=", "static", "::", "find_migrations", "(", "$", "name", ",", "$", "type", ",", "$", "match", "[", "1", "]", ",", "$", "version", ")", ";", "}", "else", "{", "$", "migrations", "=", "static", "::", "find_migrations", "(", "$", "name", ",", "$", "type", ",", "$", "version", ",", "$", "match", "[", "1", "]", ",", "$", "direction", ")", ";", "// we're going down, so reverse the order of mygrations", "$", "migrations", "=", "array_reverse", "(", "$", "migrations", ",", "true", ")", ";", "}", "// run migrations from current version to given version", "return", "static", "::", "run", "(", "$", "migrations", ",", "$", "name", ",", "$", "type", ",", "$", "direction", ")", ";", "}", "else", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Could not determine a valid version from '", ".", "$", "current", ".", "'.'", ")", ";", "}", "}", "// run migrations from the beginning to given version", "return", "static", "::", "run", "(", "static", "::", "find_migrations", "(", "$", "name", ",", "$", "type", ",", "null", ",", "$", "version", ")", ",", "$", "name", ",", "$", "type", ",", "'up'", ")", ";", "}" ]
migrate to a specific version, range of versions, or all @param mixed version to migrate to (up or down!) @param string name of the package, module or app @param string type of migration (package, module or app) @param bool if true, also run out-of-sequence migrations @throws UnexpectedValueException @return array
[ "migrate", "to", "a", "specific", "version", "range", "of", "versions", "or", "all" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/migrate.php#L104-L142
1,427
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/migrate.php
Migrate.current
public static function current($name = 'default', $type = 'app') { // get the current version from the config $current = \Config::get('migrations.version.'.$type.'.'.$name); // any migrations defined? if ( ! empty($current)) { // get the timestamp of the last installed migration if (preg_match('/^(.*?)_(.*)$/', end($current), $match)) { // run migrations from start to current version return static::run(static::find_migrations($name, $type, null, $match[1]), $name, $type, 'up'); } } // nothing to migrate return array(); }
php
public static function current($name = 'default', $type = 'app') { // get the current version from the config $current = \Config::get('migrations.version.'.$type.'.'.$name); // any migrations defined? if ( ! empty($current)) { // get the timestamp of the last installed migration if (preg_match('/^(.*?)_(.*)$/', end($current), $match)) { // run migrations from start to current version return static::run(static::find_migrations($name, $type, null, $match[1]), $name, $type, 'up'); } } // nothing to migrate return array(); }
[ "public", "static", "function", "current", "(", "$", "name", "=", "'default'", ",", "$", "type", "=", "'app'", ")", "{", "// get the current version from the config", "$", "current", "=", "\\", "Config", "::", "get", "(", "'migrations.version.'", ".", "$", "type", ".", "'.'", ".", "$", "name", ")", ";", "// any migrations defined?", "if", "(", "!", "empty", "(", "$", "current", ")", ")", "{", "// get the timestamp of the last installed migration", "if", "(", "preg_match", "(", "'/^(.*?)_(.*)$/'", ",", "end", "(", "$", "current", ")", ",", "$", "match", ")", ")", "{", "// run migrations from start to current version", "return", "static", "::", "run", "(", "static", "::", "find_migrations", "(", "$", "name", ",", "$", "type", ",", "null", ",", "$", "match", "[", "1", "]", ")", ",", "$", "name", ",", "$", "type", ",", "'up'", ")", ";", "}", "}", "// nothing to migrate", "return", "array", "(", ")", ";", "}" ]
migrate to the version defined in the config file @param string name of the package, module or app @param string type of migration (package, module or app) @return array
[ "migrate", "to", "the", "version", "defined", "in", "the", "config", "file" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/migrate.php#L167-L185
1,428
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/migrate.php
Migrate.up
public static function up($version = null, $name = 'default', $type = 'app') { // get the current version info from the config $current = \Config::get('migrations.version.'.$type.'.'.$name); // get the last migration installed $current = empty($current) ? null : end($current); // get the available migrations after the current one $migrations = static::find_migrations($name, $type, $current, $version); // found any? if ( ! empty($migrations)) { // if no version was given, only install the next migration is_null($version) and $migrations = array(reset($migrations)); // install migrations found return static::run($migrations, $name, $type, 'up'); } // nothing to migrate return array(); }
php
public static function up($version = null, $name = 'default', $type = 'app') { // get the current version info from the config $current = \Config::get('migrations.version.'.$type.'.'.$name); // get the last migration installed $current = empty($current) ? null : end($current); // get the available migrations after the current one $migrations = static::find_migrations($name, $type, $current, $version); // found any? if ( ! empty($migrations)) { // if no version was given, only install the next migration is_null($version) and $migrations = array(reset($migrations)); // install migrations found return static::run($migrations, $name, $type, 'up'); } // nothing to migrate return array(); }
[ "public", "static", "function", "up", "(", "$", "version", "=", "null", ",", "$", "name", "=", "'default'", ",", "$", "type", "=", "'app'", ")", "{", "// get the current version info from the config", "$", "current", "=", "\\", "Config", "::", "get", "(", "'migrations.version.'", ".", "$", "type", ".", "'.'", ".", "$", "name", ")", ";", "// get the last migration installed", "$", "current", "=", "empty", "(", "$", "current", ")", "?", "null", ":", "end", "(", "$", "current", ")", ";", "// get the available migrations after the current one", "$", "migrations", "=", "static", "::", "find_migrations", "(", "$", "name", ",", "$", "type", ",", "$", "current", ",", "$", "version", ")", ";", "// found any?", "if", "(", "!", "empty", "(", "$", "migrations", ")", ")", "{", "// if no version was given, only install the next migration", "is_null", "(", "$", "version", ")", "and", "$", "migrations", "=", "array", "(", "reset", "(", "$", "migrations", ")", ")", ";", "// install migrations found", "return", "static", "::", "run", "(", "$", "migrations", ",", "$", "name", ",", "$", "type", ",", "'up'", ")", ";", "}", "// nothing to migrate", "return", "array", "(", ")", ";", "}" ]
migrate up to the next version @param mixed version to migrate up to @param string name of the package, module or app @param string type of migration (package, module or app) @return array
[ "migrate", "up", "to", "the", "next", "version" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/migrate.php#L196-L219
1,429
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/migrate.php
Migrate.run
protected static function run($migrations, $name, $type, $method = 'up') { // storage for installed migrations $done = array(); static::$connection === null or \DBUtil::set_connection(static::$connection); // Loop through the runnable migrations and run them foreach ($migrations as $ver => $migration) { logger(Fuel::L_INFO, 'Migrating to version: '.$ver); $result = call_user_func(array(new $migration['class'], $method)); if ($result === false) { logger(Fuel::L_INFO, 'Skipped migration to '.$ver.'.'); return false; } $file = basename($migration['path'], '.php'); $method == 'up' ? static::write_install($name, $type, $file) : static::write_revert($name, $type, $file); $done[] = $file; } static::$connection === null or \DBUtil::set_connection(null); empty($done) or logger(Fuel::L_INFO, 'Migrated to '.$ver.' successfully.'); return $done; }
php
protected static function run($migrations, $name, $type, $method = 'up') { // storage for installed migrations $done = array(); static::$connection === null or \DBUtil::set_connection(static::$connection); // Loop through the runnable migrations and run them foreach ($migrations as $ver => $migration) { logger(Fuel::L_INFO, 'Migrating to version: '.$ver); $result = call_user_func(array(new $migration['class'], $method)); if ($result === false) { logger(Fuel::L_INFO, 'Skipped migration to '.$ver.'.'); return false; } $file = basename($migration['path'], '.php'); $method == 'up' ? static::write_install($name, $type, $file) : static::write_revert($name, $type, $file); $done[] = $file; } static::$connection === null or \DBUtil::set_connection(null); empty($done) or logger(Fuel::L_INFO, 'Migrated to '.$ver.' successfully.'); return $done; }
[ "protected", "static", "function", "run", "(", "$", "migrations", ",", "$", "name", ",", "$", "type", ",", "$", "method", "=", "'up'", ")", "{", "// storage for installed migrations", "$", "done", "=", "array", "(", ")", ";", "static", "::", "$", "connection", "===", "null", "or", "\\", "DBUtil", "::", "set_connection", "(", "static", "::", "$", "connection", ")", ";", "// Loop through the runnable migrations and run them", "foreach", "(", "$", "migrations", "as", "$", "ver", "=>", "$", "migration", ")", "{", "logger", "(", "Fuel", "::", "L_INFO", ",", "'Migrating to version: '", ".", "$", "ver", ")", ";", "$", "result", "=", "call_user_func", "(", "array", "(", "new", "$", "migration", "[", "'class'", "]", ",", "$", "method", ")", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "logger", "(", "Fuel", "::", "L_INFO", ",", "'Skipped migration to '", ".", "$", "ver", ".", "'.'", ")", ";", "return", "false", ";", "}", "$", "file", "=", "basename", "(", "$", "migration", "[", "'path'", "]", ",", "'.php'", ")", ";", "$", "method", "==", "'up'", "?", "static", "::", "write_install", "(", "$", "name", ",", "$", "type", ",", "$", "file", ")", ":", "static", "::", "write_revert", "(", "$", "name", ",", "$", "type", ",", "$", "file", ")", ";", "$", "done", "[", "]", "=", "$", "file", ";", "}", "static", "::", "$", "connection", "===", "null", "or", "\\", "DBUtil", "::", "set_connection", "(", "null", ")", ";", "empty", "(", "$", "done", ")", "or", "logger", "(", "Fuel", "::", "L_INFO", ",", "'Migrated to '", ".", "$", "ver", ".", "' successfully.'", ")", ";", "return", "$", "done", ";", "}" ]
run the action migrations found @param array list of files to migrate @param string name of the package, module or app @param string type of migration (package, module or app) @param string method to call on the migration @return array
[ "run", "the", "action", "migrations", "found" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/migrate.php#L277-L305
1,430
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/migrate.php
Migrate.write_install
protected static function write_install($name, $type, $file) { // add the migration just run \DB::insert(static::$table)->set(array( 'name' => $name, 'type' => $type, 'migration' => $file, ))->execute(static::$connection); // add the file to the list of run migrations static::$migrations[$type][$name][] = $file; // make sure the migrations are in the correct order sort(static::$migrations[$type][$name]); // and save the update to the environment config file \Config::set('migrations.version.'.$type.'.'.$name, static::$migrations[$type][$name]); \Config::save(\Fuel::$env.DS.'migrations', 'migrations'); }
php
protected static function write_install($name, $type, $file) { // add the migration just run \DB::insert(static::$table)->set(array( 'name' => $name, 'type' => $type, 'migration' => $file, ))->execute(static::$connection); // add the file to the list of run migrations static::$migrations[$type][$name][] = $file; // make sure the migrations are in the correct order sort(static::$migrations[$type][$name]); // and save the update to the environment config file \Config::set('migrations.version.'.$type.'.'.$name, static::$migrations[$type][$name]); \Config::save(\Fuel::$env.DS.'migrations', 'migrations'); }
[ "protected", "static", "function", "write_install", "(", "$", "name", ",", "$", "type", ",", "$", "file", ")", "{", "// add the migration just run", "\\", "DB", "::", "insert", "(", "static", "::", "$", "table", ")", "->", "set", "(", "array", "(", "'name'", "=>", "$", "name", ",", "'type'", "=>", "$", "type", ",", "'migration'", "=>", "$", "file", ",", ")", ")", "->", "execute", "(", "static", "::", "$", "connection", ")", ";", "// add the file to the list of run migrations", "static", "::", "$", "migrations", "[", "$", "type", "]", "[", "$", "name", "]", "[", "]", "=", "$", "file", ";", "// make sure the migrations are in the correct order", "sort", "(", "static", "::", "$", "migrations", "[", "$", "type", "]", "[", "$", "name", "]", ")", ";", "// and save the update to the environment config file", "\\", "Config", "::", "set", "(", "'migrations.version.'", ".", "$", "type", ".", "'.'", ".", "$", "name", ",", "static", "::", "$", "migrations", "[", "$", "type", "]", "[", "$", "name", "]", ")", ";", "\\", "Config", "::", "save", "(", "\\", "Fuel", "::", "$", "env", ".", "DS", ".", "'migrations'", ",", "'migrations'", ")", ";", "}" ]
add an installed migration to the database @param string name of the package, module or app @param string type of migration (package, module or app) @param string name of the migration file just run @return void
[ "add", "an", "installed", "migration", "to", "the", "database" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/migrate.php#L317-L335
1,431
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/migrate.php
Migrate.write_revert
protected static function write_revert($name, $type, $file) { // remove the migration just run \DB::delete(static::$table) ->where('name', $name) ->where('type', $type) ->where('migration', $file) ->execute(static::$connection); // remove the file from the list of run migrations if (($key = array_search($file, static::$migrations[$type][$name])) !== false) { unset(static::$migrations[$type][$name][$key]); } // make sure the migrations are in the correct order sort(static::$migrations[$type][$name]); // and save the update to the config file \Config::set('migrations.version.'.$type.'.'.$name, static::$migrations[$type][$name]); \Config::save(\Fuel::$env.DS.'migrations', 'migrations'); }
php
protected static function write_revert($name, $type, $file) { // remove the migration just run \DB::delete(static::$table) ->where('name', $name) ->where('type', $type) ->where('migration', $file) ->execute(static::$connection); // remove the file from the list of run migrations if (($key = array_search($file, static::$migrations[$type][$name])) !== false) { unset(static::$migrations[$type][$name][$key]); } // make sure the migrations are in the correct order sort(static::$migrations[$type][$name]); // and save the update to the config file \Config::set('migrations.version.'.$type.'.'.$name, static::$migrations[$type][$name]); \Config::save(\Fuel::$env.DS.'migrations', 'migrations'); }
[ "protected", "static", "function", "write_revert", "(", "$", "name", ",", "$", "type", ",", "$", "file", ")", "{", "// remove the migration just run", "\\", "DB", "::", "delete", "(", "static", "::", "$", "table", ")", "->", "where", "(", "'name'", ",", "$", "name", ")", "->", "where", "(", "'type'", ",", "$", "type", ")", "->", "where", "(", "'migration'", ",", "$", "file", ")", "->", "execute", "(", "static", "::", "$", "connection", ")", ";", "// remove the file from the list of run migrations", "if", "(", "(", "$", "key", "=", "array_search", "(", "$", "file", ",", "static", "::", "$", "migrations", "[", "$", "type", "]", "[", "$", "name", "]", ")", ")", "!==", "false", ")", "{", "unset", "(", "static", "::", "$", "migrations", "[", "$", "type", "]", "[", "$", "name", "]", "[", "$", "key", "]", ")", ";", "}", "// make sure the migrations are in the correct order", "sort", "(", "static", "::", "$", "migrations", "[", "$", "type", "]", "[", "$", "name", "]", ")", ";", "// and save the update to the config file", "\\", "Config", "::", "set", "(", "'migrations.version.'", ".", "$", "type", ".", "'.'", ".", "$", "name", ",", "static", "::", "$", "migrations", "[", "$", "type", "]", "[", "$", "name", "]", ")", ";", "\\", "Config", "::", "save", "(", "\\", "Fuel", "::", "$", "env", ".", "DS", ".", "'migrations'", ",", "'migrations'", ")", ";", "}" ]
remove a reverted migration from the database @param string name of the package, module or app @param string type of migration (package, module or app) @param string name of the migration file just run @return void
[ "remove", "a", "reverted", "migration", "from", "the", "database" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/migrate.php#L346-L367
1,432
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/migrate.php
Migrate._find_app
protected static function _find_app($name = null) { $found = array(); $files = new \GlobIterator(APPPATH.\Config::get('migrations.folder').'*_*.php'); foreach($files as $file) { $found[] = $file->getPathname(); } return $found; }
php
protected static function _find_app($name = null) { $found = array(); $files = new \GlobIterator(APPPATH.\Config::get('migrations.folder').'*_*.php'); foreach($files as $file) { $found[] = $file->getPathname(); } return $found; }
[ "protected", "static", "function", "_find_app", "(", "$", "name", "=", "null", ")", "{", "$", "found", "=", "array", "(", ")", ";", "$", "files", "=", "new", "\\", "GlobIterator", "(", "APPPATH", ".", "\\", "Config", "::", "get", "(", "'migrations.folder'", ")", ".", "'*_*.php'", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "found", "[", "]", "=", "$", "file", "->", "getPathname", "(", ")", ";", "}", "return", "$", "found", ";", "}" ]
finds migrations for the given app @param string name of the app (not used at the moment) @return array
[ "finds", "migrations", "for", "the", "given", "app" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/migrate.php#L483-L494
1,433
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/migrate.php
Migrate.table_version_check
protected static function table_version_check() { // set connection static::$connection === null or \DBUtil::set_connection(static::$connection); // if table does not exist if ( ! \DBUtil::table_exists(static::$table)) { // create table \DBUtil::create_table(static::$table, static::$table_definition); } // check if a table upgrade is needed elseif ( ! \DBUtil::field_exists(static::$table, array('migration'))) { // get the current migration status $current = \DB::select()->from(static::$table)->order_by('type', 'ASC')->order_by('name', 'ASC')->execute(static::$connection)->as_array(); // drop the existing table, and recreate it in the new layout \DBUtil::drop_table(static::$table); \DBUtil::create_table(static::$table, static::$table_definition); // check if we had a current migration status if ( ! empty($current)) { // do we need to migrate from a v1.0 migration environment? if (isset($current[0]['current'])) { // convert the current result into a v1.1. migration environment structure $current = array(0 => array('name' => 'default', 'type' => 'app', 'version' => $current[0]['current'])); } // build a new config structure $configs = array(); // convert the v1.1 structure to the v1.2 structure foreach ($current as $migration) { // find the migrations for this entry $migrations = static::find_migrations($migration['name'], $migration['type'], null, $migration['version']); // array to keep track of the migrations already run $config = array(); // add the individual migrations found foreach ($migrations as $file) { $file = pathinfo($file['path']); // add this migration to the table \DB::insert(static::$table)->set(array( 'name' => $migration['name'], 'type' => $migration['type'], 'migration' => $file['filename'], ))->execute(static::$connection); // and to the config $config[] = $file['filename']; } // create a config entry for this name and type if needed isset($configs[$migration['type']]) or $configs[$migration['type']] = array(); $configs[$migration['type']][$migration['name']] = $config; } // write the updated migrations config back \Config::set('migrations.version', $configs); \Config::save(\Fuel::$env.DS.'migrations', 'migrations'); } // delete any old migration config file that may exist is_file(APPPATH.'config'.DS.'migrations.php') and unlink(APPPATH.'config'.DS.'migrations.php'); } // set connection to default static::$connection === null or \DBUtil::set_connection(null); }
php
protected static function table_version_check() { // set connection static::$connection === null or \DBUtil::set_connection(static::$connection); // if table does not exist if ( ! \DBUtil::table_exists(static::$table)) { // create table \DBUtil::create_table(static::$table, static::$table_definition); } // check if a table upgrade is needed elseif ( ! \DBUtil::field_exists(static::$table, array('migration'))) { // get the current migration status $current = \DB::select()->from(static::$table)->order_by('type', 'ASC')->order_by('name', 'ASC')->execute(static::$connection)->as_array(); // drop the existing table, and recreate it in the new layout \DBUtil::drop_table(static::$table); \DBUtil::create_table(static::$table, static::$table_definition); // check if we had a current migration status if ( ! empty($current)) { // do we need to migrate from a v1.0 migration environment? if (isset($current[0]['current'])) { // convert the current result into a v1.1. migration environment structure $current = array(0 => array('name' => 'default', 'type' => 'app', 'version' => $current[0]['current'])); } // build a new config structure $configs = array(); // convert the v1.1 structure to the v1.2 structure foreach ($current as $migration) { // find the migrations for this entry $migrations = static::find_migrations($migration['name'], $migration['type'], null, $migration['version']); // array to keep track of the migrations already run $config = array(); // add the individual migrations found foreach ($migrations as $file) { $file = pathinfo($file['path']); // add this migration to the table \DB::insert(static::$table)->set(array( 'name' => $migration['name'], 'type' => $migration['type'], 'migration' => $file['filename'], ))->execute(static::$connection); // and to the config $config[] = $file['filename']; } // create a config entry for this name and type if needed isset($configs[$migration['type']]) or $configs[$migration['type']] = array(); $configs[$migration['type']][$migration['name']] = $config; } // write the updated migrations config back \Config::set('migrations.version', $configs); \Config::save(\Fuel::$env.DS.'migrations', 'migrations'); } // delete any old migration config file that may exist is_file(APPPATH.'config'.DS.'migrations.php') and unlink(APPPATH.'config'.DS.'migrations.php'); } // set connection to default static::$connection === null or \DBUtil::set_connection(null); }
[ "protected", "static", "function", "table_version_check", "(", ")", "{", "// set connection", "static", "::", "$", "connection", "===", "null", "or", "\\", "DBUtil", "::", "set_connection", "(", "static", "::", "$", "connection", ")", ";", "// if table does not exist", "if", "(", "!", "\\", "DBUtil", "::", "table_exists", "(", "static", "::", "$", "table", ")", ")", "{", "// create table", "\\", "DBUtil", "::", "create_table", "(", "static", "::", "$", "table", ",", "static", "::", "$", "table_definition", ")", ";", "}", "// check if a table upgrade is needed", "elseif", "(", "!", "\\", "DBUtil", "::", "field_exists", "(", "static", "::", "$", "table", ",", "array", "(", "'migration'", ")", ")", ")", "{", "// get the current migration status", "$", "current", "=", "\\", "DB", "::", "select", "(", ")", "->", "from", "(", "static", "::", "$", "table", ")", "->", "order_by", "(", "'type'", ",", "'ASC'", ")", "->", "order_by", "(", "'name'", ",", "'ASC'", ")", "->", "execute", "(", "static", "::", "$", "connection", ")", "->", "as_array", "(", ")", ";", "// drop the existing table, and recreate it in the new layout", "\\", "DBUtil", "::", "drop_table", "(", "static", "::", "$", "table", ")", ";", "\\", "DBUtil", "::", "create_table", "(", "static", "::", "$", "table", ",", "static", "::", "$", "table_definition", ")", ";", "// check if we had a current migration status", "if", "(", "!", "empty", "(", "$", "current", ")", ")", "{", "// do we need to migrate from a v1.0 migration environment?", "if", "(", "isset", "(", "$", "current", "[", "0", "]", "[", "'current'", "]", ")", ")", "{", "// convert the current result into a v1.1. migration environment structure", "$", "current", "=", "array", "(", "0", "=>", "array", "(", "'name'", "=>", "'default'", ",", "'type'", "=>", "'app'", ",", "'version'", "=>", "$", "current", "[", "0", "]", "[", "'current'", "]", ")", ")", ";", "}", "// build a new config structure", "$", "configs", "=", "array", "(", ")", ";", "// convert the v1.1 structure to the v1.2 structure", "foreach", "(", "$", "current", "as", "$", "migration", ")", "{", "// find the migrations for this entry", "$", "migrations", "=", "static", "::", "find_migrations", "(", "$", "migration", "[", "'name'", "]", ",", "$", "migration", "[", "'type'", "]", ",", "null", ",", "$", "migration", "[", "'version'", "]", ")", ";", "// array to keep track of the migrations already run", "$", "config", "=", "array", "(", ")", ";", "// add the individual migrations found", "foreach", "(", "$", "migrations", "as", "$", "file", ")", "{", "$", "file", "=", "pathinfo", "(", "$", "file", "[", "'path'", "]", ")", ";", "// add this migration to the table", "\\", "DB", "::", "insert", "(", "static", "::", "$", "table", ")", "->", "set", "(", "array", "(", "'name'", "=>", "$", "migration", "[", "'name'", "]", ",", "'type'", "=>", "$", "migration", "[", "'type'", "]", ",", "'migration'", "=>", "$", "file", "[", "'filename'", "]", ",", ")", ")", "->", "execute", "(", "static", "::", "$", "connection", ")", ";", "// and to the config", "$", "config", "[", "]", "=", "$", "file", "[", "'filename'", "]", ";", "}", "// create a config entry for this name and type if needed", "isset", "(", "$", "configs", "[", "$", "migration", "[", "'type'", "]", "]", ")", "or", "$", "configs", "[", "$", "migration", "[", "'type'", "]", "]", "=", "array", "(", ")", ";", "$", "configs", "[", "$", "migration", "[", "'type'", "]", "]", "[", "$", "migration", "[", "'name'", "]", "]", "=", "$", "config", ";", "}", "// write the updated migrations config back", "\\", "Config", "::", "set", "(", "'migrations.version'", ",", "$", "configs", ")", ";", "\\", "Config", "::", "save", "(", "\\", "Fuel", "::", "$", "env", ".", "DS", ".", "'migrations'", ",", "'migrations'", ")", ";", "}", "// delete any old migration config file that may exist", "is_file", "(", "APPPATH", ".", "'config'", ".", "DS", ".", "'migrations.php'", ")", "and", "unlink", "(", "APPPATH", ".", "'config'", ".", "DS", ".", "'migrations.php'", ")", ";", "}", "// set connection to default", "static", "::", "$", "connection", "===", "null", "or", "\\", "DBUtil", "::", "set_connection", "(", "null", ")", ";", "}" ]
installs or upgrades the migration table to the current schema @return void @deprecated Remove upgrade check in 1.4
[ "installs", "or", "upgrades", "the", "migration", "table", "to", "the", "current", "schema" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/migrate.php#L589-L665
1,434
SerafimArts/Gist
src/Gist/AbstractSerialize.php
AbstractSerialize.getName
protected function getName($name) { $renames = $this->getRenames(); if (isset($renames[$name])) { return $renames[$name]; } return $name; }
php
protected function getName($name) { $renames = $this->getRenames(); if (isset($renames[$name])) { return $renames[$name]; } return $name; }
[ "protected", "function", "getName", "(", "$", "name", ")", "{", "$", "renames", "=", "$", "this", "->", "getRenames", "(", ")", ";", "if", "(", "isset", "(", "$", "renames", "[", "$", "name", "]", ")", ")", "{", "return", "$", "renames", "[", "$", "name", "]", ";", "}", "return", "$", "name", ";", "}" ]
Return property name @param $name @return mixed
[ "Return", "property", "name" ]
5d0610c033b3840a42a42bcfc2de5277a7cab30d
https://github.com/SerafimArts/Gist/blob/5d0610c033b3840a42a42bcfc2de5277a7cab30d/src/Gist/AbstractSerialize.php#L93-L101
1,435
movicon/movicon-db
src/db/DbRecord.php
DbRecord.save
public function save() { if ($this->_isSaved) { $this->update($this->id); } else { $this->id = $this->insert(); $this->_isSaved = true; } }
php
public function save() { if ($this->_isSaved) { $this->update($this->id); } else { $this->id = $this->insert(); $this->_isSaved = true; } }
[ "public", "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "_isSaved", ")", "{", "$", "this", "->", "update", "(", "$", "this", "->", "id", ")", ";", "}", "else", "{", "$", "this", "->", "id", "=", "$", "this", "->", "insert", "(", ")", ";", "$", "this", "->", "_isSaved", "=", "true", ";", "}", "}" ]
Saves this record. @return void
[ "Saves", "this", "record", "." ]
505023932d6cd82462bb0e89b9057175c4b14e38
https://github.com/movicon/movicon-db/blob/505023932d6cd82462bb0e89b9057175c4b14e38/src/db/DbRecord.php#L53-L61
1,436
mszewcz/php-json-schema-validator
src/Validators/NumericValidators/ExclusiveMinimumValidator.php
ExclusiveMinimumValidator.validate
public function validate($subject): bool { if (\is_numeric($this->schema['exclusiveMinimum'])) { if ($subject <= $this->schema['exclusiveMinimum']) { return false; } } return true; }
php
public function validate($subject): bool { if (\is_numeric($this->schema['exclusiveMinimum'])) { if ($subject <= $this->schema['exclusiveMinimum']) { return false; } } return true; }
[ "public", "function", "validate", "(", "$", "subject", ")", ":", "bool", "{", "if", "(", "\\", "is_numeric", "(", "$", "this", "->", "schema", "[", "'exclusiveMinimum'", "]", ")", ")", "{", "if", "(", "$", "subject", "<=", "$", "this", "->", "schema", "[", "'exclusiveMinimum'", "]", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Validates subject against exclusiveMinimum @param $subject @return bool
[ "Validates", "subject", "against", "exclusiveMinimum" ]
f7768bfe07ce6508bb1ff36163560a5e5791de7d
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/NumericValidators/ExclusiveMinimumValidator.php#L47-L55
1,437
Gelembjuk/locale
src/Gelembjuk/Locale/Languages.php
Languages.getAllLanguages
public function getAllLanguages() { if (is_array($this->alllanguages)) { return $this->alllanguages; } // find languages file in a locales path $langfile = $this->localespath.'languages.txt'; if (!file_exists($langfile)) { // if no in locales then use default from this package $langfile = dirname(__FILE__).'/languages.txt'; } if (!file_exists($langfile)) { // if not found then show error or return empty array if ($this->errorondatamissed) { throw new \Exception('No languages file found'); } return array(); } // load a file $list = @file_get_contents($langfile); if (!$list) { // if somethign went wrong throw error or return empty array if ($this->errorondatamissed) { throw new \Exception('Can not load languages list'); } return array(); } $languages = array(); foreach (preg_split('!\\r?\\n!',$list) as $line) { list ($code,$name) = explode('=',$line); $code = trim($code); $name = trim($name); if ($code == '' || $name == '') { continue; } $origname = $name; $tags = array(); $splitsettings = explode(':',$name,3); if (count($splitsettings) > 1) { $name = $splitsettings[0]; $origname = $splitsettings[1]; if (isset($splitsettings[2]) && $splitsettings[2] != '') { $tags = explode(',',$splitsettings[2]); } } $flagfile = $this->localespath.'flags/small/'.$code.'.png'; $hasflag = file_exists($flagfile); $languages[$code] = array( 'code'=>$code, 'name'=>$name, 'origname'=>$origname, 'hasflag'=>$hasflag, 'tags' => $tags ); } return $languages; }
php
public function getAllLanguages() { if (is_array($this->alllanguages)) { return $this->alllanguages; } // find languages file in a locales path $langfile = $this->localespath.'languages.txt'; if (!file_exists($langfile)) { // if no in locales then use default from this package $langfile = dirname(__FILE__).'/languages.txt'; } if (!file_exists($langfile)) { // if not found then show error or return empty array if ($this->errorondatamissed) { throw new \Exception('No languages file found'); } return array(); } // load a file $list = @file_get_contents($langfile); if (!$list) { // if somethign went wrong throw error or return empty array if ($this->errorondatamissed) { throw new \Exception('Can not load languages list'); } return array(); } $languages = array(); foreach (preg_split('!\\r?\\n!',$list) as $line) { list ($code,$name) = explode('=',$line); $code = trim($code); $name = trim($name); if ($code == '' || $name == '') { continue; } $origname = $name; $tags = array(); $splitsettings = explode(':',$name,3); if (count($splitsettings) > 1) { $name = $splitsettings[0]; $origname = $splitsettings[1]; if (isset($splitsettings[2]) && $splitsettings[2] != '') { $tags = explode(',',$splitsettings[2]); } } $flagfile = $this->localespath.'flags/small/'.$code.'.png'; $hasflag = file_exists($flagfile); $languages[$code] = array( 'code'=>$code, 'name'=>$name, 'origname'=>$origname, 'hasflag'=>$hasflag, 'tags' => $tags ); } return $languages; }
[ "public", "function", "getAllLanguages", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "alllanguages", ")", ")", "{", "return", "$", "this", "->", "alllanguages", ";", "}", "// find languages file in a locales path", "$", "langfile", "=", "$", "this", "->", "localespath", ".", "'languages.txt'", ";", "if", "(", "!", "file_exists", "(", "$", "langfile", ")", ")", "{", "// if no in locales then use default from this package", "$", "langfile", "=", "dirname", "(", "__FILE__", ")", ".", "'/languages.txt'", ";", "}", "if", "(", "!", "file_exists", "(", "$", "langfile", ")", ")", "{", "// if not found then show error or return empty array", "if", "(", "$", "this", "->", "errorondatamissed", ")", "{", "throw", "new", "\\", "Exception", "(", "'No languages file found'", ")", ";", "}", "return", "array", "(", ")", ";", "}", "// load a file", "$", "list", "=", "@", "file_get_contents", "(", "$", "langfile", ")", ";", "if", "(", "!", "$", "list", ")", "{", "// if somethign went wrong throw error or return empty array", "if", "(", "$", "this", "->", "errorondatamissed", ")", "{", "throw", "new", "\\", "Exception", "(", "'Can not load languages list'", ")", ";", "}", "return", "array", "(", ")", ";", "}", "$", "languages", "=", "array", "(", ")", ";", "foreach", "(", "preg_split", "(", "'!\\\\r?\\\\n!'", ",", "$", "list", ")", "as", "$", "line", ")", "{", "list", "(", "$", "code", ",", "$", "name", ")", "=", "explode", "(", "'='", ",", "$", "line", ")", ";", "$", "code", "=", "trim", "(", "$", "code", ")", ";", "$", "name", "=", "trim", "(", "$", "name", ")", ";", "if", "(", "$", "code", "==", "''", "||", "$", "name", "==", "''", ")", "{", "continue", ";", "}", "$", "origname", "=", "$", "name", ";", "$", "tags", "=", "array", "(", ")", ";", "$", "splitsettings", "=", "explode", "(", "':'", ",", "$", "name", ",", "3", ")", ";", "if", "(", "count", "(", "$", "splitsettings", ")", ">", "1", ")", "{", "$", "name", "=", "$", "splitsettings", "[", "0", "]", ";", "$", "origname", "=", "$", "splitsettings", "[", "1", "]", ";", "if", "(", "isset", "(", "$", "splitsettings", "[", "2", "]", ")", "&&", "$", "splitsettings", "[", "2", "]", "!=", "''", ")", "{", "$", "tags", "=", "explode", "(", "','", ",", "$", "splitsettings", "[", "2", "]", ")", ";", "}", "}", "$", "flagfile", "=", "$", "this", "->", "localespath", ".", "'flags/small/'", ".", "$", "code", ".", "'.png'", ";", "$", "hasflag", "=", "file_exists", "(", "$", "flagfile", ")", ";", "$", "languages", "[", "$", "code", "]", "=", "array", "(", "'code'", "=>", "$", "code", ",", "'name'", "=>", "$", "name", ",", "'origname'", "=>", "$", "origname", ",", "'hasflag'", "=>", "$", "hasflag", ",", "'tags'", "=>", "$", "tags", ")", ";", "}", "return", "$", "languages", ";", "}" ]
Returns all languages with all attributes installed on the system @return array
[ "Returns", "all", "languages", "with", "all", "attributes", "installed", "on", "the", "system" ]
4d59f6518bf765c3653f3d2583e6e262ff8bfb29
https://github.com/Gelembjuk/locale/blob/4d59f6518bf765c3653f3d2583e6e262ff8bfb29/src/Gelembjuk/Locale/Languages.php#L68-L141
1,438
Gelembjuk/locale
src/Gelembjuk/Locale/Languages.php
Languages.getLanguagesFromList
public function getLanguagesFromList($list) { $alllanguages = $this->getAllLanguages(); $languages = array(); foreach ($alllanguages as $code=>$lang) { if (in_array($code,$list)) { $languages[$code] = $lang; } } return $languages; }
php
public function getLanguagesFromList($list) { $alllanguages = $this->getAllLanguages(); $languages = array(); foreach ($alllanguages as $code=>$lang) { if (in_array($code,$list)) { $languages[$code] = $lang; } } return $languages; }
[ "public", "function", "getLanguagesFromList", "(", "$", "list", ")", "{", "$", "alllanguages", "=", "$", "this", "->", "getAllLanguages", "(", ")", ";", "$", "languages", "=", "array", "(", ")", ";", "foreach", "(", "$", "alllanguages", "as", "$", "code", "=>", "$", "lang", ")", "{", "if", "(", "in_array", "(", "$", "code", ",", "$", "list", ")", ")", "{", "$", "languages", "[", "$", "code", "]", "=", "$", "lang", ";", "}", "}", "return", "$", "languages", ";", "}" ]
Return languages listed in the argument array. Is used for case when it is needed to get list of specified languages @return array
[ "Return", "languages", "listed", "in", "the", "argument", "array", ".", "Is", "used", "for", "case", "when", "it", "is", "needed", "to", "get", "list", "of", "specified", "languages" ]
4d59f6518bf765c3653f3d2583e6e262ff8bfb29
https://github.com/Gelembjuk/locale/blob/4d59f6518bf765c3653f3d2583e6e262ff8bfb29/src/Gelembjuk/Locale/Languages.php#L186-L198
1,439
Gelembjuk/locale
src/Gelembjuk/Locale/Languages.php
Languages.getHTMLSelect
public function getHTMLSelect($attributes = '',$currentlang = '',$orignames = false) { $html = '<select '.$attributes.'>'; foreach ($this->getUsedLanguages() as $code=>$lang) { $html .= '<option value="'.$code.'" '; if ($currentlang == $code) { $html .= 'selected'; } $html .= '>'; if ($orignames) { $html .= $lang['origname']; } else { $html .= $lang['name']; } } $html .= '</select>'; return $html; }
php
public function getHTMLSelect($attributes = '',$currentlang = '',$orignames = false) { $html = '<select '.$attributes.'>'; foreach ($this->getUsedLanguages() as $code=>$lang) { $html .= '<option value="'.$code.'" '; if ($currentlang == $code) { $html .= 'selected'; } $html .= '>'; if ($orignames) { $html .= $lang['origname']; } else { $html .= $lang['name']; } } $html .= '</select>'; return $html; }
[ "public", "function", "getHTMLSelect", "(", "$", "attributes", "=", "''", ",", "$", "currentlang", "=", "''", ",", "$", "orignames", "=", "false", ")", "{", "$", "html", "=", "'<select '", ".", "$", "attributes", ".", "'>'", ";", "foreach", "(", "$", "this", "->", "getUsedLanguages", "(", ")", "as", "$", "code", "=>", "$", "lang", ")", "{", "$", "html", ".=", "'<option value=\"'", ".", "$", "code", ".", "'\" '", ";", "if", "(", "$", "currentlang", "==", "$", "code", ")", "{", "$", "html", ".=", "'selected'", ";", "}", "$", "html", ".=", "'>'", ";", "if", "(", "$", "orignames", ")", "{", "$", "html", ".=", "$", "lang", "[", "'origname'", "]", ";", "}", "else", "{", "$", "html", ".=", "$", "lang", "[", "'name'", "]", ";", "}", "}", "$", "html", ".=", "'</select>'", ";", "return", "$", "html", ";", "}" ]
Build HTML select consruction with used languages Can be used on a web site to show a Language change dropbox @param string $attributes for a select box @param string $currentlang Current selected language code (locale) @param boolean $orignames If true then original manes of languages ill be used as titles in a dropbox @return string
[ "Build", "HTML", "select", "consruction", "with", "used", "languages", "Can", "be", "used", "on", "a", "web", "site", "to", "show", "a", "Language", "change", "dropbox" ]
4d59f6518bf765c3653f3d2583e6e262ff8bfb29
https://github.com/Gelembjuk/locale/blob/4d59f6518bf765c3653f3d2583e6e262ff8bfb29/src/Gelembjuk/Locale/Languages.php#L223-L245
1,440
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/query/builder/join.php
Database_Query_Builder_Join.or_on
public function or_on($c1, $op, $c2) { $this->_on[] = array($c1, $op, $c2, 'OR'); return $this; }
php
public function or_on($c1, $op, $c2) { $this->_on[] = array($c1, $op, $c2, 'OR'); return $this; }
[ "public", "function", "or_on", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ")", "{", "$", "this", "->", "_on", "[", "]", "=", "array", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ",", "'OR'", ")", ";", "return", "$", "this", ";", "}" ]
Adds a new OR condition for joining. @param mixed $c1 column name or array($column, $alias) or object @param string $op logic operator @param mixed $c2 column name or array($column, $alias) or object @return $this
[ "Adds", "a", "new", "OR", "condition", "for", "joining", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/join.php#L59-L64
1,441
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/query/builder/join.php
Database_Query_Builder_Join.on
public function on($c1, $op, $c2) { $this->_on[] = array($c1, $op, $c2, 'AND'); return $this; }
php
public function on($c1, $op, $c2) { $this->_on[] = array($c1, $op, $c2, 'AND'); return $this; }
[ "public", "function", "on", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ")", "{", "$", "this", "->", "_on", "[", "]", "=", "array", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ",", "'AND'", ")", ";", "return", "$", "this", ";", "}" ]
Adds a new AND condition for joining. @param mixed $c1 column name or array($column, $alias) or object @param string $op logic operator @param mixed $c2 column name or array($column, $alias) or object @return $this
[ "Adds", "a", "new", "AND", "condition", "for", "joining", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/join.php#L75-L80
1,442
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/query/builder/join.php
Database_Query_Builder_Join.compile
public function compile($db = null) { if ( ! $db instanceof \Database_Connection) { // Get the database instance $db = \Database_Connection::instance($db); } if ($this->_type) { $sql = strtoupper($this->_type).' JOIN'; } else { $sql = 'JOIN'; } // Quote the table name that is being joined $sql .= ' '.$db->quote_table($this->_table); $conditions = array(); foreach ($this->_on as $condition) { // Split the condition list($c1, $op, $c2, $chaining) = $condition; // Add chain type $conditions[] = ' '.$chaining.' '; if ($op) { // Make the operator uppercase and spaced $op = ' '.strtoupper($op); } // Quote each of the identifiers used for the condition $conditions[] = $db->quote_identifier($c1).$op.' '.(is_null($c2)?'NULL':$db->quote_identifier($c2)); } // remove the first chain type array_shift($conditions); // if there are conditions, concat the conditions "... AND ..." and glue them on... empty($conditions) or $sql .= ' ON ('.implode('', $conditions).')'; return $sql; }
php
public function compile($db = null) { if ( ! $db instanceof \Database_Connection) { // Get the database instance $db = \Database_Connection::instance($db); } if ($this->_type) { $sql = strtoupper($this->_type).' JOIN'; } else { $sql = 'JOIN'; } // Quote the table name that is being joined $sql .= ' '.$db->quote_table($this->_table); $conditions = array(); foreach ($this->_on as $condition) { // Split the condition list($c1, $op, $c2, $chaining) = $condition; // Add chain type $conditions[] = ' '.$chaining.' '; if ($op) { // Make the operator uppercase and spaced $op = ' '.strtoupper($op); } // Quote each of the identifiers used for the condition $conditions[] = $db->quote_identifier($c1).$op.' '.(is_null($c2)?'NULL':$db->quote_identifier($c2)); } // remove the first chain type array_shift($conditions); // if there are conditions, concat the conditions "... AND ..." and glue them on... empty($conditions) or $sql .= ' ON ('.implode('', $conditions).')'; return $sql; }
[ "public", "function", "compile", "(", "$", "db", "=", "null", ")", "{", "if", "(", "!", "$", "db", "instanceof", "\\", "Database_Connection", ")", "{", "// Get the database instance", "$", "db", "=", "\\", "Database_Connection", "::", "instance", "(", "$", "db", ")", ";", "}", "if", "(", "$", "this", "->", "_type", ")", "{", "$", "sql", "=", "strtoupper", "(", "$", "this", "->", "_type", ")", ".", "' JOIN'", ";", "}", "else", "{", "$", "sql", "=", "'JOIN'", ";", "}", "// Quote the table name that is being joined", "$", "sql", ".=", "' '", ".", "$", "db", "->", "quote_table", "(", "$", "this", "->", "_table", ")", ";", "$", "conditions", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_on", "as", "$", "condition", ")", "{", "// Split the condition", "list", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ",", "$", "chaining", ")", "=", "$", "condition", ";", "// Add chain type", "$", "conditions", "[", "]", "=", "' '", ".", "$", "chaining", ".", "' '", ";", "if", "(", "$", "op", ")", "{", "// Make the operator uppercase and spaced", "$", "op", "=", "' '", ".", "strtoupper", "(", "$", "op", ")", ";", "}", "// Quote each of the identifiers used for the condition", "$", "conditions", "[", "]", "=", "$", "db", "->", "quote_identifier", "(", "$", "c1", ")", ".", "$", "op", ".", "' '", ".", "(", "is_null", "(", "$", "c2", ")", "?", "'NULL'", ":", "$", "db", "->", "quote_identifier", "(", "$", "c2", ")", ")", ";", "}", "// remove the first chain type", "array_shift", "(", "$", "conditions", ")", ";", "// if there are conditions, concat the conditions \"... AND ...\" and glue them on...", "empty", "(", "$", "conditions", ")", "or", "$", "sql", ".=", "' ON ('", ".", "implode", "(", "''", ",", "$", "conditions", ")", ".", "')'", ";", "return", "$", "sql", ";", "}" ]
Compile the SQL partial for a JOIN statement and return it. @param mixed $db Database_Connection instance or instance name @return string
[ "Compile", "the", "SQL", "partial", "for", "a", "JOIN", "statement", "and", "return", "it", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/join.php#L103-L150
1,443
trendwerk/dev-mail
class-tp-dev-mail.php
TP_Dev_Mail.send_to
function send_to( $mail ) { $mail['subject'] .= ' [' . $mail['to'] . ']'; if( 'staging' == WP_ENV ) $mail['to'] = get_option( 'admin_email' ); else if( defined( 'TP_DEV_MAIL' ) ) $mail['to'] = TP_DEV_MAIL; else $mail['to'] = ''; return $mail; }
php
function send_to( $mail ) { $mail['subject'] .= ' [' . $mail['to'] . ']'; if( 'staging' == WP_ENV ) $mail['to'] = get_option( 'admin_email' ); else if( defined( 'TP_DEV_MAIL' ) ) $mail['to'] = TP_DEV_MAIL; else $mail['to'] = ''; return $mail; }
[ "function", "send_to", "(", "$", "mail", ")", "{", "$", "mail", "[", "'subject'", "]", ".=", "' ['", ".", "$", "mail", "[", "'to'", "]", ".", "']'", ";", "if", "(", "'staging'", "==", "WP_ENV", ")", "$", "mail", "[", "'to'", "]", "=", "get_option", "(", "'admin_email'", ")", ";", "else", "if", "(", "defined", "(", "'TP_DEV_MAIL'", ")", ")", "$", "mail", "[", "'to'", "]", "=", "TP_DEV_MAIL", ";", "else", "$", "mail", "[", "'to'", "]", "=", "''", ";", "return", "$", "mail", ";", "}" ]
Don't send e-mails in development and staging environments
[ "Don", "t", "send", "e", "-", "mails", "in", "development", "and", "staging", "environments" ]
b5465d11ab305222ca2545344e5873711026a9e3
https://github.com/trendwerk/dev-mail/blob/b5465d11ab305222ca2545344e5873711026a9e3/class-tp-dev-mail.php#L24-L35
1,444
Stratadox/Deserializer
src/IllegalInputKey.php
IllegalInputKey.illegal
public static function illegal( object $collection, string $key ): CannotDeserialize { return new IllegalInputKey(withMessage( 'Invalid collection deserialization input: Unexpected key `%s` for the `%s` class.', $key, classOfThe($collection) )); }
php
public static function illegal( object $collection, string $key ): CannotDeserialize { return new IllegalInputKey(withMessage( 'Invalid collection deserialization input: Unexpected key `%s` for the `%s` class.', $key, classOfThe($collection) )); }
[ "public", "static", "function", "illegal", "(", "object", "$", "collection", ",", "string", "$", "key", ")", ":", "CannotDeserialize", "{", "return", "new", "IllegalInputKey", "(", "withMessage", "(", "'Invalid collection deserialization input: Unexpected key `%s` for the `%s` class.'", ",", "$", "key", ",", "classOfThe", "(", "$", "collection", ")", ")", ")", ";", "}" ]
Produces a deserialization exception to throw when a collection input key is not considered valid. @param object $collection The collection that was assigned the illegal input key. @param string $key The input key that was considered invalid. @return CannotDeserialize The deserialization exception to throw.
[ "Produces", "a", "deserialization", "exception", "to", "throw", "when", "a", "collection", "input", "key", "is", "not", "considered", "valid", "." ]
26f282837f310cc7eb1aec01579edde04c84a80c
https://github.com/Stratadox/Deserializer/blob/26f282837f310cc7eb1aec01579edde04c84a80c/src/IllegalInputKey.php#L27-L36
1,445
FlexPress/component-popular-posts
src/FlexPress/Components/PopularPosts/Helper.php
Helper.sortByScore
protected function sortByScore($a, $b) { if ($a->score == $b->score) { return 0; } return ($a->score > $b->score) ? -1 : 1; }
php
protected function sortByScore($a, $b) { if ($a->score == $b->score) { return 0; } return ($a->score > $b->score) ? -1 : 1; }
[ "protected", "function", "sortByScore", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "$", "a", "->", "score", "==", "$", "b", "->", "score", ")", "{", "return", "0", ";", "}", "return", "(", "$", "a", "->", "score", ">", "$", "b", "->", "score", ")", "?", "-", "1", ":", "1", ";", "}" ]
Sorting function, uses the score of a object to determine the order of the array @param $a @param $b @return int @author Tim Perry
[ "Sorting", "function", "uses", "the", "score", "of", "a", "object", "to", "determine", "the", "order", "of", "the", "array" ]
b187c66ee28a2afe72ad10aad87c75090d490c4e
https://github.com/FlexPress/component-popular-posts/blob/b187c66ee28a2afe72ad10aad87c75090d490c4e/src/FlexPress/Components/PopularPosts/Helper.php#L67-L76
1,446
nano7/Foundation
src/Translation/TranslationServiceProvider.php
TranslationServiceProvider.registerTraslator
protected function registerTraslator() { $this->app->singleton('translator', function ($app) { $loader = $app['translation.loader']; // When registering the translator component, we'll need to set the default // locale as well as the fallback locale. So, we'll grab the application // configuration so we can easily get both of these values from there. $locale = $app['config']['app.locale']; $trans = new Translator($loader, $locale); $trans->setFallback($app['config']['app.fallback_locale']); return $trans; }); }
php
protected function registerTraslator() { $this->app->singleton('translator', function ($app) { $loader = $app['translation.loader']; // When registering the translator component, we'll need to set the default // locale as well as the fallback locale. So, we'll grab the application // configuration so we can easily get both of these values from there. $locale = $app['config']['app.locale']; $trans = new Translator($loader, $locale); $trans->setFallback($app['config']['app.fallback_locale']); return $trans; }); }
[ "protected", "function", "registerTraslator", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'translator'", ",", "function", "(", "$", "app", ")", "{", "$", "loader", "=", "$", "app", "[", "'translation.loader'", "]", ";", "// When registering the translator component, we'll need to set the default", "// locale as well as the fallback locale. So, we'll grab the application", "// configuration so we can easily get both of these values from there.", "$", "locale", "=", "$", "app", "[", "'config'", "]", "[", "'app.locale'", "]", ";", "$", "trans", "=", "new", "Translator", "(", "$", "loader", ",", "$", "locale", ")", ";", "$", "trans", "->", "setFallback", "(", "$", "app", "[", "'config'", "]", "[", "'app.fallback_locale'", "]", ")", ";", "return", "$", "trans", ";", "}", ")", ";", "}" ]
Register translator. @return void
[ "Register", "translator", "." ]
8328423f81c69b8fabc04b4f6b1f3ba712695374
https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Translation/TranslationServiceProvider.php#L44-L60
1,447
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/arr.php
Arr.keyval_to_assoc
public static function keyval_to_assoc($array, $key_field, $val_field) { if ( ! is_array($array) and ! $array instanceof \Iterator) { throw new \InvalidArgumentException('The first parameter must be an array.'); } $output = array(); foreach ($array as $key => $value) { $output[] = array( $key_field => $key, $val_field => $value ); } return $output; }
php
public static function keyval_to_assoc($array, $key_field, $val_field) { if ( ! is_array($array) and ! $array instanceof \Iterator) { throw new \InvalidArgumentException('The first parameter must be an array.'); } $output = array(); foreach ($array as $key => $value) { $output[] = array( $key_field => $key, $val_field => $value ); } return $output; }
[ "public", "static", "function", "keyval_to_assoc", "(", "$", "array", ",", "$", "key_field", ",", "$", "val_field", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", "and", "!", "$", "array", "instanceof", "\\", "Iterator", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The first parameter must be an array.'", ")", ";", "}", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "output", "[", "]", "=", "array", "(", "$", "key_field", "=>", "$", "key", ",", "$", "val_field", "=>", "$", "value", ")", ";", "}", "return", "$", "output", ";", "}" ]
Converts an array of key => values into a multi-dimensional associative array with the provided field names @param array $array the array to convert @param string $key_field the field name of the key field @param string $val_field the field name of the value field @return array @throws \InvalidArgumentException
[ "Converts", "an", "array", "of", "key", "=", ">", "values", "into", "a", "multi", "-", "dimensional", "associative", "array", "with", "the", "provided", "field", "names" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/arr.php#L261-L278
1,448
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/arr.php
Arr.is_assoc
public static function is_assoc($arr) { if ( ! is_array($arr)) { throw new \InvalidArgumentException('The parameter must be an array.'); } $counter = 0; foreach ($arr as $key => $unused) { if ( ! is_int($key) or $key !== $counter++) { return true; } } return false; }
php
public static function is_assoc($arr) { if ( ! is_array($arr)) { throw new \InvalidArgumentException('The parameter must be an array.'); } $counter = 0; foreach ($arr as $key => $unused) { if ( ! is_int($key) or $key !== $counter++) { return true; } } return false; }
[ "public", "static", "function", "is_assoc", "(", "$", "arr", ")", "{", "if", "(", "!", "is_array", "(", "$", "arr", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The parameter must be an array.'", ")", ";", "}", "$", "counter", "=", "0", ";", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "unused", ")", "{", "if", "(", "!", "is_int", "(", "$", "key", ")", "or", "$", "key", "!==", "$", "counter", "++", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the given array is an assoc array. @param array $arr the array to check @return bool true if its an assoc array, false if not
[ "Checks", "if", "the", "given", "array", "is", "an", "assoc", "array", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/arr.php#L314-L330
1,449
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/arr.php
Arr.multisort
public static function multisort($array, $conditions, $ignore_case = false) { $temp = array(); $keys = array_keys($conditions); foreach($keys as $key) { $temp[$key] = static::pluck($array, $key, true); is_array($conditions[$key]) or $conditions[$key] = array($conditions[$key]); } $args = array(); foreach ($keys as $key) { $args[] = $ignore_case ? array_map('strtolower', $temp[$key]) : $temp[$key]; foreach($conditions[$key] as $flag) { $args[] = $flag; } } $args[] = &$array; call_fuel_func_array('array_multisort', $args); return $array; }
php
public static function multisort($array, $conditions, $ignore_case = false) { $temp = array(); $keys = array_keys($conditions); foreach($keys as $key) { $temp[$key] = static::pluck($array, $key, true); is_array($conditions[$key]) or $conditions[$key] = array($conditions[$key]); } $args = array(); foreach ($keys as $key) { $args[] = $ignore_case ? array_map('strtolower', $temp[$key]) : $temp[$key]; foreach($conditions[$key] as $flag) { $args[] = $flag; } } $args[] = &$array; call_fuel_func_array('array_multisort', $args); return $array; }
[ "public", "static", "function", "multisort", "(", "$", "array", ",", "$", "conditions", ",", "$", "ignore_case", "=", "false", ")", "{", "$", "temp", "=", "array", "(", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "conditions", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "temp", "[", "$", "key", "]", "=", "static", "::", "pluck", "(", "$", "array", ",", "$", "key", ",", "true", ")", ";", "is_array", "(", "$", "conditions", "[", "$", "key", "]", ")", "or", "$", "conditions", "[", "$", "key", "]", "=", "array", "(", "$", "conditions", "[", "$", "key", "]", ")", ";", "}", "$", "args", "=", "array", "(", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "args", "[", "]", "=", "$", "ignore_case", "?", "array_map", "(", "'strtolower'", ",", "$", "temp", "[", "$", "key", "]", ")", ":", "$", "temp", "[", "$", "key", "]", ";", "foreach", "(", "$", "conditions", "[", "$", "key", "]", "as", "$", "flag", ")", "{", "$", "args", "[", "]", "=", "$", "flag", ";", "}", "}", "$", "args", "[", "]", "=", "&", "$", "array", ";", "call_fuel_func_array", "(", "'array_multisort'", ",", "$", "args", ")", ";", "return", "$", "array", ";", "}" ]
Sorts an array on multitiple values, with deep sorting support. @param array $array collection of arrays/objects to sort @param array $conditions sorting conditions @param bool @ignore_case wether to sort case insensitive
[ "Sorts", "an", "array", "on", "multitiple", "values", "with", "deep", "sorting", "support", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/arr.php#L748-L773
1,450
gplcart/installer
controllers/Upload.php
Upload.setBreadcrumbEditUpload
protected function setBreadcrumbEditUpload() { $breadcrumbs = array(); $breadcrumbs[] = array( 'text' => $this->text('Dashboard'), 'url' => $this->url('admin') ); $breadcrumbs[] = array( 'text' => $this->text('Modules'), 'url' => $this->url('admin/module/list') ); $this->setBreadcrumbs($breadcrumbs); }
php
protected function setBreadcrumbEditUpload() { $breadcrumbs = array(); $breadcrumbs[] = array( 'text' => $this->text('Dashboard'), 'url' => $this->url('admin') ); $breadcrumbs[] = array( 'text' => $this->text('Modules'), 'url' => $this->url('admin/module/list') ); $this->setBreadcrumbs($breadcrumbs); }
[ "protected", "function", "setBreadcrumbEditUpload", "(", ")", "{", "$", "breadcrumbs", "=", "array", "(", ")", ";", "$", "breadcrumbs", "[", "]", "=", "array", "(", "'text'", "=>", "$", "this", "->", "text", "(", "'Dashboard'", ")", ",", "'url'", "=>", "$", "this", "->", "url", "(", "'admin'", ")", ")", ";", "$", "breadcrumbs", "[", "]", "=", "array", "(", "'text'", "=>", "$", "this", "->", "text", "(", "'Modules'", ")", ",", "'url'", "=>", "$", "this", "->", "url", "(", "'admin/module/list'", ")", ")", ";", "$", "this", "->", "setBreadcrumbs", "(", "$", "breadcrumbs", ")", ";", "}" ]
Set breadcrumbs on the module upload page
[ "Set", "breadcrumbs", "on", "the", "module", "upload", "page" ]
a0cc7525268c176c910953f422365e86e5e0dac7
https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/controllers/Upload.php#L78-L93
1,451
gplcart/installer
controllers/Upload.php
Upload.validateUpload
protected function validateUpload() { $file = $this->request->file('file'); if (empty($file)) { $this->setError('file', $this->text('Nothing to install')); return false; } $result = $this->file_transfer->upload($file, 'zip', gplcart_file_private_module('installer')); if ($result !== true) { $this->setError('file', $result); return false; } $this->setSubmitted('file', $this->file_transfer->getTransferred()); return !$this->hasErrors(); }
php
protected function validateUpload() { $file = $this->request->file('file'); if (empty($file)) { $this->setError('file', $this->text('Nothing to install')); return false; } $result = $this->file_transfer->upload($file, 'zip', gplcart_file_private_module('installer')); if ($result !== true) { $this->setError('file', $result); return false; } $this->setSubmitted('file', $this->file_transfer->getTransferred()); return !$this->hasErrors(); }
[ "protected", "function", "validateUpload", "(", ")", "{", "$", "file", "=", "$", "this", "->", "request", "->", "file", "(", "'file'", ")", ";", "if", "(", "empty", "(", "$", "file", ")", ")", "{", "$", "this", "->", "setError", "(", "'file'", ",", "$", "this", "->", "text", "(", "'Nothing to install'", ")", ")", ";", "return", "false", ";", "}", "$", "result", "=", "$", "this", "->", "file_transfer", "->", "upload", "(", "$", "file", ",", "'zip'", ",", "gplcart_file_private_module", "(", "'installer'", ")", ")", ";", "if", "(", "$", "result", "!==", "true", ")", "{", "$", "this", "->", "setError", "(", "'file'", ",", "$", "result", ")", ";", "return", "false", ";", "}", "$", "this", "->", "setSubmitted", "(", "'file'", ",", "$", "this", "->", "file_transfer", "->", "getTransferred", "(", ")", ")", ";", "return", "!", "$", "this", "->", "hasErrors", "(", ")", ";", "}" ]
Validate a submitted data
[ "Validate", "a", "submitted", "data" ]
a0cc7525268c176c910953f422365e86e5e0dac7
https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/controllers/Upload.php#L108-L126
1,452
gplcart/installer
controllers/Upload.php
Upload.installModuleUpload
protected function installModuleUpload() { $this->controlAccess('file_upload'); $this->controlAccess('module_installer_upload'); $file = $this->getSubmitted('file'); $result = $this->install->fromZip($file); if ($result !== true) { $this->redirect('', $result, 'warning'); } if ($this->install->isUpdate()) { $message = $this->text('Module has been updated. Previous version has been saved to a <a href="@url">backup</a> file', array('@url' => $this->url('admin/report/backup'))); } else { $message = $this->text('Module has been uploaded. You should <a href="@url">enable</a> it manually', array('@url' => $this->url('admin/module/list'))); } $this->redirect('', $message, 'success'); }
php
protected function installModuleUpload() { $this->controlAccess('file_upload'); $this->controlAccess('module_installer_upload'); $file = $this->getSubmitted('file'); $result = $this->install->fromZip($file); if ($result !== true) { $this->redirect('', $result, 'warning'); } if ($this->install->isUpdate()) { $message = $this->text('Module has been updated. Previous version has been saved to a <a href="@url">backup</a> file', array('@url' => $this->url('admin/report/backup'))); } else { $message = $this->text('Module has been uploaded. You should <a href="@url">enable</a> it manually', array('@url' => $this->url('admin/module/list'))); } $this->redirect('', $message, 'success'); }
[ "protected", "function", "installModuleUpload", "(", ")", "{", "$", "this", "->", "controlAccess", "(", "'file_upload'", ")", ";", "$", "this", "->", "controlAccess", "(", "'module_installer_upload'", ")", ";", "$", "file", "=", "$", "this", "->", "getSubmitted", "(", "'file'", ")", ";", "$", "result", "=", "$", "this", "->", "install", "->", "fromZip", "(", "$", "file", ")", ";", "if", "(", "$", "result", "!==", "true", ")", "{", "$", "this", "->", "redirect", "(", "''", ",", "$", "result", ",", "'warning'", ")", ";", "}", "if", "(", "$", "this", "->", "install", "->", "isUpdate", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "text", "(", "'Module has been updated. Previous version has been saved to a <a href=\"@url\">backup</a> file'", ",", "array", "(", "'@url'", "=>", "$", "this", "->", "url", "(", "'admin/report/backup'", ")", ")", ")", ";", "}", "else", "{", "$", "message", "=", "$", "this", "->", "text", "(", "'Module has been uploaded. You should <a href=\"@url\">enable</a> it manually'", ",", "array", "(", "'@url'", "=>", "$", "this", "->", "url", "(", "'admin/module/list'", ")", ")", ")", ";", "}", "$", "this", "->", "redirect", "(", "''", ",", "$", "message", ",", "'success'", ")", ";", "}" ]
Install uploaded module
[ "Install", "uploaded", "module" ]
a0cc7525268c176c910953f422365e86e5e0dac7
https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/controllers/Upload.php#L131-L150
1,453
jaeger-app/rest-server
src/Rest/AbstractServer.php
AbstractServer.getVersion
public function getVersion($version_key) { if(is_null($this->version)) { //determine the version $headers = \getallheaders(); if(isset($headers[$version_key]) && is_numeric($headers[$version_key]) && in_array($headers[$version_key], $this->api_versions)) { $version = 'V'.str_replace('.','_',$headers[$version_key]); } else { $version = 'V1'; } $this->version = $version; } return $this->version; }
php
public function getVersion($version_key) { if(is_null($this->version)) { //determine the version $headers = \getallheaders(); if(isset($headers[$version_key]) && is_numeric($headers[$version_key]) && in_array($headers[$version_key], $this->api_versions)) { $version = 'V'.str_replace('.','_',$headers[$version_key]); } else { $version = 'V1'; } $this->version = $version; } return $this->version; }
[ "public", "function", "getVersion", "(", "$", "version_key", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "version", ")", ")", "{", "//determine the version", "$", "headers", "=", "\\", "getallheaders", "(", ")", ";", "if", "(", "isset", "(", "$", "headers", "[", "$", "version_key", "]", ")", "&&", "is_numeric", "(", "$", "headers", "[", "$", "version_key", "]", ")", "&&", "in_array", "(", "$", "headers", "[", "$", "version_key", "]", ",", "$", "this", "->", "api_versions", ")", ")", "{", "$", "version", "=", "'V'", ".", "str_replace", "(", "'.'", ",", "'_'", ",", "$", "headers", "[", "$", "version_key", "]", ")", ";", "}", "else", "{", "$", "version", "=", "'V1'", ";", "}", "$", "this", "->", "version", "=", "$", "version", ";", "}", "return", "$", "this", "->", "version", ";", "}" ]
Creates the version of the API we're expected to use @param string $version_key @return string
[ "Creates", "the", "version", "of", "the", "API", "we", "re", "expected", "to", "use" ]
fb99bd1d935b7c1f5cbaf335a178727cb7945690
https://github.com/jaeger-app/rest-server/blob/fb99bd1d935b7c1f5cbaf335a178727cb7945690/src/Rest/AbstractServer.php#L66-L85
1,454
webmaniacs-net/lib-uri
lib/Uri.php
Uri.init
protected function init() { $uri = $this->token; // check scheme if (($pos = strpos($uri, ':')) !== false) { $this->scheme = substr($uri, 0, $pos); $rest = substr($uri, $pos + 1); } else { $rest = $uri; } // check fragment if (($pos = strrpos($rest, '#')) !== false) { $this->fragment = substr($rest, $pos + 1); $rest = substr($rest, 0, $pos); } $this->schemeSpecificPart = $rest; // A hierarchical URI if (($this->isAbsolute() && $this->schemeSpecificPart{0} == '/') || !$this->isAbsolute()) { $parts = array(); if (preg_match('/^(\/\/([^\/]*))?(\/?[^\?]+)?(\?(.*?))?$/S', $this->schemeSpecificPart, $parts)) { if (isset($parts[2])) { $this->setAuthority($parts[2]); } if (isset($parts[3]) && $parts[3]) { $this->path = $parts[3]; } if (isset($parts[5]) && $parts[5]) { $this->query = $parts[5]; } } else { throw new \DomainException("Hierarchical URI scheme-specific part syntax error"); } } $this->hash = null; }
php
protected function init() { $uri = $this->token; // check scheme if (($pos = strpos($uri, ':')) !== false) { $this->scheme = substr($uri, 0, $pos); $rest = substr($uri, $pos + 1); } else { $rest = $uri; } // check fragment if (($pos = strrpos($rest, '#')) !== false) { $this->fragment = substr($rest, $pos + 1); $rest = substr($rest, 0, $pos); } $this->schemeSpecificPart = $rest; // A hierarchical URI if (($this->isAbsolute() && $this->schemeSpecificPart{0} == '/') || !$this->isAbsolute()) { $parts = array(); if (preg_match('/^(\/\/([^\/]*))?(\/?[^\?]+)?(\?(.*?))?$/S', $this->schemeSpecificPart, $parts)) { if (isset($parts[2])) { $this->setAuthority($parts[2]); } if (isset($parts[3]) && $parts[3]) { $this->path = $parts[3]; } if (isset($parts[5]) && $parts[5]) { $this->query = $parts[5]; } } else { throw new \DomainException("Hierarchical URI scheme-specific part syntax error"); } } $this->hash = null; }
[ "protected", "function", "init", "(", ")", "{", "$", "uri", "=", "$", "this", "->", "token", ";", "// check scheme", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "uri", ",", "':'", ")", ")", "!==", "false", ")", "{", "$", "this", "->", "scheme", "=", "substr", "(", "$", "uri", ",", "0", ",", "$", "pos", ")", ";", "$", "rest", "=", "substr", "(", "$", "uri", ",", "$", "pos", "+", "1", ")", ";", "}", "else", "{", "$", "rest", "=", "$", "uri", ";", "}", "// check fragment", "if", "(", "(", "$", "pos", "=", "strrpos", "(", "$", "rest", ",", "'#'", ")", ")", "!==", "false", ")", "{", "$", "this", "->", "fragment", "=", "substr", "(", "$", "rest", ",", "$", "pos", "+", "1", ")", ";", "$", "rest", "=", "substr", "(", "$", "rest", ",", "0", ",", "$", "pos", ")", ";", "}", "$", "this", "->", "schemeSpecificPart", "=", "$", "rest", ";", "// A hierarchical URI", "if", "(", "(", "$", "this", "->", "isAbsolute", "(", ")", "&&", "$", "this", "->", "schemeSpecificPart", "{", "0", "}", "==", "'/'", ")", "||", "!", "$", "this", "->", "isAbsolute", "(", ")", ")", "{", "$", "parts", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", "'/^(\\/\\/([^\\/]*))?(\\/?[^\\?]+)?(\\?(.*?))?$/S'", ",", "$", "this", "->", "schemeSpecificPart", ",", "$", "parts", ")", ")", "{", "if", "(", "isset", "(", "$", "parts", "[", "2", "]", ")", ")", "{", "$", "this", "->", "setAuthority", "(", "$", "parts", "[", "2", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "parts", "[", "3", "]", ")", "&&", "$", "parts", "[", "3", "]", ")", "{", "$", "this", "->", "path", "=", "$", "parts", "[", "3", "]", ";", "}", "if", "(", "isset", "(", "$", "parts", "[", "5", "]", ")", "&&", "$", "parts", "[", "5", "]", ")", "{", "$", "this", "->", "query", "=", "$", "parts", "[", "5", "]", ";", "}", "}", "else", "{", "throw", "new", "\\", "DomainException", "(", "\"Hierarchical URI scheme-specific part syntax error\"", ")", ";", "}", "}", "$", "this", "->", "hash", "=", "null", ";", "}" ]
Constructs a URI by parsing the given string. This constructor parses the given string exactly as specified by the grammar in RFC 2396, Appendix A, except for the following deviations: - An empty authority component is permitted as long as it is followed by a non-empty path, a query component, or a fragment component. This allows the parsing of URIs such as "file:///foo/bar", which seems to be the intent of RFC 2396 although the grammar does not permit it. If the authority component is empty then the user-information, host, and port components are undefined. - Empty relative paths are permitted; this seems to be the intent of RFC 2396 although the grammar does not permit it. The primary consequence of this deviation is that a standalone fragment such as "#foo" parses as a relative URI with an empty path and the given fragment, and can be usefully resolved against a base URI. - IPv4 addresses in host components are parsed rigorously, as specified by RFC 2732: Each element of a dotted-quad address must contain no more than three decimal digits. Each element is further constrained to have a value no greater than 255. - Hostnames in host components that comprise only a single domain label are permitted to start with an alphanum character. This seems to be the intent of RFC 2396 section 3.2.2 although the grammar does not permit it. The consequence of this deviation is that the authority component of a hierarchical URI such as s://123, will parse as a server-based authority. - IPv6 addresses are permitted for the host component. An IPv6 address must be enclosed in square brackets ('[' and ']') as specified by RFC 2732. The IPv6 address itself must parse according to RFC 2373. IPv6 addresses are further constrained to describe no more than sixteen bytes of address information, a constraint implicit in RFC 2373 but not expressible in the grammar. - Characters in the other category are permitted wherever RFC 2396 permits escaped octets, that is, in the user-information, path, query, and fragment components, as well as in the authority component if the authority is registry-based. This allows URIs to contain Unicode characters beyond those in the US-ASCII character set. @throws \DomainException If the given string violates RFC 2396, as augmented by the above deviations.
[ "Constructs", "a", "URI", "by", "parsing", "the", "given", "string", "." ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L86-L122
1,455
webmaniacs-net/lib-uri
lib/Uri.php
Uri.resolve
public function resolve(Uri $uri) { static $resolve = array(); return (isset($resolve[$hash = $this->hashCode() . $uri->hashCode()])) ? $resolve[$hash] : ($resolve[$hash] = $this->createResolve($uri)); }
php
public function resolve(Uri $uri) { static $resolve = array(); return (isset($resolve[$hash = $this->hashCode() . $uri->hashCode()])) ? $resolve[$hash] : ($resolve[$hash] = $this->createResolve($uri)); }
[ "public", "function", "resolve", "(", "Uri", "$", "uri", ")", "{", "static", "$", "resolve", "=", "array", "(", ")", ";", "return", "(", "isset", "(", "$", "resolve", "[", "$", "hash", "=", "$", "this", "->", "hashCode", "(", ")", ".", "$", "uri", "->", "hashCode", "(", ")", "]", ")", ")", "?", "$", "resolve", "[", "$", "hash", "]", ":", "(", "$", "resolve", "[", "$", "hash", "]", "=", "$", "this", "->", "createResolve", "(", "$", "uri", ")", ")", ";", "}" ]
Resolves the given URI against this URI. If the given URI is already absolute, or if this URI is opaque, then the given URI is returned. If the given URI's fragment component is defined, its path component is empty, and its scheme, authority, and query components are undefined, then a URI with the given fragment but with all other components equal to those of this URI is returned. This allows a URI representing a standalone fragment reference, such as "#foo", to be usefully resolved against a base URI. Otherwise this method constructs a new hierarchical URI in a manner consistent with RFC 2396, section 5.2; that is: - A new URI is constructed with this URI's scheme and the given URI's query and fragment components. - If the given URI has an authority component then the new URI's authority and path are taken from the given URI. - Otherwise the new URI's authority component is copied from this URI, and its path is computed as follows: - If the given URI's path is absolute then the new URI's path is taken from the given URI. - Otherwise the given URI's path is relative, and so the new URI's path is computed by resolving the path of the given URI against the path of this URI. This is done by concatenating all but the last segment of this URI's path, if any, with the given URI's path and then normalizing the result as if by invoking the normalize method. - The result of this method is absolute if, and only if, either this URI is absolute or the given URI is absolute @param Uri $uri The URI to be resolved against this URI @return Uri The resulting URI
[ "Resolves", "the", "given", "URI", "against", "this", "URI", "." ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L153-L158
1,456
webmaniacs-net/lib-uri
lib/Uri.php
Uri.normalize
public function normalize() { if ($this->isOpaque() || !$this->path) { return clone $this; } else { $uri = clone $this; $uri->path = self::normalizePath($this->path); return $uri; } }
php
public function normalize() { if ($this->isOpaque() || !$this->path) { return clone $this; } else { $uri = clone $this; $uri->path = self::normalizePath($this->path); return $uri; } }
[ "public", "function", "normalize", "(", ")", "{", "if", "(", "$", "this", "->", "isOpaque", "(", ")", "||", "!", "$", "this", "->", "path", ")", "{", "return", "clone", "$", "this", ";", "}", "else", "{", "$", "uri", "=", "clone", "$", "this", ";", "$", "uri", "->", "path", "=", "self", "::", "normalizePath", "(", "$", "this", "->", "path", ")", ";", "return", "$", "uri", ";", "}", "}" ]
Normalizes this URI's path. If this URI is opaque, or if its path is already in normal form, then this URI is returned. Otherwise a new URI is constructed that is identical to this URI except that its path is computed by normalizing this URI's path in a manner consistent with RFC 2396, section 5.2, step 6, sub-steps c through f; that is: - All "." segments are removed - If a ".." segment is preceded by a non-".." segment then both of these segments are removed. This step is repeated until it is no longer applicable. - If the path is relative, and if its first segment contains a colon character (':'), then a "." segment is prepended. This prevents a relative URI with a path such as "a:b/c/d" from later being re-parsed as an opaque URI with a scheme of "a" and a scheme-specific part of "b/c/d". (Deviation from RFC 2396) A normalized path will begin with one or more ".." segments if there were insufficient non-".." segments preceding them to allow their removal. A normalized path will begin with a "." segment if one was inserted by step 3 above. Otherwise, a normalized path will not contain any "." or ".." segments @return Uri A URI equivalent to this URI, but whose path is in normal form.
[ "Normalizes", "this", "URI", "s", "path", "." ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L213-L223
1,457
webmaniacs-net/lib-uri
lib/Uri.php
Uri.buildStr
protected function buildStr() { $uri = ($this->scheme != null) ? ($this->scheme . ':') : ''; if ($this->isOpaque()) { $uri .= $this->schemeSpecificPart; } else { $uri .= $this->buildAuthorityStr(); if ($this->path !== null) { $uri .= $this->path; } if (!empty($this->query)) { $uri .= '?' . $this->query; } } if (!empty($this->fragment)) { $uri .= '#' . $this->fragment; } return $uri; }
php
protected function buildStr() { $uri = ($this->scheme != null) ? ($this->scheme . ':') : ''; if ($this->isOpaque()) { $uri .= $this->schemeSpecificPart; } else { $uri .= $this->buildAuthorityStr(); if ($this->path !== null) { $uri .= $this->path; } if (!empty($this->query)) { $uri .= '?' . $this->query; } } if (!empty($this->fragment)) { $uri .= '#' . $this->fragment; } return $uri; }
[ "protected", "function", "buildStr", "(", ")", "{", "$", "uri", "=", "(", "$", "this", "->", "scheme", "!=", "null", ")", "?", "(", "$", "this", "->", "scheme", ".", "':'", ")", ":", "''", ";", "if", "(", "$", "this", "->", "isOpaque", "(", ")", ")", "{", "$", "uri", ".=", "$", "this", "->", "schemeSpecificPart", ";", "}", "else", "{", "$", "uri", ".=", "$", "this", "->", "buildAuthorityStr", "(", ")", ";", "if", "(", "$", "this", "->", "path", "!==", "null", ")", "{", "$", "uri", ".=", "$", "this", "->", "path", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "query", ")", ")", "{", "$", "uri", ".=", "'?'", ".", "$", "this", "->", "query", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "fragment", ")", ")", "{", "$", "uri", ".=", "'#'", ".", "$", "this", "->", "fragment", ";", "}", "return", "$", "uri", ";", "}" ]
Returns the content of this URI as a string. This URI was created by normalization, resolution, or relativization, and so a string is constructed from this URI's components according to the rules specified in RFC 2396, section 5.2, step 7. @return string
[ "Returns", "the", "content", "of", "this", "URI", "as", "a", "string", "." ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L485-L505
1,458
webmaniacs-net/lib-uri
lib/Uri.php
Uri.setAuthority
protected function setAuthority($authority) { $aparts = []; if (preg_match('/^(([^\@]+)\@)?(.*?)(\:(.+))?$/S', $authority, $aparts)) { $this->authority = $authority; $this->hash = null; if (isset($aparts[2]) && $aparts[2]) { $this->userInfo = $aparts[2]; } if (isset($aparts[3]) && $aparts[3]) { $this->host = $aparts[3]; } if (isset($aparts[5]) && $aparts[5]) { $this->port = (int)$aparts[5]; } } else { throw new \DomainException("Hierarchical URL authority part syntax error"); } return $this; }
php
protected function setAuthority($authority) { $aparts = []; if (preg_match('/^(([^\@]+)\@)?(.*?)(\:(.+))?$/S', $authority, $aparts)) { $this->authority = $authority; $this->hash = null; if (isset($aparts[2]) && $aparts[2]) { $this->userInfo = $aparts[2]; } if (isset($aparts[3]) && $aparts[3]) { $this->host = $aparts[3]; } if (isset($aparts[5]) && $aparts[5]) { $this->port = (int)$aparts[5]; } } else { throw new \DomainException("Hierarchical URL authority part syntax error"); } return $this; }
[ "protected", "function", "setAuthority", "(", "$", "authority", ")", "{", "$", "aparts", "=", "[", "]", ";", "if", "(", "preg_match", "(", "'/^(([^\\@]+)\\@)?(.*?)(\\:(.+))?$/S'", ",", "$", "authority", ",", "$", "aparts", ")", ")", "{", "$", "this", "->", "authority", "=", "$", "authority", ";", "$", "this", "->", "hash", "=", "null", ";", "if", "(", "isset", "(", "$", "aparts", "[", "2", "]", ")", "&&", "$", "aparts", "[", "2", "]", ")", "{", "$", "this", "->", "userInfo", "=", "$", "aparts", "[", "2", "]", ";", "}", "if", "(", "isset", "(", "$", "aparts", "[", "3", "]", ")", "&&", "$", "aparts", "[", "3", "]", ")", "{", "$", "this", "->", "host", "=", "$", "aparts", "[", "3", "]", ";", "}", "if", "(", "isset", "(", "$", "aparts", "[", "5", "]", ")", "&&", "$", "aparts", "[", "5", "]", ")", "{", "$", "this", "->", "port", "=", "(", "int", ")", "$", "aparts", "[", "5", "]", ";", "}", "}", "else", "{", "throw", "new", "\\", "DomainException", "(", "\"Hierarchical URL authority part syntax error\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set authority component of this URI. @param string $authority The decoded authority component of this URI, or null if the authority is undefined. @throws \DomainException @return Uri
[ "Set", "authority", "component", "of", "this", "URI", "." ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L524-L546
1,459
webmaniacs-net/lib-uri
lib/Uri.php
Uri.getRelated
public function getRelated(Uri $baseUri) { $path = $baseUri->getPath(); if (substr($this->getPath(), 0, strlen($path)) == $path) { $class = get_called_class(); $uri = new $class(''); $uri->fragment = $this->fragment; $uri->path = substr($this->getPath(), strlen($path)); $uri->query = $this->query; return $uri; } return $this; }
php
public function getRelated(Uri $baseUri) { $path = $baseUri->getPath(); if (substr($this->getPath(), 0, strlen($path)) == $path) { $class = get_called_class(); $uri = new $class(''); $uri->fragment = $this->fragment; $uri->path = substr($this->getPath(), strlen($path)); $uri->query = $this->query; return $uri; } return $this; }
[ "public", "function", "getRelated", "(", "Uri", "$", "baseUri", ")", "{", "$", "path", "=", "$", "baseUri", "->", "getPath", "(", ")", ";", "if", "(", "substr", "(", "$", "this", "->", "getPath", "(", ")", ",", "0", ",", "strlen", "(", "$", "path", ")", ")", "==", "$", "path", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "$", "uri", "=", "new", "$", "class", "(", "''", ")", ";", "$", "uri", "->", "fragment", "=", "$", "this", "->", "fragment", ";", "$", "uri", "->", "path", "=", "substr", "(", "$", "this", "->", "getPath", "(", ")", ",", "strlen", "(", "$", "path", ")", ")", ";", "$", "uri", "->", "query", "=", "$", "this", "->", "query", ";", "return", "$", "uri", ";", "}", "return", "$", "this", ";", "}" ]
Get new uri instance related to provided base Current: http://user:[email protected]/path/path2?k=v#fragment Base: /path/ Return: path2?k=v#fragment @param Uri $baseUri Base uri @return $this
[ "Get", "new", "uri", "instance", "related", "to", "provided", "base" ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L638-L650
1,460
webmaniacs-net/lib-uri
lib/Uri.php
Uri.buildAuthorityStr
protected function buildAuthorityStr() { if ($this->host != null) { $authority = '//'; if ($this->userInfo != null) { $authority .= $this->userInfo . '@'; } $flag = (strpos($this->host, ':') !== false) && !(substr($this->host, 0, 1) == '[') && !(substr($this->host, -1) == ']'); if ($flag) { $authority .= '['; } $authority .= $this->host; if ($flag) { $authority .= ']'; } if ($this->port != null) { $authority .= ':' . $this->port; } return $authority; } else { if ($this->scheme) { return '//' . $this->authority; } else { return $this->authority; } } }
php
protected function buildAuthorityStr() { if ($this->host != null) { $authority = '//'; if ($this->userInfo != null) { $authority .= $this->userInfo . '@'; } $flag = (strpos($this->host, ':') !== false) && !(substr($this->host, 0, 1) == '[') && !(substr($this->host, -1) == ']'); if ($flag) { $authority .= '['; } $authority .= $this->host; if ($flag) { $authority .= ']'; } if ($this->port != null) { $authority .= ':' . $this->port; } return $authority; } else { if ($this->scheme) { return '//' . $this->authority; } else { return $this->authority; } } }
[ "protected", "function", "buildAuthorityStr", "(", ")", "{", "if", "(", "$", "this", "->", "host", "!=", "null", ")", "{", "$", "authority", "=", "'//'", ";", "if", "(", "$", "this", "->", "userInfo", "!=", "null", ")", "{", "$", "authority", ".=", "$", "this", "->", "userInfo", ".", "'@'", ";", "}", "$", "flag", "=", "(", "strpos", "(", "$", "this", "->", "host", ",", "':'", ")", "!==", "false", ")", "&&", "!", "(", "substr", "(", "$", "this", "->", "host", ",", "0", ",", "1", ")", "==", "'['", ")", "&&", "!", "(", "substr", "(", "$", "this", "->", "host", ",", "-", "1", ")", "==", "']'", ")", ";", "if", "(", "$", "flag", ")", "{", "$", "authority", ".=", "'['", ";", "}", "$", "authority", ".=", "$", "this", "->", "host", ";", "if", "(", "$", "flag", ")", "{", "$", "authority", ".=", "']'", ";", "}", "if", "(", "$", "this", "->", "port", "!=", "null", ")", "{", "$", "authority", ".=", "':'", ".", "$", "this", "->", "port", ";", "}", "return", "$", "authority", ";", "}", "else", "{", "if", "(", "$", "this", "->", "scheme", ")", "{", "return", "'//'", ".", "$", "this", "->", "authority", ";", "}", "else", "{", "return", "$", "this", "->", "authority", ";", "}", "}", "}" ]
Returns the authority parts string of url @see buildStr() @return string
[ "Returns", "the", "authority", "parts", "string", "of", "url" ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L701-L728
1,461
webmaniacs-net/lib-uri
lib/Uri.php
Uri.withHost
public function withHost($host) { $url = clone $this; $url->host = $host; $url->hash = null; return $url; }
php
public function withHost($host) { $url = clone $this; $url->host = $host; $url->hash = null; return $url; }
[ "public", "function", "withHost", "(", "$", "host", ")", "{", "$", "url", "=", "clone", "$", "this", ";", "$", "url", "->", "host", "=", "$", "host", ";", "$", "url", "->", "hash", "=", "null", ";", "return", "$", "url", ";", "}" ]
Create a new instance with the specified host. This method MUST retain the state of the current instance, and return a new instance that contains the specified host. An empty host value is equivalent to removing the host. @param string $host Hostname to use with the new instance. @return self A new instance with the specified host. @throws \InvalidArgumentException for invalid hostnames.
[ "Create", "a", "new", "instance", "with", "the", "specified", "host", "." ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L788-L796
1,462
webmaniacs-net/lib-uri
lib/Uri.php
Uri.withPort
public function withPort($port) { $url = clone $this; $url->port = $port; $url->hash = null; return $url; }
php
public function withPort($port) { $url = clone $this; $url->port = $port; $url->hash = null; return $url; }
[ "public", "function", "withPort", "(", "$", "port", ")", "{", "$", "url", "=", "clone", "$", "this", ";", "$", "url", "->", "port", "=", "$", "port", ";", "$", "url", "->", "hash", "=", "null", ";", "return", "$", "url", ";", "}" ]
Create a new instance with the specified port. This method MUST retain the state of the current instance, and return a new instance that contains the specified port. Implementations MUST raise an exception for ports outside the established TCP and UDP port ranges. A null value provided for the port is equivalent to removing the port information. @param null|int $port Port to use with the new instance; a null value removes the port information. @return self A new instance with the specified port. @throws \InvalidArgumentException for invalid ports.
[ "Create", "a", "new", "instance", "with", "the", "specified", "port", "." ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L815-L822
1,463
webmaniacs-net/lib-uri
lib/Uri.php
Uri.withQuery
public function withQuery($query) { $url = clone $this; $url->query = $query; $url->hash = null; return $url; }
php
public function withQuery($query) { $url = clone $this; $url->query = $query; $url->hash = null; return $url; }
[ "public", "function", "withQuery", "(", "$", "query", ")", "{", "$", "url", "=", "clone", "$", "this", ";", "$", "url", "->", "query", "=", "$", "query", ";", "$", "url", "->", "hash", "=", "null", ";", "return", "$", "url", ";", "}" ]
Create a new instance with the specified query string. This method MUST retain the state of the current instance, and return a new instance that contains the specified query string. If the query string is prefixed by "?", that character MUST be removed. Additionally, the query string SHOULD be parseable by parse_str() in order to be valid. An empty query string value is equivalent to removing the query string. @param string $query The query string to use with the new instance. @return self A new instance with the specified query string. @throws \InvalidArgumentException for invalid query strings.
[ "Create", "a", "new", "instance", "with", "the", "specified", "query", "string", "." ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/Uri.php#L863-L870
1,464
osflab/container
PluginManager.php
PluginManager.registerApplicationPlugin
public static function registerApplicationPlugin(ApplicationPlugin $plugin, $priority = self::PRIORITY_NORMAL) { if ($priority != self::PRIORITY_HIGH && $priority != self::PRIORITY_NORMAL && $priority != self::PRIORITY_LOW) { throw new ArchException('Bad plugin priority'); } $pluginClass = get_class($plugin); if (isset(self::$plugins[$pluginClass])) { throw new ArchException('Plugin ' . $pluginClass . ' already registered'); } self::$plugins[$pluginClass] = $plugin; self::$pluginsOrder[$priority][] = $pluginClass; }
php
public static function registerApplicationPlugin(ApplicationPlugin $plugin, $priority = self::PRIORITY_NORMAL) { if ($priority != self::PRIORITY_HIGH && $priority != self::PRIORITY_NORMAL && $priority != self::PRIORITY_LOW) { throw new ArchException('Bad plugin priority'); } $pluginClass = get_class($plugin); if (isset(self::$plugins[$pluginClass])) { throw new ArchException('Plugin ' . $pluginClass . ' already registered'); } self::$plugins[$pluginClass] = $plugin; self::$pluginsOrder[$priority][] = $pluginClass; }
[ "public", "static", "function", "registerApplicationPlugin", "(", "ApplicationPlugin", "$", "plugin", ",", "$", "priority", "=", "self", "::", "PRIORITY_NORMAL", ")", "{", "if", "(", "$", "priority", "!=", "self", "::", "PRIORITY_HIGH", "&&", "$", "priority", "!=", "self", "::", "PRIORITY_NORMAL", "&&", "$", "priority", "!=", "self", "::", "PRIORITY_LOW", ")", "{", "throw", "new", "ArchException", "(", "'Bad plugin priority'", ")", ";", "}", "$", "pluginClass", "=", "get_class", "(", "$", "plugin", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "plugins", "[", "$", "pluginClass", "]", ")", ")", "{", "throw", "new", "ArchException", "(", "'Plugin '", ".", "$", "pluginClass", ".", "' already registered'", ")", ";", "}", "self", "::", "$", "plugins", "[", "$", "pluginClass", "]", "=", "$", "plugin", ";", "self", "::", "$", "pluginsOrder", "[", "$", "priority", "]", "[", "]", "=", "$", "pluginClass", ";", "}" ]
Register a MVC plugin @param PluginAbstract $plugin @param integer $priority @throws ArchException
[ "Register", "a", "MVC", "plugin" ]
415b374260ad377df00f8b3683b99f08bb4d25b6
https://github.com/osflab/container/blob/415b374260ad377df00f8b3683b99f08bb4d25b6/PluginManager.php#L46-L59
1,465
osflab/container
PluginManager.php
PluginManager.getApplicationPlugin
public static function getApplicationPlugin($pluginClass) { return isset(self::$plugins[$pluginClass]) ? self::$plugins[$pluginClass] : null; }
php
public static function getApplicationPlugin($pluginClass) { return isset(self::$plugins[$pluginClass]) ? self::$plugins[$pluginClass] : null; }
[ "public", "static", "function", "getApplicationPlugin", "(", "$", "pluginClass", ")", "{", "return", "isset", "(", "self", "::", "$", "plugins", "[", "$", "pluginClass", "]", ")", "?", "self", "::", "$", "plugins", "[", "$", "pluginClass", "]", ":", "null", ";", "}" ]
Get a registered plugin by class name @param string $pluginClass @return \Osf\Application\PluginAbstract
[ "Get", "a", "registered", "plugin", "by", "class", "name" ]
415b374260ad377df00f8b3683b99f08bb4d25b6
https://github.com/osflab/container/blob/415b374260ad377df00f8b3683b99f08bb4d25b6/PluginManager.php#L66-L69
1,466
osflab/container
PluginManager.php
PluginManager.handleApplicationPlugins
public static function handleApplicationPlugins($step) { foreach (self::$pluginsOrder as $plugins) { foreach ($plugins as $pluginClass) { self::$plugins[$pluginClass]->$step(); } } }
php
public static function handleApplicationPlugins($step) { foreach (self::$pluginsOrder as $plugins) { foreach ($plugins as $pluginClass) { self::$plugins[$pluginClass]->$step(); } } }
[ "public", "static", "function", "handleApplicationPlugins", "(", "$", "step", ")", "{", "foreach", "(", "self", "::", "$", "pluginsOrder", "as", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "pluginClass", ")", "{", "self", "::", "$", "plugins", "[", "$", "pluginClass", "]", "->", "$", "step", "(", ")", ";", "}", "}", "}" ]
Used in Application core, please do not touch @param string $step
[ "Used", "in", "Application", "core", "please", "do", "not", "touch" ]
415b374260ad377df00f8b3683b99f08bb4d25b6
https://github.com/osflab/container/blob/415b374260ad377df00f8b3683b99f08bb4d25b6/PluginManager.php#L75-L82
1,467
prestaconcept/PrestaCMSMediaBundle
Model/Carousel/Repository.php
Repository.findLimited
public function findLimited($limit = 0) { $queryBuilder = $this->createQueryBuilder('c') ->where('c.enabled = :enabled') ->orderBy('c.position') ->setParameters(array( 'enabled' => true, )); if ($limit != 0) { $queryBuilder->setMaxResults($limit); } return $queryBuilder->getQuery()->getResult(); }
php
public function findLimited($limit = 0) { $queryBuilder = $this->createQueryBuilder('c') ->where('c.enabled = :enabled') ->orderBy('c.position') ->setParameters(array( 'enabled' => true, )); if ($limit != 0) { $queryBuilder->setMaxResults($limit); } return $queryBuilder->getQuery()->getResult(); }
[ "public", "function", "findLimited", "(", "$", "limit", "=", "0", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'c'", ")", "->", "where", "(", "'c.enabled = :enabled'", ")", "->", "orderBy", "(", "'c.position'", ")", "->", "setParameters", "(", "array", "(", "'enabled'", "=>", "true", ",", ")", ")", ";", "if", "(", "$", "limit", "!=", "0", ")", "{", "$", "queryBuilder", "->", "setMaxResults", "(", "$", "limit", ")", ";", "}", "return", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Return a list of carousel items @param integer $limit @return ArrayCollection
[ "Return", "a", "list", "of", "carousel", "items" ]
e442d2bae2d1624f7ff234d003f82b5e1c6c4555
https://github.com/prestaconcept/PrestaCMSMediaBundle/blob/e442d2bae2d1624f7ff234d003f82b5e1c6c4555/Model/Carousel/Repository.php#L25-L39
1,468
imsamurai/cakephp-task-plugin
View/Helper/TaskHelper.php
TaskHelper.codeString
public function codeString(array $task, $full = true) { return $this->_isCli || (!$task['code_string']) ? $task['code_string'] : $this->Html->tag('span', $this->_text($task['code_string'], $full ? 0 : Configure::read('Task.truncateCode'), true), array( 'class' => 'label label-' . ($task['code_string'] == 'OK' ? 'success' : 'important' ))); }
php
public function codeString(array $task, $full = true) { return $this->_isCli || (!$task['code_string']) ? $task['code_string'] : $this->Html->tag('span', $this->_text($task['code_string'], $full ? 0 : Configure::read('Task.truncateCode'), true), array( 'class' => 'label label-' . ($task['code_string'] == 'OK' ? 'success' : 'important' ))); }
[ "public", "function", "codeString", "(", "array", "$", "task", ",", "$", "full", "=", "true", ")", "{", "return", "$", "this", "->", "_isCli", "||", "(", "!", "$", "task", "[", "'code_string'", "]", ")", "?", "$", "task", "[", "'code_string'", "]", ":", "$", "this", "->", "Html", "->", "tag", "(", "'span'", ",", "$", "this", "->", "_text", "(", "$", "task", "[", "'code_string'", "]", ",", "$", "full", "?", "0", ":", "Configure", "::", "read", "(", "'Task.truncateCode'", ")", ",", "true", ")", ",", "array", "(", "'class'", "=>", "'label label-'", ".", "(", "$", "task", "[", "'code_string'", "]", "==", "'OK'", "?", "'success'", ":", "'important'", ")", ")", ")", ";", "}" ]
String return code @param array $task @param bool $full @return string
[ "String", "return", "code" ]
9d7bd9fa908abf0ae5c24f27aa829a39ac034961
https://github.com/imsamurai/cakephp-task-plugin/blob/9d7bd9fa908abf0ae5c24f27aa829a39ac034961/View/Helper/TaskHelper.php#L252-L256
1,469
imsamurai/cakephp-task-plugin
View/Helper/TaskHelper.php
TaskHelper.waiting
public function waiting(array $tasks, $full = true) { $formattedTasks = $this->_formatWaiting($tasks, true); $tasksCount = count($formattedTasks); if ($tasksCount === 0) { return $this->_none(); } if ($this->_isCli) { return implode(', ', $formattedTasks); } elseif ($full) { return implode(', ', $this->_formatWaiting($tasks, false)); } else { $text = implode(', ', $this->_formatWaiting(array_slice($tasks, 0, Configure::read('Task.truncateWaitFor')), false)); $text .= $tasksCount > Configure::read('Task.truncateWaitFor') ? '...' : ''; return $this->Html->tag('span', $text, array( 'title' => implode(', ', $formattedTasks) )); } }
php
public function waiting(array $tasks, $full = true) { $formattedTasks = $this->_formatWaiting($tasks, true); $tasksCount = count($formattedTasks); if ($tasksCount === 0) { return $this->_none(); } if ($this->_isCli) { return implode(', ', $formattedTasks); } elseif ($full) { return implode(', ', $this->_formatWaiting($tasks, false)); } else { $text = implode(', ', $this->_formatWaiting(array_slice($tasks, 0, Configure::read('Task.truncateWaitFor')), false)); $text .= $tasksCount > Configure::read('Task.truncateWaitFor') ? '...' : ''; return $this->Html->tag('span', $text, array( 'title' => implode(', ', $formattedTasks) )); } }
[ "public", "function", "waiting", "(", "array", "$", "tasks", ",", "$", "full", "=", "true", ")", "{", "$", "formattedTasks", "=", "$", "this", "->", "_formatWaiting", "(", "$", "tasks", ",", "true", ")", ";", "$", "tasksCount", "=", "count", "(", "$", "formattedTasks", ")", ";", "if", "(", "$", "tasksCount", "===", "0", ")", "{", "return", "$", "this", "->", "_none", "(", ")", ";", "}", "if", "(", "$", "this", "->", "_isCli", ")", "{", "return", "implode", "(", "', '", ",", "$", "formattedTasks", ")", ";", "}", "elseif", "(", "$", "full", ")", "{", "return", "implode", "(", "', '", ",", "$", "this", "->", "_formatWaiting", "(", "$", "tasks", ",", "false", ")", ")", ";", "}", "else", "{", "$", "text", "=", "implode", "(", "', '", ",", "$", "this", "->", "_formatWaiting", "(", "array_slice", "(", "$", "tasks", ",", "0", ",", "Configure", "::", "read", "(", "'Task.truncateWaitFor'", ")", ")", ",", "false", ")", ")", ";", "$", "text", ".=", "$", "tasksCount", ">", "Configure", "::", "read", "(", "'Task.truncateWaitFor'", ")", "?", "'...'", ":", "''", ";", "return", "$", "this", "->", "Html", "->", "tag", "(", "'span'", ",", "$", "text", ",", "array", "(", "'title'", "=>", "implode", "(", "', '", ",", "$", "formattedTasks", ")", ")", ")", ";", "}", "}" ]
Waiting for tasks @param array $tasks @param bool $full @return string
[ "Waiting", "for", "tasks" ]
9d7bd9fa908abf0ae5c24f27aa829a39ac034961
https://github.com/imsamurai/cakephp-task-plugin/blob/9d7bd9fa908abf0ae5c24f27aa829a39ac034961/View/Helper/TaskHelper.php#L354-L372
1,470
imsamurai/cakephp-task-plugin
View/Helper/TaskHelper.php
TaskHelper.statistics
public function statistics(array $statistics) { if ($this->_isCli) { return $this->_none('Not allowed in cli'); } if (!$this->settings['chartEnabled']) { return $this->_none('Please install <b>imsamurai/cakephp-google-chart</b> plugin to view graph'); } if (empty($statistics)) { return $this->_none(); } $this->GoogleChart->load(); $chartData = $this->GoogleChart->dataFromArray(array( 'memory' => array_map('floatval', Hash::extract($statistics, '{n}.memory')), 'cpu' => array_map('floatval', Hash::extract($statistics, '{n}.cpu')), 'date' => array_map('strtotime', Hash::extract($statistics, '{n}.created')), 'statistics' => $statistics ), array( 'date' => array( 'v' => 'date.{n}', 'f' => 'statistics.{n}.created' ), 'memory' => 'memory.{n}', 'cpu' => 'cpu.{n}', '{"role": "annotation"}' => 'statistics.{n}.status', ) ); return $this->GoogleChart->draw('LineChart', $chartData, array( 'height' => 300, 'width' => 800, 'pointSize' => 5, 'vAxis' => array( 'title' => 'Percentage' ), 'hAxis' => array( 'title' => 'Time' ), 'chartArea' => array( 'left' => 50, 'top' => 10, 'height' => 230, 'width' => 650, ) ) ); }
php
public function statistics(array $statistics) { if ($this->_isCli) { return $this->_none('Not allowed in cli'); } if (!$this->settings['chartEnabled']) { return $this->_none('Please install <b>imsamurai/cakephp-google-chart</b> plugin to view graph'); } if (empty($statistics)) { return $this->_none(); } $this->GoogleChart->load(); $chartData = $this->GoogleChart->dataFromArray(array( 'memory' => array_map('floatval', Hash::extract($statistics, '{n}.memory')), 'cpu' => array_map('floatval', Hash::extract($statistics, '{n}.cpu')), 'date' => array_map('strtotime', Hash::extract($statistics, '{n}.created')), 'statistics' => $statistics ), array( 'date' => array( 'v' => 'date.{n}', 'f' => 'statistics.{n}.created' ), 'memory' => 'memory.{n}', 'cpu' => 'cpu.{n}', '{"role": "annotation"}' => 'statistics.{n}.status', ) ); return $this->GoogleChart->draw('LineChart', $chartData, array( 'height' => 300, 'width' => 800, 'pointSize' => 5, 'vAxis' => array( 'title' => 'Percentage' ), 'hAxis' => array( 'title' => 'Time' ), 'chartArea' => array( 'left' => 50, 'top' => 10, 'height' => 230, 'width' => 650, ) ) ); }
[ "public", "function", "statistics", "(", "array", "$", "statistics", ")", "{", "if", "(", "$", "this", "->", "_isCli", ")", "{", "return", "$", "this", "->", "_none", "(", "'Not allowed in cli'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "settings", "[", "'chartEnabled'", "]", ")", "{", "return", "$", "this", "->", "_none", "(", "'Please install <b>imsamurai/cakephp-google-chart</b> plugin to view graph'", ")", ";", "}", "if", "(", "empty", "(", "$", "statistics", ")", ")", "{", "return", "$", "this", "->", "_none", "(", ")", ";", "}", "$", "this", "->", "GoogleChart", "->", "load", "(", ")", ";", "$", "chartData", "=", "$", "this", "->", "GoogleChart", "->", "dataFromArray", "(", "array", "(", "'memory'", "=>", "array_map", "(", "'floatval'", ",", "Hash", "::", "extract", "(", "$", "statistics", ",", "'{n}.memory'", ")", ")", ",", "'cpu'", "=>", "array_map", "(", "'floatval'", ",", "Hash", "::", "extract", "(", "$", "statistics", ",", "'{n}.cpu'", ")", ")", ",", "'date'", "=>", "array_map", "(", "'strtotime'", ",", "Hash", "::", "extract", "(", "$", "statistics", ",", "'{n}.created'", ")", ")", ",", "'statistics'", "=>", "$", "statistics", ")", ",", "array", "(", "'date'", "=>", "array", "(", "'v'", "=>", "'date.{n}'", ",", "'f'", "=>", "'statistics.{n}.created'", ")", ",", "'memory'", "=>", "'memory.{n}'", ",", "'cpu'", "=>", "'cpu.{n}'", ",", "'{\"role\": \"annotation\"}'", "=>", "'statistics.{n}.status'", ",", ")", ")", ";", "return", "$", "this", "->", "GoogleChart", "->", "draw", "(", "'LineChart'", ",", "$", "chartData", ",", "array", "(", "'height'", "=>", "300", ",", "'width'", "=>", "800", ",", "'pointSize'", "=>", "5", ",", "'vAxis'", "=>", "array", "(", "'title'", "=>", "'Percentage'", ")", ",", "'hAxis'", "=>", "array", "(", "'title'", "=>", "'Time'", ")", ",", "'chartArea'", "=>", "array", "(", "'left'", "=>", "50", ",", "'top'", "=>", "10", ",", "'height'", "=>", "230", ",", "'width'", "=>", "650", ",", ")", ")", ")", ";", "}" ]
Make statistics graph @param array $statistics @return string
[ "Make", "statistics", "graph" ]
9d7bd9fa908abf0ae5c24f27aa829a39ac034961
https://github.com/imsamurai/cakephp-task-plugin/blob/9d7bd9fa908abf0ae5c24f27aa829a39ac034961/View/Helper/TaskHelper.php#L380-L427
1,471
imsamurai/cakephp-task-plugin
View/Helper/TaskHelper.php
TaskHelper._formatWaiting
protected function _formatWaiting(array $tasks, $plain) { $dependsOnTaskFormatted = array(); foreach ($tasks as $task) { if (!in_array((int)$task['status'], array(TaskType::DEFFERED, TaskType::RUNNING, TaskType::STOPPING, TaskType::UNSTARTED))) { continue; } $dependsOnTaskFormatted[] = $plain ? $task['id'] : $this->id($task); } return $dependsOnTaskFormatted; }
php
protected function _formatWaiting(array $tasks, $plain) { $dependsOnTaskFormatted = array(); foreach ($tasks as $task) { if (!in_array((int)$task['status'], array(TaskType::DEFFERED, TaskType::RUNNING, TaskType::STOPPING, TaskType::UNSTARTED))) { continue; } $dependsOnTaskFormatted[] = $plain ? $task['id'] : $this->id($task); } return $dependsOnTaskFormatted; }
[ "protected", "function", "_formatWaiting", "(", "array", "$", "tasks", ",", "$", "plain", ")", "{", "$", "dependsOnTaskFormatted", "=", "array", "(", ")", ";", "foreach", "(", "$", "tasks", "as", "$", "task", ")", "{", "if", "(", "!", "in_array", "(", "(", "int", ")", "$", "task", "[", "'status'", "]", ",", "array", "(", "TaskType", "::", "DEFFERED", ",", "TaskType", "::", "RUNNING", ",", "TaskType", "::", "STOPPING", ",", "TaskType", "::", "UNSTARTED", ")", ")", ")", "{", "continue", ";", "}", "$", "dependsOnTaskFormatted", "[", "]", "=", "$", "plain", "?", "$", "task", "[", "'id'", "]", ":", "$", "this", "->", "id", "(", "$", "task", ")", ";", "}", "return", "$", "dependsOnTaskFormatted", ";", "}" ]
Waiting tasks formatter @param array $tasks @param bool $plain @return array
[ "Waiting", "tasks", "formatter" ]
9d7bd9fa908abf0ae5c24f27aa829a39ac034961
https://github.com/imsamurai/cakephp-task-plugin/blob/9d7bd9fa908abf0ae5c24f27aa829a39ac034961/View/Helper/TaskHelper.php#L436-L445
1,472
imsamurai/cakephp-task-plugin
View/Helper/TaskHelper.php
TaskHelper._dateDiff
protected function _dateDiff($start = null, $stop = null) { if ($start) { $endDate = $stop instanceof DateTime ? $stop : new DateTime($stop ? $stop : 'now'); $startDate = $start instanceof DateTime ? $start : new DateTime($start); $diff = $startDate->diff($endDate)->format(Configure::read('Task.dateDiffFormat')); return $this->_isCli ? $diff : $this->Html->tag('span', $diff); } else { return $this->_none(); } }
php
protected function _dateDiff($start = null, $stop = null) { if ($start) { $endDate = $stop instanceof DateTime ? $stop : new DateTime($stop ? $stop : 'now'); $startDate = $start instanceof DateTime ? $start : new DateTime($start); $diff = $startDate->diff($endDate)->format(Configure::read('Task.dateDiffFormat')); return $this->_isCli ? $diff : $this->Html->tag('span', $diff); } else { return $this->_none(); } }
[ "protected", "function", "_dateDiff", "(", "$", "start", "=", "null", ",", "$", "stop", "=", "null", ")", "{", "if", "(", "$", "start", ")", "{", "$", "endDate", "=", "$", "stop", "instanceof", "DateTime", "?", "$", "stop", ":", "new", "DateTime", "(", "$", "stop", "?", "$", "stop", ":", "'now'", ")", ";", "$", "startDate", "=", "$", "start", "instanceof", "DateTime", "?", "$", "start", ":", "new", "DateTime", "(", "$", "start", ")", ";", "$", "diff", "=", "$", "startDate", "->", "diff", "(", "$", "endDate", ")", "->", "format", "(", "Configure", "::", "read", "(", "'Task.dateDiffFormat'", ")", ")", ";", "return", "$", "this", "->", "_isCli", "?", "$", "diff", ":", "$", "this", "->", "Html", "->", "tag", "(", "'span'", ",", "$", "diff", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_none", "(", ")", ";", "}", "}" ]
Date diff formatter @param DateTime|string $start @param DateTime|string $stop @return string
[ "Date", "diff", "formatter" ]
9d7bd9fa908abf0ae5c24f27aa829a39ac034961
https://github.com/imsamurai/cakephp-task-plugin/blob/9d7bd9fa908abf0ae5c24f27aa829a39ac034961/View/Helper/TaskHelper.php#L465-L474
1,473
jianfengye/hades
src/Hades/Route/Manager.php
Manager.get
public static function get($uri, $callback, $params = []) { if (is_string($callback)) { $callback = self::str2closure($callback); } $middlewares = array_merge(self::middlewaresByParams($params), self::middlewaresByParams(self::$group_params)); self::$routes[] = new Route('get', $uri, $callback, $middlewares); }
php
public static function get($uri, $callback, $params = []) { if (is_string($callback)) { $callback = self::str2closure($callback); } $middlewares = array_merge(self::middlewaresByParams($params), self::middlewaresByParams(self::$group_params)); self::$routes[] = new Route('get', $uri, $callback, $middlewares); }
[ "public", "static", "function", "get", "(", "$", "uri", ",", "$", "callback", ",", "$", "params", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "callback", ")", ")", "{", "$", "callback", "=", "self", "::", "str2closure", "(", "$", "callback", ")", ";", "}", "$", "middlewares", "=", "array_merge", "(", "self", "::", "middlewaresByParams", "(", "$", "params", ")", ",", "self", "::", "middlewaresByParams", "(", "self", "::", "$", "group_params", ")", ")", ";", "self", "::", "$", "routes", "[", "]", "=", "new", "Route", "(", "'get'", ",", "$", "uri", ",", "$", "callback", ",", "$", "middlewares", ")", ";", "}" ]
set get route
[ "set", "get", "route" ]
a0690d96dada070b4cf4b9ff63ab3aa024c34a67
https://github.com/jianfengye/hades/blob/a0690d96dada070b4cf4b9ff63ab3aa024c34a67/src/Hades/Route/Manager.php#L27-L36
1,474
jianfengye/hades
src/Hades/Route/Manager.php
Manager.str2closure
private static function str2closure($controllerAction) { list($controller, $action) = explode('@', $controllerAction); return function($request) use ($controller, $action) { $c = new $controller; return call_user_func([$c, $action], $request); }; }
php
private static function str2closure($controllerAction) { list($controller, $action) = explode('@', $controllerAction); return function($request) use ($controller, $action) { $c = new $controller; return call_user_func([$c, $action], $request); }; }
[ "private", "static", "function", "str2closure", "(", "$", "controllerAction", ")", "{", "list", "(", "$", "controller", ",", "$", "action", ")", "=", "explode", "(", "'@'", ",", "$", "controllerAction", ")", ";", "return", "function", "(", "$", "request", ")", "use", "(", "$", "controller", ",", "$", "action", ")", "{", "$", "c", "=", "new", "$", "controller", ";", "return", "call_user_func", "(", "[", "$", "c", ",", "$", "action", "]", ",", "$", "request", ")", ";", "}", ";", "}" ]
convert string to closure
[ "convert", "string", "to", "closure" ]
a0690d96dada070b4cf4b9ff63ab3aa024c34a67
https://github.com/jianfengye/hades/blob/a0690d96dada070b4cf4b9ff63ab3aa024c34a67/src/Hades/Route/Manager.php#L81-L88
1,475
donghaichen/session
src/Flash.php
Flash.get
public function get($key, $default = null) { if(isset($this->data[$key])) { return $this->data[$key]; } return isset($this->session[$key]) ? $this->session[$key] : $default; }
php
public function get($key, $default = null) { if(isset($this->data[$key])) { return $this->data[$key]; } return isset($this->session[$key]) ? $this->session[$key] : $default; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "$", "key", "]", ";", "}", "return", "isset", "(", "$", "this", "->", "session", "[", "$", "key", "]", ")", "?", "$", "this", "->", "session", "[", "$", "key", "]", ":", "$", "default", ";", "}" ]
Retrive a value @access public @param string $key Key @param mixed $default (optional) Default value @return \Clovers\Session\Flash
[ "Retrive", "a", "value" ]
704e506f06fdc9641f80ebde60e092027447624f
https://github.com/donghaichen/session/blob/704e506f06fdc9641f80ebde60e092027447624f/src/Flash.php#L47-L55
1,476
donghaichen/session
src/Flash.php
Flash.load
public function load($key, Clovers $callback) { if(!$this->has($key)) { $this->set($key, $callback($key)); } return $this->get($key); }
php
public function load($key, Clovers $callback) { if(!$this->has($key)) { $this->set($key, $callback($key)); } return $this->get($key); }
[ "public", "function", "load", "(", "$", "key", ",", "Clovers", "$", "callback", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "callback", "(", "$", "key", ")", ")", ";", "}", "return", "$", "this", "->", "get", "(", "$", "key", ")", ";", "}" ]
Retrive the value associated with the specified key or associate the specified key with the value returned by invoking the callback. @access public @param string $key Key @param \Clovers $callback Callback @return mixed
[ "Retrive", "the", "value", "associated", "with", "the", "specified", "key", "or", "associate", "the", "specified", "key", "with", "the", "value", "returned", "by", "invoking", "the", "callback", "." ]
704e506f06fdc9641f80ebde60e092027447624f
https://github.com/donghaichen/session/blob/704e506f06fdc9641f80ebde60e092027447624f/src/Flash.php#L69-L77
1,477
HustleWorks/chute
src/ImageUploader.php
ImageUploader.handle
public function handle($framework_file, ImageConfiguration $config, array $optional_data = []) { /* Create ImageFile object for processing */ $image_file = $this->prepareImageFile($framework_file); /* run validation on upload */ $response = $this->validator->validate($image_file, $config->rules); /* if valid create database entry, store image to disk and generate response */ if ($response->success()) { if ($record = $this->image_repo->findExistingImageable($config->optional_data)) { $this->image_repo->delete($record); } $record = $this->image_repo->create([ 'name' => $config->image_name, 'disk' => $config->temp_disk, 'filename' => $image_file->filename, 'path' => $config->directory, 'status' => 'pending', 'width' => $image_file->width, 'height' => $image_file->height, 'mime_type' => $image_file->mime_type, 'extension' => $image_file->extension, 'size' => $image_file->size, 'alt' => $optional_data['alt'] ?? null, 'title' => $optional_data['title'] ?? null, 'description' => $optional_data['description'] ?? null, ]); $this->storage->put($image_file->stream, $record->disk, "$record->path/$record->uuid", $record->filename); $response = new StandardServiceResponse(true, [ 'image' => $record, ], 'File successfully uploaded'); } return $response; }
php
public function handle($framework_file, ImageConfiguration $config, array $optional_data = []) { /* Create ImageFile object for processing */ $image_file = $this->prepareImageFile($framework_file); /* run validation on upload */ $response = $this->validator->validate($image_file, $config->rules); /* if valid create database entry, store image to disk and generate response */ if ($response->success()) { if ($record = $this->image_repo->findExistingImageable($config->optional_data)) { $this->image_repo->delete($record); } $record = $this->image_repo->create([ 'name' => $config->image_name, 'disk' => $config->temp_disk, 'filename' => $image_file->filename, 'path' => $config->directory, 'status' => 'pending', 'width' => $image_file->width, 'height' => $image_file->height, 'mime_type' => $image_file->mime_type, 'extension' => $image_file->extension, 'size' => $image_file->size, 'alt' => $optional_data['alt'] ?? null, 'title' => $optional_data['title'] ?? null, 'description' => $optional_data['description'] ?? null, ]); $this->storage->put($image_file->stream, $record->disk, "$record->path/$record->uuid", $record->filename); $response = new StandardServiceResponse(true, [ 'image' => $record, ], 'File successfully uploaded'); } return $response; }
[ "public", "function", "handle", "(", "$", "framework_file", ",", "ImageConfiguration", "$", "config", ",", "array", "$", "optional_data", "=", "[", "]", ")", "{", "/* Create ImageFile object for processing */", "$", "image_file", "=", "$", "this", "->", "prepareImageFile", "(", "$", "framework_file", ")", ";", "/* run validation on upload */", "$", "response", "=", "$", "this", "->", "validator", "->", "validate", "(", "$", "image_file", ",", "$", "config", "->", "rules", ")", ";", "/* if valid create database entry, store image to disk and generate response */", "if", "(", "$", "response", "->", "success", "(", ")", ")", "{", "if", "(", "$", "record", "=", "$", "this", "->", "image_repo", "->", "findExistingImageable", "(", "$", "config", "->", "optional_data", ")", ")", "{", "$", "this", "->", "image_repo", "->", "delete", "(", "$", "record", ")", ";", "}", "$", "record", "=", "$", "this", "->", "image_repo", "->", "create", "(", "[", "'name'", "=>", "$", "config", "->", "image_name", ",", "'disk'", "=>", "$", "config", "->", "temp_disk", ",", "'filename'", "=>", "$", "image_file", "->", "filename", ",", "'path'", "=>", "$", "config", "->", "directory", ",", "'status'", "=>", "'pending'", ",", "'width'", "=>", "$", "image_file", "->", "width", ",", "'height'", "=>", "$", "image_file", "->", "height", ",", "'mime_type'", "=>", "$", "image_file", "->", "mime_type", ",", "'extension'", "=>", "$", "image_file", "->", "extension", ",", "'size'", "=>", "$", "image_file", "->", "size", ",", "'alt'", "=>", "$", "optional_data", "[", "'alt'", "]", "??", "null", ",", "'title'", "=>", "$", "optional_data", "[", "'title'", "]", "??", "null", ",", "'description'", "=>", "$", "optional_data", "[", "'description'", "]", "??", "null", ",", "]", ")", ";", "$", "this", "->", "storage", "->", "put", "(", "$", "image_file", "->", "stream", ",", "$", "record", "->", "disk", ",", "\"$record->path/$record->uuid\"", ",", "$", "record", "->", "filename", ")", ";", "$", "response", "=", "new", "StandardServiceResponse", "(", "true", ",", "[", "'image'", "=>", "$", "record", ",", "]", ",", "'File successfully uploaded'", ")", ";", "}", "return", "$", "response", ";", "}" ]
Handle Image Upload @param mixed $framework_file @param ImageConfiguration $config @param array $optional_data @return ServiceResponse
[ "Handle", "Image", "Upload" ]
ede5a83dd74925e734b9b0063502c7e4b9085cb2
https://github.com/HustleWorks/chute/blob/ede5a83dd74925e734b9b0063502c7e4b9085cb2/src/ImageUploader.php#L56-L94
1,478
tacone/datasource
src/AbstractEloquentDataSource.php
AbstractEloquentDataSource.createChild
protected function createChild($key) { $relation = $this->getValueOrRelationForKey($key); // if this is not a relation, then it's the actual value // returned by a method (like for example computed attributes) // so we just return it as the value if (!$relation instanceof Relation) { return $relation; } $this->supportedRelationOrThrow($key, $relation); // TODO we need to bind the relation to the datasource here $model = Rel::make($relation)->getChild(); if (!$this->isEloquentObject($model)) { throw new \LogicException(sprintf( 'newModelFromRelation should return an Eloquent Model/Collection, but returned a %s (parent: %s, key: %s, relation: %s)', get_type_class($model), get_type_class($this->getDelegatedStorage()), $key, get_type_class($relation) )); } return $model; }
php
protected function createChild($key) { $relation = $this->getValueOrRelationForKey($key); // if this is not a relation, then it's the actual value // returned by a method (like for example computed attributes) // so we just return it as the value if (!$relation instanceof Relation) { return $relation; } $this->supportedRelationOrThrow($key, $relation); // TODO we need to bind the relation to the datasource here $model = Rel::make($relation)->getChild(); if (!$this->isEloquentObject($model)) { throw new \LogicException(sprintf( 'newModelFromRelation should return an Eloquent Model/Collection, but returned a %s (parent: %s, key: %s, relation: %s)', get_type_class($model), get_type_class($this->getDelegatedStorage()), $key, get_type_class($relation) )); } return $model; }
[ "protected", "function", "createChild", "(", "$", "key", ")", "{", "$", "relation", "=", "$", "this", "->", "getValueOrRelationForKey", "(", "$", "key", ")", ";", "// if this is not a relation, then it's the actual value", "// returned by a method (like for example computed attributes)", "// so we just return it as the value", "if", "(", "!", "$", "relation", "instanceof", "Relation", ")", "{", "return", "$", "relation", ";", "}", "$", "this", "->", "supportedRelationOrThrow", "(", "$", "key", ",", "$", "relation", ")", ";", "// TODO we need to bind the relation to the datasource here", "$", "model", "=", "Rel", "::", "make", "(", "$", "relation", ")", "->", "getChild", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isEloquentObject", "(", "$", "model", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'newModelFromRelation should return an Eloquent Model/Collection, but returned a %s (parent: %s, key: %s, relation: %s)'", ",", "get_type_class", "(", "$", "model", ")", ",", "get_type_class", "(", "$", "this", "->", "getDelegatedStorage", "(", ")", ")", ",", "$", "key", ",", "get_type_class", "(", "$", "relation", ")", ")", ")", ";", "}", "return", "$", "model", ";", "}" ]
Caches a relation for later use. Creates a new model in case of empty values. We need to invoke this method for every field we want to save later, no exception @param $key @param $model @return mixed
[ "Caches", "a", "relation", "for", "later", "use", ".", "Creates", "a", "new", "model", "in", "case", "of", "empty", "values", "." ]
9cf4423764ba14e9bbd9fa7d5cdbed27d70001f3
https://github.com/tacone/datasource/blob/9cf4423764ba14e9bbd9fa7d5cdbed27d70001f3/src/AbstractEloquentDataSource.php#L57-L82
1,479
snowiow/cocurl
src/Client.php
Client.clans
public function clans($param, $members = false) { if (is_array($param)) { return $this->_clansByFilter($param); } else if ($members) { return $this->_clansMembersOnly($param); } return $this->_clanById($param); }
php
public function clans($param, $members = false) { if (is_array($param)) { return $this->_clansByFilter($param); } else if ($members) { return $this->_clansMembersOnly($param); } return $this->_clanById($param); }
[ "public", "function", "clans", "(", "$", "param", ",", "$", "members", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "param", ")", ")", "{", "return", "$", "this", "->", "_clansByFilter", "(", "$", "param", ")", ";", "}", "else", "if", "(", "$", "members", ")", "{", "return", "$", "this", "->", "_clansMembersOnly", "(", "$", "param", ")", ";", "}", "return", "$", "this", "->", "_clanById", "(", "$", "param", ")", ";", "}" ]
Search for clans by different approaches. @param array|string $param if array it represents the possible filters, which can be send to the coc api. If it is a string it represents the clan tag which is send @return array|Clan if searched with filters, it returns an array with clans, who match the filter. If searched by tag, the Clan object is returned
[ "Search", "for", "clans", "by", "different", "approaches", "." ]
583df05bd3c8f24fd99f294da9906a3e4b1a9c7b
https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/Client.php#L121-L129
1,480
snowiow/cocurl
src/Client.php
Client._clansMembersOnly
private function _clansMembersOnly(string $param): array { $curlClient = curl_init( self::BASE_URL . self::CLANS_URL . '/' . \urlencode($param) . '/members' ); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $results = json_decode(curl_exec($curlClient), true); $members = []; foreach ($results['items'] as $result) { $members[] = Player::create($result); } return $members; }
php
private function _clansMembersOnly(string $param): array { $curlClient = curl_init( self::BASE_URL . self::CLANS_URL . '/' . \urlencode($param) . '/members' ); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $results = json_decode(curl_exec($curlClient), true); $members = []; foreach ($results['items'] as $result) { $members[] = Player::create($result); } return $members; }
[ "private", "function", "_clansMembersOnly", "(", "string", "$", "param", ")", ":", "array", "{", "$", "curlClient", "=", "curl_init", "(", "self", "::", "BASE_URL", ".", "self", "::", "CLANS_URL", ".", "'/'", ".", "\\", "urlencode", "(", "$", "param", ")", ".", "'/members'", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_HTTPHEADER", ",", "$", "this", "->", "_curlHeader", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "results", "=", "json_decode", "(", "curl_exec", "(", "$", "curlClient", ")", ",", "true", ")", ";", "$", "members", "=", "[", "]", ";", "foreach", "(", "$", "results", "[", "'items'", "]", "as", "$", "result", ")", "{", "$", "members", "[", "]", "=", "Player", "::", "create", "(", "$", "result", ")", ";", "}", "return", "$", "members", ";", "}" ]
Search for clan members only of a specific clan @param string $param the clan tag @return array array of player who are members of the clan, hwich matches the clan tag
[ "Search", "for", "clan", "members", "only", "of", "a", "specific", "clan" ]
583df05bd3c8f24fd99f294da9906a3e4b1a9c7b
https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/Client.php#L137-L154
1,481
snowiow/cocurl
src/Client.php
Client._clanById
private function _clanById(string $param): Clan { $curlClient = curl_init( self::BASE_URL . self::CLANS_URL . '/' . \urlencode($param) ); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $result = json_decode(curl_exec($curlClient), true); return Clan::create($result); }
php
private function _clanById(string $param): Clan { $curlClient = curl_init( self::BASE_URL . self::CLANS_URL . '/' . \urlencode($param) ); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $result = json_decode(curl_exec($curlClient), true); return Clan::create($result); }
[ "private", "function", "_clanById", "(", "string", "$", "param", ")", ":", "Clan", "{", "$", "curlClient", "=", "curl_init", "(", "self", "::", "BASE_URL", ".", "self", "::", "CLANS_URL", ".", "'/'", ".", "\\", "urlencode", "(", "$", "param", ")", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_HTTPHEADER", ",", "$", "this", "->", "_curlHeader", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "result", "=", "json_decode", "(", "curl_exec", "(", "$", "curlClient", ")", ",", "true", ")", ";", "return", "Clan", "::", "create", "(", "$", "result", ")", ";", "}" ]
Retrieves the clan, who matches the given id @param string $param the clan tag @return Clan a Clan object, containing the searched clan
[ "Retrieves", "the", "clan", "who", "matches", "the", "given", "id" ]
583df05bd3c8f24fd99f294da9906a3e4b1a9c7b
https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/Client.php#L161-L173
1,482
snowiow/cocurl
src/Client.php
Client._clansByFilter
private function _clansByFilter(array $params): array { $url = self::BASE_URL . self::CLANS_URL . '?'; $url .= http_build_query($params); $curlClient = curl_init($url); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $results = json_decode(curl_exec($curlClient), true); $clans = []; foreach ($results['items'] as $result) { $clans[] = Clan::create($result); } return $clans; }
php
private function _clansByFilter(array $params): array { $url = self::BASE_URL . self::CLANS_URL . '?'; $url .= http_build_query($params); $curlClient = curl_init($url); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $results = json_decode(curl_exec($curlClient), true); $clans = []; foreach ($results['items'] as $result) { $clans[] = Clan::create($result); } return $clans; }
[ "private", "function", "_clansByFilter", "(", "array", "$", "params", ")", ":", "array", "{", "$", "url", "=", "self", "::", "BASE_URL", ".", "self", "::", "CLANS_URL", ".", "'?'", ";", "$", "url", ".=", "http_build_query", "(", "$", "params", ")", ";", "$", "curlClient", "=", "curl_init", "(", "$", "url", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_HTTPHEADER", ",", "$", "this", "->", "_curlHeader", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "results", "=", "json_decode", "(", "curl_exec", "(", "$", "curlClient", ")", ",", "true", ")", ";", "$", "clans", "=", "[", "]", ";", "foreach", "(", "$", "results", "[", "'items'", "]", "as", "$", "result", ")", "{", "$", "clans", "[", "]", "=", "Clan", "::", "create", "(", "$", "result", ")", ";", "}", "return", "$", "clans", ";", "}" ]
Retrieves a list of clans, who matches a set of filters @param array $params an array of filters. Keys are the names of filters, like they are defined in the coc api, values are the filter values @return array an array of clans who match the filters
[ "Retrieves", "a", "list", "of", "clans", "who", "matches", "a", "set", "of", "filters" ]
583df05bd3c8f24fd99f294da9906a3e4b1a9c7b
https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/Client.php#L181-L195
1,483
snowiow/cocurl
src/Client.php
Client._locationsById
private function _locationsById(int $id): Location { $curlClient = curl_init(self::BASE_URL . self::LOCATIONS_URL . '/' . $id); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $result = json_decode(curl_exec($curlClient), true); return Location::create($result); }
php
private function _locationsById(int $id): Location { $curlClient = curl_init(self::BASE_URL . self::LOCATIONS_URL . '/' . $id); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $result = json_decode(curl_exec($curlClient), true); return Location::create($result); }
[ "private", "function", "_locationsById", "(", "int", "$", "id", ")", ":", "Location", "{", "$", "curlClient", "=", "curl_init", "(", "self", "::", "BASE_URL", ".", "self", "::", "LOCATIONS_URL", ".", "'/'", ".", "$", "id", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_HTTPHEADER", ",", "$", "this", "->", "_curlHeader", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "result", "=", "json_decode", "(", "curl_exec", "(", "$", "curlClient", ")", ",", "true", ")", ";", "return", "Location", "::", "create", "(", "$", "result", ")", ";", "}" ]
Returns a location with the given id @param int $id the unique identifier of the location @return The Location with the given id
[ "Returns", "a", "location", "with", "the", "given", "id" ]
583df05bd3c8f24fd99f294da9906a3e4b1a9c7b
https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/Client.php#L202-L209
1,484
snowiow/cocurl
src/Client.php
Client._locationsByIdAndRank
private function _locationsByIdAndRank(int $id, $rank) { $curlClient = curl_init( self::BASE_URL . self::LOCATIONS_URL . '/' . $id . '/rankings/' . $rank ); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $results = json_decode(curl_exec($curlClient), true); $items = []; foreach ($results['items'] as $result) { if ($rank === RankingId::CLANS) { $items[] = Clan::create($result); } else { $items[] = Player::create($result); } } return $items; }
php
private function _locationsByIdAndRank(int $id, $rank) { $curlClient = curl_init( self::BASE_URL . self::LOCATIONS_URL . '/' . $id . '/rankings/' . $rank ); curl_setopt($curlClient, CURLOPT_HTTPHEADER, $this->_curlHeader); curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, true); $results = json_decode(curl_exec($curlClient), true); $items = []; foreach ($results['items'] as $result) { if ($rank === RankingId::CLANS) { $items[] = Clan::create($result); } else { $items[] = Player::create($result); } } return $items; }
[ "private", "function", "_locationsByIdAndRank", "(", "int", "$", "id", ",", "$", "rank", ")", "{", "$", "curlClient", "=", "curl_init", "(", "self", "::", "BASE_URL", ".", "self", "::", "LOCATIONS_URL", ".", "'/'", ".", "$", "id", ".", "'/rankings/'", ".", "$", "rank", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_HTTPHEADER", ",", "$", "this", "->", "_curlHeader", ")", ";", "curl_setopt", "(", "$", "curlClient", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "results", "=", "json_decode", "(", "curl_exec", "(", "$", "curlClient", ")", ",", "true", ")", ";", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "results", "[", "'items'", "]", "as", "$", "result", ")", "{", "if", "(", "$", "rank", "===", "RankingId", "::", "CLANS", ")", "{", "$", "items", "[", "]", "=", "Clan", "::", "create", "(", "$", "result", ")", ";", "}", "else", "{", "$", "items", "[", "]", "=", "Player", "::", "create", "(", "$", "result", ")", ";", "}", "}", "return", "$", "items", ";", "}" ]
Based on a Location, retrieve the local rankings @param int $id the unique identifier of the location @param string|RankingId $rank the kind of ranking you want to retrieve. Based on Clans and based on players is supported at the moment. @return The clans/player who are located at the location id
[ "Based", "on", "a", "Location", "retrieve", "the", "local", "rankings" ]
583df05bd3c8f24fd99f294da9906a3e4b1a9c7b
https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/Client.php#L218-L240
1,485
affinitidev/silex-config
Source/Loader/Concrete/YamlLoader.php
YamlLoader.load
public function load($resource, $type = null) { $path = $this->locator->locate($resource); if (!stream_is_local($path)) { throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path)); } if (!file_exists($path)) { throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path)); } $this->loaded[$resource] = $path; return Yaml::parse(file_get_contents($path)); }
php
public function load($resource, $type = null) { $path = $this->locator->locate($resource); if (!stream_is_local($path)) { throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path)); } if (!file_exists($path)) { throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path)); } $this->loaded[$resource] = $path; return Yaml::parse(file_get_contents($path)); }
[ "public", "function", "load", "(", "$", "resource", ",", "$", "type", "=", "null", ")", "{", "$", "path", "=", "$", "this", "->", "locator", "->", "locate", "(", "$", "resource", ")", ";", "if", "(", "!", "stream_is_local", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'This is not a local file \"%s\".'", ",", "$", "path", ")", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'File \"%s\" not found.'", ",", "$", "path", ")", ")", ";", "}", "$", "this", "->", "loaded", "[", "$", "resource", "]", "=", "$", "path", ";", "return", "Yaml", "::", "parse", "(", "file_get_contents", "(", "$", "path", ")", ")", ";", "}" ]
Loads and parses the given Yaml file into a PHP array. @param string $resource @param string $type
[ "Loads", "and", "parses", "the", "given", "Yaml", "file", "into", "a", "PHP", "array", "." ]
6c9cd170b26a6d30f31334ccfaca203304ad8f72
https://github.com/affinitidev/silex-config/blob/6c9cd170b26a6d30f31334ccfaca203304ad8f72/Source/Loader/Concrete/YamlLoader.php#L30-L45
1,486
bugotech/http
src/Exceptions/HttpException.php
HttpException.getResponse
public function getResponse() { $response = redirect()->to($this->getRedirectUrl()); $response->withInput($this->request->input()); $response->withErrors($this->getErrors(), 'default'); $response->setCharset(config('app.charset', 'UTF-8')); return $response; }
php
public function getResponse() { $response = redirect()->to($this->getRedirectUrl()); $response->withInput($this->request->input()); $response->withErrors($this->getErrors(), 'default'); $response->setCharset(config('app.charset', 'UTF-8')); return $response; }
[ "public", "function", "getResponse", "(", ")", "{", "$", "response", "=", "redirect", "(", ")", "->", "to", "(", "$", "this", "->", "getRedirectUrl", "(", ")", ")", ";", "$", "response", "->", "withInput", "(", "$", "this", "->", "request", "->", "input", "(", ")", ")", ";", "$", "response", "->", "withErrors", "(", "$", "this", "->", "getErrors", "(", ")", ",", "'default'", ")", ";", "$", "response", "->", "setCharset", "(", "config", "(", "'app.charset'", ",", "'UTF-8'", ")", ")", ";", "return", "$", "response", ";", "}" ]
Get the underlying response instance. @return \Symfony\Component\HttpFoundation\Response
[ "Get", "the", "underlying", "response", "instance", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Exceptions/HttpException.php#L44-L52
1,487
bugotech/http
src/Exceptions/HttpException.php
HttpException.getErrors
protected function getErrors() { $arr = ['error' => $this->getMessage()]; if (count($this->attrs) > 0) { $arr['attrs'] = $this->getAttrs(); } if (count($this->attrsCustom) > 0) { $arr['attrscustom'] = $this->getAttrsCustom(); } return $arr; }
php
protected function getErrors() { $arr = ['error' => $this->getMessage()]; if (count($this->attrs) > 0) { $arr['attrs'] = $this->getAttrs(); } if (count($this->attrsCustom) > 0) { $arr['attrscustom'] = $this->getAttrsCustom(); } return $arr; }
[ "protected", "function", "getErrors", "(", ")", "{", "$", "arr", "=", "[", "'error'", "=>", "$", "this", "->", "getMessage", "(", ")", "]", ";", "if", "(", "count", "(", "$", "this", "->", "attrs", ")", ">", "0", ")", "{", "$", "arr", "[", "'attrs'", "]", "=", "$", "this", "->", "getAttrs", "(", ")", ";", "}", "if", "(", "count", "(", "$", "this", "->", "attrsCustom", ")", ">", "0", ")", "{", "$", "arr", "[", "'attrscustom'", "]", "=", "$", "this", "->", "getAttrsCustom", "(", ")", ";", "}", "return", "$", "arr", ";", "}" ]
Array de erros. @return array
[ "Array", "de", "erros", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Exceptions/HttpException.php#L59-L72
1,488
Puzzlout/FrameworkMvcLegacy
src/Helpers/WebIdeAjaxHelper.php
WebIdeAjaxHelper.GetSolutionDirectoryList
public function GetSolutionDirectoryList(\Puzzlout\Framework\Core\Application $app) { $Cacher = \Puzzlout\Framework\Core\Cache\BaseCache::Init($app->config); //$Cacher->Remove(CacheKeys::SOLUTION_FOLDERS); if (!$Cacher->KeyExists(CacheKeys::SOLUTION_FOLDERS)) { $SolutionPathListArray = ArrayFilterDirectorySearch::Init($app)->RecursiveScanOf( "APP_ROOT_DIR", \Puzzlout\Framework\Core\DirectoryManager\Algorithms\ArrayListAlgorithm::ExcludeList()); $Cacher->Create(CacheKeys::SOLUTION_FOLDERS, $SolutionPathListArray); } else { $SolutionPathListArray = $Cacher->Read(CacheKeys::SOLUTION_FOLDERS, array()); } return $SolutionPathListArray; }
php
public function GetSolutionDirectoryList(\Puzzlout\Framework\Core\Application $app) { $Cacher = \Puzzlout\Framework\Core\Cache\BaseCache::Init($app->config); //$Cacher->Remove(CacheKeys::SOLUTION_FOLDERS); if (!$Cacher->KeyExists(CacheKeys::SOLUTION_FOLDERS)) { $SolutionPathListArray = ArrayFilterDirectorySearch::Init($app)->RecursiveScanOf( "APP_ROOT_DIR", \Puzzlout\Framework\Core\DirectoryManager\Algorithms\ArrayListAlgorithm::ExcludeList()); $Cacher->Create(CacheKeys::SOLUTION_FOLDERS, $SolutionPathListArray); } else { $SolutionPathListArray = $Cacher->Read(CacheKeys::SOLUTION_FOLDERS, array()); } return $SolutionPathListArray; }
[ "public", "function", "GetSolutionDirectoryList", "(", "\\", "Puzzlout", "\\", "Framework", "\\", "Core", "\\", "Application", "$", "app", ")", "{", "$", "Cacher", "=", "\\", "Puzzlout", "\\", "Framework", "\\", "Core", "\\", "Cache", "\\", "BaseCache", "::", "Init", "(", "$", "app", "->", "config", ")", ";", "//$Cacher->Remove(CacheKeys::SOLUTION_FOLDERS);", "if", "(", "!", "$", "Cacher", "->", "KeyExists", "(", "CacheKeys", "::", "SOLUTION_FOLDERS", ")", ")", "{", "$", "SolutionPathListArray", "=", "ArrayFilterDirectorySearch", "::", "Init", "(", "$", "app", ")", "->", "RecursiveScanOf", "(", "\"APP_ROOT_DIR\"", ",", "\\", "Puzzlout", "\\", "Framework", "\\", "Core", "\\", "DirectoryManager", "\\", "Algorithms", "\\", "ArrayListAlgorithm", "::", "ExcludeList", "(", ")", ")", ";", "$", "Cacher", "->", "Create", "(", "CacheKeys", "::", "SOLUTION_FOLDERS", ",", "$", "SolutionPathListArray", ")", ";", "}", "else", "{", "$", "SolutionPathListArray", "=", "$", "Cacher", "->", "Read", "(", "CacheKeys", "::", "SOLUTION_FOLDERS", ",", "array", "(", ")", ")", ";", "}", "return", "$", "SolutionPathListArray", ";", "}" ]
Retrieves the solution directory list. It caches the result if not already done so that it retrieves it faster the next occurrences. @param \Puzzlout\Framework\Core\Application $app The current application instance. @return array(of String)
[ "Retrieves", "the", "solution", "directory", "list", ".", "It", "caches", "the", "result", "if", "not", "already", "done", "so", "that", "it", "retrieves", "it", "faster", "the", "next", "occurrences", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/WebIdeAjaxHelper.php#L35-L46
1,489
Puzzlout/FrameworkMvcLegacy
src/Helpers/WebIdeAjaxHelper.php
WebIdeAjaxHelper.IsFolderMatchingFilter
public function IsFolderMatchingFilter($path, $regexFilter) { return \Puzzlout\Framework\Helpers\RegexHelper::Init($path)->IsMatch($regexFilter); }
php
public function IsFolderMatchingFilter($path, $regexFilter) { return \Puzzlout\Framework\Helpers\RegexHelper::Init($path)->IsMatch($regexFilter); }
[ "public", "function", "IsFolderMatchingFilter", "(", "$", "path", ",", "$", "regexFilter", ")", "{", "return", "\\", "Puzzlout", "\\", "Framework", "\\", "Helpers", "\\", "RegexHelper", "::", "Init", "(", "$", "path", ")", "->", "IsMatch", "(", "$", "regexFilter", ")", ";", "}" ]
Test to the path against the filter. @param string $path The folder path @param string $regexFilter The regex to test the path
[ "Test", "to", "the", "path", "against", "the", "filter", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/WebIdeAjaxHelper.php#L85-L87
1,490
Puzzlout/FrameworkMvcLegacy
src/Helpers/WebIdeAjaxHelper.php
WebIdeAjaxHelper.AddFolderPathToListItems
public function AddFolderPathToListItems($key, $path) { array_push($this->ListItemArray, \Puzzlout\Framework\BO\ListItem::Init($key, $path)); }
php
public function AddFolderPathToListItems($key, $path) { array_push($this->ListItemArray, \Puzzlout\Framework\BO\ListItem::Init($key, $path)); }
[ "public", "function", "AddFolderPathToListItems", "(", "$", "key", ",", "$", "path", ")", "{", "array_push", "(", "$", "this", "->", "ListItemArray", ",", "\\", "Puzzlout", "\\", "Framework", "\\", "BO", "\\", "ListItem", "::", "Init", "(", "$", "key", ",", "$", "path", ")", ")", ";", "}" ]
Add a ListItem object to the field ListItemArray. @param type $key @param string $path The folder path
[ "Add", "a", "ListItem", "object", "to", "the", "field", "ListItemArray", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/WebIdeAjaxHelper.php#L95-L97
1,491
tenside/core
src/Task/Composer/AbstractComposerCommandTask.php
AbstractComposerCommandTask.fixCommandDefinition
protected function fixCommandDefinition(BaseCommand $command) { $definition = $command->getDefinition(); if (!$definition->hasOption('verbose')) { $definition->addOption( new InputOption( 'verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.' ) ); } if (!$definition->hasOption('profile')) { $definition->addOption( new InputOption( 'profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information' ) ); } if (!$definition->hasOption('no-plugins')) { $definition->addOption( new InputOption( 'no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.' ) ); } if (!$definition->hasOption('working-dir')) { $definition->addOption( new InputOption( 'working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.' ) ); } }
php
protected function fixCommandDefinition(BaseCommand $command) { $definition = $command->getDefinition(); if (!$definition->hasOption('verbose')) { $definition->addOption( new InputOption( 'verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.' ) ); } if (!$definition->hasOption('profile')) { $definition->addOption( new InputOption( 'profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information' ) ); } if (!$definition->hasOption('no-plugins')) { $definition->addOption( new InputOption( 'no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.' ) ); } if (!$definition->hasOption('working-dir')) { $definition->addOption( new InputOption( 'working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.' ) ); } }
[ "protected", "function", "fixCommandDefinition", "(", "BaseCommand", "$", "command", ")", "{", "$", "definition", "=", "$", "command", "->", "getDefinition", "(", ")", ";", "if", "(", "!", "$", "definition", "->", "hasOption", "(", "'verbose'", ")", ")", "{", "$", "definition", "->", "addOption", "(", "new", "InputOption", "(", "'verbose'", ",", "'v|vv|vvv'", ",", "InputOption", "::", "VALUE_NONE", ",", "'Shows more details including new commits pulled in when updating packages.'", ")", ")", ";", "}", "if", "(", "!", "$", "definition", "->", "hasOption", "(", "'profile'", ")", ")", "{", "$", "definition", "->", "addOption", "(", "new", "InputOption", "(", "'profile'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Display timing and memory usage information'", ")", ")", ";", "}", "if", "(", "!", "$", "definition", "->", "hasOption", "(", "'no-plugins'", ")", ")", "{", "$", "definition", "->", "addOption", "(", "new", "InputOption", "(", "'no-plugins'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Whether to disable plugins.'", ")", ")", ";", "}", "if", "(", "!", "$", "definition", "->", "hasOption", "(", "'working-dir'", ")", ")", "{", "$", "definition", "->", "addOption", "(", "new", "InputOption", "(", "'working-dir'", ",", "'-d'", ",", "InputOption", "::", "VALUE_REQUIRED", ",", "'If specified, use the given directory as working directory.'", ")", ")", ";", "}", "}" ]
Add missing definition options to the command usually defined by the application. See also composer/composer in src/Composer/Console/Application.php @param BaseCommand $command The command to fix. @return void
[ "Add", "missing", "definition", "options", "to", "the", "command", "usually", "defined", "by", "the", "application", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/AbstractComposerCommandTask.php#L60-L104
1,492
tenside/core
src/Task/Composer/AbstractComposerCommandTask.php
AbstractComposerCommandTask.attachComposerFactory
protected function attachComposerFactory(BaseCommand $command) { if (!method_exists($command, 'setComposerFactory')) { throw new \InvalidArgumentException('The passed command does not implement method setComposerFactory()'); } /** @var WrappedCommandTrait $command */ $command->setComposerFactory( function () { return Factory::create($this->getIO()); } ); return $command; }
php
protected function attachComposerFactory(BaseCommand $command) { if (!method_exists($command, 'setComposerFactory')) { throw new \InvalidArgumentException('The passed command does not implement method setComposerFactory()'); } /** @var WrappedCommandTrait $command */ $command->setComposerFactory( function () { return Factory::create($this->getIO()); } ); return $command; }
[ "protected", "function", "attachComposerFactory", "(", "BaseCommand", "$", "command", ")", "{", "if", "(", "!", "method_exists", "(", "$", "command", ",", "'setComposerFactory'", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The passed command does not implement method setComposerFactory()'", ")", ";", "}", "/** @var WrappedCommandTrait $command */", "$", "command", "->", "setComposerFactory", "(", "function", "(", ")", "{", "return", "Factory", "::", "create", "(", "$", "this", "->", "getIO", "(", ")", ")", ";", "}", ")", ";", "return", "$", "command", ";", "}" ]
Attach the composer factory to the command. @param BaseCommand $command The command to patch. @return BaseCommand @throws \InvalidArgumentException When no setComposerFactory method is declared.
[ "Attach", "the", "composer", "factory", "to", "the", "command", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/AbstractComposerCommandTask.php#L115-L129
1,493
tenside/core
src/Task/Composer/AbstractComposerCommandTask.php
AbstractComposerCommandTask.executeCommand
protected function executeCommand(BaseCommand $command, InputInterface $input, OutputInterface $output) { try { if (0 !== ($statusCode = $command->run($input, $output))) { throw new \RuntimeException('Error: command exit code was ' . $statusCode); } } catch (\Exception $exception) { throw new \RuntimeException($exception->getMessage(), $exception->getCode(), $exception); } }
php
protected function executeCommand(BaseCommand $command, InputInterface $input, OutputInterface $output) { try { if (0 !== ($statusCode = $command->run($input, $output))) { throw new \RuntimeException('Error: command exit code was ' . $statusCode); } } catch (\Exception $exception) { throw new \RuntimeException($exception->getMessage(), $exception->getCode(), $exception); } }
[ "protected", "function", "executeCommand", "(", "BaseCommand", "$", "command", ",", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "try", "{", "if", "(", "0", "!==", "(", "$", "statusCode", "=", "$", "command", "->", "run", "(", "$", "input", ",", "$", "output", ")", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Error: command exit code was '", ".", "$", "statusCode", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "exception", "->", "getMessage", "(", ")", ",", "$", "exception", "->", "getCode", "(", ")", ",", "$", "exception", ")", ";", "}", "}" ]
Execute the command and throw exceptions on errors. @param BaseCommand $command The command to execute. @param InputInterface $input The input to use. @param OutputInterface $output The output to use. @return void @throws \RuntimeException On exceptions or when the command has an non zero exit code.
[ "Execute", "the", "command", "and", "throw", "exceptions", "on", "errors", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/AbstractComposerCommandTask.php#L144-L153
1,494
cundd/test-flight
src/Event/EventDispatcher.php
EventDispatcher.register
public function register(string $eventCode, callable $listener) { $this->assertValidEventCode($eventCode); if (false === isset($this->eventListeners[$eventCode])) { $this->eventListeners[$eventCode] = []; } $this->eventListeners[$eventCode][] = $listener; return $this; }
php
public function register(string $eventCode, callable $listener) { $this->assertValidEventCode($eventCode); if (false === isset($this->eventListeners[$eventCode])) { $this->eventListeners[$eventCode] = []; } $this->eventListeners[$eventCode][] = $listener; return $this; }
[ "public", "function", "register", "(", "string", "$", "eventCode", ",", "callable", "$", "listener", ")", "{", "$", "this", "->", "assertValidEventCode", "(", "$", "eventCode", ")", ";", "if", "(", "false", "===", "isset", "(", "$", "this", "->", "eventListeners", "[", "$", "eventCode", "]", ")", ")", "{", "$", "this", "->", "eventListeners", "[", "$", "eventCode", "]", "=", "[", "]", ";", "}", "$", "this", "->", "eventListeners", "[", "$", "eventCode", "]", "[", "]", "=", "$", "listener", ";", "return", "$", "this", ";", "}" ]
Register a listener for the given event code @param string $eventCode @param callable $listener @return $this
[ "Register", "a", "listener", "for", "the", "given", "event", "code" ]
9d8424dfb586f823f9dad2dcb81ff3986e255d56
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Event/EventDispatcher.php#L24-L33
1,495
cundd/test-flight
src/Event/EventDispatcher.php
EventDispatcher.dispatch
public function dispatch(string $eventCode, EventInterface $event) { $this->assertValidEventCode($eventCode); if (true === isset($this->eventListeners[$eventCode])) { foreach ($this->eventListeners[$eventCode] as $listener) { $listener($event); } } return $this; }
php
public function dispatch(string $eventCode, EventInterface $event) { $this->assertValidEventCode($eventCode); if (true === isset($this->eventListeners[$eventCode])) { foreach ($this->eventListeners[$eventCode] as $listener) { $listener($event); } } return $this; }
[ "public", "function", "dispatch", "(", "string", "$", "eventCode", ",", "EventInterface", "$", "event", ")", "{", "$", "this", "->", "assertValidEventCode", "(", "$", "eventCode", ")", ";", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "eventListeners", "[", "$", "eventCode", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "eventListeners", "[", "$", "eventCode", "]", "as", "$", "listener", ")", "{", "$", "listener", "(", "$", "event", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Invoke all event listeners for the given event code @param string $eventCode @param EventInterface $event @return $this
[ "Invoke", "all", "event", "listeners", "for", "the", "given", "event", "code" ]
9d8424dfb586f823f9dad2dcb81ff3986e255d56
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Event/EventDispatcher.php#L42-L52
1,496
themichaelhall/bluemvc-twig
src/TwigViewRenderer.php
TwigViewRenderer.setStrictVariables
public function setStrictVariables(bool $isEnabled = true): self { if ($isEnabled) { $this->twigEnvironment->enableStrictVariables(); } else { $this->twigEnvironment->disableStrictVariables(); } return $this; }
php
public function setStrictVariables(bool $isEnabled = true): self { if ($isEnabled) { $this->twigEnvironment->enableStrictVariables(); } else { $this->twigEnvironment->disableStrictVariables(); } return $this; }
[ "public", "function", "setStrictVariables", "(", "bool", "$", "isEnabled", "=", "true", ")", ":", "self", "{", "if", "(", "$", "isEnabled", ")", "{", "$", "this", "->", "twigEnvironment", "->", "enableStrictVariables", "(", ")", ";", "}", "else", "{", "$", "this", "->", "twigEnvironment", "->", "disableStrictVariables", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets whether strict variables should be enabled. @since 1.1.0 @param bool $isEnabled True if strict variables should be enabled, false otherwise. @return self The Twig view renderer.
[ "Sets", "whether", "strict", "variables", "should", "be", "enabled", "." ]
75ccddcb3645e703d3f98d94c819fe912c6cd55f
https://github.com/themichaelhall/bluemvc-twig/blob/75ccddcb3645e703d3f98d94c819fe912c6cd55f/src/TwigViewRenderer.php#L117-L126
1,497
PentagonalProject/SlimService
src/Configurator.php
Configurator.remove
public function remove($key) { if (!is_string($key) && !is_numeric($key)) { throw new InvalidArgumentException( 'Invalid key name given! Key config to remove must be as a string!' ); } if (!$this->exist($key)) { return; } if (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $key, $matches)) > 1) { $firstKey = reset($matches[0]); $keyName = $firstKey; $tmp = $this->collection[$keyName]; if (!is_array($tmp)) { return; } array_shift($matches[0]); $unsetPosition = 0; foreach ($matches[0] as $keyNum => $keyName) { $keyName = trim($keyName, '[]'); if ($unsetPosition <> $keyNum && (!is_array($tmp) || ! array_key_exists($keyName, $tmp)) ) { return; } $unsetPosition++; $tmp = $tmp[$keyName]; } $tmp = $this->collection[$firstKey]; $currentUnsetPosition = 0; // binding anonymous function to handle array reference $recursiveUnset = function ( &$array, $unwanted_key ) use ( $unsetPosition, &$currentUnsetPosition, &$recursiveUnset ) { $currentUnsetPosition++; if ($unsetPosition !== $currentUnsetPosition) { if (array_key_exists($unwanted_key, $array)) { unset($array[$unwanted_key]); } // stop return; } foreach ($array as &$value) { if (is_array($value)) { $recursiveUnset($value, $unwanted_key); } } }; // call closure to binding reference $recursiveUnset($tmp, $keyName); $this->collection[$firstKey] = $tmp; unset($tmp); return; // stop } unset($this->collection[$key]); }
php
public function remove($key) { if (!is_string($key) && !is_numeric($key)) { throw new InvalidArgumentException( 'Invalid key name given! Key config to remove must be as a string!' ); } if (!$this->exist($key)) { return; } if (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $key, $matches)) > 1) { $firstKey = reset($matches[0]); $keyName = $firstKey; $tmp = $this->collection[$keyName]; if (!is_array($tmp)) { return; } array_shift($matches[0]); $unsetPosition = 0; foreach ($matches[0] as $keyNum => $keyName) { $keyName = trim($keyName, '[]'); if ($unsetPosition <> $keyNum && (!is_array($tmp) || ! array_key_exists($keyName, $tmp)) ) { return; } $unsetPosition++; $tmp = $tmp[$keyName]; } $tmp = $this->collection[$firstKey]; $currentUnsetPosition = 0; // binding anonymous function to handle array reference $recursiveUnset = function ( &$array, $unwanted_key ) use ( $unsetPosition, &$currentUnsetPosition, &$recursiveUnset ) { $currentUnsetPosition++; if ($unsetPosition !== $currentUnsetPosition) { if (array_key_exists($unwanted_key, $array)) { unset($array[$unwanted_key]); } // stop return; } foreach ($array as &$value) { if (is_array($value)) { $recursiveUnset($value, $unwanted_key); } } }; // call closure to binding reference $recursiveUnset($tmp, $keyName); $this->collection[$firstKey] = $tmp; unset($tmp); return; // stop } unset($this->collection[$key]); }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", "&&", "!", "is_numeric", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid key name given! Key config to remove must be as a string!'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "exist", "(", "$", "key", ")", ")", "{", "return", ";", "}", "if", "(", "(", "$", "count", "=", "preg_match_all", "(", "'/(?:^[^\\[]+)|\\[[^]]*\\]/'", ",", "$", "key", ",", "$", "matches", ")", ")", ">", "1", ")", "{", "$", "firstKey", "=", "reset", "(", "$", "matches", "[", "0", "]", ")", ";", "$", "keyName", "=", "$", "firstKey", ";", "$", "tmp", "=", "$", "this", "->", "collection", "[", "$", "keyName", "]", ";", "if", "(", "!", "is_array", "(", "$", "tmp", ")", ")", "{", "return", ";", "}", "array_shift", "(", "$", "matches", "[", "0", "]", ")", ";", "$", "unsetPosition", "=", "0", ";", "foreach", "(", "$", "matches", "[", "0", "]", "as", "$", "keyNum", "=>", "$", "keyName", ")", "{", "$", "keyName", "=", "trim", "(", "$", "keyName", ",", "'[]'", ")", ";", "if", "(", "$", "unsetPosition", "<>", "$", "keyNum", "&&", "(", "!", "is_array", "(", "$", "tmp", ")", "||", "!", "array_key_exists", "(", "$", "keyName", ",", "$", "tmp", ")", ")", ")", "{", "return", ";", "}", "$", "unsetPosition", "++", ";", "$", "tmp", "=", "$", "tmp", "[", "$", "keyName", "]", ";", "}", "$", "tmp", "=", "$", "this", "->", "collection", "[", "$", "firstKey", "]", ";", "$", "currentUnsetPosition", "=", "0", ";", "// binding anonymous function to handle array reference", "$", "recursiveUnset", "=", "function", "(", "&", "$", "array", ",", "$", "unwanted_key", ")", "use", "(", "$", "unsetPosition", ",", "&", "$", "currentUnsetPosition", ",", "&", "$", "recursiveUnset", ")", "{", "$", "currentUnsetPosition", "++", ";", "if", "(", "$", "unsetPosition", "!==", "$", "currentUnsetPosition", ")", "{", "if", "(", "array_key_exists", "(", "$", "unwanted_key", ",", "$", "array", ")", ")", "{", "unset", "(", "$", "array", "[", "$", "unwanted_key", "]", ")", ";", "}", "// stop", "return", ";", "}", "foreach", "(", "$", "array", "as", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "recursiveUnset", "(", "$", "value", ",", "$", "unwanted_key", ")", ";", "}", "}", "}", ";", "// call closure to binding reference", "$", "recursiveUnset", "(", "$", "tmp", ",", "$", "keyName", ")", ";", "$", "this", "->", "collection", "[", "$", "firstKey", "]", "=", "$", "tmp", ";", "unset", "(", "$", "tmp", ")", ";", "return", ";", "// stop", "}", "unset", "(", "$", "this", "->", "collection", "[", "$", "key", "]", ")", ";", "}" ]
Remove Key from nested selector @param string $key
[ "Remove", "Key", "from", "nested", "selector" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Configurator.php#L250-L317
1,498
rozaverta/cmf
core/Filesystem/Resource.php
Resource.ready
public function ready() { if( $this->ready ) { return $this; } $this->raw = @ file_get_contents($this->pathname); if( !$this->raw ) { throw new AccessFileException($this->pathname,"Cannot ready resource '{$this->name}'"); } try { $data = Json::parse($this->raw, true); if( ! is_array($data) ) { throw new \InvalidArgumentException("Resource data is not array"); } } catch( \InvalidArgumentException $e ) { throw new ReadFileException($this->pathname,"Cannot read resource '{$this->name}', json parser error: " . $e->getCode()); } if( isset($data['type']) && is_string($data['type']) ) { $this->type = $data['type']; } $this->ready = true; $this->items = $data; return $this; }
php
public function ready() { if( $this->ready ) { return $this; } $this->raw = @ file_get_contents($this->pathname); if( !$this->raw ) { throw new AccessFileException($this->pathname,"Cannot ready resource '{$this->name}'"); } try { $data = Json::parse($this->raw, true); if( ! is_array($data) ) { throw new \InvalidArgumentException("Resource data is not array"); } } catch( \InvalidArgumentException $e ) { throw new ReadFileException($this->pathname,"Cannot read resource '{$this->name}', json parser error: " . $e->getCode()); } if( isset($data['type']) && is_string($data['type']) ) { $this->type = $data['type']; } $this->ready = true; $this->items = $data; return $this; }
[ "public", "function", "ready", "(", ")", "{", "if", "(", "$", "this", "->", "ready", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "raw", "=", "@", "file_get_contents", "(", "$", "this", "->", "pathname", ")", ";", "if", "(", "!", "$", "this", "->", "raw", ")", "{", "throw", "new", "AccessFileException", "(", "$", "this", "->", "pathname", ",", "\"Cannot ready resource '{$this->name}'\"", ")", ";", "}", "try", "{", "$", "data", "=", "Json", "::", "parse", "(", "$", "this", "->", "raw", ",", "true", ")", ";", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Resource data is not array\"", ")", ";", "}", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "throw", "new", "ReadFileException", "(", "$", "this", "->", "pathname", ",", "\"Cannot read resource '{$this->name}', json parser error: \"", ".", "$", "e", "->", "getCode", "(", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'type'", "]", ")", "&&", "is_string", "(", "$", "data", "[", "'type'", "]", ")", ")", "{", "$", "this", "->", "type", "=", "$", "data", "[", "'type'", "]", ";", "}", "$", "this", "->", "ready", "=", "true", ";", "$", "this", "->", "items", "=", "$", "data", ";", "return", "$", "this", ";", "}" ]
Load resource content data @return $this @throws AccessFileException @throws ReadFileException
[ "Load", "resource", "content", "data" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Filesystem/Resource.php#L126-L159
1,499
rozaverta/cmf
core/Filesystem/Resource.php
Resource.hasType
public function hasType( string $type ): bool { if( substr($type, 0, 2) !== "#/" ) { $type = "#/{$type}"; } return $this->getType() === $type; }
php
public function hasType( string $type ): bool { if( substr($type, 0, 2) !== "#/" ) { $type = "#/{$type}"; } return $this->getType() === $type; }
[ "public", "function", "hasType", "(", "string", "$", "type", ")", ":", "bool", "{", "if", "(", "substr", "(", "$", "type", ",", "0", ",", "2", ")", "!==", "\"#/\"", ")", "{", "$", "type", "=", "\"#/{$type}\"", ";", "}", "return", "$", "this", "->", "getType", "(", ")", "===", "$", "type", ";", "}" ]
Compare resource type @param string $type @return bool
[ "Compare", "resource", "type" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Filesystem/Resource.php#L177-L184