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
240,900
xcitestudios/php-network
src/Email/EmailSerializable.php
EmailSerializable.setSender
public function setSender(ContactInterface $sender = null) { if ($sender !== null && !($sender instanceof Contact)) { throw new InvalidArgumentException( sprintf( '%s expects an instance of %s.', __FUNCTION__, Contact::class ) ); } $this->sender = $sender; return $this; }
php
public function setSender(ContactInterface $sender = null) { if ($sender !== null && !($sender instanceof Contact)) { throw new InvalidArgumentException( sprintf( '%s expects an instance of %s.', __FUNCTION__, Contact::class ) ); } $this->sender = $sender; return $this; }
[ "public", "function", "setSender", "(", "ContactInterface", "$", "sender", "=", "null", ")", "{", "if", "(", "$", "sender", "!==", "null", "&&", "!", "(", "$", "sender", "instanceof", "Contact", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'%s expects an instance of %s.'", ",", "__FUNCTION__", ",", "Contact", "::", "class", ")", ")", ";", "}", "$", "this", "->", "sender", "=", "$", "sender", ";", "return", "$", "this", ";", "}" ]
Sets the sender. Optional OR Required. Optional where From is one person. Required where From is multiple people. @param Contact|null $sender @throws InvalidArgumentException @return static
[ "Sets", "the", "sender", ".", "Optional", "OR", "Required", ".", "Optional", "where", "From", "is", "one", "person", ".", "Required", "where", "From", "is", "multiple", "people", "." ]
4278b7bd5b5cf64ceb08005f6bce18be79b76cd3
https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Email/EmailSerializable.php#L139-L152
240,901
xcitestudios/php-network
src/Email/EmailSerializable.php
EmailSerializable.setBodyParts
public function setBodyParts(array $bodyParts) { $collection = new EmailBodyPartCollection(); foreach ($bodyParts as $k => $v) { $collection->add($v); } $this->bodyParts = $collection; return $this; }
php
public function setBodyParts(array $bodyParts) { $collection = new EmailBodyPartCollection(); foreach ($bodyParts as $k => $v) { $collection->add($v); } $this->bodyParts = $collection; return $this; }
[ "public", "function", "setBodyParts", "(", "array", "$", "bodyParts", ")", "{", "$", "collection", "=", "new", "EmailBodyPartCollection", "(", ")", ";", "foreach", "(", "$", "bodyParts", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "collection", "->", "add", "(", "$", "v", ")", ";", "}", "$", "this", "->", "bodyParts", "=", "$", "collection", ";", "return", "$", "this", ";", "}" ]
Set the body of the email. For a single content-type email, just put one in this array. It is presumed if you add multiple items to this array then it must be multipart. For multipart/alternative (multiple versions of the body such as text / html) add in one body part of type multipart/alternative which has multiple body parts. @param EmailBodyPart[] $bodyParts @throws InvalidArgumentException @return static
[ "Set", "the", "body", "of", "the", "email", ".", "For", "a", "single", "content", "-", "type", "email", "just", "put", "one", "in", "this", "array", ".", "It", "is", "presumed", "if", "you", "add", "multiple", "items", "to", "this", "array", "then", "it", "must", "be", "multipart", "." ]
4278b7bd5b5cf64ceb08005f6bce18be79b76cd3
https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Email/EmailSerializable.php#L347-L358
240,902
nirix/radium
src/Http/Controller.php
Controller.respondTo
public function respondTo($func) { $route = Router::currentRoute(); $response = $func($route['extension'], $this); if ($response === null) { return $this->show404(); } return $response; }
php
public function respondTo($func) { $route = Router::currentRoute(); $response = $func($route['extension'], $this); if ($response === null) { return $this->show404(); } return $response; }
[ "public", "function", "respondTo", "(", "$", "func", ")", "{", "$", "route", "=", "Router", "::", "currentRoute", "(", ")", ";", "$", "response", "=", "$", "func", "(", "$", "route", "[", "'extension'", "]", ",", "$", "this", ")", ";", "if", "(", "$", "response", "===", "null", ")", "{", "return", "$", "this", "->", "show404", "(", ")", ";", "}", "return", "$", "response", ";", "}" ]
Easily respond to different request formats. @param callable $func @return object
[ "Easily", "respond", "to", "different", "request", "formats", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Http/Controller.php#L160-L170
240,903
nirix/radium
src/Http/Controller.php
Controller.show404
public function show404() { $this->executeAction = false; return new Response(function($resp){ $resp->status = 404; $resp->body = $this->renderView($this->notFoundView, [ '_layout' => $this->layout ]); }); }
php
public function show404() { $this->executeAction = false; return new Response(function($resp){ $resp->status = 404; $resp->body = $this->renderView($this->notFoundView, [ '_layout' => $this->layout ]); }); }
[ "public", "function", "show404", "(", ")", "{", "$", "this", "->", "executeAction", "=", "false", ";", "return", "new", "Response", "(", "function", "(", "$", "resp", ")", "{", "$", "resp", "->", "status", "=", "404", ";", "$", "resp", "->", "body", "=", "$", "this", "->", "renderView", "(", "$", "this", "->", "notFoundView", ",", "[", "'_layout'", "=>", "$", "this", "->", "layout", "]", ")", ";", "}", ")", ";", "}" ]
Sets the response to a 404 Not Found
[ "Sets", "the", "response", "to", "a", "404", "Not", "Found" ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Http/Controller.php#L175-L184
240,904
nirix/radium
src/Http/Controller.php
Controller.addFilter
protected function addFilter($when, $action, $callback) { if (!is_callable($callback) && !is_array($callback)) { $callback = [$this, $callback]; } if (is_array($action)) { foreach ($action as $method) { $this->addFilter($when, $method, $callback); } } else { EventDispatcher::addListener("{$when}." . get_called_class() . "::{$action}", $callback); } }
php
protected function addFilter($when, $action, $callback) { if (!is_callable($callback) && !is_array($callback)) { $callback = [$this, $callback]; } if (is_array($action)) { foreach ($action as $method) { $this->addFilter($when, $method, $callback); } } else { EventDispatcher::addListener("{$when}." . get_called_class() . "::{$action}", $callback); } }
[ "protected", "function", "addFilter", "(", "$", "when", ",", "$", "action", ",", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", "&&", "!", "is_array", "(", "$", "callback", ")", ")", "{", "$", "callback", "=", "[", "$", "this", ",", "$", "callback", "]", ";", "}", "if", "(", "is_array", "(", "$", "action", ")", ")", "{", "foreach", "(", "$", "action", "as", "$", "method", ")", "{", "$", "this", "->", "addFilter", "(", "$", "when", ",", "$", "method", ",", "$", "callback", ")", ";", "}", "}", "else", "{", "EventDispatcher", "::", "addListener", "(", "\"{$when}.\"", ".", "get_called_class", "(", ")", ".", "\"::{$action}\"", ",", "$", "callback", ")", ";", "}", "}" ]
Adds the filter to the event dispatcher. @param string $when Either 'before' or 'after' @param string $action @param mixed $callback
[ "Adds", "the", "filter", "to", "the", "event", "dispatcher", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Http/Controller.php#L222-L235
240,905
onesimus-systems/oslogger
src/Logger.php
Logger.addAdaptor
public function addAdaptor(AbstractAdaptor $adaptor) { // The key will be the adaptor's name or the next numerical // count if a name is blank $adaptorName = $adaptor->getName() ?: $this->adaptorCount; $this->adaptors[$adaptorName] = $adaptor; $this->adaptorCount++; }
php
public function addAdaptor(AbstractAdaptor $adaptor) { // The key will be the adaptor's name or the next numerical // count if a name is blank $adaptorName = $adaptor->getName() ?: $this->adaptorCount; $this->adaptors[$adaptorName] = $adaptor; $this->adaptorCount++; }
[ "public", "function", "addAdaptor", "(", "AbstractAdaptor", "$", "adaptor", ")", "{", "// The key will be the adaptor's name or the next numerical", "// count if a name is blank", "$", "adaptorName", "=", "$", "adaptor", "->", "getName", "(", ")", "?", ":", "$", "this", "->", "adaptorCount", ";", "$", "this", "->", "adaptors", "[", "$", "adaptorName", "]", "=", "$", "adaptor", ";", "$", "this", "->", "adaptorCount", "++", ";", "}" ]
Add an adaptor to write logs @param AbstractAdaptor $adaptor Adaptor to add to list
[ "Add", "an", "adaptor", "to", "write", "logs" ]
98138d4fbcae83b9cedac13ab173a3f8273de3e0
https://github.com/onesimus-systems/oslogger/blob/98138d4fbcae83b9cedac13ab173a3f8273de3e0/src/Logger.php#L64-L71
240,906
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/StockTransferController.php
StockTransferController.showAction
public function showAction(StockTransfer $stocktransfer) { $editForm = $this->createForm(new StockTransferType(), $stocktransfer, array( 'action' => $this->generateUrl('stock_transfers_update', array('id' => $stocktransfer->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($stocktransfer->getId(), 'stock_transfers_delete'); return array( 'stocktransfer' => $stocktransfer, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function showAction(StockTransfer $stocktransfer) { $editForm = $this->createForm(new StockTransferType(), $stocktransfer, array( 'action' => $this->generateUrl('stock_transfers_update', array('id' => $stocktransfer->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($stocktransfer->getId(), 'stock_transfers_delete'); return array( 'stocktransfer' => $stocktransfer, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "showAction", "(", "StockTransfer", "$", "stocktransfer", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "new", "StockTransferType", "(", ")", ",", "$", "stocktransfer", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'stock_transfers_update'", ",", "array", "(", "'id'", "=>", "$", "stocktransfer", "->", "getid", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "stocktransfer", "->", "getId", "(", ")", ",", "'stock_transfers_delete'", ")", ";", "return", "array", "(", "'stocktransfer'", "=>", "$", "stocktransfer", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Finds and displays a StockTransfer entity. @Route("/{id}/show", name="stock_transfers_show", requirements={"id"="\d+"}) @Method("GET") @Template()
[ "Finds", "and", "displays", "a", "StockTransfer", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferController.php#L49-L64
240,907
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/StockTransferController.php
StockTransferController.newAction
public function newAction() { $stocktransfer = new StockTransfer(); $nextCode = $this->get('flower.stock.service.stock_transfer')->getNextCode(); $stocktransfer->setCode($nextCode); $stocktransfer->setUser($this->getUser()); $form = $this->createForm(new StockTransferType(), $stocktransfer); return array( 'stocktransfer' => $stocktransfer, 'form' => $form->createView(), ); }
php
public function newAction() { $stocktransfer = new StockTransfer(); $nextCode = $this->get('flower.stock.service.stock_transfer')->getNextCode(); $stocktransfer->setCode($nextCode); $stocktransfer->setUser($this->getUser()); $form = $this->createForm(new StockTransferType(), $stocktransfer); return array( 'stocktransfer' => $stocktransfer, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", ")", "{", "$", "stocktransfer", "=", "new", "StockTransfer", "(", ")", ";", "$", "nextCode", "=", "$", "this", "->", "get", "(", "'flower.stock.service.stock_transfer'", ")", "->", "getNextCode", "(", ")", ";", "$", "stocktransfer", "->", "setCode", "(", "$", "nextCode", ")", ";", "$", "stocktransfer", "->", "setUser", "(", "$", "this", "->", "getUser", "(", ")", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "StockTransferType", "(", ")", ",", "$", "stocktransfer", ")", ";", "return", "array", "(", "'stocktransfer'", "=>", "$", "stocktransfer", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to create a new StockTransfer entity. @Route("/new", name="stock_transfers_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "StockTransfer", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferController.php#L73-L87
240,908
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/StockTransferController.php
StockTransferController.createAction
public function createAction(Request $request) { $stocktransfer = new StockTransfer(); $stocktransfer->setUser($this->getUser()); $form = $this->createForm(new StockTransferType(), $stocktransfer); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($stocktransfer); $em->flush(); return $this->redirect($this->generateUrl('stock_transfers_show', array('id' => $stocktransfer->getId()))); } return array( 'stocktransfer' => $stocktransfer, 'form' => $form->createView(), ); }
php
public function createAction(Request $request) { $stocktransfer = new StockTransfer(); $stocktransfer->setUser($this->getUser()); $form = $this->createForm(new StockTransferType(), $stocktransfer); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($stocktransfer); $em->flush(); return $this->redirect($this->generateUrl('stock_transfers_show', array('id' => $stocktransfer->getId()))); } return array( 'stocktransfer' => $stocktransfer, 'form' => $form->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "stocktransfer", "=", "new", "StockTransfer", "(", ")", ";", "$", "stocktransfer", "->", "setUser", "(", "$", "this", "->", "getUser", "(", ")", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "StockTransferType", "(", ")", ",", "$", "stocktransfer", ")", ";", "if", "(", "$", "form", "->", "handleRequest", "(", "$", "request", ")", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "stocktransfer", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'stock_transfers_show'", ",", "array", "(", "'id'", "=>", "$", "stocktransfer", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "return", "array", "(", "'stocktransfer'", "=>", "$", "stocktransfer", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new StockTransfer entity. @Route("/create", name="stock_transfers_create") @Method("POST") @Template("FlowerStockBundle:StockTransfer:new.html.twig")
[ "Creates", "a", "new", "StockTransfer", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferController.php#L96-L113
240,909
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/StockTransferController.php
StockTransferController.updateAction
public function updateAction(StockTransfer $stocktransfer, Request $request) { $editForm = $this->createForm(new StockTransferType(), $stocktransfer, array( 'action' => $this->generateUrl('stock_transfers_update', array('id' => $stocktransfer->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('stock_transfers_show', array('id' => $stocktransfer->getId()))); } $deleteForm = $this->createDeleteForm($stocktransfer->getId(), 'stock_transfers_delete'); return array( 'stocktransfer' => $stocktransfer, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function updateAction(StockTransfer $stocktransfer, Request $request) { $editForm = $this->createForm(new StockTransferType(), $stocktransfer, array( 'action' => $this->generateUrl('stock_transfers_update', array('id' => $stocktransfer->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('stock_transfers_show', array('id' => $stocktransfer->getId()))); } $deleteForm = $this->createDeleteForm($stocktransfer->getId(), 'stock_transfers_delete'); return array( 'stocktransfer' => $stocktransfer, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "updateAction", "(", "StockTransfer", "$", "stocktransfer", ",", "Request", "$", "request", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "new", "StockTransferType", "(", ")", ",", "$", "stocktransfer", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'stock_transfers_update'", ",", "array", "(", "'id'", "=>", "$", "stocktransfer", "->", "getid", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "if", "(", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'stock_transfers_show'", ",", "array", "(", "'id'", "=>", "$", "stocktransfer", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "stocktransfer", "->", "getId", "(", ")", ",", "'stock_transfers_delete'", ")", ";", "return", "array", "(", "'stocktransfer'", "=>", "$", "stocktransfer", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Edits an existing StockTransfer entity. @Route("/{id}/update", name="stock_transfers_update", requirements={"id"="\d+"}) @Method("PUT") @Template("FlowerStockBundle:StockTransfer:edit.html.twig")
[ "Edits", "an", "existing", "StockTransfer", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferController.php#L144-L162
240,910
asbsoft/yii2module-users_0_170112
controllers/AdminController.php
AdminController.actionChangeStatus
public function actionChangeStatus($id, $value) { $model = $this->findModel($id); if (empty($model)) { Yii::$app->session->setFlash('error', Yii::t($this->tcModule, 'User {id} not found.', ['id' => $id])); } else { $model->status = $value; $model->pageSize = intval($this->module->params['pageSizeAdmin']); $result = $model->save(true, ['status']); // update only status field if ($result) { Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'Status changed.')); } else { foreach ($model->errors as $attribute => $errors) { Yii::$app->session->setFlash('error', Yii::t($this->tcModule, "Status didn't change.") . ' ' . Yii::t($this->tcModule, "Error on field: '{field}'.", ['field' => $attribute]) . ' ' . $errors[0] ); break; } } } return $this->redirect(['index', 'id' => $id, 'page' => empty($model->page) ? 1 : $model->page, ]); }
php
public function actionChangeStatus($id, $value) { $model = $this->findModel($id); if (empty($model)) { Yii::$app->session->setFlash('error', Yii::t($this->tcModule, 'User {id} not found.', ['id' => $id])); } else { $model->status = $value; $model->pageSize = intval($this->module->params['pageSizeAdmin']); $result = $model->save(true, ['status']); // update only status field if ($result) { Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'Status changed.')); } else { foreach ($model->errors as $attribute => $errors) { Yii::$app->session->setFlash('error', Yii::t($this->tcModule, "Status didn't change.") . ' ' . Yii::t($this->tcModule, "Error on field: '{field}'.", ['field' => $attribute]) . ' ' . $errors[0] ); break; } } } return $this->redirect(['index', 'id' => $id, 'page' => empty($model->page) ? 1 : $model->page, ]); }
[ "public", "function", "actionChangeStatus", "(", "$", "id", ",", "$", "value", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "model", ")", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'error'", ",", "Yii", "::", "t", "(", "$", "this", "->", "tcModule", ",", "'User {id} not found.'", ",", "[", "'id'", "=>", "$", "id", "]", ")", ")", ";", "}", "else", "{", "$", "model", "->", "status", "=", "$", "value", ";", "$", "model", "->", "pageSize", "=", "intval", "(", "$", "this", "->", "module", "->", "params", "[", "'pageSizeAdmin'", "]", ")", ";", "$", "result", "=", "$", "model", "->", "save", "(", "true", ",", "[", "'status'", "]", ")", ";", "// update only status field", "if", "(", "$", "result", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'success'", ",", "Yii", "::", "t", "(", "$", "this", "->", "tcModule", ",", "'Status changed.'", ")", ")", ";", "}", "else", "{", "foreach", "(", "$", "model", "->", "errors", "as", "$", "attribute", "=>", "$", "errors", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'error'", ",", "Yii", "::", "t", "(", "$", "this", "->", "tcModule", ",", "\"Status didn't change.\"", ")", ".", "' '", ".", "Yii", "::", "t", "(", "$", "this", "->", "tcModule", ",", "\"Error on field: '{field}'.\"", ",", "[", "'field'", "=>", "$", "attribute", "]", ")", ".", "' '", ".", "$", "errors", "[", "0", "]", ")", ";", "break", ";", "}", "}", "}", "return", "$", "this", "->", "redirect", "(", "[", "'index'", ",", "'id'", "=>", "$", "id", ",", "'page'", "=>", "empty", "(", "$", "model", "->", "page", ")", "?", "1", ":", "$", "model", "->", "page", ",", "]", ")", ";", "}" ]
Change status of user. @param integer $id @param integer $value @return mixed
[ "Change", "status", "of", "user", "." ]
3906fdde2d5fdd54637f2b5246d52fe91ec5f648
https://github.com/asbsoft/yii2module-users_0_170112/blob/3906fdde2d5fdd54637f2b5246d52fe91ec5f648/controllers/AdminController.php#L202-L229
240,911
flowcode/ceibo
src/flowcode/ceibo/domain/Mapper.php
Mapper.getRelation
public function getRelation($relationName) { $relationInstance = null; if (isset($this->relations[$relationName])) { $relationInstance = $this->relations[$relationName]; } return $relationInstance; }
php
public function getRelation($relationName) { $relationInstance = null; if (isset($this->relations[$relationName])) { $relationInstance = $this->relations[$relationName]; } return $relationInstance; }
[ "public", "function", "getRelation", "(", "$", "relationName", ")", "{", "$", "relationInstance", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "relations", "[", "$", "relationName", "]", ")", ")", "{", "$", "relationInstance", "=", "$", "this", "->", "relations", "[", "$", "relationName", "]", ";", "}", "return", "$", "relationInstance", ";", "}" ]
Get a relation bby its name. @param string $relationName @return Relation
[ "Get", "a", "relation", "bby", "its", "name", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Mapper.php#L101-L107
240,912
flowcode/ceibo
src/flowcode/ceibo/domain/Mapper.php
Mapper.getFilter
public function getFilter($filtername) { $filter = null; if (!is_null($this->filters) && isset($this->filters[$filtername])) { $filter = $this->filters[$filtername]; } return $filter; }
php
public function getFilter($filtername) { $filter = null; if (!is_null($this->filters) && isset($this->filters[$filtername])) { $filter = $this->filters[$filtername]; } return $filter; }
[ "public", "function", "getFilter", "(", "$", "filtername", ")", "{", "$", "filter", "=", "null", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "filters", ")", "&&", "isset", "(", "$", "this", "->", "filters", "[", "$", "filtername", "]", ")", ")", "{", "$", "filter", "=", "$", "this", "->", "filters", "[", "$", "filtername", "]", ";", "}", "return", "$", "filter", ";", "}" ]
Return the filter or null. @param String $filtername @return Filter $filter.
[ "Return", "the", "filter", "or", "null", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Mapper.php#L122-L128
240,913
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.getEntityNameFromClassName
public static function getEntityNameFromClassName(string $className) { $entityName = constant(sprintf(self::ENTITY_NAME_CONST_FORMAT, $className)); if ($entityName === AbstractEntity::ENTITY_NAME or !is_string($entityName)) { throw new NoEntityNameException($className); } return $entityName; }
php
public static function getEntityNameFromClassName(string $className) { $entityName = constant(sprintf(self::ENTITY_NAME_CONST_FORMAT, $className)); if ($entityName === AbstractEntity::ENTITY_NAME or !is_string($entityName)) { throw new NoEntityNameException($className); } return $entityName; }
[ "public", "static", "function", "getEntityNameFromClassName", "(", "string", "$", "className", ")", "{", "$", "entityName", "=", "constant", "(", "sprintf", "(", "self", "::", "ENTITY_NAME_CONST_FORMAT", ",", "$", "className", ")", ")", ";", "if", "(", "$", "entityName", "===", "AbstractEntity", "::", "ENTITY_NAME", "or", "!", "is_string", "(", "$", "entityName", ")", ")", "{", "throw", "new", "NoEntityNameException", "(", "$", "className", ")", ";", "}", "return", "$", "entityName", ";", "}" ]
Gets an entity name from an entity class name if it provides an ENTITY_NAME constant @param string $className @return string
[ "Gets", "an", "entity", "name", "from", "an", "entity", "class", "name", "if", "it", "provides", "an", "ENTITY_NAME", "constant" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L83-L92
240,914
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.loadRegistries
public function loadRegistries() { $registries = $this->registryFactory->getDefaultRegistries(); foreach ($registries as $registry) { $this->addRegistry($registry); } }
php
public function loadRegistries() { $registries = $this->registryFactory->getDefaultRegistries(); foreach ($registries as $registry) { $this->addRegistry($registry); } }
[ "public", "function", "loadRegistries", "(", ")", "{", "$", "registries", "=", "$", "this", "->", "registryFactory", "->", "getDefaultRegistries", "(", ")", ";", "foreach", "(", "$", "registries", "as", "$", "registry", ")", "{", "$", "this", "->", "addRegistry", "(", "$", "registry", ")", ";", "}", "}" ]
Loads the registries
[ "Loads", "the", "registries" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L144-L151
240,915
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.getEntityName
public function getEntityName() { if (is_null($this->entityName)) { $this->entityName = self::getEntityNameFromClassName($this->getEntityClass()); } return $this->entityName; }
php
public function getEntityName() { if (is_null($this->entityName)) { $this->entityName = self::getEntityNameFromClassName($this->getEntityClass()); } return $this->entityName; }
[ "public", "function", "getEntityName", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "entityName", ")", ")", "{", "$", "this", "->", "entityName", "=", "self", "::", "getEntityNameFromClassName", "(", "$", "this", "->", "getEntityClass", "(", ")", ")", ";", "}", "return", "$", "this", "->", "entityName", ";", "}" ]
Gets the entity name @return string
[ "Gets", "the", "entity", "name" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L158-L165
240,916
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.findById
public function findById(int $id) { $entity = null; for ($i = 0; $i < count($this->registries); $i++) { /** @var RegistryInterface $registry */ $registry = $this->registries[ $i ]; $entity = $registry->findByKey($id); if ($entity instanceof AbstractEntity) { $this->updateRegistries([$entity], $i - 1); break; } } return $entity; }
php
public function findById(int $id) { $entity = null; for ($i = 0; $i < count($this->registries); $i++) { /** @var RegistryInterface $registry */ $registry = $this->registries[ $i ]; $entity = $registry->findByKey($id); if ($entity instanceof AbstractEntity) { $this->updateRegistries([$entity], $i - 1); break; } } return $entity; }
[ "public", "function", "findById", "(", "int", "$", "id", ")", "{", "$", "entity", "=", "null", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "registries", ")", ";", "$", "i", "++", ")", "{", "/** @var RegistryInterface $registry */", "$", "registry", "=", "$", "this", "->", "registries", "[", "$", "i", "]", ";", "$", "entity", "=", "$", "registry", "->", "findByKey", "(", "$", "id", ")", ";", "if", "(", "$", "entity", "instanceof", "AbstractEntity", ")", "{", "$", "this", "->", "updateRegistries", "(", "[", "$", "entity", "]", ",", "$", "i", "-", "1", ")", ";", "break", ";", "}", "}", "return", "$", "entity", ";", "}" ]
Finds an entity by its id @param int $id @return AbstractEntity|null
[ "Finds", "an", "entity", "by", "its", "id" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L237-L253
240,917
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.findByIds
public function findByIds(array $ids) { $entities = []; for ($i = 0; $i < count($this->registries); $i++) { /** @var RegistryInterface $registry */ $registry = $this->registries[ $i ]; $found = $registry->findByKeys($ids); $entities = array_merge($entities, $found); $this->updateRegistries($found, $i - 1); if (count($entities) === count($ids)) { break; } } return $entities; }
php
public function findByIds(array $ids) { $entities = []; for ($i = 0; $i < count($this->registries); $i++) { /** @var RegistryInterface $registry */ $registry = $this->registries[ $i ]; $found = $registry->findByKeys($ids); $entities = array_merge($entities, $found); $this->updateRegistries($found, $i - 1); if (count($entities) === count($ids)) { break; } } return $entities; }
[ "public", "function", "findByIds", "(", "array", "$", "ids", ")", "{", "$", "entities", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "registries", ")", ";", "$", "i", "++", ")", "{", "/** @var RegistryInterface $registry */", "$", "registry", "=", "$", "this", "->", "registries", "[", "$", "i", "]", ";", "$", "found", "=", "$", "registry", "->", "findByKeys", "(", "$", "ids", ")", ";", "$", "entities", "=", "array_merge", "(", "$", "entities", ",", "$", "found", ")", ";", "$", "this", "->", "updateRegistries", "(", "$", "found", ",", "$", "i", "-", "1", ")", ";", "if", "(", "count", "(", "$", "entities", ")", "===", "count", "(", "$", "ids", ")", ")", "{", "break", ";", "}", "}", "return", "$", "entities", ";", "}" ]
Finds a list of entities by their ids @param array $ids @return array
[ "Finds", "a", "list", "of", "entities", "by", "their", "ids" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L262-L280
240,918
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.findOneBy
public function findOneBy(array $criteria = [], array $orders = [], $offset = null): ?AbstractEntity { $array = $this->findBy($criteria, $orders, 1, $offset); return array_shift($array); }
php
public function findOneBy(array $criteria = [], array $orders = [], $offset = null): ?AbstractEntity { $array = $this->findBy($criteria, $orders, 1, $offset); return array_shift($array); }
[ "public", "function", "findOneBy", "(", "array", "$", "criteria", "=", "[", "]", ",", "array", "$", "orders", "=", "[", "]", ",", "$", "offset", "=", "null", ")", ":", "?", "AbstractEntity", "{", "$", "array", "=", "$", "this", "->", "findBy", "(", "$", "criteria", ",", "$", "orders", ",", "1", ",", "$", "offset", ")", ";", "return", "array_shift", "(", "$", "array", ")", ";", "}" ]
Finds one entity from criteria @param array $criteria @param array $orders @param null $offset @return AbstractEntity
[ "Finds", "one", "entity", "from", "criteria" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L323-L328
240,919
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.matching
public function matching(Criteria $criteria): array { $queryBuilder = $this->entityManager->createQueryBuilder() ->select('e.id') ->from($this->getEntityName(), 'e'); $queryBuilder->addCriteria($criteria); $ids = $queryBuilder->getQuery()->getResult(ColumnHydrator::HYDRATOR_MODE); if (count($ids) === 0) { return []; } return $this->findByIds($ids); }
php
public function matching(Criteria $criteria): array { $queryBuilder = $this->entityManager->createQueryBuilder() ->select('e.id') ->from($this->getEntityName(), 'e'); $queryBuilder->addCriteria($criteria); $ids = $queryBuilder->getQuery()->getResult(ColumnHydrator::HYDRATOR_MODE); if (count($ids) === 0) { return []; } return $this->findByIds($ids); }
[ "public", "function", "matching", "(", "Criteria", "$", "criteria", ")", ":", "array", "{", "$", "queryBuilder", "=", "$", "this", "->", "entityManager", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'e.id'", ")", "->", "from", "(", "$", "this", "->", "getEntityName", "(", ")", ",", "'e'", ")", ";", "$", "queryBuilder", "->", "addCriteria", "(", "$", "criteria", ")", ";", "$", "ids", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", "ColumnHydrator", "::", "HYDRATOR_MODE", ")", ";", "if", "(", "count", "(", "$", "ids", ")", "===", "0", ")", "{", "return", "[", "]", ";", "}", "return", "$", "this", "->", "findByIds", "(", "$", "ids", ")", ";", "}" ]
Gets all entities matching query criteria @param Criteria $criteria @return array
[ "Gets", "all", "entities", "matching", "query", "criteria" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L337-L352
240,920
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.getEntityRepository
public function getEntityRepository() { $repository = $this->entityManager->getRepository($this->getEntityName()); if (!($repository instanceof EntityRepository)) { throw new InvalidEntityNameException($this->getEntityName(), $this->getEntityClass()); } return $repository; }
php
public function getEntityRepository() { $repository = $this->entityManager->getRepository($this->getEntityName()); if (!($repository instanceof EntityRepository)) { throw new InvalidEntityNameException($this->getEntityName(), $this->getEntityClass()); } return $repository; }
[ "public", "function", "getEntityRepository", "(", ")", "{", "$", "repository", "=", "$", "this", "->", "entityManager", "->", "getRepository", "(", "$", "this", "->", "getEntityName", "(", ")", ")", ";", "if", "(", "!", "(", "$", "repository", "instanceof", "EntityRepository", ")", ")", "{", "throw", "new", "InvalidEntityNameException", "(", "$", "this", "->", "getEntityName", "(", ")", ",", "$", "this", "->", "getEntityClass", "(", ")", ")", ";", "}", "return", "$", "repository", ";", "}" ]
Gets the doctrine's entity repository for the entity @return \Doctrine\ORM\EntityRepository
[ "Gets", "the", "doctrine", "s", "entity", "repository", "for", "the", "entity" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L359-L368
240,921
Thuata/FrameworkBundle
Repository/AbstractRepository.php
AbstractRepository.updateRegistries
private function updateRegistries($entities, $from) { if (count($entities) >= 0) { for ($j = $from; $j >= 0; $j--) { /** @var RegistryInterface $registry */ $registry = $this->registries[ $j ]; /** @var AbstractEntity $entity */ foreach ($entities as $entity) { $registry->add($entity->getId(), $entity); } } } }
php
private function updateRegistries($entities, $from) { if (count($entities) >= 0) { for ($j = $from; $j >= 0; $j--) { /** @var RegistryInterface $registry */ $registry = $this->registries[ $j ]; /** @var AbstractEntity $entity */ foreach ($entities as $entity) { $registry->add($entity->getId(), $entity); } } } }
[ "private", "function", "updateRegistries", "(", "$", "entities", ",", "$", "from", ")", "{", "if", "(", "count", "(", "$", "entities", ")", ">=", "0", ")", "{", "for", "(", "$", "j", "=", "$", "from", ";", "$", "j", ">=", "0", ";", "$", "j", "--", ")", "{", "/** @var RegistryInterface $registry */", "$", "registry", "=", "$", "this", "->", "registries", "[", "$", "j", "]", ";", "/** @var AbstractEntity $entity */", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "$", "registry", "->", "add", "(", "$", "entity", "->", "getId", "(", ")", ",", "$", "entity", ")", ";", "}", "}", "}", "}" ]
Updates the registries @param array $entities @param int $from
[ "Updates", "the", "registries" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L376-L388
240,922
arnold-almeida/UIKit
src/Almeida/UIKit/Lib/Base.php
Base.render
public function render() { $args = func_get_args(); foreach ($args as $arg) { if(isset($this->output[$arg])) { return $this->output[$arg]; } throw new Exception("{$arg} is not set!", 1); } }
php
public function render() { $args = func_get_args(); foreach ($args as $arg) { if(isset($this->output[$arg])) { return $this->output[$arg]; } throw new Exception("{$arg} is not set!", 1); } }
[ "public", "function", "render", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "output", "[", "$", "arg", "]", ")", ")", "{", "return", "$", "this", "->", "output", "[", "$", "arg", "]", ";", "}", "throw", "new", "Exception", "(", "\"{$arg} is not set!\"", ",", "1", ")", ";", "}", "}" ]
Render compiled HTML
[ "Render", "compiled", "HTML" ]
cc52f46df011ec2f3676245c90c376da20c40e41
https://github.com/arnold-almeida/UIKit/blob/cc52f46df011ec2f3676245c90c376da20c40e41/src/Almeida/UIKit/Lib/Base.php#L65-L76
240,923
popy-dev/popy-calendar
src/Parser/ResultMapper/Chain.php
Chain.addMapper
public function addMapper(ResultMapperInterface $mapper) { if ($mapper instanceof self) { return $this->addMappers($mapper->mappers); } $this->mappers[] = $mapper; return $this; }
php
public function addMapper(ResultMapperInterface $mapper) { if ($mapper instanceof self) { return $this->addMappers($mapper->mappers); } $this->mappers[] = $mapper; return $this; }
[ "public", "function", "addMapper", "(", "ResultMapperInterface", "$", "mapper", ")", "{", "if", "(", "$", "mapper", "instanceof", "self", ")", "{", "return", "$", "this", "->", "addMappers", "(", "$", "mapper", "->", "mappers", ")", ";", "}", "$", "this", "->", "mappers", "[", "]", "=", "$", "mapper", ";", "return", "$", "this", ";", "}" ]
Adds a Mapper to the chain. @param ResultMapperInterface $mapper
[ "Adds", "a", "Mapper", "to", "the", "chain", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Parser/ResultMapper/Chain.php#L36-L45
240,924
zerospam/sdk-framework
src/Request/Api/HasNullableFields.php
HasNullableFields.isValueChanged
public function isValueChanged($field) { if (!$this->IsNullable($field)) { return false; } return isset($this->nullableChanged[$field]); }
php
public function isValueChanged($field) { if (!$this->IsNullable($field)) { return false; } return isset($this->nullableChanged[$field]); }
[ "public", "function", "isValueChanged", "(", "$", "field", ")", "{", "if", "(", "!", "$", "this", "->", "IsNullable", "(", "$", "field", ")", ")", "{", "return", "false", ";", "}", "return", "isset", "(", "$", "this", "->", "nullableChanged", "[", "$", "field", "]", ")", ";", "}" ]
Check if the given field is nullable and if it should be included in the request @param $field @return bool @internal param $value
[ "Check", "if", "the", "given", "field", "is", "nullable", "and", "if", "it", "should", "be", "included", "in", "the", "request" ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Request/Api/HasNullableFields.php#L40-L47
240,925
zerospam/sdk-framework
src/Request/Api/HasNullableFields.php
HasNullableFields.nullableChanged
protected function nullableChanged($field = null) { if (!$field) { $function = debug_backtrace()[1]['function']; $field = lcfirst(substr($function, 3)); } $this->nullableChanged[$field] = true; }
php
protected function nullableChanged($field = null) { if (!$field) { $function = debug_backtrace()[1]['function']; $field = lcfirst(substr($function, 3)); } $this->nullableChanged[$field] = true; }
[ "protected", "function", "nullableChanged", "(", "$", "field", "=", "null", ")", "{", "if", "(", "!", "$", "field", ")", "{", "$", "function", "=", "debug_backtrace", "(", ")", "[", "1", "]", "[", "'function'", "]", ";", "$", "field", "=", "lcfirst", "(", "substr", "(", "$", "function", ",", "3", ")", ")", ";", "}", "$", "this", "->", "nullableChanged", "[", "$", "field", "]", "=", "true", ";", "}" ]
Trigger the fact the nullable changed @param null $field
[ "Trigger", "the", "fact", "the", "nullable", "changed" ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Request/Api/HasNullableFields.php#L54-L62
240,926
vinala/kernel
src/Database/Database.php
Database.newConnection
public function newConnection($host, $database, $user, $password) { return self::$driver->connect($host, $database, $user, $password); }
php
public function newConnection($host, $database, $user, $password) { return self::$driver->connect($host, $database, $user, $password); }
[ "public", "function", "newConnection", "(", "$", "host", ",", "$", "database", ",", "$", "user", ",", "$", "password", ")", "{", "return", "self", "::", "$", "driver", "->", "connect", "(", "$", "host", ",", "$", "database", ",", "$", "user", ",", "$", "password", ")", ";", "}" ]
Connect to another driver database server. @param string, string, string, string @return PDO
[ "Connect", "to", "another", "driver", "database", "server", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Database.php#L109-L112
240,927
gibboncms/gibbon
src/Filesystems/FileCache.php
FileCache.persist
public function persist() { $parts = explode('/', $this->file); array_pop($parts); $dir = implode('/', $parts); if (!is_dir($dir)) { mkdir($dir, 493, true); } return file_put_contents($this->file, serialize($this->data)); }
php
public function persist() { $parts = explode('/', $this->file); array_pop($parts); $dir = implode('/', $parts); if (!is_dir($dir)) { mkdir($dir, 493, true); } return file_put_contents($this->file, serialize($this->data)); }
[ "public", "function", "persist", "(", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "this", "->", "file", ")", ";", "array_pop", "(", "$", "parts", ")", ";", "$", "dir", "=", "implode", "(", "'/'", ",", "$", "parts", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "493", ",", "true", ")", ";", "}", "return", "file_put_contents", "(", "$", "this", "->", "file", ",", "serialize", "(", "$", "this", "->", "data", ")", ")", ";", "}" ]
Persist the cache data @return bool
[ "Persist", "the", "cache", "data" ]
2905e90b2902149b3358b385264e98b97cf4fc00
https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Filesystems/FileCache.php#L92-L104
240,928
gibboncms/gibbon
src/Filesystems/FileCache.php
FileCache.rebuild
public function rebuild() { if (file_exists($this->file)) { try { $this->data = unserialize(file_get_contents($this->file)); return true; } catch (\Exception $e) { // Try just used to suppress the exception. If the cache is corrupted we just start from scratch. } } $this->data = []; $this->persist(); return false; }
php
public function rebuild() { if (file_exists($this->file)) { try { $this->data = unserialize(file_get_contents($this->file)); return true; } catch (\Exception $e) { // Try just used to suppress the exception. If the cache is corrupted we just start from scratch. } } $this->data = []; $this->persist(); return false; }
[ "public", "function", "rebuild", "(", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "file", ")", ")", "{", "try", "{", "$", "this", "->", "data", "=", "unserialize", "(", "file_get_contents", "(", "$", "this", "->", "file", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Try just used to suppress the exception. If the cache is corrupted we just start from scratch.", "}", "}", "$", "this", "->", "data", "=", "[", "]", ";", "$", "this", "->", "persist", "(", ")", ";", "return", "false", ";", "}" ]
Try to unserialize the existing cache, if it's corrupted, it's lost, let it go. @return bool
[ "Try", "to", "unserialize", "the", "existing", "cache", "if", "it", "s", "corrupted", "it", "s", "lost", "let", "it", "go", "." ]
2905e90b2902149b3358b385264e98b97cf4fc00
https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Filesystems/FileCache.php#L111-L125
240,929
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Asset/IconsBuilder.php
IconsBuilder.build
public function build($basePath) { $cache = new PuliResourceCollectionCache($this->cacheDir.'gui-icons.css', $this->debug); $resources = $this->resourceFinder->findByType('phlexible/icons'); if (!$cache->isFresh($resources)) { $content = $this->buildIcons($resources, $basePath); $cache->write($content); if (!$this->debug) { $this->compressor->compressFile((string) $cache); } } return new Asset((string) $cache); }
php
public function build($basePath) { $cache = new PuliResourceCollectionCache($this->cacheDir.'gui-icons.css', $this->debug); $resources = $this->resourceFinder->findByType('phlexible/icons'); if (!$cache->isFresh($resources)) { $content = $this->buildIcons($resources, $basePath); $cache->write($content); if (!$this->debug) { $this->compressor->compressFile((string) $cache); } } return new Asset((string) $cache); }
[ "public", "function", "build", "(", "$", "basePath", ")", "{", "$", "cache", "=", "new", "PuliResourceCollectionCache", "(", "$", "this", "->", "cacheDir", ".", "'gui-icons.css'", ",", "$", "this", "->", "debug", ")", ";", "$", "resources", "=", "$", "this", "->", "resourceFinder", "->", "findByType", "(", "'phlexible/icons'", ")", ";", "if", "(", "!", "$", "cache", "->", "isFresh", "(", "$", "resources", ")", ")", "{", "$", "content", "=", "$", "this", "->", "buildIcons", "(", "$", "resources", ",", "$", "basePath", ")", ";", "$", "cache", "->", "write", "(", "$", "content", ")", ";", "if", "(", "!", "$", "this", "->", "debug", ")", "{", "$", "this", "->", "compressor", "->", "compressFile", "(", "(", "string", ")", "$", "cache", ")", ";", "}", "}", "return", "new", "Asset", "(", "(", "string", ")", "$", "cache", ")", ";", "}" ]
Get all Stylesheets for the given section. @param string $basePath @return Asset
[ "Get", "all", "Stylesheets", "for", "the", "given", "section", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Asset/IconsBuilder.php#L72-L89
240,930
budkit/budkit-framework
src/Budkit/Parameter/Factory.php
Factory.getParameterListAsObject
public function getParameterListAsObject($name, $delimiter = ";") { $parameter = $this->getValidParameterOfType($name, "string"); $list = preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/', $parameter, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); //if emptyparameter return throw an exception because they'd be expecting an object; $parameters = []; $values = []; foreach ($list as $itemValue) { //if items have qualities associated with them we shall sort the parameter array by qualities; $bits = preg_split('/\s*(?:;*("[^"]+");*|;*(\'[^\']+\');*|;+)\s*/', $itemValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $value = array_shift($bits); $attributes = []; $lastNullAttribute = null; foreach ($bits as $bit) { if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ($start === '"' || $start === '\'') ) { $attributes[$lastNullAttribute] = substr($bit, 1, -1); } elseif ('=' === $end) { $lastNullAttribute = $bit = substr($bit, 0, -1); $attributes[$bit] = null; } else { $parts = explode('=', $bit); $attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : ''; } } $parameters[($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'') ? substr($value, 1, -1) : $value] = $attributes; } return new Factory($name, $parameters, static::$sanitizer, static::$validator, false); }
php
public function getParameterListAsObject($name, $delimiter = ";") { $parameter = $this->getValidParameterOfType($name, "string"); $list = preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/', $parameter, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); //if emptyparameter return throw an exception because they'd be expecting an object; $parameters = []; $values = []; foreach ($list as $itemValue) { //if items have qualities associated with them we shall sort the parameter array by qualities; $bits = preg_split('/\s*(?:;*("[^"]+");*|;*(\'[^\']+\');*|;+)\s*/', $itemValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $value = array_shift($bits); $attributes = []; $lastNullAttribute = null; foreach ($bits as $bit) { if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ($start === '"' || $start === '\'') ) { $attributes[$lastNullAttribute] = substr($bit, 1, -1); } elseif ('=' === $end) { $lastNullAttribute = $bit = substr($bit, 0, -1); $attributes[$bit] = null; } else { $parts = explode('=', $bit); $attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : ''; } } $parameters[($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'') ? substr($value, 1, -1) : $value] = $attributes; } return new Factory($name, $parameters, static::$sanitizer, static::$validator, false); }
[ "public", "function", "getParameterListAsObject", "(", "$", "name", ",", "$", "delimiter", "=", "\";\"", ")", "{", "$", "parameter", "=", "$", "this", "->", "getValidParameterOfType", "(", "$", "name", ",", "\"string\"", ")", ";", "$", "list", "=", "preg_split", "(", "'/\\s*(?:,*(\"[^\"]+\"),*|,*(\\'[^\\']+\\'),*|,+)\\s*/'", ",", "$", "parameter", ",", "null", ",", "PREG_SPLIT_NO_EMPTY", "|", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "//if emptyparameter return throw an exception because they'd be expecting an object;", "$", "parameters", "=", "[", "]", ";", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "list", "as", "$", "itemValue", ")", "{", "//if items have qualities associated with them we shall sort the parameter array by qualities;", "$", "bits", "=", "preg_split", "(", "'/\\s*(?:;*(\"[^\"]+\");*|;*(\\'[^\\']+\\');*|;+)\\s*/'", ",", "$", "itemValue", ",", "0", ",", "PREG_SPLIT_NO_EMPTY", "|", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "$", "value", "=", "array_shift", "(", "$", "bits", ")", ";", "$", "attributes", "=", "[", "]", ";", "$", "lastNullAttribute", "=", "null", ";", "foreach", "(", "$", "bits", "as", "$", "bit", ")", "{", "if", "(", "(", "$", "start", "=", "substr", "(", "$", "bit", ",", "0", ",", "1", ")", ")", "===", "(", "$", "end", "=", "substr", "(", "$", "bit", ",", "-", "1", ")", ")", "&&", "(", "$", "start", "===", "'\"'", "||", "$", "start", "===", "'\\''", ")", ")", "{", "$", "attributes", "[", "$", "lastNullAttribute", "]", "=", "substr", "(", "$", "bit", ",", "1", ",", "-", "1", ")", ";", "}", "elseif", "(", "'='", "===", "$", "end", ")", "{", "$", "lastNullAttribute", "=", "$", "bit", "=", "substr", "(", "$", "bit", ",", "0", ",", "-", "1", ")", ";", "$", "attributes", "[", "$", "bit", "]", "=", "null", ";", "}", "else", "{", "$", "parts", "=", "explode", "(", "'='", ",", "$", "bit", ")", ";", "$", "attributes", "[", "$", "parts", "[", "0", "]", "]", "=", "isset", "(", "$", "parts", "[", "1", "]", ")", "&&", "strlen", "(", "$", "parts", "[", "1", "]", ")", ">", "0", "?", "$", "parts", "[", "1", "]", ":", "''", ";", "}", "}", "$", "parameters", "[", "(", "$", "start", "=", "substr", "(", "$", "value", ",", "0", ",", "1", ")", ")", "===", "(", "$", "end", "=", "substr", "(", "$", "value", ",", "-", "1", ")", ")", "&&", "(", "$", "start", "===", "'\"'", "||", "$", "start", "===", "'\\''", ")", "?", "substr", "(", "$", "value", ",", "1", ",", "-", "1", ")", ":", "$", "value", "]", "=", "$", "attributes", ";", "}", "return", "new", "Factory", "(", "$", "name", ",", "$", "parameters", ",", "static", "::", "$", "sanitizer", ",", "static", "::", "$", "validator", ",", "false", ")", ";", "}" ]
Get a comma seperated list of params as a Parameter object; e.g key1=value1;q=0.31,key2=value2.... @param $name
[ "Get", "a", "comma", "seperated", "list", "of", "params", "as", "a", "Parameter", "object", ";" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Parameter/Factory.php#L56-L97
240,931
strident/Trident
src/Trident/Component/Debug/Toolbar/Toolbar.php
Toolbar.removeExtension
public function removeExtension($name) { if (isset($this->extensions[$name])) { unset($this->extensions[$name]); } return $this; }
php
public function removeExtension($name) { if (isset($this->extensions[$name])) { unset($this->extensions[$name]); } return $this; }
[ "public", "function", "removeExtension", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "extensions", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "extensions", "[", "$", "name", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove an extension. @param string $name @return Toolbar
[ "Remove", "an", "extension", "." ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/Debug/Toolbar/Toolbar.php#L82-L89
240,932
iRAP-software/package-core-libs
src/Core.php
Core.javascriptRedirectUser
public static function javascriptRedirectUser($url, $numSeconds = 0) { $htmlString = ''; $htmlString .= "<script type='text/javascript'>" . "var redirectTime=" . $numSeconds * 1000 . ";" . PHP_EOL . "var redirectURL='" . $url . "';" . PHP_EOL . 'setTimeout("location.href = redirectURL;", redirectTime);' . PHP_EOL . "</script>"; return $htmlString; }
php
public static function javascriptRedirectUser($url, $numSeconds = 0) { $htmlString = ''; $htmlString .= "<script type='text/javascript'>" . "var redirectTime=" . $numSeconds * 1000 . ";" . PHP_EOL . "var redirectURL='" . $url . "';" . PHP_EOL . 'setTimeout("location.href = redirectURL;", redirectTime);' . PHP_EOL . "</script>"; return $htmlString; }
[ "public", "static", "function", "javascriptRedirectUser", "(", "$", "url", ",", "$", "numSeconds", "=", "0", ")", "{", "$", "htmlString", "=", "''", ";", "$", "htmlString", ".=", "\"<script type='text/javascript'>\"", ".", "\"var redirectTime=\"", ".", "$", "numSeconds", "*", "1000", ".", "\";\"", ".", "PHP_EOL", ".", "\"var redirectURL='\"", ".", "$", "url", ".", "\"';\"", ".", "PHP_EOL", ".", "'setTimeout(\"location.href = redirectURL;\", redirectTime);'", ".", "PHP_EOL", ".", "\"</script>\"", ";", "return", "$", "htmlString", ";", "}" ]
Allows us to re-direct the user using javascript when headers have already been submitted. @param string url that we want to re-direct the user to. @param int numSeconds - optional integer specifying the number of seconds to delay. @return htmlString - the html to print out in order to redirect the user.
[ "Allows", "us", "to", "re", "-", "direct", "the", "user", "using", "javascript", "when", "headers", "have", "already", "been", "submitted", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L116-L128
240,933
iRAP-software/package-core-libs
src/Core.php
Core.setCliTitle
public static function setCliTitle($nameingPrefix) { $succeeded = false; $num_running = self::getNumProcRunning($nameingPrefix); if (function_exists('cli_set_process_title')) { cli_set_process_title($nameingPrefix . $num_running); $succeeded = true; } return $succeeded; }
php
public static function setCliTitle($nameingPrefix) { $succeeded = false; $num_running = self::getNumProcRunning($nameingPrefix); if (function_exists('cli_set_process_title')) { cli_set_process_title($nameingPrefix . $num_running); $succeeded = true; } return $succeeded; }
[ "public", "static", "function", "setCliTitle", "(", "$", "nameingPrefix", ")", "{", "$", "succeeded", "=", "false", ";", "$", "num_running", "=", "self", "::", "getNumProcRunning", "(", "$", "nameingPrefix", ")", ";", "if", "(", "function_exists", "(", "'cli_set_process_title'", ")", ")", "{", "cli_set_process_title", "(", "$", "nameingPrefix", ".", "$", "num_running", ")", ";", "$", "succeeded", "=", "true", ";", "}", "return", "$", "succeeded", ";", "}" ]
Sets the title of the process and will append the appropriate number of already existing processes with the same title. WARNING - this will fail and return FALSE if you are on Windows @param string $nameingPrefix - the name to give the process. @return boolean - true if successfully set the title, false if not.
[ "Sets", "the", "title", "of", "the", "process", "and", "will", "append", "the", "appropriate", "number", "of", "already", "existing", "processes", "with", "the", "same", "title", ".", "WARNING", "-", "this", "will", "fail", "and", "return", "FALSE", "if", "you", "are", "on", "Windows" ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L138-L150
240,934
iRAP-software/package-core-libs
src/Core.php
Core.sendApiRequest
public static function sendApiRequest($url, array $parameters, $requestType="POST", $headers=array()) { $allowedRequestTypes = array("GET", "POST", "PUT", "PATCH", "DELETE"); $requestTypeUpper = strtoupper($requestType); if (!in_array($requestTypeUpper, $allowedRequestTypes)) { throw new \Exception("API request needs to be one of GET, POST, PUT, PATCH, or DELETE."); } if ($requestType === "GET") { $ret = self::sendGetRequest($url, $parameters); } else { $query_string = http_build_query($parameters, '', '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); switch ($requestTypeUpper) { case "POST": { curl_setopt($ch, CURLOPT_POST, 1); } break; case "PUT": case "PATCH": case "DELETE": { curl_setopt($this->m_ch, CURLOPT_CUSTOMREQUEST, $requestTypeUpper); } break; default: { throw new \Exception("Unrecognized request type."); } } curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); // @TODO - S.P. to review... curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Manage if user provided headers. if (count($headers) > 0) { $headersStrings = array(); foreach ($headers as $key=>$value) { $headersStrings[] = "{$key}: {$value}"; } curl_setopt($this->m_ch, CURLOPT_HTTPHEADER, $this->m_headers); } $jsondata = curl_exec($ch); if (curl_error($ch)) { $errMsg = "Connection Error: " . curl_errno($ch) . ' - ' . curl_error($ch); throw new \Exception($errMsg); } curl_close($ch); $ret = json_decode($jsondata); # Decode JSON String if ($ret == null) { $errMsg = 'Recieved a non json response from API: ' . $jsondata; throw new \Exception($errMsg); } } return $ret; }
php
public static function sendApiRequest($url, array $parameters, $requestType="POST", $headers=array()) { $allowedRequestTypes = array("GET", "POST", "PUT", "PATCH", "DELETE"); $requestTypeUpper = strtoupper($requestType); if (!in_array($requestTypeUpper, $allowedRequestTypes)) { throw new \Exception("API request needs to be one of GET, POST, PUT, PATCH, or DELETE."); } if ($requestType === "GET") { $ret = self::sendGetRequest($url, $parameters); } else { $query_string = http_build_query($parameters, '', '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); switch ($requestTypeUpper) { case "POST": { curl_setopt($ch, CURLOPT_POST, 1); } break; case "PUT": case "PATCH": case "DELETE": { curl_setopt($this->m_ch, CURLOPT_CUSTOMREQUEST, $requestTypeUpper); } break; default: { throw new \Exception("Unrecognized request type."); } } curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); // @TODO - S.P. to review... curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Manage if user provided headers. if (count($headers) > 0) { $headersStrings = array(); foreach ($headers as $key=>$value) { $headersStrings[] = "{$key}: {$value}"; } curl_setopt($this->m_ch, CURLOPT_HTTPHEADER, $this->m_headers); } $jsondata = curl_exec($ch); if (curl_error($ch)) { $errMsg = "Connection Error: " . curl_errno($ch) . ' - ' . curl_error($ch); throw new \Exception($errMsg); } curl_close($ch); $ret = json_decode($jsondata); # Decode JSON String if ($ret == null) { $errMsg = 'Recieved a non json response from API: ' . $jsondata; throw new \Exception($errMsg); } } return $ret; }
[ "public", "static", "function", "sendApiRequest", "(", "$", "url", ",", "array", "$", "parameters", ",", "$", "requestType", "=", "\"POST\"", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "allowedRequestTypes", "=", "array", "(", "\"GET\"", ",", "\"POST\"", ",", "\"PUT\"", ",", "\"PATCH\"", ",", "\"DELETE\"", ")", ";", "$", "requestTypeUpper", "=", "strtoupper", "(", "$", "requestType", ")", ";", "if", "(", "!", "in_array", "(", "$", "requestTypeUpper", ",", "$", "allowedRequestTypes", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"API request needs to be one of GET, POST, PUT, PATCH, or DELETE.\"", ")", ";", "}", "if", "(", "$", "requestType", "===", "\"GET\"", ")", "{", "$", "ret", "=", "self", "::", "sendGetRequest", "(", "$", "url", ",", "$", "parameters", ")", ";", "}", "else", "{", "$", "query_string", "=", "http_build_query", "(", "$", "parameters", ",", "''", ",", "'&'", ")", ";", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "switch", "(", "$", "requestTypeUpper", ")", "{", "case", "\"POST\"", ":", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "1", ")", ";", "}", "break", ";", "case", "\"PUT\"", ":", "case", "\"PATCH\"", ":", "case", "\"DELETE\"", ":", "{", "curl_setopt", "(", "$", "this", "->", "m_ch", ",", "CURLOPT_CUSTOMREQUEST", ",", "$", "requestTypeUpper", ")", ";", "}", "break", ";", "default", ":", "{", "throw", "new", "\\", "Exception", "(", "\"Unrecognized request type.\"", ")", ";", "}", "}", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_TIMEOUT", ",", "30", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "query_string", ")", ";", "// @TODO - S.P. to review...", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYHOST", ",", "0", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYPEER", ",", "0", ")", ";", "// Manage if user provided headers.", "if", "(", "count", "(", "$", "headers", ")", ">", "0", ")", "{", "$", "headersStrings", "=", "array", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "headersStrings", "[", "]", "=", "\"{$key}: {$value}\"", ";", "}", "curl_setopt", "(", "$", "this", "->", "m_ch", ",", "CURLOPT_HTTPHEADER", ",", "$", "this", "->", "m_headers", ")", ";", "}", "$", "jsondata", "=", "curl_exec", "(", "$", "ch", ")", ";", "if", "(", "curl_error", "(", "$", "ch", ")", ")", "{", "$", "errMsg", "=", "\"Connection Error: \"", ".", "curl_errno", "(", "$", "ch", ")", ".", "' - '", ".", "curl_error", "(", "$", "ch", ")", ";", "throw", "new", "\\", "Exception", "(", "$", "errMsg", ")", ";", "}", "curl_close", "(", "$", "ch", ")", ";", "$", "ret", "=", "json_decode", "(", "$", "jsondata", ")", ";", "# Decode JSON String", "if", "(", "$", "ret", "==", "null", ")", "{", "$", "errMsg", "=", "'Recieved a non json response from API: '", ".", "$", "jsondata", ";", "throw", "new", "\\", "Exception", "(", "$", "errMsg", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Sends an api request through the use of CURL @param string url - the url where the api is located. @param array parameters - name value pairs for sending to the api server @param string $requestType - the request type. One of GET, POST, PUT, PATCH or DELETE @param array $headers - name/value pairs for headers. Useful for authentication etc. @return stdObject - json response object from the api server @throws \Exception
[ "Sends", "an", "api", "request", "through", "the", "use", "of", "CURL" ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L190-L275
240,935
iRAP-software/package-core-libs
src/Core.php
Core.sendGetRequest
public static function sendGetRequest($url, array $parameters=array(), $arrayForm=false) { if (count($parameters) > 0) { $query_string = http_build_query($parameters, '', '&'); $url .= $query_string; } # Get cURL resource $curl = curl_init(); # Set some options - we are passing in a useragent too here $curlOptions = array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, ); curl_setopt_array($curl, $curlOptions); # Send the request $rawResponse = curl_exec($curl); # Close request to clear up some resources curl_close($curl); # Convert to json object. $responseObj = json_decode($rawResponse, $arrayForm); # Decode JSON String if ($responseObj == null) { $errMsg = 'Recieved a non json response from API: ' . $rawResponse; throw new \Exception($errMsg); } return $responseObj; }
php
public static function sendGetRequest($url, array $parameters=array(), $arrayForm=false) { if (count($parameters) > 0) { $query_string = http_build_query($parameters, '', '&'); $url .= $query_string; } # Get cURL resource $curl = curl_init(); # Set some options - we are passing in a useragent too here $curlOptions = array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, ); curl_setopt_array($curl, $curlOptions); # Send the request $rawResponse = curl_exec($curl); # Close request to clear up some resources curl_close($curl); # Convert to json object. $responseObj = json_decode($rawResponse, $arrayForm); # Decode JSON String if ($responseObj == null) { $errMsg = 'Recieved a non json response from API: ' . $rawResponse; throw new \Exception($errMsg); } return $responseObj; }
[ "public", "static", "function", "sendGetRequest", "(", "$", "url", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "arrayForm", "=", "false", ")", "{", "if", "(", "count", "(", "$", "parameters", ")", ">", "0", ")", "{", "$", "query_string", "=", "http_build_query", "(", "$", "parameters", ",", "''", ",", "'&'", ")", ";", "$", "url", ".=", "$", "query_string", ";", "}", "# Get cURL resource", "$", "curl", "=", "curl_init", "(", ")", ";", "# Set some options - we are passing in a useragent too here", "$", "curlOptions", "=", "array", "(", "CURLOPT_RETURNTRANSFER", "=>", "1", ",", "CURLOPT_URL", "=>", "$", "url", ",", ")", ";", "curl_setopt_array", "(", "$", "curl", ",", "$", "curlOptions", ")", ";", "# Send the request", "$", "rawResponse", "=", "curl_exec", "(", "$", "curl", ")", ";", "# Close request to clear up some resources", "curl_close", "(", "$", "curl", ")", ";", "# Convert to json object.", "$", "responseObj", "=", "json_decode", "(", "$", "rawResponse", ",", "$", "arrayForm", ")", ";", "# Decode JSON String", "if", "(", "$", "responseObj", "==", "null", ")", "{", "$", "errMsg", "=", "'Recieved a non json response from API: '", ".", "$", "rawResponse", ";", "throw", "new", "\\", "Exception", "(", "$", "errMsg", ")", ";", "}", "return", "$", "responseObj", ";", "}" ]
Sends a GET request to a RESTful API through cURL. @param string url - the url where the api is located. @param array parameters - optional array of name value pairs for sending to the RESTful API. @param bool arrayForm - optional - set to true to return an array instead of a stdClass object. @return stdObject - json response object from the api server
[ "Sends", "a", "GET", "request", "to", "a", "RESTful", "API", "through", "cURL", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L289-L324
240,936
iRAP-software/package-core-libs
src/Core.php
Core.fetchArgs
public static function fetchArgs(array $reqArgs, array $optionalArgs) { $values = self::fetchReqArgs($reqArgs); $values = array_merge($values, self::fetchOptionalArgs($optionalArgs)); return $values; }
php
public static function fetchArgs(array $reqArgs, array $optionalArgs) { $values = self::fetchReqArgs($reqArgs); $values = array_merge($values, self::fetchOptionalArgs($optionalArgs)); return $values; }
[ "public", "static", "function", "fetchArgs", "(", "array", "$", "reqArgs", ",", "array", "$", "optionalArgs", ")", "{", "$", "values", "=", "self", "::", "fetchReqArgs", "(", "$", "reqArgs", ")", ";", "$", "values", "=", "array_merge", "(", "$", "values", ",", "self", "::", "fetchOptionalArgs", "(", "$", "optionalArgs", ")", ")", ";", "return", "$", "values", ";", "}" ]
Retrieves the specified arguments from REQUEST. This will throw an exception if a required argument is not present, but not if an optional argument is not. @param array reqArgs - required arguments that must exist @param array optionalArgs - arguments that should be retrieved if exist @return values - map of argument name/value pairs retrieved.
[ "Retrieves", "the", "specified", "arguments", "from", "REQUEST", ".", "This", "will", "throw", "an", "exception", "if", "a", "required", "argument", "is", "not", "present", "but", "not", "if", "an", "optional", "argument", "is", "not", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L525-L530
240,937
iRAP-software/package-core-libs
src/Core.php
Core.getCurrentUrl
public static function getCurrentUrl() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"])) { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; }
php
public static function getCurrentUrl() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"])) { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; }
[ "public", "static", "function", "getCurrentUrl", "(", ")", "{", "$", "pageURL", "=", "'http'", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "\"HTTPS\"", "]", ")", ")", "{", "$", "pageURL", ".=", "\"s\"", ";", "}", "$", "pageURL", ".=", "\"://\"", ";", "if", "(", "$", "_SERVER", "[", "\"SERVER_PORT\"", "]", "!=", "\"80\"", ")", "{", "$", "pageURL", ".=", "$", "_SERVER", "[", "\"SERVER_NAME\"", "]", ".", "\":\"", ".", "$", "_SERVER", "[", "\"SERVER_PORT\"", "]", ".", "$", "_SERVER", "[", "\"REQUEST_URI\"", "]", ";", "}", "else", "{", "$", "pageURL", ".=", "$", "_SERVER", "[", "\"SERVER_NAME\"", "]", ".", "$", "_SERVER", "[", "\"REQUEST_URI\"", "]", ";", "}", "return", "$", "pageURL", ";", "}" ]
Builds url of the current page, excluding any ?=&stuff, @param void @return pageURL - full page url of the current page e.g. https://www.google.com/some-page
[ "Builds", "url", "of", "the", "current", "page", "excluding", "any", "?", "=", "&stuff" ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L539-L561
240,938
iRAP-software/package-core-libs
src/Core.php
Core.versionGuard
public static function versionGuard($reqVersion, $errMsg='') { if (version_compare(PHP_VERSION, $reqVersion) == -1) { if ($errMsg == '') { $errMsg = 'Required PHP version: ' . $reqVersion . ', current Version: ' . PHP_VERSION; } die($errMsg); } }
php
public static function versionGuard($reqVersion, $errMsg='') { if (version_compare(PHP_VERSION, $reqVersion) == -1) { if ($errMsg == '') { $errMsg = 'Required PHP version: ' . $reqVersion . ', current Version: ' . PHP_VERSION; } die($errMsg); } }
[ "public", "static", "function", "versionGuard", "(", "$", "reqVersion", ",", "$", "errMsg", "=", "''", ")", "{", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "$", "reqVersion", ")", "==", "-", "1", ")", "{", "if", "(", "$", "errMsg", "==", "''", ")", "{", "$", "errMsg", "=", "'Required PHP version: '", ".", "$", "reqVersion", ".", "', current Version: '", ".", "PHP_VERSION", ";", "}", "die", "(", "$", "errMsg", ")", ";", "}", "}" ]
Implement a version guard. This will throw an exception if we do not have the required version of PHP that is specified. @param String $reqVersion - required version of php, e.g '5.4.0' @throws an exception if we do not meet the required php version.
[ "Implement", "a", "version", "guard", ".", "This", "will", "throw", "an", "exception", "if", "we", "do", "not", "have", "the", "required", "version", "of", "PHP", "that", "is", "specified", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L744-L756
240,939
iRAP-software/package-core-libs
src/Core.php
Core.isPortOpen
public static function isPortOpen($host, $port, $protocol) { $protocol = strtolower($protocol); if ($protocol != 'tcp' && $protocol != 'udp') { $errMsg = 'Unrecognized protocol [' . $protocol . '] ' . 'please specify [tcp] or [udp]'; throw new \Exception($errMsg); } if (empty($host)) { $host = self::getPublicIp(); } foreach ($ports as $port) { $connection = @fsockopen($host, $port); if (is_resource($connection)) { $isOpen = true; fclose($connection); } else { $isOpen = false; } } return $isOpen; }
php
public static function isPortOpen($host, $port, $protocol) { $protocol = strtolower($protocol); if ($protocol != 'tcp' && $protocol != 'udp') { $errMsg = 'Unrecognized protocol [' . $protocol . '] ' . 'please specify [tcp] or [udp]'; throw new \Exception($errMsg); } if (empty($host)) { $host = self::getPublicIp(); } foreach ($ports as $port) { $connection = @fsockopen($host, $port); if (is_resource($connection)) { $isOpen = true; fclose($connection); } else { $isOpen = false; } } return $isOpen; }
[ "public", "static", "function", "isPortOpen", "(", "$", "host", ",", "$", "port", ",", "$", "protocol", ")", "{", "$", "protocol", "=", "strtolower", "(", "$", "protocol", ")", ";", "if", "(", "$", "protocol", "!=", "'tcp'", "&&", "$", "protocol", "!=", "'udp'", ")", "{", "$", "errMsg", "=", "'Unrecognized protocol ['", ".", "$", "protocol", ".", "'] '", ".", "'please specify [tcp] or [udp]'", ";", "throw", "new", "\\", "Exception", "(", "$", "errMsg", ")", ";", "}", "if", "(", "empty", "(", "$", "host", ")", ")", "{", "$", "host", "=", "self", "::", "getPublicIp", "(", ")", ";", "}", "foreach", "(", "$", "ports", "as", "$", "port", ")", "{", "$", "connection", "=", "@", "fsockopen", "(", "$", "host", ",", "$", "port", ")", ";", "if", "(", "is_resource", "(", "$", "connection", ")", ")", "{", "$", "isOpen", "=", "true", ";", "fclose", "(", "$", "connection", ")", ";", "}", "else", "{", "$", "isOpen", "=", "false", ";", "}", "}", "return", "$", "isOpen", ";", "}" ]
Checks to see if the specified port is open. @param string $host - the host to check against. @param int $port - the port to check @return $isOpen - true if port is open, false if not.
[ "Checks", "to", "see", "if", "the", "specified", "port", "is", "open", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L804-L837
240,940
iRAP-software/package-core-libs
src/Core.php
Core.generateConfig
public static function generateConfig($settings, $variableName, $filePath) { $varStr = var_export($settings, true); $output = '<?php' . PHP_EOL . '$' . $variableName . ' = ' . $varStr . ';'; # file_put_contents returns num bytes written or boolean false if fail $wroteFile = file_put_contents($filePath, $output); if ($wroteFile === FALSE) { $msg = "Failed to generate config file. Check permissions!"; throw new \Exception($msg); } }
php
public static function generateConfig($settings, $variableName, $filePath) { $varStr = var_export($settings, true); $output = '<?php' . PHP_EOL . '$' . $variableName . ' = ' . $varStr . ';'; # file_put_contents returns num bytes written or boolean false if fail $wroteFile = file_put_contents($filePath, $output); if ($wroteFile === FALSE) { $msg = "Failed to generate config file. Check permissions!"; throw new \Exception($msg); } }
[ "public", "static", "function", "generateConfig", "(", "$", "settings", ",", "$", "variableName", ",", "$", "filePath", ")", "{", "$", "varStr", "=", "var_export", "(", "$", "settings", ",", "true", ")", ";", "$", "output", "=", "'<?php'", ".", "PHP_EOL", ".", "'$'", ".", "$", "variableName", ".", "' = '", ".", "$", "varStr", ".", "';'", ";", "# file_put_contents returns num bytes written or boolean false if fail", "$", "wroteFile", "=", "file_put_contents", "(", "$", "filePath", ",", "$", "output", ")", ";", "if", "(", "$", "wroteFile", "===", "FALSE", ")", "{", "$", "msg", "=", "\"Failed to generate config file. Check permissions!\"", ";", "throw", "new", "\\", "Exception", "(", "$", "msg", ")", ";", "}", "}" ]
Generate a php config file to have the setting provided. This is useful if we want to be able to update our config file through code, such as a web ui to upadate settings. Platforms like wordpress allow updating the settings, but do this through a database. @param mixed $settings - array or variable that we want to save to the file @param string $variableName - name of the settings variable so that it is reloaded correctly @param string $filePath - path to the file where we want to save the settings. (overwritten) @return void - creates a config file, or throws an exception if failed. @throws Exception if failed to write to the specified filePath, e.g dont have permissions.
[ "Generate", "a", "php", "config", "file", "to", "have", "the", "setting", "provided", ".", "This", "is", "useful", "if", "we", "want", "to", "be", "able", "to", "update", "our", "config", "file", "through", "code", "such", "as", "a", "web", "ui", "to", "upadate", "settings", ".", "Platforms", "like", "wordpress", "allow", "updating", "the", "settings", "but", "do", "this", "through", "a", "database", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L910-L926
240,941
iRAP-software/package-core-libs
src/Core.php
Core.generatePasswordHash
public static function generatePasswordHash($rawPassword, $cost=11) { $cost = intval($cost); $cost = self::clampValue($cost, $max=31, $min=4); # has to be 2 digits, eg. 04 if ($cost < 10) { $cost = "0" . $cost; } $options = array('cost' => $cost); $hash = password_hash($rawPassword, PASSWORD_BCRYPT, $options); return $hash; }
php
public static function generatePasswordHash($rawPassword, $cost=11) { $cost = intval($cost); $cost = self::clampValue($cost, $max=31, $min=4); # has to be 2 digits, eg. 04 if ($cost < 10) { $cost = "0" . $cost; } $options = array('cost' => $cost); $hash = password_hash($rawPassword, PASSWORD_BCRYPT, $options); return $hash; }
[ "public", "static", "function", "generatePasswordHash", "(", "$", "rawPassword", ",", "$", "cost", "=", "11", ")", "{", "$", "cost", "=", "intval", "(", "$", "cost", ")", ";", "$", "cost", "=", "self", "::", "clampValue", "(", "$", "cost", ",", "$", "max", "=", "31", ",", "$", "min", "=", "4", ")", ";", "# has to be 2 digits, eg. 04", "if", "(", "$", "cost", "<", "10", ")", "{", "$", "cost", "=", "\"0\"", ".", "$", "cost", ";", "}", "$", "options", "=", "array", "(", "'cost'", "=>", "$", "cost", ")", ";", "$", "hash", "=", "password_hash", "(", "$", "rawPassword", ",", "PASSWORD_BCRYPT", ",", "$", "options", ")", ";", "return", "$", "hash", ";", "}" ]
Converts a raw password into a hash using PHP 5.5's new hashing method @param String $rawPassword - the password we wish to hash @param int $cost - The two digit cost parameter is the base-2 logarithm of the iteration count for the underlying Blowfish-based hashing algorithmeter and must be in range 04-31 @return string - the generated hash
[ "Converts", "a", "raw", "password", "into", "a", "hash", "using", "PHP", "5", ".", "5", "s", "new", "hashing", "method" ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L938-L953
240,942
iRAP-software/package-core-libs
src/Core.php
Core.isValidSignedRequest
public static function isValidSignedRequest(array $data, string $signature) { $generated_signature = SiteSpecific::generateSignature($data); return ($generated_signature == $signature); }
php
public static function isValidSignedRequest(array $data, string $signature) { $generated_signature = SiteSpecific::generateSignature($data); return ($generated_signature == $signature); }
[ "public", "static", "function", "isValidSignedRequest", "(", "array", "$", "data", ",", "string", "$", "signature", ")", "{", "$", "generated_signature", "=", "SiteSpecific", "::", "generateSignature", "(", "$", "data", ")", ";", "return", "(", "$", "generated_signature", "==", "$", "signature", ")", ";", "}" ]
Check if the provided data has the correct signature. @param array $data - the data we recieved that was signed. The signature MUST NOT be in this array. @param string $signature - the signature that came with the data. This is what we will check if is valid for the data recieved. @return bool - true if the signature is correct for the data, or false if not (in which case a user probably tried to manipulate the data).
[ "Check", "if", "the", "provided", "data", "has", "the", "correct", "signature", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L1003-L1007
240,943
osflab/view
Helper/Bootstrap/ButtonGroup.php
ButtonGroup.button
public function button( $label = null, $url = null, $status = null, $icon = null, $block = false, $disabled = false, $flat = false, $size = Button::SIZE_NORMAL) { $button = new Button($label, $url, $status, $icon, $block, $disabled, $flat, $size); return $this->addButton($button); }
php
public function button( $label = null, $url = null, $status = null, $icon = null, $block = false, $disabled = false, $flat = false, $size = Button::SIZE_NORMAL) { $button = new Button($label, $url, $status, $icon, $block, $disabled, $flat, $size); return $this->addButton($button); }
[ "public", "function", "button", "(", "$", "label", "=", "null", ",", "$", "url", "=", "null", ",", "$", "status", "=", "null", ",", "$", "icon", "=", "null", ",", "$", "block", "=", "false", ",", "$", "disabled", "=", "false", ",", "$", "flat", "=", "false", ",", "$", "size", "=", "Button", "::", "SIZE_NORMAL", ")", "{", "$", "button", "=", "new", "Button", "(", "$", "label", ",", "$", "url", ",", "$", "status", ",", "$", "icon", ",", "$", "block", ",", "$", "disabled", ",", "$", "flat", ",", "$", "size", ")", ";", "return", "$", "this", "->", "addButton", "(", "$", "button", ")", ";", "}" ]
Create a new button @param string $label @param string $url @param string $status @param string $icon @param bool $block @param bool $disabled @param bool $flat @param string $size @return $this
[ "Create", "a", "new", "button" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/ButtonGroup.php#L66-L78
240,944
bfansports/CloudProcessingEngine-SDK
src/SA/CpeSdk/CpeLogger.php
CpeLogger.logOut
public function logOut( $type, $source, $message, $logKey = null, $printOut = true) { $log = [ "time" => date("Y-m-d H:i:s", time()), "source" => $source, "type" => $type, "message" => $message ]; if ($printOut) $this->printOut = $printOut; if ($logKey) $log["logKey"] = $logKey; // Set the log filaname based on the logkey If provided. // If not then it will log in a file that has the name of the PHP activity file $file = $this->activityName; // Append progname to the path $this->filePath = $this->logPath . "/" . $file.".log"; // Open Syslog. Use programe name as key if (!openlog (__FILE__, LOG_CONS|LOG_PID, LOG_LOCAL1)) throw new CpeException("Unable to connect to Syslog!", OPENLOG_ERROR); // Change Syslog priority level switch ($type) { case "INFO": $priority = LOG_INFO; break; case "ERROR": $priority = LOG_ERR; break; case "FATAL": $priority = LOG_ALERT; break; case "WARNING": $priority = LOG_WARNING; break; case "DEBUG": $priority = LOG_DEBUG; break; default: throw new CpeException("Unknown log Type!", LOG_TYPE_ERROR); } // Print log in file $this->printToFile($log); // Encode log message in JSON for better parsing $out = json_encode($log); // Send to syslog syslog($priority, $out); }
php
public function logOut( $type, $source, $message, $logKey = null, $printOut = true) { $log = [ "time" => date("Y-m-d H:i:s", time()), "source" => $source, "type" => $type, "message" => $message ]; if ($printOut) $this->printOut = $printOut; if ($logKey) $log["logKey"] = $logKey; // Set the log filaname based on the logkey If provided. // If not then it will log in a file that has the name of the PHP activity file $file = $this->activityName; // Append progname to the path $this->filePath = $this->logPath . "/" . $file.".log"; // Open Syslog. Use programe name as key if (!openlog (__FILE__, LOG_CONS|LOG_PID, LOG_LOCAL1)) throw new CpeException("Unable to connect to Syslog!", OPENLOG_ERROR); // Change Syslog priority level switch ($type) { case "INFO": $priority = LOG_INFO; break; case "ERROR": $priority = LOG_ERR; break; case "FATAL": $priority = LOG_ALERT; break; case "WARNING": $priority = LOG_WARNING; break; case "DEBUG": $priority = LOG_DEBUG; break; default: throw new CpeException("Unknown log Type!", LOG_TYPE_ERROR); } // Print log in file $this->printToFile($log); // Encode log message in JSON for better parsing $out = json_encode($log); // Send to syslog syslog($priority, $out); }
[ "public", "function", "logOut", "(", "$", "type", ",", "$", "source", ",", "$", "message", ",", "$", "logKey", "=", "null", ",", "$", "printOut", "=", "true", ")", "{", "$", "log", "=", "[", "\"time\"", "=>", "date", "(", "\"Y-m-d H:i:s\"", ",", "time", "(", ")", ")", ",", "\"source\"", "=>", "$", "source", ",", "\"type\"", "=>", "$", "type", ",", "\"message\"", "=>", "$", "message", "]", ";", "if", "(", "$", "printOut", ")", "$", "this", "->", "printOut", "=", "$", "printOut", ";", "if", "(", "$", "logKey", ")", "$", "log", "[", "\"logKey\"", "]", "=", "$", "logKey", ";", "// Set the log filaname based on the logkey If provided.", "// If not then it will log in a file that has the name of the PHP activity file", "$", "file", "=", "$", "this", "->", "activityName", ";", "// Append progname to the path", "$", "this", "->", "filePath", "=", "$", "this", "->", "logPath", ".", "\"/\"", ".", "$", "file", ".", "\".log\"", ";", "// Open Syslog. Use programe name as key", "if", "(", "!", "openlog", "(", "__FILE__", ",", "LOG_CONS", "|", "LOG_PID", ",", "LOG_LOCAL1", ")", ")", "throw", "new", "CpeException", "(", "\"Unable to connect to Syslog!\"", ",", "OPENLOG_ERROR", ")", ";", "// Change Syslog priority level", "switch", "(", "$", "type", ")", "{", "case", "\"INFO\"", ":", "$", "priority", "=", "LOG_INFO", ";", "break", ";", "case", "\"ERROR\"", ":", "$", "priority", "=", "LOG_ERR", ";", "break", ";", "case", "\"FATAL\"", ":", "$", "priority", "=", "LOG_ALERT", ";", "break", ";", "case", "\"WARNING\"", ":", "$", "priority", "=", "LOG_WARNING", ";", "break", ";", "case", "\"DEBUG\"", ":", "$", "priority", "=", "LOG_DEBUG", ";", "break", ";", "default", ":", "throw", "new", "CpeException", "(", "\"Unknown log Type!\"", ",", "LOG_TYPE_ERROR", ")", ";", "}", "// Print log in file", "$", "this", "->", "printToFile", "(", "$", "log", ")", ";", "// Encode log message in JSON for better parsing", "$", "out", "=", "json_encode", "(", "$", "log", ")", ";", "// Send to syslog", "syslog", "(", "$", "priority", ",", "$", "out", ")", ";", "}" ]
Log message to syslog and log file. Will print
[ "Log", "message", "to", "syslog", "and", "log", "file", ".", "Will", "print" ]
8714d088a16c6dd4735df68e17256cc41bba2cfb
https://github.com/bfansports/CloudProcessingEngine-SDK/blob/8714d088a16c6dd4735df68e17256cc41bba2cfb/src/SA/CpeSdk/CpeLogger.php#L44-L105
240,945
bfansports/CloudProcessingEngine-SDK
src/SA/CpeSdk/CpeLogger.php
CpeLogger.printToFile
private function printToFile($log) { if (!is_string($log['message'])) $log['message'] = json_encode($log['message']); $toPrint = $log['time'] . " [" . $log['type'] . "] [" . $log['source'] . "] "; // If there is a workflow ID. We append it. if (isset($log['logKey']) && $log['logKey']) $toPrint .= "[".$log['logKey']."] "; $toPrint .= $log['message'] . "\n"; if ($this->printout) print $toPrint; if (file_put_contents( $this->filePath, $toPrint, FILE_APPEND) === false) { throw new CpeException("Can't write into log file: $this->logPath", LOGFILE_ERROR); } }
php
private function printToFile($log) { if (!is_string($log['message'])) $log['message'] = json_encode($log['message']); $toPrint = $log['time'] . " [" . $log['type'] . "] [" . $log['source'] . "] "; // If there is a workflow ID. We append it. if (isset($log['logKey']) && $log['logKey']) $toPrint .= "[".$log['logKey']."] "; $toPrint .= $log['message'] . "\n"; if ($this->printout) print $toPrint; if (file_put_contents( $this->filePath, $toPrint, FILE_APPEND) === false) { throw new CpeException("Can't write into log file: $this->logPath", LOGFILE_ERROR); } }
[ "private", "function", "printToFile", "(", "$", "log", ")", "{", "if", "(", "!", "is_string", "(", "$", "log", "[", "'message'", "]", ")", ")", "$", "log", "[", "'message'", "]", "=", "json_encode", "(", "$", "log", "[", "'message'", "]", ")", ";", "$", "toPrint", "=", "$", "log", "[", "'time'", "]", ".", "\" [\"", ".", "$", "log", "[", "'type'", "]", ".", "\"] [\"", ".", "$", "log", "[", "'source'", "]", ".", "\"] \"", ";", "// If there is a workflow ID. We append it.", "if", "(", "isset", "(", "$", "log", "[", "'logKey'", "]", ")", "&&", "$", "log", "[", "'logKey'", "]", ")", "$", "toPrint", ".=", "\"[\"", ".", "$", "log", "[", "'logKey'", "]", ".", "\"] \"", ";", "$", "toPrint", ".=", "$", "log", "[", "'message'", "]", ".", "\"\\n\"", ";", "if", "(", "$", "this", "->", "printout", ")", "print", "$", "toPrint", ";", "if", "(", "file_put_contents", "(", "$", "this", "->", "filePath", ",", "$", "toPrint", ",", "FILE_APPEND", ")", "===", "false", ")", "{", "throw", "new", "CpeException", "(", "\"Can't write into log file: $this->logPath\"", ",", "LOGFILE_ERROR", ")", ";", "}", "}" ]
Write log in file
[ "Write", "log", "in", "file" ]
8714d088a16c6dd4735df68e17256cc41bba2cfb
https://github.com/bfansports/CloudProcessingEngine-SDK/blob/8714d088a16c6dd4735df68e17256cc41bba2cfb/src/SA/CpeSdk/CpeLogger.php#L108-L129
240,946
novuso/system
src/Type/Enum.php
Enum.fromString
final public static function fromString(string $string): Enum { $parts = explode('::', $string); return self::fromName(end($parts)); }
php
final public static function fromString(string $string): Enum { $parts = explode('::', $string); return self::fromName(end($parts)); }
[ "final", "public", "static", "function", "fromString", "(", "string", "$", "string", ")", ":", "Enum", "{", "$", "parts", "=", "explode", "(", "'::'", ",", "$", "string", ")", ";", "return", "self", "::", "fromName", "(", "end", "(", "$", "parts", ")", ")", ";", "}" ]
Creates instance from a string representation @param string $string The string representation @return Enum @throws DomainException When the string is invalid
[ "Creates", "instance", "from", "a", "string", "representation" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L113-L118
240,947
novuso/system
src/Type/Enum.php
Enum.fromName
final public static function fromName(string $name): Enum { $constName = sprintf('%s::%s', static::class, $name); if (!defined($constName)) { $message = sprintf('%s is not a member constant of enum %s', $name, static::class); throw new DomainException($message); } return new static(constant($constName)); }
php
final public static function fromName(string $name): Enum { $constName = sprintf('%s::%s', static::class, $name); if (!defined($constName)) { $message = sprintf('%s is not a member constant of enum %s', $name, static::class); throw new DomainException($message); } return new static(constant($constName)); }
[ "final", "public", "static", "function", "fromName", "(", "string", "$", "name", ")", ":", "Enum", "{", "$", "constName", "=", "sprintf", "(", "'%s::%s'", ",", "static", "::", "class", ",", "$", "name", ")", ";", "if", "(", "!", "defined", "(", "$", "constName", ")", ")", "{", "$", "message", "=", "sprintf", "(", "'%s is not a member constant of enum %s'", ",", "$", "name", ",", "static", "::", "class", ")", ";", "throw", "new", "DomainException", "(", "$", "message", ")", ";", "}", "return", "new", "static", "(", "constant", "(", "$", "constName", ")", ")", ";", "}" ]
Creates instance from an enum constant name @param string $name The enum constant name @return Enum @throws DomainException When the name is invalid
[ "Creates", "instance", "from", "an", "enum", "constant", "name" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L129-L139
240,948
novuso/system
src/Type/Enum.php
Enum.fromOrdinal
final public static function fromOrdinal(int $ordinal): Enum { $constants = self::getMembers(); $item = array_slice($constants, $ordinal, 1, true); if (!$item) { $end = count($constants) - 1; $message = sprintf('Enum ordinal (%d) out of range [0, %d]', $ordinal, $end); throw new DomainException($message); } return new static(current($item)); }
php
final public static function fromOrdinal(int $ordinal): Enum { $constants = self::getMembers(); $item = array_slice($constants, $ordinal, 1, true); if (!$item) { $end = count($constants) - 1; $message = sprintf('Enum ordinal (%d) out of range [0, %d]', $ordinal, $end); throw new DomainException($message); } return new static(current($item)); }
[ "final", "public", "static", "function", "fromOrdinal", "(", "int", "$", "ordinal", ")", ":", "Enum", "{", "$", "constants", "=", "self", "::", "getMembers", "(", ")", ";", "$", "item", "=", "array_slice", "(", "$", "constants", ",", "$", "ordinal", ",", "1", ",", "true", ")", ";", "if", "(", "!", "$", "item", ")", "{", "$", "end", "=", "count", "(", "$", "constants", ")", "-", "1", ";", "$", "message", "=", "sprintf", "(", "'Enum ordinal (%d) out of range [0, %d]'", ",", "$", "ordinal", ",", "$", "end", ")", ";", "throw", "new", "DomainException", "(", "$", "message", ")", ";", "}", "return", "new", "static", "(", "current", "(", "$", "item", ")", ")", ";", "}" ]
Creates instance from an enum ordinal position @param int $ordinal The enum ordinal position @return Enum @throws DomainException When the ordinal is invalid
[ "Creates", "instance", "from", "an", "enum", "ordinal", "position" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L150-L162
240,949
novuso/system
src/Type/Enum.php
Enum.getMembers
final public static function getMembers(): array { if (!isset(self::$constants[static::class])) { $reflection = new ReflectionClass(static::class); $constants = self::sortConstants($reflection); self::guardConstants($constants); self::$constants[static::class] = $constants; } return self::$constants[static::class]; }
php
final public static function getMembers(): array { if (!isset(self::$constants[static::class])) { $reflection = new ReflectionClass(static::class); $constants = self::sortConstants($reflection); self::guardConstants($constants); self::$constants[static::class] = $constants; } return self::$constants[static::class]; }
[ "final", "public", "static", "function", "getMembers", "(", ")", ":", "array", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "constants", "[", "static", "::", "class", "]", ")", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "static", "::", "class", ")", ";", "$", "constants", "=", "self", "::", "sortConstants", "(", "$", "reflection", ")", ";", "self", "::", "guardConstants", "(", "$", "constants", ")", ";", "self", "::", "$", "constants", "[", "static", "::", "class", "]", "=", "$", "constants", ";", "}", "return", "self", "::", "$", "constants", "[", "static", "::", "class", "]", ";", "}" ]
Retrieves enum member names and values @return array @throws DomainException When more than one constant has the same value
[ "Retrieves", "enum", "member", "names", "and", "values" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L171-L181
240,950
novuso/system
src/Type/Enum.php
Enum.name
final public function name(): string { if ($this->name === null) { $constants = self::getMembers(); $this->name = array_search($this->value, $constants, true); } return $this->name; }
php
final public function name(): string { if ($this->name === null) { $constants = self::getMembers(); $this->name = array_search($this->value, $constants, true); } return $this->name; }
[ "final", "public", "function", "name", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "name", "===", "null", ")", "{", "$", "constants", "=", "self", "::", "getMembers", "(", ")", ";", "$", "this", "->", "name", "=", "array_search", "(", "$", "this", "->", "value", ",", "$", "constants", ",", "true", ")", ";", "}", "return", "$", "this", "->", "name", ";", "}" ]
Retrieves the enum constant name @return string
[ "Retrieves", "the", "enum", "constant", "name" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L198-L206
240,951
novuso/system
src/Type/Enum.php
Enum.ordinal
final public function ordinal(): int { if ($this->ordinal === null) { $ordinal = 0; foreach (self::getMembers() as $constValue) { if ($this->value === $constValue) { break; } $ordinal++; } $this->ordinal = $ordinal; } return $this->ordinal; }
php
final public function ordinal(): int { if ($this->ordinal === null) { $ordinal = 0; foreach (self::getMembers() as $constValue) { if ($this->value === $constValue) { break; } $ordinal++; } $this->ordinal = $ordinal; } return $this->ordinal; }
[ "final", "public", "function", "ordinal", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "ordinal", "===", "null", ")", "{", "$", "ordinal", "=", "0", ";", "foreach", "(", "self", "::", "getMembers", "(", ")", "as", "$", "constValue", ")", "{", "if", "(", "$", "this", "->", "value", "===", "$", "constValue", ")", "{", "break", ";", "}", "$", "ordinal", "++", ";", "}", "$", "this", "->", "ordinal", "=", "$", "ordinal", ";", "}", "return", "$", "this", "->", "ordinal", ";", "}" ]
Retrieves the enum ordinal position @return int
[ "Retrieves", "the", "enum", "ordinal", "position" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L213-L227
240,952
novuso/system
src/Type/Enum.php
Enum.guardConstants
final private static function guardConstants(array $constants): void { $duplicates = []; foreach ($constants as $value) { $names = array_keys($constants, $value, $strict = true); if (count($names) > 1) { $duplicates[VarPrinter::toString($value)] = $names; } } if (!empty($duplicates)) { $list = array_map(function ($names) use ($constants) { return sprintf('(%s)=%s', implode('|', $names), VarPrinter::toString($constants[$names[0]])); }, $duplicates); $message = sprintf('Duplicate enum values: %s', implode(', ', $list)); throw new DomainException($message); } }
php
final private static function guardConstants(array $constants): void { $duplicates = []; foreach ($constants as $value) { $names = array_keys($constants, $value, $strict = true); if (count($names) > 1) { $duplicates[VarPrinter::toString($value)] = $names; } } if (!empty($duplicates)) { $list = array_map(function ($names) use ($constants) { return sprintf('(%s)=%s', implode('|', $names), VarPrinter::toString($constants[$names[0]])); }, $duplicates); $message = sprintf('Duplicate enum values: %s', implode(', ', $list)); throw new DomainException($message); } }
[ "final", "private", "static", "function", "guardConstants", "(", "array", "$", "constants", ")", ":", "void", "{", "$", "duplicates", "=", "[", "]", ";", "foreach", "(", "$", "constants", "as", "$", "value", ")", "{", "$", "names", "=", "array_keys", "(", "$", "constants", ",", "$", "value", ",", "$", "strict", "=", "true", ")", ";", "if", "(", "count", "(", "$", "names", ")", ">", "1", ")", "{", "$", "duplicates", "[", "VarPrinter", "::", "toString", "(", "$", "value", ")", "]", "=", "$", "names", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "duplicates", ")", ")", "{", "$", "list", "=", "array_map", "(", "function", "(", "$", "names", ")", "use", "(", "$", "constants", ")", "{", "return", "sprintf", "(", "'(%s)=%s'", ",", "implode", "(", "'|'", ",", "$", "names", ")", ",", "VarPrinter", "::", "toString", "(", "$", "constants", "[", "$", "names", "[", "0", "]", "]", ")", ")", ";", "}", ",", "$", "duplicates", ")", ";", "$", "message", "=", "sprintf", "(", "'Duplicate enum values: %s'", ",", "implode", "(", "', '", ",", "$", "list", ")", ")", ";", "throw", "new", "DomainException", "(", "$", "message", ")", ";", "}", "}" ]
Validates enum constants @param array $constants The enum constants @return void @throws DomainException When more than one constant has the same value
[ "Validates", "enum", "constants" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L332-L348
240,953
novuso/system
src/Type/Enum.php
Enum.sortConstants
final private static function sortConstants(ReflectionClass $reflection): array { $constants = []; while ($reflection && __CLASS__ !== $reflection->getName()) { $scope = []; foreach ($reflection->getReflectionConstants() as $const) { if ($const->isPublic()) { $scope[$const->getName()] = $const->getValue(); } } $constants = $scope + $constants; $reflection = $reflection->getParentClass(); } return $constants; }
php
final private static function sortConstants(ReflectionClass $reflection): array { $constants = []; while ($reflection && __CLASS__ !== $reflection->getName()) { $scope = []; foreach ($reflection->getReflectionConstants() as $const) { if ($const->isPublic()) { $scope[$const->getName()] = $const->getValue(); } } $constants = $scope + $constants; $reflection = $reflection->getParentClass(); } return $constants; }
[ "final", "private", "static", "function", "sortConstants", "(", "ReflectionClass", "$", "reflection", ")", ":", "array", "{", "$", "constants", "=", "[", "]", ";", "while", "(", "$", "reflection", "&&", "__CLASS__", "!==", "$", "reflection", "->", "getName", "(", ")", ")", "{", "$", "scope", "=", "[", "]", ";", "foreach", "(", "$", "reflection", "->", "getReflectionConstants", "(", ")", "as", "$", "const", ")", "{", "if", "(", "$", "const", "->", "isPublic", "(", ")", ")", "{", "$", "scope", "[", "$", "const", "->", "getName", "(", ")", "]", "=", "$", "const", "->", "getValue", "(", ")", ";", "}", "}", "$", "constants", "=", "$", "scope", "+", "$", "constants", ";", "$", "reflection", "=", "$", "reflection", "->", "getParentClass", "(", ")", ";", "}", "return", "$", "constants", ";", "}" ]
Sorts member constants @param ReflectionClass $reflection The reflection instance @return array
[ "Sorts", "member", "constants" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L357-L373
240,954
ntentan/utils
src/Validator.php
Validator.getValidation
private function getValidation(string $name): validator\Validation { if (!isset($this->validations[$name])) { if (isset($this->validationRegister[$name])) { $class = $this->validationRegister[$name]; } else { throw new exceptions\ValidatorException("Validator [$name] not found"); } $params = isset($this->validationData[$name]) ? $this->validationData[$name] : null; $this->validations[$name] = new $class($params); } return $this->validations[$name]; }
php
private function getValidation(string $name): validator\Validation { if (!isset($this->validations[$name])) { if (isset($this->validationRegister[$name])) { $class = $this->validationRegister[$name]; } else { throw new exceptions\ValidatorException("Validator [$name] not found"); } $params = isset($this->validationData[$name]) ? $this->validationData[$name] : null; $this->validations[$name] = new $class($params); } return $this->validations[$name]; }
[ "private", "function", "getValidation", "(", "string", "$", "name", ")", ":", "validator", "\\", "Validation", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "validations", "[", "$", "name", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "validationRegister", "[", "$", "name", "]", ")", ")", "{", "$", "class", "=", "$", "this", "->", "validationRegister", "[", "$", "name", "]", ";", "}", "else", "{", "throw", "new", "exceptions", "\\", "ValidatorException", "(", "\"Validator [$name] not found\"", ")", ";", "}", "$", "params", "=", "isset", "(", "$", "this", "->", "validationData", "[", "$", "name", "]", ")", "?", "$", "this", "->", "validationData", "[", "$", "name", "]", ":", "null", ";", "$", "this", "->", "validations", "[", "$", "name", "]", "=", "new", "$", "class", "(", "$", "params", ")", ";", "}", "return", "$", "this", "->", "validations", "[", "$", "name", "]", ";", "}" ]
Get an instance of a validation class. @param string $name @return validator\Validation @throws exceptions\ValidatorException
[ "Get", "an", "instance", "of", "a", "validation", "class", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/Validator.php#L87-L100
240,955
ntentan/utils
src/Validator.php
Validator.registerValidation
protected function registerValidation(string $name, string $class, $data = null) { $this->validationRegister[$name] = $class; $this->validationData[$name] = $data; }
php
protected function registerValidation(string $name, string $class, $data = null) { $this->validationRegister[$name] = $class; $this->validationData[$name] = $data; }
[ "protected", "function", "registerValidation", "(", "string", "$", "name", ",", "string", "$", "class", ",", "$", "data", "=", "null", ")", "{", "$", "this", "->", "validationRegister", "[", "$", "name", "]", "=", "$", "class", ";", "$", "this", "->", "validationData", "[", "$", "name", "]", "=", "$", "data", ";", "}" ]
Register a validation type. @param string $name The name of the validation to be used in validation descriptions. @param string $class The name of the validation class to load. @param mixed $data Any extra validation data that would be necessary for the validation.
[ "Register", "a", "validation", "type", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/Validator.php#L109-L113
240,956
ntentan/utils
src/Validator.php
Validator.getFieldInfo
private function getFieldInfo($key, $value): array { $name = null; $options = []; if (is_numeric($key) && is_string($value)) { $name = $value; } else if (is_numeric($key) && is_array($value)) { $name = array_shift($value); $options = $value; } else if (is_string($key)) { $name = $key; $options = $value; } return ['name' => $name, 'options' => $options]; }
php
private function getFieldInfo($key, $value): array { $name = null; $options = []; if (is_numeric($key) && is_string($value)) { $name = $value; } else if (is_numeric($key) && is_array($value)) { $name = array_shift($value); $options = $value; } else if (is_string($key)) { $name = $key; $options = $value; } return ['name' => $name, 'options' => $options]; }
[ "private", "function", "getFieldInfo", "(", "$", "key", ",", "$", "value", ")", ":", "array", "{", "$", "name", "=", "null", ";", "$", "options", "=", "[", "]", ";", "if", "(", "is_numeric", "(", "$", "key", ")", "&&", "is_string", "(", "$", "value", ")", ")", "{", "$", "name", "=", "$", "value", ";", "}", "else", "if", "(", "is_numeric", "(", "$", "key", ")", "&&", "is_array", "(", "$", "value", ")", ")", "{", "$", "name", "=", "array_shift", "(", "$", "value", ")", ";", "$", "options", "=", "$", "value", ";", "}", "else", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "name", "=", "$", "key", ";", "$", "options", "=", "$", "value", ";", "}", "return", "[", "'name'", "=>", "$", "name", ",", "'options'", "=>", "$", "options", "]", ";", "}" ]
Build a uniform field info array for various types of validations. @param mixed $key @param mixed $value @return array
[ "Build", "a", "uniform", "field", "info", "array", "for", "various", "types", "of", "validations", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/Validator.php#L142-L156
240,957
ntentan/utils
src/Validator.php
Validator.validate
public function validate(array $data) : bool { $passed = true; $this->invalidFields = []; $rules = $this->getRules(); foreach ($rules as $validation => $fields) { foreach ($fields as $key => $value) { $field = $this->getFieldInfo($key, $value); $validationInstance = $this->getValidation($validation); $validationStatus = $validationInstance->run($field, $data); $passed = $passed && $validationStatus; $this->invalidFields = array_merge_recursive( $this->invalidFields, $validationInstance->getMessages() ); } } return $passed; }
php
public function validate(array $data) : bool { $passed = true; $this->invalidFields = []; $rules = $this->getRules(); foreach ($rules as $validation => $fields) { foreach ($fields as $key => $value) { $field = $this->getFieldInfo($key, $value); $validationInstance = $this->getValidation($validation); $validationStatus = $validationInstance->run($field, $data); $passed = $passed && $validationStatus; $this->invalidFields = array_merge_recursive( $this->invalidFields, $validationInstance->getMessages() ); } } return $passed; }
[ "public", "function", "validate", "(", "array", "$", "data", ")", ":", "bool", "{", "$", "passed", "=", "true", ";", "$", "this", "->", "invalidFields", "=", "[", "]", ";", "$", "rules", "=", "$", "this", "->", "getRules", "(", ")", ";", "foreach", "(", "$", "rules", "as", "$", "validation", "=>", "$", "fields", ")", "{", "foreach", "(", "$", "fields", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "field", "=", "$", "this", "->", "getFieldInfo", "(", "$", "key", ",", "$", "value", ")", ";", "$", "validationInstance", "=", "$", "this", "->", "getValidation", "(", "$", "validation", ")", ";", "$", "validationStatus", "=", "$", "validationInstance", "->", "run", "(", "$", "field", ",", "$", "data", ")", ";", "$", "passed", "=", "$", "passed", "&&", "$", "validationStatus", ";", "$", "this", "->", "invalidFields", "=", "array_merge_recursive", "(", "$", "this", "->", "invalidFields", ",", "$", "validationInstance", "->", "getMessages", "(", ")", ")", ";", "}", "}", "return", "$", "passed", ";", "}" ]
Validate data according to validation rules that have been set into this validator. @param array $data The data to be validated @return bool @throws exceptions\ValidatorException
[ "Validate", "data", "according", "to", "validation", "rules", "that", "have", "been", "set", "into", "this", "validator", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/Validator.php#L176-L193
240,958
lutsen/lagan-core
src/Lagan.php
Lagan.universalCreate
protected function universalCreate() { $bean = \R::dispense($this->type); $bean->created = \R::isoDateTime(); return $bean; }
php
protected function universalCreate() { $bean = \R::dispense($this->type); $bean->created = \R::isoDateTime(); return $bean; }
[ "protected", "function", "universalCreate", "(", ")", "{", "$", "bean", "=", "\\", "R", "::", "dispense", "(", "$", "this", "->", "type", ")", ";", "$", "bean", "->", "created", "=", "\\", "R", "::", "isoDateTime", "(", ")", ";", "return", "$", "bean", ";", "}" ]
Dispenses a Redbean bean ans sets it's creation date. @return bean
[ "Dispenses", "a", "Redbean", "bean", "ans", "sets", "it", "s", "creation", "date", "." ]
257244219a046293f506de68e54f0c16c35d8217
https://github.com/lutsen/lagan-core/blob/257244219a046293f506de68e54f0c16c35d8217/src/Lagan.php#L30-L37
240,959
lutsen/lagan-core
src/Lagan.php
Lagan.set
public function set($data, $bean) { // Add all properties to bean foreach ( $this->properties as $property ) { $value = false; // We need to clear possible previous $value // Define property controller $c = new $property['type']; // New input for the property if ( isset( $data[ $property['name'] ] ) || ( isset( $_FILES[ $property['name'] ] ) && $_FILES[ $property['name'] ]['size'] > 0 ) || $property['autovalue'] == true ) { // Check if specific set property type method exists if ( method_exists( $c, 'set' ) ) { $value = $c->set( $bean, $property, $data[ $property['name'] ] ); } else { $value = $data[ $property['name'] ]; } if ($value) { $hasvalue = true; } else { $hasvalue = false; } // No new input for the property } else { // Check if property already has value for required validation if ( isset( $property['required'] ) ) { if ( method_exists( $c, 'read' ) && $c->read( $bean, $property ) ) { $hasvalue = true; } else if ( $bean->{ $property['name'] } ) { $hasvalue = true; } else { $hasvalue = false; } } } // Check if property is required if ( isset( $property['required'] ) ) { if ( $property['required'] && !$hasvalue ) { throw new \Exception('Validation error. '.$property['description'].' is required.'); } } // Results from methods that return boolean values are not stored. // Many-to-many relations for example are stored in a seperate table. if ( !is_bool($value) ) { // Check if property value is unique if ( isset( $property['unique'] ) ) { $duplicate = \R::findOne( $this->type, $property['name'].' = :val ', [ ':val' => $value ] ); if ( $duplicate && $duplicate->id != $bean->id ) { throw new \Exception('Validation error. '.$property['description'].' should be unique.'); } } $bean->{ $property['name'] } = $value; } } $bean->modified = \R::isoDateTime(); \R::store($bean); return $bean; }
php
public function set($data, $bean) { // Add all properties to bean foreach ( $this->properties as $property ) { $value = false; // We need to clear possible previous $value // Define property controller $c = new $property['type']; // New input for the property if ( isset( $data[ $property['name'] ] ) || ( isset( $_FILES[ $property['name'] ] ) && $_FILES[ $property['name'] ]['size'] > 0 ) || $property['autovalue'] == true ) { // Check if specific set property type method exists if ( method_exists( $c, 'set' ) ) { $value = $c->set( $bean, $property, $data[ $property['name'] ] ); } else { $value = $data[ $property['name'] ]; } if ($value) { $hasvalue = true; } else { $hasvalue = false; } // No new input for the property } else { // Check if property already has value for required validation if ( isset( $property['required'] ) ) { if ( method_exists( $c, 'read' ) && $c->read( $bean, $property ) ) { $hasvalue = true; } else if ( $bean->{ $property['name'] } ) { $hasvalue = true; } else { $hasvalue = false; } } } // Check if property is required if ( isset( $property['required'] ) ) { if ( $property['required'] && !$hasvalue ) { throw new \Exception('Validation error. '.$property['description'].' is required.'); } } // Results from methods that return boolean values are not stored. // Many-to-many relations for example are stored in a seperate table. if ( !is_bool($value) ) { // Check if property value is unique if ( isset( $property['unique'] ) ) { $duplicate = \R::findOne( $this->type, $property['name'].' = :val ', [ ':val' => $value ] ); if ( $duplicate && $duplicate->id != $bean->id ) { throw new \Exception('Validation error. '.$property['description'].' should be unique.'); } } $bean->{ $property['name'] } = $value; } } $bean->modified = \R::isoDateTime(); \R::store($bean); return $bean; }
[ "public", "function", "set", "(", "$", "data", ",", "$", "bean", ")", "{", "// Add all properties to bean", "foreach", "(", "$", "this", "->", "properties", "as", "$", "property", ")", "{", "$", "value", "=", "false", ";", "// We need to clear possible previous $value", "// Define property controller", "$", "c", "=", "new", "$", "property", "[", "'type'", "]", ";", "// New input for the property", "if", "(", "isset", "(", "$", "data", "[", "$", "property", "[", "'name'", "]", "]", ")", "||", "(", "isset", "(", "$", "_FILES", "[", "$", "property", "[", "'name'", "]", "]", ")", "&&", "$", "_FILES", "[", "$", "property", "[", "'name'", "]", "]", "[", "'size'", "]", ">", "0", ")", "||", "$", "property", "[", "'autovalue'", "]", "==", "true", ")", "{", "// Check if specific set property type method exists", "if", "(", "method_exists", "(", "$", "c", ",", "'set'", ")", ")", "{", "$", "value", "=", "$", "c", "->", "set", "(", "$", "bean", ",", "$", "property", ",", "$", "data", "[", "$", "property", "[", "'name'", "]", "]", ")", ";", "}", "else", "{", "$", "value", "=", "$", "data", "[", "$", "property", "[", "'name'", "]", "]", ";", "}", "if", "(", "$", "value", ")", "{", "$", "hasvalue", "=", "true", ";", "}", "else", "{", "$", "hasvalue", "=", "false", ";", "}", "// No new input for the property", "}", "else", "{", "// Check if property already has value for required validation", "if", "(", "isset", "(", "$", "property", "[", "'required'", "]", ")", ")", "{", "if", "(", "method_exists", "(", "$", "c", ",", "'read'", ")", "&&", "$", "c", "->", "read", "(", "$", "bean", ",", "$", "property", ")", ")", "{", "$", "hasvalue", "=", "true", ";", "}", "else", "if", "(", "$", "bean", "->", "{", "$", "property", "[", "'name'", "]", "}", ")", "{", "$", "hasvalue", "=", "true", ";", "}", "else", "{", "$", "hasvalue", "=", "false", ";", "}", "}", "}", "// Check if property is required", "if", "(", "isset", "(", "$", "property", "[", "'required'", "]", ")", ")", "{", "if", "(", "$", "property", "[", "'required'", "]", "&&", "!", "$", "hasvalue", ")", "{", "throw", "new", "\\", "Exception", "(", "'Validation error. '", ".", "$", "property", "[", "'description'", "]", ".", "' is required.'", ")", ";", "}", "}", "// Results from methods that return boolean values are not stored.", "// Many-to-many relations for example are stored in a seperate table.", "if", "(", "!", "is_bool", "(", "$", "value", ")", ")", "{", "// Check if property value is unique", "if", "(", "isset", "(", "$", "property", "[", "'unique'", "]", ")", ")", "{", "$", "duplicate", "=", "\\", "R", "::", "findOne", "(", "$", "this", "->", "type", ",", "$", "property", "[", "'name'", "]", ".", "' = :val '", ",", "[", "':val'", "=>", "$", "value", "]", ")", ";", "if", "(", "$", "duplicate", "&&", "$", "duplicate", "->", "id", "!=", "$", "bean", "->", "id", ")", "{", "throw", "new", "\\", "Exception", "(", "'Validation error. '", ".", "$", "property", "[", "'description'", "]", ".", "' should be unique.'", ")", ";", "}", "}", "$", "bean", "->", "{", "$", "property", "[", "'name'", "]", "}", "=", "$", "value", ";", "}", "}", "$", "bean", "->", "modified", "=", "\\", "R", "::", "isoDateTime", "(", ")", ";", "\\", "R", "::", "store", "(", "$", "bean", ")", ";", "return", "$", "bean", ";", "}" ]
Set values for a bean. Used by Create and Update. Checks for each property if a "set" method exists for it's type. If so, it executes it. @param array $data The raw data, usually from the Slim $request->getParsedBody() @param bean $bean @return bean Bean with values based on $data.
[ "Set", "values", "for", "a", "bean", ".", "Used", "by", "Create", "and", "Update", ".", "Checks", "for", "each", "property", "if", "a", "set", "method", "exists", "for", "it", "s", "type", ".", "If", "so", "it", "executes", "it", "." ]
257244219a046293f506de68e54f0c16c35d8217
https://github.com/lutsen/lagan-core/blob/257244219a046293f506de68e54f0c16c35d8217/src/Lagan.php#L50-L133
240,960
MacFJA/value-provider
src/ChainProvider.php
ChainProvider.tryGetValue
protected static function tryGetValue($provider, $object, $propertyName, &$error) { try { return call_user_func(array($provider, 'getValue'), $object, $propertyName); } catch (\InvalidArgumentException $e) { $error = $e; return null; } }
php
protected static function tryGetValue($provider, $object, $propertyName, &$error) { try { return call_user_func(array($provider, 'getValue'), $object, $propertyName); } catch (\InvalidArgumentException $e) { $error = $e; return null; } }
[ "protected", "static", "function", "tryGetValue", "(", "$", "provider", ",", "$", "object", ",", "$", "propertyName", ",", "&", "$", "error", ")", "{", "try", "{", "return", "call_user_func", "(", "array", "(", "$", "provider", ",", "'getValue'", ")", ",", "$", "object", ",", "$", "propertyName", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "$", "error", "=", "$", "e", ";", "return", "null", ";", "}", "}" ]
Try to get the value of an object property with a specific provider @param string|object $provider The provider class(name) to use @param object $object The object to read @param string $propertyName The name of the property to read @param \InvalidArgumentException|mixed $error <p> If an error occurs, this variable will be set to the error triggered </p> @return mixed|null <p> The value of the object property, or <tt>null</tt> and an error in <tt>$error</tt> if an error occur. </p>
[ "Try", "to", "get", "the", "value", "of", "an", "object", "property", "with", "a", "specific", "provider" ]
eab0d8a52062e21fa91041f9fb6df38fd9c0dd28
https://github.com/MacFJA/value-provider/blob/eab0d8a52062e21fa91041f9fb6df38fd9c0dd28/src/ChainProvider.php#L119-L127
240,961
MacFJA/value-provider
src/ChainProvider.php
ChainProvider.trySetValue
protected static function trySetValue($provider, &$object, $propertyName, $value, &$error) { try { return call_user_func(array($provider, 'setValue'), $object, $propertyName, $value); } catch (\InvalidArgumentException $e) { $error = $e; return null; } }
php
protected static function trySetValue($provider, &$object, $propertyName, $value, &$error) { try { return call_user_func(array($provider, 'setValue'), $object, $propertyName, $value); } catch (\InvalidArgumentException $e) { $error = $e; return null; } }
[ "protected", "static", "function", "trySetValue", "(", "$", "provider", ",", "&", "$", "object", ",", "$", "propertyName", ",", "$", "value", ",", "&", "$", "error", ")", "{", "try", "{", "return", "call_user_func", "(", "array", "(", "$", "provider", ",", "'setValue'", ")", ",", "$", "object", ",", "$", "propertyName", ",", "$", "value", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "$", "error", "=", "$", "e", ";", "return", "null", ";", "}", "}" ]
Try to set the value of an object property with a specific provider @param string|object $provider The provider class(name) to use @param object $object The object to write @param string $propertyName The name of the property to write @param mixed $value The value to set @param \InvalidArgumentException|mixed $error <p> If an error occurs, this variable will be set to the error triggered </p> @return mixed|null The object, or <tt>null</tt> and an error in <tt>$error</tt> if an error occur.
[ "Try", "to", "set", "the", "value", "of", "an", "object", "property", "with", "a", "specific", "provider" ]
eab0d8a52062e21fa91041f9fb6df38fd9c0dd28
https://github.com/MacFJA/value-provider/blob/eab0d8a52062e21fa91041f9fb6df38fd9c0dd28/src/ChainProvider.php#L142-L150
240,962
dlds/yii2-rels
components/Behavior.php
Behavior.canGetProperty
public function canGetProperty($name, $checkVars = true) { if (!in_array($name, $this->attrs)) { return parent::canGetProperty($name, $checkVars); } return true; }
php
public function canGetProperty($name, $checkVars = true) { if (!in_array($name, $this->attrs)) { return parent::canGetProperty($name, $checkVars); } return true; }
[ "public", "function", "canGetProperty", "(", "$", "name", ",", "$", "checkVars", "=", "true", ")", "{", "if", "(", "!", "in_array", "(", "$", "name", ",", "$", "this", "->", "attrs", ")", ")", "{", "return", "parent", "::", "canGetProperty", "(", "$", "name", ",", "$", "checkVars", ")", ";", "}", "return", "true", ";", "}" ]
Indicates whether a property can be read. @param string $name the property name @param boolean $checkVars whether to treat member variables as properties
[ "Indicates", "whether", "a", "property", "can", "be", "read", "." ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Behavior.php#L71-L78
240,963
dlds/yii2-rels
components/Behavior.php
Behavior.events
public function events() { return [ \yii\db\ActiveRecord::EVENT_BEFORE_VALIDATE => 'handleValidate', \yii\db\ActiveRecord::EVENT_AFTER_INSERT => 'handleAfterSave', \yii\db\ActiveRecord::EVENT_AFTER_UPDATE => 'handleAfterSave', ]; }
php
public function events() { return [ \yii\db\ActiveRecord::EVENT_BEFORE_VALIDATE => 'handleValidate', \yii\db\ActiveRecord::EVENT_AFTER_INSERT => 'handleAfterSave', \yii\db\ActiveRecord::EVENT_AFTER_UPDATE => 'handleAfterSave', ]; }
[ "public", "function", "events", "(", ")", "{", "return", "[", "\\", "yii", "\\", "db", "\\", "ActiveRecord", "::", "EVENT_BEFORE_VALIDATE", "=>", "'handleValidate'", ",", "\\", "yii", "\\", "db", "\\", "ActiveRecord", "::", "EVENT_AFTER_INSERT", "=>", "'handleAfterSave'", ",", "\\", "yii", "\\", "db", "\\", "ActiveRecord", "::", "EVENT_AFTER_UPDATE", "=>", "'handleAfterSave'", ",", "]", ";", "}" ]
Validates interpreter together with owner
[ "Validates", "interpreter", "together", "with", "owner" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Behavior.php#L83-L90
240,964
dlds/yii2-rels
components/Behavior.php
Behavior.interpreter
public function interpreter(array $restriction = []) { if (null === $this->_interpreter) { $this->_interpreter = new Interpreter($this->owner, $this->config, $this->allowCache, $this->attrActive); } $this->_interpreter->setRestriction($restriction); return $this->_interpreter; }
php
public function interpreter(array $restriction = []) { if (null === $this->_interpreter) { $this->_interpreter = new Interpreter($this->owner, $this->config, $this->allowCache, $this->attrActive); } $this->_interpreter->setRestriction($restriction); return $this->_interpreter; }
[ "public", "function", "interpreter", "(", "array", "$", "restriction", "=", "[", "]", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_interpreter", ")", "{", "$", "this", "->", "_interpreter", "=", "new", "Interpreter", "(", "$", "this", "->", "owner", ",", "$", "this", "->", "config", ",", "$", "this", "->", "allowCache", ",", "$", "this", "->", "attrActive", ")", ";", "}", "$", "this", "->", "_interpreter", "->", "setRestriction", "(", "$", "restriction", ")", ";", "return", "$", "this", "->", "_interpreter", ";", "}" ]
Retrieves instance to multilang interperter
[ "Retrieves", "instance", "to", "multilang", "interperter" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Behavior.php#L188-L197
240,965
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.getUserFeed
public function getUserFeed($userName = null, $location = null) { if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('feed'); if ($userName !== null) { $location->setUser($userName); } $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Query) { if ($userName !== null) { $location->setUser($userName); } $uri = $location->getQueryUrl(); } else if ($location !== null) { $uri = $location; } else if ($userName !== null) { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' . $userName; } else { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' . self::DEFAULT_USER; } return parent::getFeed($uri, 'Zend_Gdata_Photos_UserFeed'); }
php
public function getUserFeed($userName = null, $location = null) { if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('feed'); if ($userName !== null) { $location->setUser($userName); } $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Query) { if ($userName !== null) { $location->setUser($userName); } $uri = $location->getQueryUrl(); } else if ($location !== null) { $uri = $location; } else if ($userName !== null) { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' . $userName; } else { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' . self::DEFAULT_USER; } return parent::getFeed($uri, 'Zend_Gdata_Photos_UserFeed'); }
[ "public", "function", "getUserFeed", "(", "$", "userName", "=", "null", ",", "$", "location", "=", "null", ")", "{", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Photos_UserQuery", ")", "{", "$", "location", "->", "setType", "(", "'feed'", ")", ";", "if", "(", "$", "userName", "!==", "null", ")", "{", "$", "location", "->", "setUser", "(", "$", "userName", ")", ";", "}", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Query", ")", "{", "if", "(", "$", "userName", "!==", "null", ")", "{", "$", "location", "->", "setUser", "(", "$", "userName", ")", ";", "}", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "if", "(", "$", "location", "!==", "null", ")", "{", "$", "uri", "=", "$", "location", ";", "}", "else", "if", "(", "$", "userName", "!==", "null", ")", "{", "$", "uri", "=", "self", "::", "PICASA_BASE_FEED_URI", ".", "'/'", ".", "self", "::", "DEFAULT_PROJECTION", ".", "'/'", ".", "self", "::", "USER_PATH", ".", "'/'", ".", "$", "userName", ";", "}", "else", "{", "$", "uri", "=", "self", "::", "PICASA_BASE_FEED_URI", ".", "'/'", ".", "self", "::", "DEFAULT_PROJECTION", ".", "'/'", ".", "self", "::", "USER_PATH", ".", "'/'", ".", "self", "::", "DEFAULT_USER", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "'Zend_Gdata_Photos_UserFeed'", ")", ";", "}" ]
Retrieve a UserFeed containing AlbumEntries, PhotoEntries and TagEntries associated with a given user. @param string $userName The userName of interest @param mixed $location (optional) The location for the feed, as a URL or Query. If not provided, a default URL will be used instead. @return Zend_Gdata_Photos_UserFeed @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Retrieve", "a", "UserFeed", "containing", "AlbumEntries", "PhotoEntries", "and", "TagEntries", "associated", "with", "a", "given", "user", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L150-L176
240,966
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.getAlbumFeed
public function getAlbumFeed($location = null) { if ($location === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'Location must not be null'); } else if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('feed'); $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Photos_AlbumFeed'); }
php
public function getAlbumFeed($location = null) { if ($location === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'Location must not be null'); } else if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('feed'); $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Photos_AlbumFeed'); }
[ "public", "function", "getAlbumFeed", "(", "$", "location", "=", "null", ")", "{", "if", "(", "$", "location", "===", "null", ")", "{", "require_once", "'Zend/Gdata/App/InvalidArgumentException.php'", ";", "throw", "new", "Zend_Gdata_App_InvalidArgumentException", "(", "'Location must not be null'", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Photos_UserQuery", ")", "{", "$", "location", "->", "setType", "(", "'feed'", ")", ";", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Query", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "'Zend_Gdata_Photos_AlbumFeed'", ")", ";", "}" ]
Retreive AlbumFeed object containing multiple PhotoEntry or TagEntry objects. @param mixed $location (optional) The location for the feed, as a URL or Query. @return Zend_Gdata_Photos_AlbumFeed @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Retreive", "AlbumFeed", "object", "containing", "multiple", "PhotoEntry", "or", "TagEntry", "objects", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L187-L202
240,967
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.getPhotoFeed
public function getPhotoFeed($location = null) { if ($location === null) { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::COMMUNITY_SEARCH_PATH; } else if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('feed'); $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Photos_PhotoFeed'); }
php
public function getPhotoFeed($location = null) { if ($location === null) { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::COMMUNITY_SEARCH_PATH; } else if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('feed'); $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Photos_PhotoFeed'); }
[ "public", "function", "getPhotoFeed", "(", "$", "location", "=", "null", ")", "{", "if", "(", "$", "location", "===", "null", ")", "{", "$", "uri", "=", "self", "::", "PICASA_BASE_FEED_URI", ".", "'/'", ".", "self", "::", "DEFAULT_PROJECTION", ".", "'/'", ".", "self", "::", "COMMUNITY_SEARCH_PATH", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Photos_UserQuery", ")", "{", "$", "location", "->", "setType", "(", "'feed'", ")", ";", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Query", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "'Zend_Gdata_Photos_PhotoFeed'", ")", ";", "}" ]
Retreive PhotoFeed object containing comments and tags associated with a given photo. @param mixed $location (optional) The location for the feed, as a URL or Query. If not specified, the community search feed will be returned instead. @return Zend_Gdata_Photos_PhotoFeed @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Retreive", "PhotoFeed", "object", "containing", "comments", "and", "tags", "associated", "with", "a", "given", "photo", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L215-L230
240,968
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.getUserEntry
public function getUserEntry($location) { if ($location === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'Location must not be null'); } else if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('entry'); $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getEntry($uri, 'Zend_Gdata_Photos_UserEntry'); }
php
public function getUserEntry($location) { if ($location === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'Location must not be null'); } else if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('entry'); $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getEntry($uri, 'Zend_Gdata_Photos_UserEntry'); }
[ "public", "function", "getUserEntry", "(", "$", "location", ")", "{", "if", "(", "$", "location", "===", "null", ")", "{", "require_once", "'Zend/Gdata/App/InvalidArgumentException.php'", ";", "throw", "new", "Zend_Gdata_App_InvalidArgumentException", "(", "'Location must not be null'", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Photos_UserQuery", ")", "{", "$", "location", "->", "setType", "(", "'entry'", ")", ";", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Query", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getEntry", "(", "$", "uri", ",", "'Zend_Gdata_Photos_UserEntry'", ")", ";", "}" ]
Retreive a single UserEntry object. @param mixed $location The location for the feed, as a URL or Query. @return Zend_Gdata_Photos_UserEntry @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Retreive", "a", "single", "UserEntry", "object", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L240-L255
240,969
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.insertAlbumEntry
public function insertAlbumEntry($album, $uri = null) { if ($uri === null) { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' . self::DEFAULT_USER; } $newEntry = $this->insertEntry($album, $uri, 'Zend_Gdata_Photos_AlbumEntry'); return $newEntry; }
php
public function insertAlbumEntry($album, $uri = null) { if ($uri === null) { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' . self::DEFAULT_USER; } $newEntry = $this->insertEntry($album, $uri, 'Zend_Gdata_Photos_AlbumEntry'); return $newEntry; }
[ "public", "function", "insertAlbumEntry", "(", "$", "album", ",", "$", "uri", "=", "null", ")", "{", "if", "(", "$", "uri", "===", "null", ")", "{", "$", "uri", "=", "self", "::", "PICASA_BASE_FEED_URI", ".", "'/'", ".", "self", "::", "DEFAULT_PROJECTION", ".", "'/'", ".", "self", "::", "USER_PATH", ".", "'/'", ".", "self", "::", "DEFAULT_USER", ";", "}", "$", "newEntry", "=", "$", "this", "->", "insertEntry", "(", "$", "album", ",", "$", "uri", ",", "'Zend_Gdata_Photos_AlbumEntry'", ")", ";", "return", "$", "newEntry", ";", "}" ]
Create a new album from a AlbumEntry. @param Zend_Gdata_Photos_AlbumEntry $album The album entry to insert. @param string $url (optional) The URI that the album should be uploaded to. If null, the default album creation URI for this domain will be used. @return Zend_Gdata_Photos_AlbumEntry The inserted album entry as returned by the server. @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Create", "a", "new", "album", "from", "a", "AlbumEntry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L370-L379
240,970
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.insertPhotoEntry
public function insertPhotoEntry($photo, $uri = null) { if ($uri instanceof Zend_Gdata_Photos_AlbumEntry) { $uri = $uri->getLink(self::FEED_LINK_PATH)->href; } if ($uri === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'URI must not be null'); } $newEntry = $this->insertEntry($photo, $uri, 'Zend_Gdata_Photos_PhotoEntry'); return $newEntry; }
php
public function insertPhotoEntry($photo, $uri = null) { if ($uri instanceof Zend_Gdata_Photos_AlbumEntry) { $uri = $uri->getLink(self::FEED_LINK_PATH)->href; } if ($uri === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'URI must not be null'); } $newEntry = $this->insertEntry($photo, $uri, 'Zend_Gdata_Photos_PhotoEntry'); return $newEntry; }
[ "public", "function", "insertPhotoEntry", "(", "$", "photo", ",", "$", "uri", "=", "null", ")", "{", "if", "(", "$", "uri", "instanceof", "Zend_Gdata_Photos_AlbumEntry", ")", "{", "$", "uri", "=", "$", "uri", "->", "getLink", "(", "self", "::", "FEED_LINK_PATH", ")", "->", "href", ";", "}", "if", "(", "$", "uri", "===", "null", ")", "{", "require_once", "'Zend/Gdata/App/InvalidArgumentException.php'", ";", "throw", "new", "Zend_Gdata_App_InvalidArgumentException", "(", "'URI must not be null'", ")", ";", "}", "$", "newEntry", "=", "$", "this", "->", "insertEntry", "(", "$", "photo", ",", "$", "uri", ",", "'Zend_Gdata_Photos_PhotoEntry'", ")", ";", "return", "$", "newEntry", ";", "}" ]
Create a new photo from a PhotoEntry. @param Zend_Gdata_Photos_PhotoEntry $photo The photo to insert. @param string $url The URI that the photo should be uploaded to. Alternatively, an AlbumEntry can be provided and the photo will be added to that album. @return Zend_Gdata_Photos_PhotoEntry The inserted photo entry as returned by the server. @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Create", "a", "new", "photo", "from", "a", "PhotoEntry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L393-L405
240,971
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.insertTagEntry
public function insertTagEntry($tag, $uri = null) { if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) { $uri = $uri->getLink(self::FEED_LINK_PATH)->href; } if ($uri === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'URI must not be null'); } $newEntry = $this->insertEntry($tag, $uri, 'Zend_Gdata_Photos_TagEntry'); return $newEntry; }
php
public function insertTagEntry($tag, $uri = null) { if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) { $uri = $uri->getLink(self::FEED_LINK_PATH)->href; } if ($uri === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'URI must not be null'); } $newEntry = $this->insertEntry($tag, $uri, 'Zend_Gdata_Photos_TagEntry'); return $newEntry; }
[ "public", "function", "insertTagEntry", "(", "$", "tag", ",", "$", "uri", "=", "null", ")", "{", "if", "(", "$", "uri", "instanceof", "Zend_Gdata_Photos_PhotoEntry", ")", "{", "$", "uri", "=", "$", "uri", "->", "getLink", "(", "self", "::", "FEED_LINK_PATH", ")", "->", "href", ";", "}", "if", "(", "$", "uri", "===", "null", ")", "{", "require_once", "'Zend/Gdata/App/InvalidArgumentException.php'", ";", "throw", "new", "Zend_Gdata_App_InvalidArgumentException", "(", "'URI must not be null'", ")", ";", "}", "$", "newEntry", "=", "$", "this", "->", "insertEntry", "(", "$", "tag", ",", "$", "uri", ",", "'Zend_Gdata_Photos_TagEntry'", ")", ";", "return", "$", "newEntry", ";", "}" ]
Create a new tag from a TagEntry. @param Zend_Gdata_Photos_TagEntry $tag The tag entry to insert. @param string $url The URI where the tag should be uploaded to. Alternatively, a PhotoEntry can be provided and the tag will be added to that photo. @return Zend_Gdata_Photos_TagEntry The inserted tag entry as returned by the server. @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Create", "a", "new", "tag", "from", "a", "TagEntry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L419-L431
240,972
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.insertCommentEntry
public function insertCommentEntry($comment, $uri = null) { if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) { $uri = $uri->getLink(self::FEED_LINK_PATH)->href; } if ($uri === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'URI must not be null'); } $newEntry = $this->insertEntry($comment, $uri, 'Zend_Gdata_Photos_CommentEntry'); return $newEntry; }
php
public function insertCommentEntry($comment, $uri = null) { if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) { $uri = $uri->getLink(self::FEED_LINK_PATH)->href; } if ($uri === null) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'URI must not be null'); } $newEntry = $this->insertEntry($comment, $uri, 'Zend_Gdata_Photos_CommentEntry'); return $newEntry; }
[ "public", "function", "insertCommentEntry", "(", "$", "comment", ",", "$", "uri", "=", "null", ")", "{", "if", "(", "$", "uri", "instanceof", "Zend_Gdata_Photos_PhotoEntry", ")", "{", "$", "uri", "=", "$", "uri", "->", "getLink", "(", "self", "::", "FEED_LINK_PATH", ")", "->", "href", ";", "}", "if", "(", "$", "uri", "===", "null", ")", "{", "require_once", "'Zend/Gdata/App/InvalidArgumentException.php'", ";", "throw", "new", "Zend_Gdata_App_InvalidArgumentException", "(", "'URI must not be null'", ")", ";", "}", "$", "newEntry", "=", "$", "this", "->", "insertEntry", "(", "$", "comment", ",", "$", "uri", ",", "'Zend_Gdata_Photos_CommentEntry'", ")", ";", "return", "$", "newEntry", ";", "}" ]
Create a new comment from a CommentEntry. @param Zend_Gdata_Photos_CommentEntry $comment The comment entry to insert. @param string $url The URI where the comment should be uploaded to. Alternatively, a PhotoEntry can be provided and the comment will be added to that photo. @return Zend_Gdata_Photos_CommentEntry The inserted comment entry as returned by the server. @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Create", "a", "new", "comment", "from", "a", "CommentEntry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L446-L458
240,973
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.deleteAlbumEntry
public function deleteAlbumEntry($album, $catch) { if ($catch) { try { $this->delete($album); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_AlbumEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($album); } }
php
public function deleteAlbumEntry($album, $catch) { if ($catch) { try { $this->delete($album); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_AlbumEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($album); } }
[ "public", "function", "deleteAlbumEntry", "(", "$", "album", ",", "$", "catch", ")", "{", "if", "(", "$", "catch", ")", "{", "try", "{", "$", "this", "->", "delete", "(", "$", "album", ")", ";", "}", "catch", "(", "Zend_Gdata_App_HttpException", "$", "e", ")", "{", "if", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getStatus", "(", ")", "===", "409", ")", "{", "$", "entry", "=", "new", "Zend_Gdata_Photos_AlbumEntry", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ")", ";", "$", "this", "->", "delete", "(", "$", "entry", "->", "getLink", "(", "'edit'", ")", "->", "href", ")", ";", "}", "else", "{", "throw", "$", "e", ";", "}", "}", "}", "else", "{", "$", "this", "->", "delete", "(", "$", "album", ")", ";", "}", "}" ]
Delete an AlbumEntry. @param Zend_Gdata_Photos_AlbumEntry $album The album entry to delete. @param boolean $catch Whether to catch an exception when modified and re-delete or throw @return void. @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Delete", "an", "AlbumEntry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L471-L487
240,974
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.deletePhotoEntry
public function deletePhotoEntry($photo, $catch) { if ($catch) { try { $this->delete($photo); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_PhotoEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($photo); } }
php
public function deletePhotoEntry($photo, $catch) { if ($catch) { try { $this->delete($photo); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_PhotoEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($photo); } }
[ "public", "function", "deletePhotoEntry", "(", "$", "photo", ",", "$", "catch", ")", "{", "if", "(", "$", "catch", ")", "{", "try", "{", "$", "this", "->", "delete", "(", "$", "photo", ")", ";", "}", "catch", "(", "Zend_Gdata_App_HttpException", "$", "e", ")", "{", "if", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getStatus", "(", ")", "===", "409", ")", "{", "$", "entry", "=", "new", "Zend_Gdata_Photos_PhotoEntry", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ")", ";", "$", "this", "->", "delete", "(", "$", "entry", "->", "getLink", "(", "'edit'", ")", "->", "href", ")", ";", "}", "else", "{", "throw", "$", "e", ";", "}", "}", "}", "else", "{", "$", "this", "->", "delete", "(", "$", "photo", ")", ";", "}", "}" ]
Delete a PhotoEntry. @param Zend_Gdata_Photos_PhotoEntry $photo The photo entry to delete. @param boolean $catch Whether to catch an exception when modified and re-delete or throw @return void. @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Delete", "a", "PhotoEntry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L500-L516
240,975
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.deleteCommentEntry
public function deleteCommentEntry($comment, $catch) { if ($catch) { try { $this->delete($comment); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_CommentEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($comment); } }
php
public function deleteCommentEntry($comment, $catch) { if ($catch) { try { $this->delete($comment); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_CommentEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($comment); } }
[ "public", "function", "deleteCommentEntry", "(", "$", "comment", ",", "$", "catch", ")", "{", "if", "(", "$", "catch", ")", "{", "try", "{", "$", "this", "->", "delete", "(", "$", "comment", ")", ";", "}", "catch", "(", "Zend_Gdata_App_HttpException", "$", "e", ")", "{", "if", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getStatus", "(", ")", "===", "409", ")", "{", "$", "entry", "=", "new", "Zend_Gdata_Photos_CommentEntry", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ")", ";", "$", "this", "->", "delete", "(", "$", "entry", "->", "getLink", "(", "'edit'", ")", "->", "href", ")", ";", "}", "else", "{", "throw", "$", "e", ";", "}", "}", "}", "else", "{", "$", "this", "->", "delete", "(", "$", "comment", ")", ";", "}", "}" ]
Delete a CommentEntry. @param Zend_Gdata_Photos_CommentEntry $comment The comment entry to delete. @param boolean $catch Whether to catch an exception when modified and re-delete or throw @return void. @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Delete", "a", "CommentEntry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L529-L545
240,976
n0m4dz/laracasa
Zend/Gdata/Photos.php
Zend_Gdata_Photos.deleteTagEntry
public function deleteTagEntry($tag, $catch) { if ($catch) { try { $this->delete($tag); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_TagEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($tag); } }
php
public function deleteTagEntry($tag, $catch) { if ($catch) { try { $this->delete($tag); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_TagEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($tag); } }
[ "public", "function", "deleteTagEntry", "(", "$", "tag", ",", "$", "catch", ")", "{", "if", "(", "$", "catch", ")", "{", "try", "{", "$", "this", "->", "delete", "(", "$", "tag", ")", ";", "}", "catch", "(", "Zend_Gdata_App_HttpException", "$", "e", ")", "{", "if", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getStatus", "(", ")", "===", "409", ")", "{", "$", "entry", "=", "new", "Zend_Gdata_Photos_TagEntry", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ")", ";", "$", "this", "->", "delete", "(", "$", "entry", "->", "getLink", "(", "'edit'", ")", "->", "href", ")", ";", "}", "else", "{", "throw", "$", "e", ";", "}", "}", "}", "else", "{", "$", "this", "->", "delete", "(", "$", "tag", ")", ";", "}", "}" ]
Delete a TagEntry. @param Zend_Gdata_Photos_TagEntry $tag The tag entry to delete. @param boolean $catch Whether to catch an exception when modified and re-delete or throw @return void. @throws Zend_Gdata_App_Exception @throws Zend_Gdata_App_HttpException
[ "Delete", "a", "TagEntry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L558-L574
240,977
edunola13/enolaphp-framework
src/Cron/Models/En_CronRequest.php
En_CronRequest.getParam
public function getParam($index){ if(isset($this->params[$index])){ return $this->params[$index]; }else{ return NULL; } }
php
public function getParam($index){ if(isset($this->params[$index])){ return $this->params[$index]; }else{ return NULL; } }
[ "public", "function", "getParam", "(", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "params", "[", "$", "index", "]", ")", ")", "{", "return", "$", "this", "->", "params", "[", "$", "index", "]", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Devuelve un parametro en base a un indice - solo parametros no utilizados por el framework @param string $index @return null o string
[ "Devuelve", "un", "parametro", "en", "base", "a", "un", "indice", "-", "solo", "parametros", "no", "utilizados", "por", "el", "framework" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Cron/Models/En_CronRequest.php#L49-L55
240,978
edunola13/enolaphp-framework
src/Cron/Models/En_CronRequest.php
En_CronRequest.getParamClean
public function getParamClean($index){ if(isset($this->params[$index])){ return $this->params[$index]; }else{ return NULL; } }
php
public function getParamClean($index){ if(isset($this->params[$index])){ return $this->params[$index]; }else{ return NULL; } }
[ "public", "function", "getParamClean", "(", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "params", "[", "$", "index", "]", ")", ")", "{", "return", "$", "this", "->", "params", "[", "$", "index", "]", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Devuelve un parametro limpiado en base a un indice - solo parametros no utilizados por el framework @param string $index @return null o string
[ "Devuelve", "un", "parametro", "limpiado", "en", "base", "a", "un", "indice", "-", "solo", "parametros", "no", "utilizados", "por", "el", "framework" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Cron/Models/En_CronRequest.php#L61-L67
240,979
edunola13/enolaphp-framework
src/Cron/Models/En_CronRequest.php
En_CronRequest.getParamAll
public function getParamAll($index){ if(isset($this->allParams[$index])){ return Security::clean_vars($this->allParams[$index]); } else{ return NULL; } }
php
public function getParamAll($index){ if(isset($this->allParams[$index])){ return Security::clean_vars($this->allParams[$index]); } else{ return NULL; } }
[ "public", "function", "getParamAll", "(", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "allParams", "[", "$", "index", "]", ")", ")", "{", "return", "Security", "::", "clean_vars", "(", "$", "this", "->", "allParams", "[", "$", "index", "]", ")", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Devuelve un parametro en base a un indice - incluye todos los parametros @param string $index @return null o string
[ "Devuelve", "un", "parametro", "en", "base", "a", "un", "indice", "-", "incluye", "todos", "los", "parametros" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Cron/Models/En_CronRequest.php#L73-L80
240,980
edunola13/enolaphp-framework
src/Cron/Models/En_CronRequest.php
En_CronRequest.getParamAllClean
public function getParamAllClean($index){ if(isset($this->allParams[$index])){ return Security::clean_vars($this->allParams[$index]); } else{ return NULL; } }
php
public function getParamAllClean($index){ if(isset($this->allParams[$index])){ return Security::clean_vars($this->allParams[$index]); } else{ return NULL; } }
[ "public", "function", "getParamAllClean", "(", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "allParams", "[", "$", "index", "]", ")", ")", "{", "return", "Security", "::", "clean_vars", "(", "$", "this", "->", "allParams", "[", "$", "index", "]", ")", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Devuelve un parametro limpiado en base a un indice - incluye todos los parametros @param string $index @return null o string
[ "Devuelve", "un", "parametro", "limpiado", "en", "base", "a", "un", "indice", "-", "incluye", "todos", "los", "parametros" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Cron/Models/En_CronRequest.php#L86-L93
240,981
gplcart/xss
helpers/Filter.php
Filter.build
protected function build($m) { $string = $m[1]; if (substr($string, 0, 1) != '<') { // We matched a lone ">" character. return '&gt;'; } elseif (strlen($string) == 1) { // We matched a lone "<" character. return '&lt;'; } if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9\-]+)([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) { // Seriously malformed. return ''; } $slash = trim($matches[1]); $elem = &$matches[2]; $attrlist = &$matches[3]; $comment = &$matches[4]; if ($comment) { $elem = '!--'; } if (!in_array(strtolower($elem), $this->tags, true)) { return ''; // Disallowed HTML element. } if ($comment) { return $comment; } if ($slash != '') { return "</$elem>"; } // Is there a closing XHTML slash at the end of the attributes? $attrlist = preg_replace('%(\s?)/\s*$%', '\1', $attrlist, -1, $count); $xhtml_slash = $count ? ' /' : ''; // Clean up attributes. $attr2 = implode(' ', $this->explodeAttributes($attrlist)); $attr2 = preg_replace('/[<>]/', '', $attr2); $attr2 = strlen($attr2) ? ' ' . $attr2 : ''; return "<$elem$attr2$xhtml_slash>"; }
php
protected function build($m) { $string = $m[1]; if (substr($string, 0, 1) != '<') { // We matched a lone ">" character. return '&gt;'; } elseif (strlen($string) == 1) { // We matched a lone "<" character. return '&lt;'; } if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9\-]+)([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) { // Seriously malformed. return ''; } $slash = trim($matches[1]); $elem = &$matches[2]; $attrlist = &$matches[3]; $comment = &$matches[4]; if ($comment) { $elem = '!--'; } if (!in_array(strtolower($elem), $this->tags, true)) { return ''; // Disallowed HTML element. } if ($comment) { return $comment; } if ($slash != '') { return "</$elem>"; } // Is there a closing XHTML slash at the end of the attributes? $attrlist = preg_replace('%(\s?)/\s*$%', '\1', $attrlist, -1, $count); $xhtml_slash = $count ? ' /' : ''; // Clean up attributes. $attr2 = implode(' ', $this->explodeAttributes($attrlist)); $attr2 = preg_replace('/[<>]/', '', $attr2); $attr2 = strlen($attr2) ? ' ' . $attr2 : ''; return "<$elem$attr2$xhtml_slash>"; }
[ "protected", "function", "build", "(", "$", "m", ")", "{", "$", "string", "=", "$", "m", "[", "1", "]", ";", "if", "(", "substr", "(", "$", "string", ",", "0", ",", "1", ")", "!=", "'<'", ")", "{", "// We matched a lone \">\" character.", "return", "'&gt;'", ";", "}", "elseif", "(", "strlen", "(", "$", "string", ")", "==", "1", ")", "{", "// We matched a lone \"<\" character.", "return", "'&lt;'", ";", "}", "if", "(", "!", "preg_match", "(", "'%^<\\s*(/\\s*)?([a-zA-Z0-9\\-]+)([^>]*)>?|(<!--.*?-->)$%'", ",", "$", "string", ",", "$", "matches", ")", ")", "{", "// Seriously malformed.", "return", "''", ";", "}", "$", "slash", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "elem", "=", "&", "$", "matches", "[", "2", "]", ";", "$", "attrlist", "=", "&", "$", "matches", "[", "3", "]", ";", "$", "comment", "=", "&", "$", "matches", "[", "4", "]", ";", "if", "(", "$", "comment", ")", "{", "$", "elem", "=", "'!--'", ";", "}", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "elem", ")", ",", "$", "this", "->", "tags", ",", "true", ")", ")", "{", "return", "''", ";", "// Disallowed HTML element.", "}", "if", "(", "$", "comment", ")", "{", "return", "$", "comment", ";", "}", "if", "(", "$", "slash", "!=", "''", ")", "{", "return", "\"</$elem>\"", ";", "}", "// Is there a closing XHTML slash at the end of the attributes?", "$", "attrlist", "=", "preg_replace", "(", "'%(\\s?)/\\s*$%'", ",", "'\\1'", ",", "$", "attrlist", ",", "-", "1", ",", "$", "count", ")", ";", "$", "xhtml_slash", "=", "$", "count", "?", "' /'", ":", "''", ";", "// Clean up attributes.", "$", "attr2", "=", "implode", "(", "' '", ",", "$", "this", "->", "explodeAttributes", "(", "$", "attrlist", ")", ")", ";", "$", "attr2", "=", "preg_replace", "(", "'/[<>]/'", ",", "''", ",", "$", "attr2", ")", ";", "$", "attr2", "=", "strlen", "(", "$", "attr2", ")", "?", "' '", ".", "$", "attr2", ":", "''", ";", "return", "\"<$elem$attr2$xhtml_slash>\"", ";", "}" ]
Build a filtered tag @param array $m @return string
[ "Build", "a", "filtered", "tag" ]
85c98028b28da188a0a4e415df32b0c3e3761524
https://github.com/gplcart/xss/blob/85c98028b28da188a0a4e415df32b0c3e3761524/helpers/Filter.php#L124-L172
240,982
soloproyectos-php/array
src/arr/arguments/ArrArgumentsDescriptor.php
ArrArgumentsDescriptor.match
public function match($var) { $ret = false; foreach ($this->_types as $type) { if (array_search($type, array("*", "mixed")) !== false) { $ret = true; } elseif (array_search($type, array("number", "numeric")) !== false) { $ret = is_numeric($var); } elseif (array_search($type, array("bool", "boolean")) !== false) { $ret = is_bool($var); } elseif ($type == "string") { $ret = is_string($var); } elseif ($type == "array") { $ret = is_array($var); } elseif ($type == "object") { $ret = is_object($var); } elseif ($type == "resource") { $ret = is_resource($var); } elseif ($type == "function") { $ret = is_callable($var); } elseif ($type == "scalar") { $ret = is_scalar($var); } else { $ret = is_a($var, $type); } if ($ret) { break; } } return $ret; }
php
public function match($var) { $ret = false; foreach ($this->_types as $type) { if (array_search($type, array("*", "mixed")) !== false) { $ret = true; } elseif (array_search($type, array("number", "numeric")) !== false) { $ret = is_numeric($var); } elseif (array_search($type, array("bool", "boolean")) !== false) { $ret = is_bool($var); } elseif ($type == "string") { $ret = is_string($var); } elseif ($type == "array") { $ret = is_array($var); } elseif ($type == "object") { $ret = is_object($var); } elseif ($type == "resource") { $ret = is_resource($var); } elseif ($type == "function") { $ret = is_callable($var); } elseif ($type == "scalar") { $ret = is_scalar($var); } else { $ret = is_a($var, $type); } if ($ret) { break; } } return $ret; }
[ "public", "function", "match", "(", "$", "var", ")", "{", "$", "ret", "=", "false", ";", "foreach", "(", "$", "this", "->", "_types", "as", "$", "type", ")", "{", "if", "(", "array_search", "(", "$", "type", ",", "array", "(", "\"*\"", ",", "\"mixed\"", ")", ")", "!==", "false", ")", "{", "$", "ret", "=", "true", ";", "}", "elseif", "(", "array_search", "(", "$", "type", ",", "array", "(", "\"number\"", ",", "\"numeric\"", ")", ")", "!==", "false", ")", "{", "$", "ret", "=", "is_numeric", "(", "$", "var", ")", ";", "}", "elseif", "(", "array_search", "(", "$", "type", ",", "array", "(", "\"bool\"", ",", "\"boolean\"", ")", ")", "!==", "false", ")", "{", "$", "ret", "=", "is_bool", "(", "$", "var", ")", ";", "}", "elseif", "(", "$", "type", "==", "\"string\"", ")", "{", "$", "ret", "=", "is_string", "(", "$", "var", ")", ";", "}", "elseif", "(", "$", "type", "==", "\"array\"", ")", "{", "$", "ret", "=", "is_array", "(", "$", "var", ")", ";", "}", "elseif", "(", "$", "type", "==", "\"object\"", ")", "{", "$", "ret", "=", "is_object", "(", "$", "var", ")", ";", "}", "elseif", "(", "$", "type", "==", "\"resource\"", ")", "{", "$", "ret", "=", "is_resource", "(", "$", "var", ")", ";", "}", "elseif", "(", "$", "type", "==", "\"function\"", ")", "{", "$", "ret", "=", "is_callable", "(", "$", "var", ")", ";", "}", "elseif", "(", "$", "type", "==", "\"scalar\"", ")", "{", "$", "ret", "=", "is_scalar", "(", "$", "var", ")", ";", "}", "else", "{", "$", "ret", "=", "is_a", "(", "$", "var", ",", "$", "type", ")", ";", "}", "if", "(", "$", "ret", ")", "{", "break", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Does the variable match with this descriptor? @param mixed $var Arbitrary variable @return boolean
[ "Does", "the", "variable", "match", "with", "this", "descriptor?" ]
de38c800f3388005cbd37e70ab055f22609a5eae
https://github.com/soloproyectos-php/array/blob/de38c800f3388005cbd37e70ab055f22609a5eae/src/arr/arguments/ArrArgumentsDescriptor.php#L82-L115
240,983
arvici/framework
src/Arvici/Heart/Router/Middleware.php
Middleware.execute
public function execute() { if (is_string($this->callback)) { // Will call the controller here $parts = explode('::', $this->callback); $className = $parts[0]; $classMethod = $parts[1]; if (! class_exists($className)) { throw new RouterException("The callback class declared in your middleware is not found: '{$className}'"); } $class = new $className(); if (! $class instanceof BaseMiddleware) { throw new RouterException("The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'"); // @codeCoverageIgnore } if (! method_exists($class, $classMethod)) { throw new RouterException("The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}"); } // Call the method. Catch return $result = call_user_func(array($class, $classMethod)); } elseif (is_callable($this->callback)) { $result = call_user_func($this->callback); } else { throw new RouterException("Middleware callback is not a class or callable!"); // @codeCoverageIgnore } // See if we got a boolean back. if ($result === false && $this->position === 'before') { // We should stop! return false; } return true; }
php
public function execute() { if (is_string($this->callback)) { // Will call the controller here $parts = explode('::', $this->callback); $className = $parts[0]; $classMethod = $parts[1]; if (! class_exists($className)) { throw new RouterException("The callback class declared in your middleware is not found: '{$className}'"); } $class = new $className(); if (! $class instanceof BaseMiddleware) { throw new RouterException("The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'"); // @codeCoverageIgnore } if (! method_exists($class, $classMethod)) { throw new RouterException("The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}"); } // Call the method. Catch return $result = call_user_func(array($class, $classMethod)); } elseif (is_callable($this->callback)) { $result = call_user_func($this->callback); } else { throw new RouterException("Middleware callback is not a class or callable!"); // @codeCoverageIgnore } // See if we got a boolean back. if ($result === false && $this->position === 'before') { // We should stop! return false; } return true; }
[ "public", "function", "execute", "(", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "callback", ")", ")", "{", "// Will call the controller here", "$", "parts", "=", "explode", "(", "'::'", ",", "$", "this", "->", "callback", ")", ";", "$", "className", "=", "$", "parts", "[", "0", "]", ";", "$", "classMethod", "=", "$", "parts", "[", "1", "]", ";", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "throw", "new", "RouterException", "(", "\"The callback class declared in your middleware is not found: '{$className}'\"", ")", ";", "}", "$", "class", "=", "new", "$", "className", "(", ")", ";", "if", "(", "!", "$", "class", "instanceof", "BaseMiddleware", ")", "{", "throw", "new", "RouterException", "(", "\"The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'\"", ")", ";", "// @codeCoverageIgnore", "}", "if", "(", "!", "method_exists", "(", "$", "class", ",", "$", "classMethod", ")", ")", "{", "throw", "new", "RouterException", "(", "\"The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}\"", ")", ";", "}", "// Call the method. Catch return", "$", "result", "=", "call_user_func", "(", "array", "(", "$", "class", ",", "$", "classMethod", ")", ")", ";", "}", "elseif", "(", "is_callable", "(", "$", "this", "->", "callback", ")", ")", "{", "$", "result", "=", "call_user_func", "(", "$", "this", "->", "callback", ")", ";", "}", "else", "{", "throw", "new", "RouterException", "(", "\"Middleware callback is not a class or callable!\"", ")", ";", "// @codeCoverageIgnore", "}", "// See if we got a boolean back.", "if", "(", "$", "result", "===", "false", "&&", "$", "this", "->", "position", "===", "'before'", ")", "{", "// We should stop!", "return", "false", ";", "}", "return", "true", ";", "}" ]
Execute Callback in middleware, capture the output of it. @return bool can we continue? @throws RouterException
[ "Execute", "Callback", "in", "middleware", "capture", "the", "output", "of", "it", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Middleware.php#L105-L143
240,984
samsonos/social_network
Network.php
Network.prepare
public function prepare() { $class = get_class($this); // Check table if (!isset($this->dbTable)) { return e('Cannot load "'.$class.'" module - no $dbTable is configured'); } // Social system specific configuration check if ($class != __CLASS__) { db()->createField($this, $this->dbTable, 'dbIdField', 'VARCHAR(50)'); } // Create and check general database table fields configuration db()->createField($this, $this->dbTable, 'dbNameField', 'VARCHAR(50)'); db()->createField($this, $this->dbTable, 'dbSurnameField', 'VARCHAR(50)'); db()->createField($this, $this->dbTable, 'dbEmailField', 'VARCHAR(50)'); db()->createField($this, $this->dbTable, 'dbGenderField', 'VARCHAR(10)'); db()->createField($this, $this->dbTable, 'dbBirthdayField', 'DATE'); db()->createField($this, $this->dbTable, 'dbPhotoField', 'VARCHAR(125)'); return parent::prepare(); }
php
public function prepare() { $class = get_class($this); // Check table if (!isset($this->dbTable)) { return e('Cannot load "'.$class.'" module - no $dbTable is configured'); } // Social system specific configuration check if ($class != __CLASS__) { db()->createField($this, $this->dbTable, 'dbIdField', 'VARCHAR(50)'); } // Create and check general database table fields configuration db()->createField($this, $this->dbTable, 'dbNameField', 'VARCHAR(50)'); db()->createField($this, $this->dbTable, 'dbSurnameField', 'VARCHAR(50)'); db()->createField($this, $this->dbTable, 'dbEmailField', 'VARCHAR(50)'); db()->createField($this, $this->dbTable, 'dbGenderField', 'VARCHAR(10)'); db()->createField($this, $this->dbTable, 'dbBirthdayField', 'DATE'); db()->createField($this, $this->dbTable, 'dbPhotoField', 'VARCHAR(125)'); return parent::prepare(); }
[ "public", "function", "prepare", "(", ")", "{", "$", "class", "=", "get_class", "(", "$", "this", ")", ";", "// Check table", "if", "(", "!", "isset", "(", "$", "this", "->", "dbTable", ")", ")", "{", "return", "e", "(", "'Cannot load \"'", ".", "$", "class", ".", "'\" module - no $dbTable is configured'", ")", ";", "}", "// Social system specific configuration check", "if", "(", "$", "class", "!=", "__CLASS__", ")", "{", "db", "(", ")", "->", "createField", "(", "$", "this", ",", "$", "this", "->", "dbTable", ",", "'dbIdField'", ",", "'VARCHAR(50)'", ")", ";", "}", "// Create and check general database table fields configuration", "db", "(", ")", "->", "createField", "(", "$", "this", ",", "$", "this", "->", "dbTable", ",", "'dbNameField'", ",", "'VARCHAR(50)'", ")", ";", "db", "(", ")", "->", "createField", "(", "$", "this", ",", "$", "this", "->", "dbTable", ",", "'dbSurnameField'", ",", "'VARCHAR(50)'", ")", ";", "db", "(", ")", "->", "createField", "(", "$", "this", ",", "$", "this", "->", "dbTable", ",", "'dbEmailField'", ",", "'VARCHAR(50)'", ")", ";", "db", "(", ")", "->", "createField", "(", "$", "this", ",", "$", "this", "->", "dbTable", ",", "'dbGenderField'", ",", "'VARCHAR(10)'", ")", ";", "db", "(", ")", "->", "createField", "(", "$", "this", ",", "$", "this", "->", "dbTable", ",", "'dbBirthdayField'", ",", "'DATE'", ")", ";", "db", "(", ")", "->", "createField", "(", "$", "this", ",", "$", "this", "->", "dbTable", ",", "'dbPhotoField'", ",", "'VARCHAR(125)'", ")", ";", "return", "parent", "::", "prepare", "(", ")", ";", "}" ]
Prepare module data
[ "Prepare", "module", "data" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L76-L99
240,985
samsonos/social_network
Network.php
Network.init
public function init(array $params = array()) { // Try to load token from session if (isset($_SESSION[self::SESSION_PREFIX.'_'.$this->id])) { $this->token = $_SESSION[self::SESSION_PREFIX.'_'.$this->id]; } parent::init($params); }
php
public function init(array $params = array()) { // Try to load token from session if (isset($_SESSION[self::SESSION_PREFIX.'_'.$this->id])) { $this->token = $_SESSION[self::SESSION_PREFIX.'_'.$this->id]; } parent::init($params); }
[ "public", "function", "init", "(", "array", "$", "params", "=", "array", "(", ")", ")", "{", "// Try to load token from session", "if", "(", "isset", "(", "$", "_SESSION", "[", "self", "::", "SESSION_PREFIX", ".", "'_'", ".", "$", "this", "->", "id", "]", ")", ")", "{", "$", "this", "->", "token", "=", "$", "_SESSION", "[", "self", "::", "SESSION_PREFIX", ".", "'_'", ".", "$", "this", "->", "id", "]", ";", "}", "parent", "::", "init", "(", "$", "params", ")", ";", "}" ]
Social network initialization
[ "Social", "network", "initialization" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L102-L110
240,986
samsonos/social_network
Network.php
Network.setUser
protected function setUser(array $userData, & $user = null) { // Generic birthdate parsing $user->birthday = date('Y-m-d H:i:s', strtotime($user->birthday)); // If no external user is passed set as current user if (isset($user)) { $this->user = & $user; } }
php
protected function setUser(array $userData, & $user = null) { // Generic birthdate parsing $user->birthday = date('Y-m-d H:i:s', strtotime($user->birthday)); // If no external user is passed set as current user if (isset($user)) { $this->user = & $user; } }
[ "protected", "function", "setUser", "(", "array", "$", "userData", ",", "&", "$", "user", "=", "null", ")", "{", "// Generic birthdate parsing", "$", "user", "->", "birthday", "=", "date", "(", "'Y-m-d H:i:s'", ",", "strtotime", "(", "$", "user", "->", "birthday", ")", ")", ";", "// If no external user is passed set as current user", "if", "(", "isset", "(", "$", "user", ")", ")", "{", "$", "this", "->", "user", "=", "&", "$", "user", ";", "}", "}" ]
Fill object User @param array $userData Answer of social network @param mixed $user Pointer to user object for filling
[ "Fill", "object", "User" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L118-L127
240,987
samsonos/social_network
Network.php
Network.&
protected function & storeUserData(&$user = null) { // If no user is passed - create it if (!isset($user)) { $user = new $this->dbTable(false); } // Store social data for user $user[$this->dbIdField] = $this->user->socialID; $user[$this->dbNameField] = strlen($this->user->name) ? $this->user->name : $user[$this->dbNameField]; $user[$this->dbSurnameField] = strlen($this->user->surname) ? $this->user->surname : $user[$this->dbSurnameField] ; $user[$this->dbGenderField] = strlen($this->user->gender) ? $this->user->gender : $user[$this->dbGenderField] ; $user[$this->dbBirthdayField] = max($user[$this->dbBirthdayField],$this->user->birthday); $user[$this->dbPhotoField] = strlen($this->user->photo) ? $this->user->photo : $user[$this->dbPhotoField]; // If no email is passed - set hashed socialID as email if (!strlen($this->user->email)) { if (!strlen($user->email)) { $user[$this->dbEmailField] = md5($this->user->socialID); } } else { $user[$this->dbEmailField] = $this->user->email; } $user->save(); return $user; }
php
protected function & storeUserData(&$user = null) { // If no user is passed - create it if (!isset($user)) { $user = new $this->dbTable(false); } // Store social data for user $user[$this->dbIdField] = $this->user->socialID; $user[$this->dbNameField] = strlen($this->user->name) ? $this->user->name : $user[$this->dbNameField]; $user[$this->dbSurnameField] = strlen($this->user->surname) ? $this->user->surname : $user[$this->dbSurnameField] ; $user[$this->dbGenderField] = strlen($this->user->gender) ? $this->user->gender : $user[$this->dbGenderField] ; $user[$this->dbBirthdayField] = max($user[$this->dbBirthdayField],$this->user->birthday); $user[$this->dbPhotoField] = strlen($this->user->photo) ? $this->user->photo : $user[$this->dbPhotoField]; // If no email is passed - set hashed socialID as email if (!strlen($this->user->email)) { if (!strlen($user->email)) { $user[$this->dbEmailField] = md5($this->user->socialID); } } else { $user[$this->dbEmailField] = $this->user->email; } $user->save(); return $user; }
[ "protected", "function", "&", "storeUserData", "(", "&", "$", "user", "=", "null", ")", "{", "// If no user is passed - create it", "if", "(", "!", "isset", "(", "$", "user", ")", ")", "{", "$", "user", "=", "new", "$", "this", "->", "dbTable", "(", "false", ")", ";", "}", "// Store social data for user", "$", "user", "[", "$", "this", "->", "dbIdField", "]", "=", "$", "this", "->", "user", "->", "socialID", ";", "$", "user", "[", "$", "this", "->", "dbNameField", "]", "=", "strlen", "(", "$", "this", "->", "user", "->", "name", ")", "?", "$", "this", "->", "user", "->", "name", ":", "$", "user", "[", "$", "this", "->", "dbNameField", "]", ";", "$", "user", "[", "$", "this", "->", "dbSurnameField", "]", "=", "strlen", "(", "$", "this", "->", "user", "->", "surname", ")", "?", "$", "this", "->", "user", "->", "surname", ":", "$", "user", "[", "$", "this", "->", "dbSurnameField", "]", ";", "$", "user", "[", "$", "this", "->", "dbGenderField", "]", "=", "strlen", "(", "$", "this", "->", "user", "->", "gender", ")", "?", "$", "this", "->", "user", "->", "gender", ":", "$", "user", "[", "$", "this", "->", "dbGenderField", "]", ";", "$", "user", "[", "$", "this", "->", "dbBirthdayField", "]", "=", "max", "(", "$", "user", "[", "$", "this", "->", "dbBirthdayField", "]", ",", "$", "this", "->", "user", "->", "birthday", ")", ";", "$", "user", "[", "$", "this", "->", "dbPhotoField", "]", "=", "strlen", "(", "$", "this", "->", "user", "->", "photo", ")", "?", "$", "this", "->", "user", "->", "photo", ":", "$", "user", "[", "$", "this", "->", "dbPhotoField", "]", ";", "// If no email is passed - set hashed socialID as email", "if", "(", "!", "strlen", "(", "$", "this", "->", "user", "->", "email", ")", ")", "{", "if", "(", "!", "strlen", "(", "$", "user", "->", "email", ")", ")", "{", "$", "user", "[", "$", "this", "->", "dbEmailField", "]", "=", "md5", "(", "$", "this", "->", "user", "->", "socialID", ")", ";", "}", "}", "else", "{", "$", "user", "[", "$", "this", "->", "dbEmailField", "]", "=", "$", "this", "->", "user", "->", "email", ";", "}", "$", "user", "->", "save", "(", ")", ";", "return", "$", "user", ";", "}" ]
Store current social user data in database @param \samson\activerecord\dbRecord $user @return \samson\activerecord\dbRecord Stored user database record
[ "Store", "current", "social", "user", "data", "in", "database" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L184-L211
240,988
samsonos/social_network
Network.php
Network.&
public function & friends($count = null, $offset = null) { $result = array(); // If we have authorized via one of social modules if (isset($this->active)) { // Call friends method on active social module $result = & $this->active->friends($count, $offset); } return $result; }
php
public function & friends($count = null, $offset = null) { $result = array(); // If we have authorized via one of social modules if (isset($this->active)) { // Call friends method on active social module $result = & $this->active->friends($count, $offset); } return $result; }
[ "public", "function", "&", "friends", "(", "$", "count", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// If we have authorized via one of social modules", "if", "(", "isset", "(", "$", "this", "->", "active", ")", ")", "{", "// Call friends method on active social module", "$", "result", "=", "&", "$", "this", "->", "active", "->", "friends", "(", "$", "count", ",", "$", "offset", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get user fiends list @param integer $count Friends count @param integer $offset Friends offset @return User[] Collection of user friends objects
[ "Get", "user", "fiends", "list" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L265-L276
240,989
bishopb/vanilla
applications/dashboard/models/class.spammodel.php
SpamModel.IsSpam
public static function IsSpam($RecordType, $Data, $Options = array()) { if (self::$Disabled) return FALSE; // Set some information about the user in the data. if ($RecordType == 'Registration') { TouchValue('Username', $Data, $Data['Name']); } else { TouchValue('InsertUserID', $Data, Gdn::Session()->UserID); $User = Gdn::UserModel()->GetID(GetValue('InsertUserID', $Data), DATASET_TYPE_ARRAY); if ($User) { if (GetValue('Verified', $User)) { // The user has been verified and isn't a spammer. return FALSE; } TouchValue('Username', $Data, $User['Name']); TouchValue('Email', $Data, $User['Email']); TouchValue('IPAddress', $Data, $User['LastIPAddress']); } } if (!isset($Data['Body']) && isset($Data['Story'])) { $Data['Body'] = $Data['Story']; } TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress()); $Sp = self::_Instance(); $Sp->EventArguments['RecordType'] = $RecordType; $Sp->EventArguments['Data'] =& $Data; $Sp->EventArguments['Options'] =& $Options; $Sp->EventArguments['IsSpam'] = FALSE; $Sp->FireEvent('CheckSpam'); $Spam = $Sp->EventArguments['IsSpam']; // Log the spam entry. if ($Spam && GetValue('Log', $Options, TRUE)) { $LogOptions = array(); switch ($RecordType) { case 'Registration': $LogOptions['GroupBy'] = array('RecordIPAddress'); break; case 'Comment': case 'Discussion': case 'Activity': case 'ActivityComment': $LogOptions['GroupBy'] = array('RecordID'); break; } LogModel::Insert('Spam', $RecordType, $Data, $LogOptions); } return $Spam; }
php
public static function IsSpam($RecordType, $Data, $Options = array()) { if (self::$Disabled) return FALSE; // Set some information about the user in the data. if ($RecordType == 'Registration') { TouchValue('Username', $Data, $Data['Name']); } else { TouchValue('InsertUserID', $Data, Gdn::Session()->UserID); $User = Gdn::UserModel()->GetID(GetValue('InsertUserID', $Data), DATASET_TYPE_ARRAY); if ($User) { if (GetValue('Verified', $User)) { // The user has been verified and isn't a spammer. return FALSE; } TouchValue('Username', $Data, $User['Name']); TouchValue('Email', $Data, $User['Email']); TouchValue('IPAddress', $Data, $User['LastIPAddress']); } } if (!isset($Data['Body']) && isset($Data['Story'])) { $Data['Body'] = $Data['Story']; } TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress()); $Sp = self::_Instance(); $Sp->EventArguments['RecordType'] = $RecordType; $Sp->EventArguments['Data'] =& $Data; $Sp->EventArguments['Options'] =& $Options; $Sp->EventArguments['IsSpam'] = FALSE; $Sp->FireEvent('CheckSpam'); $Spam = $Sp->EventArguments['IsSpam']; // Log the spam entry. if ($Spam && GetValue('Log', $Options, TRUE)) { $LogOptions = array(); switch ($RecordType) { case 'Registration': $LogOptions['GroupBy'] = array('RecordIPAddress'); break; case 'Comment': case 'Discussion': case 'Activity': case 'ActivityComment': $LogOptions['GroupBy'] = array('RecordID'); break; } LogModel::Insert('Spam', $RecordType, $Data, $LogOptions); } return $Spam; }
[ "public", "static", "function", "IsSpam", "(", "$", "RecordType", ",", "$", "Data", ",", "$", "Options", "=", "array", "(", ")", ")", "{", "if", "(", "self", "::", "$", "Disabled", ")", "return", "FALSE", ";", "// Set some information about the user in the data.", "if", "(", "$", "RecordType", "==", "'Registration'", ")", "{", "TouchValue", "(", "'Username'", ",", "$", "Data", ",", "$", "Data", "[", "'Name'", "]", ")", ";", "}", "else", "{", "TouchValue", "(", "'InsertUserID'", ",", "$", "Data", ",", "Gdn", "::", "Session", "(", ")", "->", "UserID", ")", ";", "$", "User", "=", "Gdn", "::", "UserModel", "(", ")", "->", "GetID", "(", "GetValue", "(", "'InsertUserID'", ",", "$", "Data", ")", ",", "DATASET_TYPE_ARRAY", ")", ";", "if", "(", "$", "User", ")", "{", "if", "(", "GetValue", "(", "'Verified'", ",", "$", "User", ")", ")", "{", "// The user has been verified and isn't a spammer.", "return", "FALSE", ";", "}", "TouchValue", "(", "'Username'", ",", "$", "Data", ",", "$", "User", "[", "'Name'", "]", ")", ";", "TouchValue", "(", "'Email'", ",", "$", "Data", ",", "$", "User", "[", "'Email'", "]", ")", ";", "TouchValue", "(", "'IPAddress'", ",", "$", "Data", ",", "$", "User", "[", "'LastIPAddress'", "]", ")", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "Data", "[", "'Body'", "]", ")", "&&", "isset", "(", "$", "Data", "[", "'Story'", "]", ")", ")", "{", "$", "Data", "[", "'Body'", "]", "=", "$", "Data", "[", "'Story'", "]", ";", "}", "TouchValue", "(", "'IPAddress'", ",", "$", "Data", ",", "Gdn", "::", "Request", "(", ")", "->", "IpAddress", "(", ")", ")", ";", "$", "Sp", "=", "self", "::", "_Instance", "(", ")", ";", "$", "Sp", "->", "EventArguments", "[", "'RecordType'", "]", "=", "$", "RecordType", ";", "$", "Sp", "->", "EventArguments", "[", "'Data'", "]", "=", "&", "$", "Data", ";", "$", "Sp", "->", "EventArguments", "[", "'Options'", "]", "=", "&", "$", "Options", ";", "$", "Sp", "->", "EventArguments", "[", "'IsSpam'", "]", "=", "FALSE", ";", "$", "Sp", "->", "FireEvent", "(", "'CheckSpam'", ")", ";", "$", "Spam", "=", "$", "Sp", "->", "EventArguments", "[", "'IsSpam'", "]", ";", "// Log the spam entry.", "if", "(", "$", "Spam", "&&", "GetValue", "(", "'Log'", ",", "$", "Options", ",", "TRUE", ")", ")", "{", "$", "LogOptions", "=", "array", "(", ")", ";", "switch", "(", "$", "RecordType", ")", "{", "case", "'Registration'", ":", "$", "LogOptions", "[", "'GroupBy'", "]", "=", "array", "(", "'RecordIPAddress'", ")", ";", "break", ";", "case", "'Comment'", ":", "case", "'Discussion'", ":", "case", "'Activity'", ":", "case", "'ActivityComment'", ":", "$", "LogOptions", "[", "'GroupBy'", "]", "=", "array", "(", "'RecordID'", ")", ";", "break", ";", "}", "LogModel", "::", "Insert", "(", "'Spam'", ",", "$", "RecordType", ",", "$", "Data", ",", "$", "LogOptions", ")", ";", "}", "return", "$", "Spam", ";", "}" ]
Check whether or not the record is spam. @param string $RecordType By default, this should be one of the following: - Comment: A comment. - Discussion: A discussion. - User: A user registration. @param array $Data The record data. @param array $Options Options for fine-tuning this method call. - Log: Log the record if it is found to be spam.
[ "Check", "whether", "or", "not", "the", "record", "is", "spam", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.spammodel.php#L33-L91
240,990
gourmet/common
Lib/Navigation.php
Navigation.clear
public static function clear($path = null) { if (empty($path)) { self::$_items = array(); return; } if (Hash::check(self::$_items, $path)) { self::$_items = Hash::insert(self::$_items, $path, array()); } }
php
public static function clear($path = null) { if (empty($path)) { self::$_items = array(); return; } if (Hash::check(self::$_items, $path)) { self::$_items = Hash::insert(self::$_items, $path, array()); } }
[ "public", "static", "function", "clear", "(", "$", "path", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "self", "::", "$", "_items", "=", "array", "(", ")", ";", "return", ";", "}", "if", "(", "Hash", "::", "check", "(", "self", "::", "$", "_items", ",", "$", "path", ")", ")", "{", "self", "::", "$", "_items", "=", "Hash", "::", "insert", "(", "self", "::", "$", "_items", ",", "$", "path", ",", "array", "(", ")", ")", ";", "}", "}" ]
Clear all menus. @return void
[ "Clear", "all", "menus", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Lib/Navigation.php#L94-L103
240,991
gourmet/common
Lib/Navigation.php
Navigation.order
public static function order($items) { if (empty($items)) { return array(); } $_items = array_combine(array_keys($items), Hash::extract($items, '{s}.weight')); asort($_items); foreach (array_keys($_items) as $key) { $_items[$key] = $items[$key]; } return $items; }
php
public static function order($items) { if (empty($items)) { return array(); } $_items = array_combine(array_keys($items), Hash::extract($items, '{s}.weight')); asort($_items); foreach (array_keys($_items) as $key) { $_items[$key] = $items[$key]; } return $items; }
[ "public", "static", "function", "order", "(", "$", "items", ")", "{", "if", "(", "empty", "(", "$", "items", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "_items", "=", "array_combine", "(", "array_keys", "(", "$", "items", ")", ",", "Hash", "::", "extract", "(", "$", "items", ",", "'{s}.weight'", ")", ")", ";", "asort", "(", "$", "_items", ")", ";", "foreach", "(", "array_keys", "(", "$", "_items", ")", "as", "$", "key", ")", "{", "$", "_items", "[", "$", "key", "]", "=", "$", "items", "[", "$", "key", "]", ";", "}", "return", "$", "items", ";", "}" ]
Orders items by weight. @param array $items @return array
[ "Orders", "items", "by", "weight", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Lib/Navigation.php#L142-L155
240,992
synga-nl/inheritance-finder
src/InheritanceFinder.php
InheritanceFinder.findMultiple
public function findMultiple($classes = [], $interfaces = [], $traits = []) { $this->init(); $classes = $this->normalizeArray($classes); $interfaces = $this->normalizeArray($interfaces); $traits = $this->normalizeArray($traits); $foundClasses = []; if ($classes !== false) { foreach ($classes as $class) { $foundClasses = array_merge($foundClasses, $this->findExtends($class)); } } if ($interfaces !== false) { foreach ($interfaces as $interface) { $foundClasses = array_merge($foundClasses, $this->findImplements($interface)); } } if ($traits !== false) { foreach ($traits as $trait) { $foundClasses = array_merge($foundClasses, $this->findTraitUse($trait)); } } return $this->arrayUniqueObject($foundClasses); }
php
public function findMultiple($classes = [], $interfaces = [], $traits = []) { $this->init(); $classes = $this->normalizeArray($classes); $interfaces = $this->normalizeArray($interfaces); $traits = $this->normalizeArray($traits); $foundClasses = []; if ($classes !== false) { foreach ($classes as $class) { $foundClasses = array_merge($foundClasses, $this->findExtends($class)); } } if ($interfaces !== false) { foreach ($interfaces as $interface) { $foundClasses = array_merge($foundClasses, $this->findImplements($interface)); } } if ($traits !== false) { foreach ($traits as $trait) { $foundClasses = array_merge($foundClasses, $this->findTraitUse($trait)); } } return $this->arrayUniqueObject($foundClasses); }
[ "public", "function", "findMultiple", "(", "$", "classes", "=", "[", "]", ",", "$", "interfaces", "=", "[", "]", ",", "$", "traits", "=", "[", "]", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "classes", "=", "$", "this", "->", "normalizeArray", "(", "$", "classes", ")", ";", "$", "interfaces", "=", "$", "this", "->", "normalizeArray", "(", "$", "interfaces", ")", ";", "$", "traits", "=", "$", "this", "->", "normalizeArray", "(", "$", "traits", ")", ";", "$", "foundClasses", "=", "[", "]", ";", "if", "(", "$", "classes", "!==", "false", ")", "{", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "foundClasses", "=", "array_merge", "(", "$", "foundClasses", ",", "$", "this", "->", "findExtends", "(", "$", "class", ")", ")", ";", "}", "}", "if", "(", "$", "interfaces", "!==", "false", ")", "{", "foreach", "(", "$", "interfaces", "as", "$", "interface", ")", "{", "$", "foundClasses", "=", "array_merge", "(", "$", "foundClasses", ",", "$", "this", "->", "findImplements", "(", "$", "interface", ")", ")", ";", "}", "}", "if", "(", "$", "traits", "!==", "false", ")", "{", "foreach", "(", "$", "traits", "as", "$", "trait", ")", "{", "$", "foundClasses", "=", "array_merge", "(", "$", "foundClasses", ",", "$", "this", "->", "findTraitUse", "(", "$", "trait", ")", ")", ";", "}", "}", "return", "$", "this", "->", "arrayUniqueObject", "(", "$", "foundClasses", ")", ";", "}" ]
Can find multiple classes at once. @param array $classes @param array $interfaces @param array $traits @return PhpClass[]
[ "Can", "find", "multiple", "classes", "at", "once", "." ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/InheritanceFinder.php#L126-L154
240,993
synga-nl/inheritance-finder
src/InheritanceFinder.php
InheritanceFinder.findImplementsOrTraitUse
protected function findImplementsOrTraitUse($fullQualifiedNamespace, $type) { $fullQualifiedNamespace = $this->trimNamespace($fullQualifiedNamespace); $phpClasses = []; $method = 'get' . ucfirst($type); foreach ($this->localCache as $phpClass) { $implementsOrTrait = $phpClass->$method(); if (is_array($implementsOrTrait) && in_array($fullQualifiedNamespace, $implementsOrTrait)) { $phpClasses[] = $phpClass; $phpClasses = array_merge($phpClasses, $this->findExtends($phpClass->getFullQualifiedNamespace())); } } return $this->arrayUniqueObject($phpClasses); }
php
protected function findImplementsOrTraitUse($fullQualifiedNamespace, $type) { $fullQualifiedNamespace = $this->trimNamespace($fullQualifiedNamespace); $phpClasses = []; $method = 'get' . ucfirst($type); foreach ($this->localCache as $phpClass) { $implementsOrTrait = $phpClass->$method(); if (is_array($implementsOrTrait) && in_array($fullQualifiedNamespace, $implementsOrTrait)) { $phpClasses[] = $phpClass; $phpClasses = array_merge($phpClasses, $this->findExtends($phpClass->getFullQualifiedNamespace())); } } return $this->arrayUniqueObject($phpClasses); }
[ "protected", "function", "findImplementsOrTraitUse", "(", "$", "fullQualifiedNamespace", ",", "$", "type", ")", "{", "$", "fullQualifiedNamespace", "=", "$", "this", "->", "trimNamespace", "(", "$", "fullQualifiedNamespace", ")", ";", "$", "phpClasses", "=", "[", "]", ";", "$", "method", "=", "'get'", ".", "ucfirst", "(", "$", "type", ")", ";", "foreach", "(", "$", "this", "->", "localCache", "as", "$", "phpClass", ")", "{", "$", "implementsOrTrait", "=", "$", "phpClass", "->", "$", "method", "(", ")", ";", "if", "(", "is_array", "(", "$", "implementsOrTrait", ")", "&&", "in_array", "(", "$", "fullQualifiedNamespace", ",", "$", "implementsOrTrait", ")", ")", "{", "$", "phpClasses", "[", "]", "=", "$", "phpClass", ";", "$", "phpClasses", "=", "array_merge", "(", "$", "phpClasses", ",", "$", "this", "->", "findExtends", "(", "$", "phpClass", "->", "getFullQualifiedNamespace", "(", ")", ")", ")", ";", "}", "}", "return", "$", "this", "->", "arrayUniqueObject", "(", "$", "phpClasses", ")", ";", "}" ]
Can find implements or detect trait use @param $fullQualifiedNamespace @param $type @return PhpClass[]
[ "Can", "find", "implements", "or", "detect", "trait", "use" ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/InheritanceFinder.php#L163-L179
240,994
synga-nl/inheritance-finder
src/InheritanceFinder.php
InheritanceFinder.arrayUniqueObject
protected function arrayUniqueObject($phpClasses) { $hashes = []; foreach ($phpClasses as $key => $phpClass) { $hashes[$key] = spl_object_hash($phpClass); } $hashes = array_unique($hashes); $uniqueArray = []; foreach ($hashes as $key => $hash) { $uniqueArray[$key] = $phpClasses[$key]; } return $uniqueArray; }
php
protected function arrayUniqueObject($phpClasses) { $hashes = []; foreach ($phpClasses as $key => $phpClass) { $hashes[$key] = spl_object_hash($phpClass); } $hashes = array_unique($hashes); $uniqueArray = []; foreach ($hashes as $key => $hash) { $uniqueArray[$key] = $phpClasses[$key]; } return $uniqueArray; }
[ "protected", "function", "arrayUniqueObject", "(", "$", "phpClasses", ")", "{", "$", "hashes", "=", "[", "]", ";", "foreach", "(", "$", "phpClasses", "as", "$", "key", "=>", "$", "phpClass", ")", "{", "$", "hashes", "[", "$", "key", "]", "=", "spl_object_hash", "(", "$", "phpClass", ")", ";", "}", "$", "hashes", "=", "array_unique", "(", "$", "hashes", ")", ";", "$", "uniqueArray", "=", "[", "]", ";", "foreach", "(", "$", "hashes", "as", "$", "key", "=>", "$", "hash", ")", "{", "$", "uniqueArray", "[", "$", "key", "]", "=", "$", "phpClasses", "[", "$", "key", "]", ";", "}", "return", "$", "uniqueArray", ";", "}" ]
Makes an array of object unique using the spl_object_hash function @param $phpClasses @return array
[ "Makes", "an", "array", "of", "object", "unique", "using", "the", "spl_object_hash", "function" ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/InheritanceFinder.php#L187-L203
240,995
digitalicagroup/slack-hook-framework
lib/SlackHookFramework/AbstractArray.php
AbstractArray.getValue
public function getValue($key) { if (isset ( $this->a [$key] )) { return $this->a [$key]; } else { return NULL; } }
php
public function getValue($key) { if (isset ( $this->a [$key] )) { return $this->a [$key]; } else { return NULL; } }
[ "public", "function", "getValue", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "a", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "a", "[", "$", "key", "]", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Getter method for a specific value referenced by the given key. @param string $key
[ "Getter", "method", "for", "a", "specific", "value", "referenced", "by", "the", "given", "key", "." ]
b2357275d6042e49cb082e375716effd4c001ee0
https://github.com/digitalicagroup/slack-hook-framework/blob/b2357275d6042e49cb082e375716effd4c001ee0/lib/SlackHookFramework/AbstractArray.php#L67-L73
240,996
SocietyCMS/Core
Utilities/Localization/Generators/LangJsGenerator.php
LangJsGenerator.getMessagesFromSourcePath
protected function getMessagesFromSourcePath($path, $namespace) { $messages = []; if (! $this->file->exists($path)) { throw new \Exception("${path} doesn't exists!"); } foreach ($this->file->allFiles($path) as $file) { $pathName = $file->getRelativePathName(); if ($this->file->extension($pathName) !== 'php') { continue; } $key = substr($pathName, 0, -4); $key = str_replace('\\', '.', $key); $key = str_replace('/', '.', $key); $array = explode('.', $key, 2); $keyWithNamespace = $array[0].'.'.$namespace.'::'.$array[1]; $messages[$keyWithNamespace] = include "${path}/${pathName}"; } return $messages; }
php
protected function getMessagesFromSourcePath($path, $namespace) { $messages = []; if (! $this->file->exists($path)) { throw new \Exception("${path} doesn't exists!"); } foreach ($this->file->allFiles($path) as $file) { $pathName = $file->getRelativePathName(); if ($this->file->extension($pathName) !== 'php') { continue; } $key = substr($pathName, 0, -4); $key = str_replace('\\', '.', $key); $key = str_replace('/', '.', $key); $array = explode('.', $key, 2); $keyWithNamespace = $array[0].'.'.$namespace.'::'.$array[1]; $messages[$keyWithNamespace] = include "${path}/${pathName}"; } return $messages; }
[ "protected", "function", "getMessagesFromSourcePath", "(", "$", "path", ",", "$", "namespace", ")", "{", "$", "messages", "=", "[", "]", ";", "if", "(", "!", "$", "this", "->", "file", "->", "exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"${path} doesn't exists!\"", ")", ";", "}", "foreach", "(", "$", "this", "->", "file", "->", "allFiles", "(", "$", "path", ")", "as", "$", "file", ")", "{", "$", "pathName", "=", "$", "file", "->", "getRelativePathName", "(", ")", ";", "if", "(", "$", "this", "->", "file", "->", "extension", "(", "$", "pathName", ")", "!==", "'php'", ")", "{", "continue", ";", "}", "$", "key", "=", "substr", "(", "$", "pathName", ",", "0", ",", "-", "4", ")", ";", "$", "key", "=", "str_replace", "(", "'\\\\'", ",", "'.'", ",", "$", "key", ")", ";", "$", "key", "=", "str_replace", "(", "'/'", ",", "'.'", ",", "$", "key", ")", ";", "$", "array", "=", "explode", "(", "'.'", ",", "$", "key", ",", "2", ")", ";", "$", "keyWithNamespace", "=", "$", "array", "[", "0", "]", ".", "'.'", ".", "$", "namespace", ".", "'::'", ".", "$", "array", "[", "1", "]", ";", "$", "messages", "[", "$", "keyWithNamespace", "]", "=", "include", "\"${path}/${pathName}\"", ";", "}", "return", "$", "messages", ";", "}" ]
Return language messages for a path. @param $path @return array @throws \Exception
[ "Return", "language", "messages", "for", "a", "path", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Utilities/Localization/Generators/LangJsGenerator.php#L88-L109
240,997
SocietyCMS/Core
Utilities/Localization/Generators/LangJsGenerator.php
LangJsGenerator.prepareTarget
protected function prepareTarget($target) { $dirname = dirname($target); if (! $this->file->exists($dirname)) { $this->file->makeDirectory($dirname); } }
php
protected function prepareTarget($target) { $dirname = dirname($target); if (! $this->file->exists($dirname)) { $this->file->makeDirectory($dirname); } }
[ "protected", "function", "prepareTarget", "(", "$", "target", ")", "{", "$", "dirname", "=", "dirname", "(", "$", "target", ")", ";", "if", "(", "!", "$", "this", "->", "file", "->", "exists", "(", "$", "dirname", ")", ")", "{", "$", "this", "->", "file", "->", "makeDirectory", "(", "$", "dirname", ")", ";", "}", "}" ]
Prepare the target directoy. @param string $target The target directory.
[ "Prepare", "the", "target", "directoy", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Utilities/Localization/Generators/LangJsGenerator.php#L116-L122
240,998
apioo/psx-oauth2
src/Authorization/AuthorizationCode.php
AuthorizationCode.redirect
public static function redirect(Url $url, $clientId, $redirectUri = null, $scope = null, $state = null) { $parameters = $url->getParameters(); $parameters['response_type'] = 'code'; $parameters['client_id'] = $clientId; if (isset($redirectUri)) { $parameters['redirect_uri'] = $redirectUri; } if (isset($scope)) { $parameters['scope'] = $scope; } if (isset($state)) { $parameters['state'] = $state; } throw new StatusCode\TemporaryRedirectException($url->withScheme('https')->withParameters($parameters)->toString()); }
php
public static function redirect(Url $url, $clientId, $redirectUri = null, $scope = null, $state = null) { $parameters = $url->getParameters(); $parameters['response_type'] = 'code'; $parameters['client_id'] = $clientId; if (isset($redirectUri)) { $parameters['redirect_uri'] = $redirectUri; } if (isset($scope)) { $parameters['scope'] = $scope; } if (isset($state)) { $parameters['state'] = $state; } throw new StatusCode\TemporaryRedirectException($url->withScheme('https')->withParameters($parameters)->toString()); }
[ "public", "static", "function", "redirect", "(", "Url", "$", "url", ",", "$", "clientId", ",", "$", "redirectUri", "=", "null", ",", "$", "scope", "=", "null", ",", "$", "state", "=", "null", ")", "{", "$", "parameters", "=", "$", "url", "->", "getParameters", "(", ")", ";", "$", "parameters", "[", "'response_type'", "]", "=", "'code'", ";", "$", "parameters", "[", "'client_id'", "]", "=", "$", "clientId", ";", "if", "(", "isset", "(", "$", "redirectUri", ")", ")", "{", "$", "parameters", "[", "'redirect_uri'", "]", "=", "$", "redirectUri", ";", "}", "if", "(", "isset", "(", "$", "scope", ")", ")", "{", "$", "parameters", "[", "'scope'", "]", "=", "$", "scope", ";", "}", "if", "(", "isset", "(", "$", "state", ")", ")", "{", "$", "parameters", "[", "'state'", "]", "=", "$", "state", ";", "}", "throw", "new", "StatusCode", "\\", "TemporaryRedirectException", "(", "$", "url", "->", "withScheme", "(", "'https'", ")", "->", "withParameters", "(", "$", "parameters", ")", "->", "toString", "(", ")", ")", ";", "}" ]
Helper method to start the flow by redirecting the user to the authentication server. The getAccessToken method must be used when the server redirects the user back to the redirect uri @param \PSX\Uri\Url $url @param string $clientId @param string $redirectUri @param string $scope @param string $state
[ "Helper", "method", "to", "start", "the", "flow", "by", "redirecting", "the", "user", "to", "the", "authentication", "server", ".", "The", "getAccessToken", "method", "must", "be", "used", "when", "the", "server", "redirects", "the", "user", "back", "to", "the", "redirect", "uri" ]
60c6eb824393bfc49f9f60ae06b56543c8eab548
https://github.com/apioo/psx-oauth2/blob/60c6eb824393bfc49f9f60ae06b56543c8eab548/src/Authorization/AuthorizationCode.php#L83-L102
240,999
mszewcz/php-light-framework
src/Text/CharCount.php
CharCount.count
public static function count(string $text = '', bool $includeSpaces = false): int { if (\trim($text) === '') { return 0; } $text = StripTags::strip($text); $text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5); $text = \preg_replace('/\s+/', $includeSpaces ? ' ' : '', $text); $text = \trim($text); return \mb_strlen($text, 'UTF-8'); }
php
public static function count(string $text = '', bool $includeSpaces = false): int { if (\trim($text) === '') { return 0; } $text = StripTags::strip($text); $text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5); $text = \preg_replace('/\s+/', $includeSpaces ? ' ' : '', $text); $text = \trim($text); return \mb_strlen($text, 'UTF-8'); }
[ "public", "static", "function", "count", "(", "string", "$", "text", "=", "''", ",", "bool", "$", "includeSpaces", "=", "false", ")", ":", "int", "{", "if", "(", "\\", "trim", "(", "$", "text", ")", "===", "''", ")", "{", "return", "0", ";", "}", "$", "text", "=", "StripTags", "::", "strip", "(", "$", "text", ")", ";", "$", "text", "=", "\\", "htmlspecialchars_decode", "(", "(", "string", ")", "$", "text", ",", "ENT_COMPAT", "|", "ENT_HTML5", ")", ";", "$", "text", "=", "\\", "preg_replace", "(", "'/\\s+/'", ",", "$", "includeSpaces", "?", "' '", ":", "''", ",", "$", "text", ")", ";", "$", "text", "=", "\\", "trim", "(", "$", "text", ")", ";", "return", "\\", "mb_strlen", "(", "$", "text", ",", "'UTF-8'", ")", ";", "}" ]
Counts characters. Strips HTML tags. Treats multiple spaces as one. @param string $text @param bool $includeSpaces @return int
[ "Counts", "characters", ".", "Strips", "HTML", "tags", ".", "Treats", "multiple", "spaces", "as", "one", "." ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Text/CharCount.php#L28-L39