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
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
15,700
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.findModel
protected function findModel($id) { $model = $this->module->manager->findGalleryById($id); if ($model === null) { throw new NotFoundHttpException('The requested page does not exist'); } return $model; }
php
protected function findModel($id) { $model = $this->module->manager->findGalleryById($id); if ($model === null) { throw new NotFoundHttpException('The requested page does not exist'); } return $model; }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "module", "->", "manager", "->", "findGalleryById", "(", "$", "id", ")", ";", "if", "(", "$", "model", "===", "null", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The requested page does not exist'", ")", ";", "}", "return", "$", "model", ";", "}" ]
Finds the Gallery model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return \wolfguard\gallery\models\Gallery the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "Gallery", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L128-L137
15,701
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.actionImages
public function actionImages($id) { $gallery = $this->findModel($id); $searchModel = $this->module->manager->createGalleryImageSearch(); $dataProvider = $searchModel->search($_GET, $id); return $this->render('image/index', [ 'gallery' => $gallery, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
php
public function actionImages($id) { $gallery = $this->findModel($id); $searchModel = $this->module->manager->createGalleryImageSearch(); $dataProvider = $searchModel->search($_GET, $id); return $this->render('image/index', [ 'gallery' => $gallery, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
[ "public", "function", "actionImages", "(", "$", "id", ")", "{", "$", "gallery", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "searchModel", "=", "$", "this", "->", "module", "->", "manager", "->", "createGalleryImageSearch", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "$", "_GET", ",", "$", "id", ")", ";", "return", "$", "this", "->", "render", "(", "'image/index'", ",", "[", "'gallery'", "=>", "$", "gallery", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "'searchModel'", "=>", "$", "searchModel", ",", "]", ")", ";", "}" ]
Lists all Gallery images models. @param $id Gallery id @return mixed
[ "Lists", "all", "Gallery", "images", "models", "." ]
3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L146-L158
15,702
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.actionCreateImage
public function actionCreateImage($id) { $gallery = $this->findModel($id); $model = $this->module->manager->createGalleryImage(['scenario' => 'create']); $model->loadDefaultValues(); if ($model->load(\Yii::$app->request->post())) { $model->gallery_id = $gallery->id; if($model->create()) { \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been created')); return $this->redirect(['images', 'id' => $id]); } } return $this->render('image/create', [ 'gallery' => $gallery, 'model' => $model ]); }
php
public function actionCreateImage($id) { $gallery = $this->findModel($id); $model = $this->module->manager->createGalleryImage(['scenario' => 'create']); $model->loadDefaultValues(); if ($model->load(\Yii::$app->request->post())) { $model->gallery_id = $gallery->id; if($model->create()) { \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been created')); return $this->redirect(['images', 'id' => $id]); } } return $this->render('image/create', [ 'gallery' => $gallery, 'model' => $model ]); }
[ "public", "function", "actionCreateImage", "(", "$", "id", ")", "{", "$", "gallery", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "model", "=", "$", "this", "->", "module", "->", "manager", "->", "createGalleryImage", "(", "[", "'scenario'", "=>", "'create'", "]", ")", ";", "$", "model", "->", "loadDefaultValues", "(", ")", ";", "if", "(", "$", "model", "->", "load", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", ")", "{", "$", "model", "->", "gallery_id", "=", "$", "gallery", "->", "id", ";", "if", "(", "$", "model", "->", "create", "(", ")", ")", "{", "\\", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "setFlash", "(", "'gallery.success'", ",", "\\", "Yii", "::", "t", "(", "'gallery'", ",", "'Image has been created'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'images'", ",", "'id'", "=>", "$", "id", "]", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'image/create'", ",", "[", "'gallery'", "=>", "$", "gallery", ",", "'model'", "=>", "$", "model", "]", ")", ";", "}" ]
Create gallery image @param $id Gallery id @return string @throws NotFoundHttpException
[ "Create", "gallery", "image" ]
3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L166-L186
15,703
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.actionUpdateImage
public function actionUpdateImage($id) { $model = $this->module->manager->findGalleryImageById($id); if ($model === null) { throw new NotFoundHttpException('The requested image does not exist'); } $model->scenario = 'update'; $gallery = $this->findModel($model->gallery_id); if ($model->load(\Yii::$app->request->post()) && $model->save()) { if(\Yii::$app->request->get('returnUrl')){ $back = urldecode(\Yii::$app->request->get('returnUrl')); return $this->redirect($back); } \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been updated')); return $this->refresh(); } return $this->render('image/update', [ 'model' => $model, 'gallery' => $gallery ]); }
php
public function actionUpdateImage($id) { $model = $this->module->manager->findGalleryImageById($id); if ($model === null) { throw new NotFoundHttpException('The requested image does not exist'); } $model->scenario = 'update'; $gallery = $this->findModel($model->gallery_id); if ($model->load(\Yii::$app->request->post()) && $model->save()) { if(\Yii::$app->request->get('returnUrl')){ $back = urldecode(\Yii::$app->request->get('returnUrl')); return $this->redirect($back); } \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been updated')); return $this->refresh(); } return $this->render('image/update', [ 'model' => $model, 'gallery' => $gallery ]); }
[ "public", "function", "actionUpdateImage", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "module", "->", "manager", "->", "findGalleryImageById", "(", "$", "id", ")", ";", "if", "(", "$", "model", "===", "null", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The requested image does not exist'", ")", ";", "}", "$", "model", "->", "scenario", "=", "'update'", ";", "$", "gallery", "=", "$", "this", "->", "findModel", "(", "$", "model", "->", "gallery_id", ")", ";", "if", "(", "$", "model", "->", "load", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "if", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", "'returnUrl'", ")", ")", "{", "$", "back", "=", "urldecode", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", "'returnUrl'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "back", ")", ";", "}", "\\", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "setFlash", "(", "'gallery.success'", ",", "\\", "Yii", "::", "t", "(", "'gallery'", ",", "'Image has been updated'", ")", ")", ";", "return", "$", "this", "->", "refresh", "(", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'image/update'", ",", "[", "'model'", "=>", "$", "model", ",", "'gallery'", "=>", "$", "gallery", "]", ")", ";", "}" ]
Updates an existing GalleryImage model. If update is successful, the browser will be redirected to the 'images' page. @param integer $id @return mixed @throws NotFoundHttpException
[ "Updates", "an", "existing", "GalleryImage", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "images", "page", "." ]
3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L196-L220
15,704
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.actionDeleteImage
public function actionDeleteImage($id) { $model = $this->module->manager->findGalleryImageById($id); if ($model === null) { throw new NotFoundHttpException('The requested page does not exist'); } $model->delete(); \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been deleted')); return $this->redirect(['images', 'id' => $model->gallery_id]); }
php
public function actionDeleteImage($id) { $model = $this->module->manager->findGalleryImageById($id); if ($model === null) { throw new NotFoundHttpException('The requested page does not exist'); } $model->delete(); \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been deleted')); return $this->redirect(['images', 'id' => $model->gallery_id]); }
[ "public", "function", "actionDeleteImage", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "module", "->", "manager", "->", "findGalleryImageById", "(", "$", "id", ")", ";", "if", "(", "$", "model", "===", "null", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The requested page does not exist'", ")", ";", "}", "$", "model", "->", "delete", "(", ")", ";", "\\", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "setFlash", "(", "'gallery.success'", ",", "\\", "Yii", "::", "t", "(", "'gallery'", ",", "'Image has been deleted'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'images'", ",", "'id'", "=>", "$", "model", "->", "gallery_id", "]", ")", ";", "}" ]
Deletes an existing GalleryImage model. If deletion is successful, the browser will be redirected to the 'images' page. @param integer $id @return \yii\web\Response @throws NotFoundHttpException @throws \Exception
[ "Deletes", "an", "existing", "GalleryImage", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "images", "page", "." ]
3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L231-L243
15,705
WellCommerce/OrderBundle
Controller/Front/AddressController.php
AddressController.copyShippingAddress
protected function copyShippingAddress(ParameterBag $parameters) { $billingAddress = $parameters->get('billingAddress'); $shippingAddress = [ 'shippingAddress.copyBillingAddress' => true, ]; foreach ($billingAddress as $key => $value) { list(, $fieldName) = explode('.', $key); $shippingAddress['shippingAddress.' . $fieldName] = $value; } $parameters->set('shippingAddress', $shippingAddress); }
php
protected function copyShippingAddress(ParameterBag $parameters) { $billingAddress = $parameters->get('billingAddress'); $shippingAddress = [ 'shippingAddress.copyBillingAddress' => true, ]; foreach ($billingAddress as $key => $value) { list(, $fieldName) = explode('.', $key); $shippingAddress['shippingAddress.' . $fieldName] = $value; } $parameters->set('shippingAddress', $shippingAddress); }
[ "protected", "function", "copyShippingAddress", "(", "ParameterBag", "$", "parameters", ")", "{", "$", "billingAddress", "=", "$", "parameters", "->", "get", "(", "'billingAddress'", ")", ";", "$", "shippingAddress", "=", "[", "'shippingAddress.copyBillingAddress'", "=>", "true", ",", "]", ";", "foreach", "(", "$", "billingAddress", "as", "$", "key", "=>", "$", "value", ")", "{", "list", "(", ",", "$", "fieldName", ")", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "$", "shippingAddress", "[", "'shippingAddress.'", ".", "$", "fieldName", "]", "=", "$", "value", ";", "}", "$", "parameters", "->", "set", "(", "'shippingAddress'", ",", "$", "shippingAddress", ")", ";", "}" ]
Copies billing address to shipping address @param ParameterBag $parameters
[ "Copies", "billing", "address", "to", "shipping", "address" ]
d72cfb51eab7a1f66f186900d1e2d533a822c424
https://github.com/WellCommerce/OrderBundle/blob/d72cfb51eab7a1f66f186900d1e2d533a822c424/Controller/Front/AddressController.php#L97-L111
15,706
EcomDev/phpspec-magento-di-adapter
src/Runner/CollaboratorMaintainer.php
CollaboratorMaintainer.prepare
public function prepare( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ) { if ($example->getSpecification()->getClassReflection()->hasMethod('let')) { $this->parameterValidator->validate($example->getSpecification()->getClassReflection()->getMethod('let')); } $this->parameterValidator->validate($example->getFunctionReflection()); return $this; }
php
public function prepare( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ) { if ($example->getSpecification()->getClassReflection()->hasMethod('let')) { $this->parameterValidator->validate($example->getSpecification()->getClassReflection()->getMethod('let')); } $this->parameterValidator->validate($example->getFunctionReflection()); return $this; }
[ "public", "function", "prepare", "(", "ExampleNode", "$", "example", ",", "Specification", "$", "context", ",", "MatcherManager", "$", "matchers", ",", "CollaboratorManager", "$", "collaborators", ")", "{", "if", "(", "$", "example", "->", "getSpecification", "(", ")", "->", "getClassReflection", "(", ")", "->", "hasMethod", "(", "'let'", ")", ")", "{", "$", "this", "->", "parameterValidator", "->", "validate", "(", "$", "example", "->", "getSpecification", "(", ")", "->", "getClassReflection", "(", ")", "->", "getMethod", "(", "'let'", ")", ")", ";", "}", "$", "this", "->", "parameterValidator", "->", "validate", "(", "$", "example", "->", "getFunctionReflection", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Generates DI related stuff via parameter validator @param ExampleNode $example @param Specification $context @param MatcherManager $matchers @param CollaboratorManager $collaborators @return $this
[ "Generates", "DI", "related", "stuff", "via", "parameter", "validator" ]
b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37
https://github.com/EcomDev/phpspec-magento-di-adapter/blob/b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37/src/Runner/CollaboratorMaintainer.php#L56-L67
15,707
EcomDev/phpspec-magento-di-adapter
src/Runner/CollaboratorMaintainer.php
CollaboratorMaintainer.teardown
public function teardown( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ) { return $this; }
php
public function teardown( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ) { return $this; }
[ "public", "function", "teardown", "(", "ExampleNode", "$", "example", ",", "Specification", "$", "context", ",", "MatcherManager", "$", "matchers", ",", "CollaboratorManager", "$", "collaborators", ")", "{", "return", "$", "this", ";", "}" ]
It does nothing on teardown... @param ExampleNode $example @param Specification $context @param MatcherManager $matchers @param CollaboratorManager $collaborators @return $this
[ "It", "does", "nothing", "on", "teardown", "..." ]
b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37
https://github.com/EcomDev/phpspec-magento-di-adapter/blob/b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37/src/Runner/CollaboratorMaintainer.php#L79-L87
15,708
czim/laravel-pxlcms
src/Generator/Analyzer/AnalyzerContext.php
AnalyzerContext.normalizeCmsAccents
public function normalizeCmsAccents($string) { $string = htmlentities($string, ENT_COMPAT | (defined('ENT_HTML401') ? ENT_HTML401 : 0), 'ISO-8859-1'); $string = preg_replace('#&([a-zA-Z])(uml|acute|grave|circ|tilde|slash|cedil|ring|caron);#','$1',$string); $string = preg_replace('#&(ae|AE)lig;#','$1',$string); // æ to ae $string = preg_replace('#&(oe|OE)lig;#','$1',$string); // Œ to OE $string = preg_replace('#ß#','ss',$string); // ß to ss $string = preg_replace('#&(eth|thorn);#','th',$string); // ð and þ to th $string = preg_replace('#&(ETH|THORN);#','Th',$string); // Ð and Þ to Th return html_entity_decode($string); }
php
public function normalizeCmsAccents($string) { $string = htmlentities($string, ENT_COMPAT | (defined('ENT_HTML401') ? ENT_HTML401 : 0), 'ISO-8859-1'); $string = preg_replace('#&([a-zA-Z])(uml|acute|grave|circ|tilde|slash|cedil|ring|caron);#','$1',$string); $string = preg_replace('#&(ae|AE)lig;#','$1',$string); // æ to ae $string = preg_replace('#&(oe|OE)lig;#','$1',$string); // Œ to OE $string = preg_replace('#ß#','ss',$string); // ß to ss $string = preg_replace('#&(eth|thorn);#','th',$string); // ð and þ to th $string = preg_replace('#&(ETH|THORN);#','Th',$string); // Ð and Þ to Th return html_entity_decode($string); }
[ "public", "function", "normalizeCmsAccents", "(", "$", "string", ")", "{", "$", "string", "=", "htmlentities", "(", "$", "string", ",", "ENT_COMPAT", "|", "(", "defined", "(", "'ENT_HTML401'", ")", "?", "ENT_HTML401", ":", "0", ")", ",", "'ISO-8859-1'", ")", ";", "$", "string", "=", "preg_replace", "(", "'#&([a-zA-Z])(uml|acute|grave|circ|tilde|slash|cedil|ring|caron);#'", ",", "'$1'", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'#&(ae|AE)lig;#'", ",", "'$1'", ",", "$", "string", ")", ";", "// æ to ae", "$", "string", "=", "preg_replace", "(", "'#&(oe|OE)lig;#'", ",", "'$1'", ",", "$", "string", ")", ";", "// Œ to OE", "$", "string", "=", "preg_replace", "(", "'#ß#'", ",", "'ss'", ",", "$", "string", ")", ";", "// ß to ss", "$", "string", "=", "preg_replace", "(", "'#&(eth|thorn);#'", ",", "'th'", ",", "$", "string", ")", ";", "// ð and þ to th", "$", "string", "=", "preg_replace", "(", "'#&(ETH|THORN);#'", ",", "'Th'", ",", "$", "string", ")", ";", "// Ð and Þ to Th", "return", "html_entity_decode", "(", "$", "string", ")", ";", "}" ]
Normalize accents just like the CMS does @param string $string @return string
[ "Normalize", "accents", "just", "like", "the", "CMS", "does" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/AnalyzerContext.php#L137-L150
15,709
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.writeTracks
private function writeTracks(\XMLWriter $xmlWriter, Workout $workout) { foreach ($workout->tracks() as $track) { $xmlWriter->startElement('trk'); $xmlWriter->writeElement('type', $track->sport()); $xmlWriter->startElement('trkseg'); $this->writeTrackPoints($xmlWriter, $track->trackPoints()); $xmlWriter->endElement(); $xmlWriter->endElement(); } }
php
private function writeTracks(\XMLWriter $xmlWriter, Workout $workout) { foreach ($workout->tracks() as $track) { $xmlWriter->startElement('trk'); $xmlWriter->writeElement('type', $track->sport()); $xmlWriter->startElement('trkseg'); $this->writeTrackPoints($xmlWriter, $track->trackPoints()); $xmlWriter->endElement(); $xmlWriter->endElement(); } }
[ "private", "function", "writeTracks", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "Workout", "$", "workout", ")", "{", "foreach", "(", "$", "workout", "->", "tracks", "(", ")", "as", "$", "track", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'trk'", ")", ";", "$", "xmlWriter", "->", "writeElement", "(", "'type'", ",", "$", "track", "->", "sport", "(", ")", ")", ";", "$", "xmlWriter", "->", "startElement", "(", "'trkseg'", ")", ";", "$", "this", "->", "writeTrackPoints", "(", "$", "xmlWriter", ",", "$", "track", "->", "trackPoints", "(", ")", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}", "}" ]
Write the tracks to the GPX. @param \XMLWriter $xmlWriter The XML writer. @param Workout $workout The workout.
[ "Write", "the", "tracks", "to", "the", "GPX", "." ]
9783e3414294f4ee555a1d538d2807269deeb9e7
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L61-L71
15,710
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.writeTrackPoints
private function writeTrackPoints(\XMLWriter $xmlWriter, array $trackPoints) { foreach ($trackPoints as $trackPoint) { $xmlWriter->startElement('trkpt'); // Location. $xmlWriter->writeAttribute('lat', (string)$trackPoint->latitude()); $xmlWriter->writeAttribute('lon', (string)$trackPoint->longitude()); // Elevation. $xmlWriter->writeElement('ele', (string)$trackPoint->elevation()); // Time of position $dateTime = clone $trackPoint->dateTime(); $dateTime->setTimezone(new \DateTimeZone('UTC')); $xmlWriter->writeElement('time', $dateTime->format(\DateTime::W3C)); // Extensions. $this->writeExtensions($xmlWriter, $trackPoint->extensions()); $xmlWriter->endElement(); } }
php
private function writeTrackPoints(\XMLWriter $xmlWriter, array $trackPoints) { foreach ($trackPoints as $trackPoint) { $xmlWriter->startElement('trkpt'); // Location. $xmlWriter->writeAttribute('lat', (string)$trackPoint->latitude()); $xmlWriter->writeAttribute('lon', (string)$trackPoint->longitude()); // Elevation. $xmlWriter->writeElement('ele', (string)$trackPoint->elevation()); // Time of position $dateTime = clone $trackPoint->dateTime(); $dateTime->setTimezone(new \DateTimeZone('UTC')); $xmlWriter->writeElement('time', $dateTime->format(\DateTime::W3C)); // Extensions. $this->writeExtensions($xmlWriter, $trackPoint->extensions()); $xmlWriter->endElement(); } }
[ "private", "function", "writeTrackPoints", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "array", "$", "trackPoints", ")", "{", "foreach", "(", "$", "trackPoints", "as", "$", "trackPoint", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'trkpt'", ")", ";", "// Location.", "$", "xmlWriter", "->", "writeAttribute", "(", "'lat'", ",", "(", "string", ")", "$", "trackPoint", "->", "latitude", "(", ")", ")", ";", "$", "xmlWriter", "->", "writeAttribute", "(", "'lon'", ",", "(", "string", ")", "$", "trackPoint", "->", "longitude", "(", ")", ")", ";", "// Elevation.", "$", "xmlWriter", "->", "writeElement", "(", "'ele'", ",", "(", "string", ")", "$", "trackPoint", "->", "elevation", "(", ")", ")", ";", "// Time of position", "$", "dateTime", "=", "clone", "$", "trackPoint", "->", "dateTime", "(", ")", ";", "$", "dateTime", "->", "setTimezone", "(", "new", "\\", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "$", "xmlWriter", "->", "writeElement", "(", "'time'", ",", "$", "dateTime", "->", "format", "(", "\\", "DateTime", "::", "W3C", ")", ")", ";", "// Extensions.", "$", "this", "->", "writeExtensions", "(", "$", "xmlWriter", ",", "$", "trackPoint", "->", "extensions", "(", ")", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}", "}" ]
Write the track points to the GPX. @param \XMLWriter $xmlWriter The XML writer. @param TrackPoint[] $trackPoints The track points to write.
[ "Write", "the", "track", "points", "to", "the", "GPX", "." ]
9783e3414294f4ee555a1d538d2807269deeb9e7
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L79-L101
15,711
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.writeExtensions
protected function writeExtensions(\XMLWriter $xmlWriter, array $extensions) { $xmlWriter->startElement('extensions'); foreach ($extensions as $extension) { switch ($extension::ID()) { case HR::ID(): $xmlWriter->startElementNs('gpxtpx', 'TrackPointExtension', null); $xmlWriter->writeElementNs('gpxtpx', 'hr', null, (string)$extension->value()); $xmlWriter->endElement(); break; } } $xmlWriter->endElement(); }
php
protected function writeExtensions(\XMLWriter $xmlWriter, array $extensions) { $xmlWriter->startElement('extensions'); foreach ($extensions as $extension) { switch ($extension::ID()) { case HR::ID(): $xmlWriter->startElementNs('gpxtpx', 'TrackPointExtension', null); $xmlWriter->writeElementNs('gpxtpx', 'hr', null, (string)$extension->value()); $xmlWriter->endElement(); break; } } $xmlWriter->endElement(); }
[ "protected", "function", "writeExtensions", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "array", "$", "extensions", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'extensions'", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "switch", "(", "$", "extension", "::", "ID", "(", ")", ")", "{", "case", "HR", "::", "ID", "(", ")", ":", "$", "xmlWriter", "->", "startElementNs", "(", "'gpxtpx'", ",", "'TrackPointExtension'", ",", "null", ")", ";", "$", "xmlWriter", "->", "writeElementNs", "(", "'gpxtpx'", ",", "'hr'", ",", "null", ",", "(", "string", ")", "$", "extension", "->", "value", "(", ")", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "break", ";", "}", "}", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}" ]
Write the extensions into the GPX. @param \XMLWriter $xmlWriter The XMLWriter. @param ExtensionInterface[] $extensions The extensions to write.
[ "Write", "the", "extensions", "into", "the", "GPX", "." ]
9783e3414294f4ee555a1d538d2807269deeb9e7
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L109-L122
15,712
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.writeMetaData
protected function writeMetaData(\XMLWriter $xmlWriter, Workout $workout) { $xmlWriter->startElement('metadata'); if ($workout->author() !== null) { $xmlWriter->startElement('author'); $xmlWriter->writeElement('name', $workout->author()->name()); $xmlWriter->endElement(); } $xmlWriter->endElement(); }
php
protected function writeMetaData(\XMLWriter $xmlWriter, Workout $workout) { $xmlWriter->startElement('metadata'); if ($workout->author() !== null) { $xmlWriter->startElement('author'); $xmlWriter->writeElement('name', $workout->author()->name()); $xmlWriter->endElement(); } $xmlWriter->endElement(); }
[ "protected", "function", "writeMetaData", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "Workout", "$", "workout", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'metadata'", ")", ";", "if", "(", "$", "workout", "->", "author", "(", ")", "!==", "null", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'author'", ")", ";", "$", "xmlWriter", "->", "writeElement", "(", "'name'", ",", "$", "workout", "->", "author", "(", ")", "->", "name", "(", ")", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}" ]
Write the metadata in the GPX. @param \XMLWriter $xmlWriter The XML writer. @param Workout $workout The workout.
[ "Write", "the", "metadata", "in", "the", "GPX", "." ]
9783e3414294f4ee555a1d538d2807269deeb9e7
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L130-L139
15,713
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php
KeyframesRule.setIdentifier
public function setIdentifier($identifier) { if (is_string($identifier)) { $this->identifier = $identifier; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($identifier). "' for argument 'identifier' given." ); } }
php
public function setIdentifier($identifier) { if (is_string($identifier)) { $this->identifier = $identifier; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($identifier). "' for argument 'identifier' given." ); } }
[ "public", "function", "setIdentifier", "(", "$", "identifier", ")", "{", "if", "(", "is_string", "(", "$", "identifier", ")", ")", "{", "$", "this", "->", "identifier", "=", "$", "identifier", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "identifier", ")", ".", "\"' for argument 'identifier' given.\"", ")", ";", "}", "}" ]
Sets the keyframes identifier. @param string $identifier
[ "Sets", "the", "keyframes", "identifier", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php#L43-L52
15,714
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php
KeyframesRule.addRule
public function addRule(RuleAbstract $rule) { // TODO Keyframes with duplicate identifiers do NOT cascade! // Last one overwrites previous ones. // @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution if ($rule instanceof KeyframesRuleSet) { $this->rules[] = $rule; } else { throw new \InvalidArgumentException( "Invalid rule instance. Instance of 'KeyframesRuleSet' expected." ); } return $this; }
php
public function addRule(RuleAbstract $rule) { // TODO Keyframes with duplicate identifiers do NOT cascade! // Last one overwrites previous ones. // @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution if ($rule instanceof KeyframesRuleSet) { $this->rules[] = $rule; } else { throw new \InvalidArgumentException( "Invalid rule instance. Instance of 'KeyframesRuleSet' expected." ); } return $this; }
[ "public", "function", "addRule", "(", "RuleAbstract", "$", "rule", ")", "{", "// TODO Keyframes with duplicate identifiers do NOT cascade!", "// Last one overwrites previous ones.", "// @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution", "if", "(", "$", "rule", "instanceof", "KeyframesRuleSet", ")", "{", "$", "this", "->", "rules", "[", "]", "=", "$", "rule", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid rule instance. Instance of 'KeyframesRuleSet' expected.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a keyframes rule set. @param KeyframesRuleSet $rule @return $this
[ "Adds", "a", "keyframes", "rule", "set", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php#L70-L85
15,715
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php
KeyframesRule.parseRuleString
protected function parseRuleString($ruleString) { if (is_string($ruleString)) { // Check for valid rule format // (with vendor prefix check to match e.g. "@-webkit-keyframes") if (preg_match( '/^[ \r\n\t\f]*@(' . self::getVendorPrefixRegExp("/") . ')?keyframes[ \r\n\t\f]+([^ \r\n\t\f]+)[ \r\n\t\f]*/i', $ruleString, $matches )) { $vendorPrefix = $matches[1]; $identifier = $matches[2]; $this->setIdentifier($identifier, $this->getStyleSheet()); if ($vendorPrefix !== "") { $this->setVendorPrefix($vendorPrefix); } } else { throw new \InvalidArgumentException("Invalid format for @keyframes rule."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($ruleString). "' for argument 'ruleString' given." ); } }
php
protected function parseRuleString($ruleString) { if (is_string($ruleString)) { // Check for valid rule format // (with vendor prefix check to match e.g. "@-webkit-keyframes") if (preg_match( '/^[ \r\n\t\f]*@(' . self::getVendorPrefixRegExp("/") . ')?keyframes[ \r\n\t\f]+([^ \r\n\t\f]+)[ \r\n\t\f]*/i', $ruleString, $matches )) { $vendorPrefix = $matches[1]; $identifier = $matches[2]; $this->setIdentifier($identifier, $this->getStyleSheet()); if ($vendorPrefix !== "") { $this->setVendorPrefix($vendorPrefix); } } else { throw new \InvalidArgumentException("Invalid format for @keyframes rule."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($ruleString). "' for argument 'ruleString' given." ); } }
[ "protected", "function", "parseRuleString", "(", "$", "ruleString", ")", "{", "if", "(", "is_string", "(", "$", "ruleString", ")", ")", "{", "// Check for valid rule format", "// (with vendor prefix check to match e.g. \"@-webkit-keyframes\")", "if", "(", "preg_match", "(", "'/^[ \\r\\n\\t\\f]*@('", ".", "self", "::", "getVendorPrefixRegExp", "(", "\"/\"", ")", ".", "')?keyframes[ \\r\\n\\t\\f]+([^ \\r\\n\\t\\f]+)[ \\r\\n\\t\\f]*/i'", ",", "$", "ruleString", ",", "$", "matches", ")", ")", "{", "$", "vendorPrefix", "=", "$", "matches", "[", "1", "]", ";", "$", "identifier", "=", "$", "matches", "[", "2", "]", ";", "$", "this", "->", "setIdentifier", "(", "$", "identifier", ",", "$", "this", "->", "getStyleSheet", "(", ")", ")", ";", "if", "(", "$", "vendorPrefix", "!==", "\"\"", ")", "{", "$", "this", "->", "setVendorPrefix", "(", "$", "vendorPrefix", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid format for @keyframes rule.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "ruleString", ")", ".", "\"' for argument 'ruleString' given.\"", ")", ";", "}", "}" ]
Parses the keyframes rule. @param string $ruleString
[ "Parses", "the", "keyframes", "rule", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php#L92-L116
15,716
harp-orm/query
src/Compiler/Union.php
Union.render
public static function render(Query\Union $query) { return Compiler::withDb($query->getDb(), function () use ($query) { return Compiler::expression(array( Arr::join(' UNION ', Arr::map(function (Query\Select $select) { return Compiler::braced(Select::render($select)); }, $query->getSelects())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit()), )); }); }
php
public static function render(Query\Union $query) { return Compiler::withDb($query->getDb(), function () use ($query) { return Compiler::expression(array( Arr::join(' UNION ', Arr::map(function (Query\Select $select) { return Compiler::braced(Select::render($select)); }, $query->getSelects())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit()), )); }); }
[ "public", "static", "function", "render", "(", "Query", "\\", "Union", "$", "query", ")", "{", "return", "Compiler", "::", "withDb", "(", "$", "query", "->", "getDb", "(", ")", ",", "function", "(", ")", "use", "(", "$", "query", ")", "{", "return", "Compiler", "::", "expression", "(", "array", "(", "Arr", "::", "join", "(", "' UNION '", ",", "Arr", "::", "map", "(", "function", "(", "Query", "\\", "Select", "$", "select", ")", "{", "return", "Compiler", "::", "braced", "(", "Select", "::", "render", "(", "$", "select", ")", ")", ";", "}", ",", "$", "query", "->", "getSelects", "(", ")", ")", ")", ",", "Compiler", "::", "word", "(", "'ORDER BY'", ",", "Direction", "::", "combine", "(", "$", "query", "->", "getOrder", "(", ")", ")", ")", ",", "Compiler", "::", "word", "(", "'LIMIT'", ",", "$", "query", "->", "getLimit", "(", ")", ")", ",", ")", ")", ";", "}", ")", ";", "}" ]
Render a Union object @param Query\Union $query @return string
[ "Render", "a", "Union", "object" ]
98ce2468a0a31fe15ed3692bad32547bf6dbe41a
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Union.php#L20-L31
15,717
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Response/Preprocessor.php
Preprocessor.get
public function get($status) { $preprocessor = $this->has($status) ? $this->preprocessors[$status] : $this->preprocessors[self::DEFAULT_STATUS]; return ($preprocessor instanceof HttpStatusPreprocessorInterface) ? $preprocessor : new $preprocessor; }
php
public function get($status) { $preprocessor = $this->has($status) ? $this->preprocessors[$status] : $this->preprocessors[self::DEFAULT_STATUS]; return ($preprocessor instanceof HttpStatusPreprocessorInterface) ? $preprocessor : new $preprocessor; }
[ "public", "function", "get", "(", "$", "status", ")", "{", "$", "preprocessor", "=", "$", "this", "->", "has", "(", "$", "status", ")", "?", "$", "this", "->", "preprocessors", "[", "$", "status", "]", ":", "$", "this", "->", "preprocessors", "[", "self", "::", "DEFAULT_STATUS", "]", ";", "return", "(", "$", "preprocessor", "instanceof", "HttpStatusPreprocessorInterface", ")", "?", "$", "preprocessor", ":", "new", "$", "preprocessor", ";", "}" ]
Get an instance of the preprocessor for the current status @param int $status The HTTP status to use @return HttpStatusPreprocessorInterface
[ "Get", "an", "instance", "of", "the", "preprocessor", "for", "the", "current", "status" ]
5093297dcb7441a8d8f79cbb2429c93232e16d1c
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Response/Preprocessor.php#L86-L95
15,718
gdbots/pbjx-bundle-php
src/Twig/PbjxExtension.php
PbjxExtension.pbjUrl
public function pbjUrl(Message $pbj, string $template): ?string { return UriTemplateService::expand("{$pbj::schema()->getQName()}.{$template}", $pbj->getUriTemplateVars()); }
php
public function pbjUrl(Message $pbj, string $template): ?string { return UriTemplateService::expand("{$pbj::schema()->getQName()}.{$template}", $pbj->getUriTemplateVars()); }
[ "public", "function", "pbjUrl", "(", "Message", "$", "pbj", ",", "string", "$", "template", ")", ":", "?", "string", "{", "return", "UriTemplateService", "::", "expand", "(", "\"{$pbj::schema()->getQName()}.{$template}\"", ",", "$", "pbj", "->", "getUriTemplateVars", "(", ")", ")", ";", "}" ]
Returns a named URL to a pbj instance. Example: {{ pbj_url(pbj, 'canonical') }} @param Message $pbj @param string $template @return string
[ "Returns", "a", "named", "URL", "to", "a", "pbj", "instance", "." ]
f3c0088583879fc92f13247a0752634bd8696eac
https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/Twig/PbjxExtension.php#L109-L112
15,719
FrenchFrogs/framework
src/Modal/Modal/Modal.php
Modal.renderRemoteEmptyModal
static function renderRemoteEmptyModal($remoteId = null) { $modal = modal(); if (!is_null($remoteId)) { $modal->setRemoteId($remoteId); } return $modal->getRenderer()->render('modal_remote', $modal); }
php
static function renderRemoteEmptyModal($remoteId = null) { $modal = modal(); if (!is_null($remoteId)) { $modal->setRemoteId($remoteId); } return $modal->getRenderer()->render('modal_remote', $modal); }
[ "static", "function", "renderRemoteEmptyModal", "(", "$", "remoteId", "=", "null", ")", "{", "$", "modal", "=", "modal", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "remoteId", ")", ")", "{", "$", "modal", "->", "setRemoteId", "(", "$", "remoteId", ")", ";", "}", "return", "$", "modal", "->", "getRenderer", "(", ")", "->", "render", "(", "'modal_remote'", ",", "$", "modal", ")", ";", "}" ]
Render an emptyl @param null $remoteId @return mixed @throws \Exception
[ "Render", "an", "emptyl" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Modal/Modal/Modal.php#L540-L548
15,720
stubbles/stubbles-webapp-core
src/main/php/response/mimetypes/Image.php
Image.loadImage
private function loadImage(string $resource) { try { return $this->resourceLoader->load( $resource, function($fileName) { return ImageSource::load($fileName); } ); } catch (\Throwable $t) { // not allowed to throw exceptions, as we are outside any catching // mechanism trigger_error( 'Can not load image "' . $resource . '": ' . $t->getMessage(), E_USER_ERROR ); return null; } }
php
private function loadImage(string $resource) { try { return $this->resourceLoader->load( $resource, function($fileName) { return ImageSource::load($fileName); } ); } catch (\Throwable $t) { // not allowed to throw exceptions, as we are outside any catching // mechanism trigger_error( 'Can not load image "' . $resource . '": ' . $t->getMessage(), E_USER_ERROR ); return null; } }
[ "private", "function", "loadImage", "(", "string", "$", "resource", ")", "{", "try", "{", "return", "$", "this", "->", "resourceLoader", "->", "load", "(", "$", "resource", ",", "function", "(", "$", "fileName", ")", "{", "return", "ImageSource", "::", "load", "(", "$", "fileName", ")", ";", "}", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "t", ")", "{", "// not allowed to throw exceptions, as we are outside any catching", "// mechanism", "trigger_error", "(", "'Can not load image \"'", ".", "$", "resource", ".", "'\": '", ".", "$", "t", "->", "getMessage", "(", ")", ",", "E_USER_ERROR", ")", ";", "return", "null", ";", "}", "}" ]
loads image from resource pathes @param string $resource @return \stubbles\img\Image|null
[ "loads", "image", "from", "resource", "pathes" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/mimetypes/Image.php#L101-L117
15,721
stubbles/stubbles-webapp-core
src/main/php/routing/api/Resource.php
Resource.addLink
public function addLink(string $rel, $uri): Link { return $this->links->add($rel, $uri); }
php
public function addLink(string $rel, $uri): Link { return $this->links->add($rel, $uri); }
[ "public", "function", "addLink", "(", "string", "$", "rel", ",", "$", "uri", ")", ":", "Link", "{", "return", "$", "this", "->", "links", "->", "add", "(", "$", "rel", ",", "$", "uri", ")", ";", "}" ]
adds a link for this resource @param string $rel relation of this link to the resource @param string $uri actual uri @return \stubbles\webapp\routing\api\Link
[ "adds", "a", "link", "for", "this", "resource" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/api/Resource.php#L132-L135
15,722
stubbles/stubbles-webapp-core
src/main/php/routing/api/Resource.php
Resource.jsonSerialize
public function jsonSerialize(): array { return [ 'name' => $this->name, 'methods' => $this->requestMethods, 'description' => $this->annotations->description(), 'produces' => $this->mimeTypes, 'responses' => $this->annotations->statusCodes(), 'headers' => $this->annotations->headers(), 'parameters' => $this->annotations->parameters(), 'auth' => $this->authConstraint, '_links' => $this->links ]; }
php
public function jsonSerialize(): array { return [ 'name' => $this->name, 'methods' => $this->requestMethods, 'description' => $this->annotations->description(), 'produces' => $this->mimeTypes, 'responses' => $this->annotations->statusCodes(), 'headers' => $this->annotations->headers(), 'parameters' => $this->annotations->parameters(), 'auth' => $this->authConstraint, '_links' => $this->links ]; }
[ "public", "function", "jsonSerialize", "(", ")", ":", "array", "{", "return", "[", "'name'", "=>", "$", "this", "->", "name", ",", "'methods'", "=>", "$", "this", "->", "requestMethods", ",", "'description'", "=>", "$", "this", "->", "annotations", "->", "description", "(", ")", ",", "'produces'", "=>", "$", "this", "->", "mimeTypes", ",", "'responses'", "=>", "$", "this", "->", "annotations", "->", "statusCodes", "(", ")", ",", "'headers'", "=>", "$", "this", "->", "annotations", "->", "headers", "(", ")", ",", "'parameters'", "=>", "$", "this", "->", "annotations", "->", "parameters", "(", ")", ",", "'auth'", "=>", "$", "this", "->", "authConstraint", ",", "'_links'", "=>", "$", "this", "->", "links", "]", ";", "}" ]
returns proper representation which can be serialized to JSON @return array @XmlIgnore
[ "returns", "proper", "representation", "which", "can", "be", "serialized", "to", "JSON" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/api/Resource.php#L253-L266
15,723
jelix/version
lib/VersionComparator.php
VersionComparator.compareVersion
public static function compareVersion($version1, $version2) { if ($version1 == $version2) { return 0; } $v1 = Parser::parse($version1); $v2 = Parser::parse($version2); return self::compare($v1, $v2); }
php
public static function compareVersion($version1, $version2) { if ($version1 == $version2) { return 0; } $v1 = Parser::parse($version1); $v2 = Parser::parse($version2); return self::compare($v1, $v2); }
[ "public", "static", "function", "compareVersion", "(", "$", "version1", ",", "$", "version2", ")", "{", "if", "(", "$", "version1", "==", "$", "version2", ")", "{", "return", "0", ";", "}", "$", "v1", "=", "Parser", "::", "parse", "(", "$", "version1", ")", ";", "$", "v2", "=", "Parser", "::", "parse", "(", "$", "version2", ")", ";", "return", "self", "::", "compare", "(", "$", "v1", ",", "$", "v2", ")", ";", "}" ]
Compare two version as string. It supports wildcard in one of the version @param string $version1 @param string $version2 @return int 0 if equal, -1 if $version1 < $version2, 1 if $version1 > $version2
[ "Compare", "two", "version", "as", "string", "." ]
1bdcea2beb7943f347fb453e3106702a460d51c2
https://github.com/jelix/version/blob/1bdcea2beb7943f347fb453e3106702a460d51c2/lib/VersionComparator.php#L143-L153
15,724
jelix/version
lib/VersionComparator.php
VersionComparator.compareVersionRange
public static function compareVersionRange($version, $range) { if ($range == '' || $version == '') { return true; } if (is_string($version)) { $v1 = Parser::parse($version); } else { $v1 = $version; } if ($v1->toString(true, false) == $range) { return true; } $expression = self::compileRange($range); return $expression->compare($v1); }
php
public static function compareVersionRange($version, $range) { if ($range == '' || $version == '') { return true; } if (is_string($version)) { $v1 = Parser::parse($version); } else { $v1 = $version; } if ($v1->toString(true, false) == $range) { return true; } $expression = self::compileRange($range); return $expression->compare($v1); }
[ "public", "static", "function", "compareVersionRange", "(", "$", "version", ",", "$", "range", ")", "{", "if", "(", "$", "range", "==", "''", "||", "$", "version", "==", "''", ")", "{", "return", "true", ";", "}", "if", "(", "is_string", "(", "$", "version", ")", ")", "{", "$", "v1", "=", "Parser", "::", "parse", "(", "$", "version", ")", ";", "}", "else", "{", "$", "v1", "=", "$", "version", ";", "}", "if", "(", "$", "v1", "->", "toString", "(", "true", ",", "false", ")", "==", "$", "range", ")", "{", "return", "true", ";", "}", "$", "expression", "=", "self", "::", "compileRange", "(", "$", "range", ")", ";", "return", "$", "expression", "->", "compare", "(", "$", "v1", ")", ";", "}" ]
Compare a version with a given range. It does not compare with secondary version. @param string|Version $version a version number @param string $range a version expression respecting Composer range syntax @return bool true if the given version match the given range
[ "Compare", "a", "version", "with", "a", "given", "range", "." ]
1bdcea2beb7943f347fb453e3106702a460d51c2
https://github.com/jelix/version/blob/1bdcea2beb7943f347fb453e3106702a460d51c2/lib/VersionComparator.php#L302-L323
15,725
FrenchFrogs/framework
src/Validator/Validator.php
Validator.addRule
public function addRule($index, $method = null, ...$params) { $this->rules[$index] = [$method, $params]; return $this; }
php
public function addRule($index, $method = null, ...$params) { $this->rules[$index] = [$method, $params]; return $this; }
[ "public", "function", "addRule", "(", "$", "index", ",", "$", "method", "=", "null", ",", "...", "$", "params", ")", "{", "$", "this", "->", "rules", "[", "$", "index", "]", "=", "[", "$", "method", ",", "$", "params", "]", ";", "return", "$", "this", ";", "}" ]
Add a single rule to the rules container @param $index @param $rule @return $this
[ "Add", "a", "single", "rule", "to", "the", "rules", "container" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Validator/Validator.php#L74-L78
15,726
FrenchFrogs/framework
src/Validator/Validator.php
Validator.formatError
public function formatError($index, $params) { $pattern = $this->hasMessage($index) ? $this->getMessage($index) : static::MESSAGE_DEFAULT_PATTERN; return vsprintf($pattern, $params); }
php
public function formatError($index, $params) { $pattern = $this->hasMessage($index) ? $this->getMessage($index) : static::MESSAGE_DEFAULT_PATTERN; return vsprintf($pattern, $params); }
[ "public", "function", "formatError", "(", "$", "index", ",", "$", "params", ")", "{", "$", "pattern", "=", "$", "this", "->", "hasMessage", "(", "$", "index", ")", "?", "$", "this", "->", "getMessage", "(", "$", "index", ")", ":", "static", "::", "MESSAGE_DEFAULT_PATTERN", ";", "return", "vsprintf", "(", "$", "pattern", ",", "$", "params", ")", ";", "}" ]
Format an error @param $index @param $params @return string @throws \Exception
[ "Format", "an", "error" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Validator/Validator.php#L331-L336
15,727
FrenchFrogs/framework
src/Validator/Validator.php
Validator.valid
public function valid($value) { foreach($this->getRules() as $index => $rule) { // check for required if (in_array($value, ['', null]) && !$this->hasRule('required')) { continue; } // extract params list($method, $params) = $rule; // If method is null, we use the index as the method name $method = is_null($method) ? $index : $method; // Build the params array_unshift($params, $value); // If it's a anonymous function if (!is_string($method) && is_callable($method)) { if (!call_user_func_array($method, $params)) { $this->addError($index, $this->formatError($index, $params)); } } else {// if it's a local method if (!method_exists($this, $method)) { throw new \Exception('Method "'. $method .'" not found for validator : ' . $index); } if (!call_user_func_array([$this, $method], $params)) { $this->addError($index, $this->formatError($index, $params)); } } } return $this; }
php
public function valid($value) { foreach($this->getRules() as $index => $rule) { // check for required if (in_array($value, ['', null]) && !$this->hasRule('required')) { continue; } // extract params list($method, $params) = $rule; // If method is null, we use the index as the method name $method = is_null($method) ? $index : $method; // Build the params array_unshift($params, $value); // If it's a anonymous function if (!is_string($method) && is_callable($method)) { if (!call_user_func_array($method, $params)) { $this->addError($index, $this->formatError($index, $params)); } } else {// if it's a local method if (!method_exists($this, $method)) { throw new \Exception('Method "'. $method .'" not found for validator : ' . $index); } if (!call_user_func_array([$this, $method], $params)) { $this->addError($index, $this->formatError($index, $params)); } } } return $this; }
[ "public", "function", "valid", "(", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "getRules", "(", ")", "as", "$", "index", "=>", "$", "rule", ")", "{", "// check for required", "if", "(", "in_array", "(", "$", "value", ",", "[", "''", ",", "null", "]", ")", "&&", "!", "$", "this", "->", "hasRule", "(", "'required'", ")", ")", "{", "continue", ";", "}", "// extract params", "list", "(", "$", "method", ",", "$", "params", ")", "=", "$", "rule", ";", "// If method is null, we use the index as the method name", "$", "method", "=", "is_null", "(", "$", "method", ")", "?", "$", "index", ":", "$", "method", ";", "// Build the params", "array_unshift", "(", "$", "params", ",", "$", "value", ")", ";", "// If it's a anonymous function", "if", "(", "!", "is_string", "(", "$", "method", ")", "&&", "is_callable", "(", "$", "method", ")", ")", "{", "if", "(", "!", "call_user_func_array", "(", "$", "method", ",", "$", "params", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "index", ",", "$", "this", "->", "formatError", "(", "$", "index", ",", "$", "params", ")", ")", ";", "}", "}", "else", "{", "// if it's a local method", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Method \"'", ".", "$", "method", ".", "'\" not found for validator : '", ".", "$", "index", ")", ";", "}", "if", "(", "!", "call_user_func_array", "(", "[", "$", "this", ",", "$", "method", "]", ",", "$", "params", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "index", ",", "$", "this", "->", "formatError", "(", "$", "index", ",", "$", "params", ")", ")", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Valid the element @param $value @return $this
[ "Valid", "the", "element" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Validator/Validator.php#L345-L384
15,728
FrenchFrogs/framework
src/Validator/Validator.php
Validator.required
public function required($value) { if(!$this->hasMessage('required')){ $this->addMessage('required', 'This value is required'); } if (is_null($value) || $value == '') { return false; } return true; }
php
public function required($value) { if(!$this->hasMessage('required')){ $this->addMessage('required', 'This value is required'); } if (is_null($value) || $value == '') { return false; } return true; }
[ "public", "function", "required", "(", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "hasMessage", "(", "'required'", ")", ")", "{", "$", "this", "->", "addMessage", "(", "'required'", ",", "'This value is required'", ")", ";", "}", "if", "(", "is_null", "(", "$", "value", ")", "||", "$", "value", "==", "''", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Return FALSE if value is null or empty string @param $value @return bool
[ "Return", "FALSE", "if", "value", "is", "null", "or", "empty", "string" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Validator/Validator.php#L432-L444
15,729
FrenchFrogs/framework
src/Validator/Validator.php
Validator.laravel
public function laravel($value, $validationString, $messages = []) { //create validator $validator = \Validator::make(['laravel' => $value], ['laravel' => $validationString]); $validator->setCustomMessages($this->getMessages()); // error message management if ($validator->fails() && !$this->hasMessage('laravel')) { $message = ''; foreach ( $validator->errors()->get('laravel') as $m) { $message .= $m . ' '; } $this->addMessage('laravel', $message); } // return validation return $validator->valid(); }
php
public function laravel($value, $validationString, $messages = []) { //create validator $validator = \Validator::make(['laravel' => $value], ['laravel' => $validationString]); $validator->setCustomMessages($this->getMessages()); // error message management if ($validator->fails() && !$this->hasMessage('laravel')) { $message = ''; foreach ( $validator->errors()->get('laravel') as $m) { $message .= $m . ' '; } $this->addMessage('laravel', $message); } // return validation return $validator->valid(); }
[ "public", "function", "laravel", "(", "$", "value", ",", "$", "validationString", ",", "$", "messages", "=", "[", "]", ")", "{", "//create validator", "$", "validator", "=", "\\", "Validator", "::", "make", "(", "[", "'laravel'", "=>", "$", "value", "]", ",", "[", "'laravel'", "=>", "$", "validationString", "]", ")", ";", "$", "validator", "->", "setCustomMessages", "(", "$", "this", "->", "getMessages", "(", ")", ")", ";", "// error message management", "if", "(", "$", "validator", "->", "fails", "(", ")", "&&", "!", "$", "this", "->", "hasMessage", "(", "'laravel'", ")", ")", "{", "$", "message", "=", "''", ";", "foreach", "(", "$", "validator", "->", "errors", "(", ")", "->", "get", "(", "'laravel'", ")", "as", "$", "m", ")", "{", "$", "message", ".=", "$", "m", ".", "' '", ";", "}", "$", "this", "->", "addMessage", "(", "'laravel'", ",", "$", "message", ")", ";", "}", "// return validation", "return", "$", "validator", "->", "valid", "(", ")", ";", "}" ]
Return true if the value is correct with a laravel validator string @param $value @param $validationString @param $messages @return array
[ "Return", "true", "if", "the", "value", "is", "correct", "with", "a", "laravel", "validator", "string" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Validator/Validator.php#L520-L537
15,730
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Cache/ServerCache.php
ServerCache.dump
public function dump( Request $request, Response $response, Route $route ) { if ( $this->bypass === true ) { return false; } $cache = strtoupper($route->getParameter('cache')); $ttl = $route->getParameter('ttl'); $name = self::getCacheName($request); $method = (string)$request->getMethod(); $status = $response->getStatus()->get(); if ( ($cache == 'SERVER' || $cache == 'BOTH') && in_array($method, self::$cachable_methods) && in_array($status, self::$cachable_statuses) ) { $this->getCache() ->setNamespace(self::$cache_namespace) ->set( $name, $response->export(), $ttl === null ? self::DEFAULTTTL : intval($ttl) ); return true; } return false; }
php
public function dump( Request $request, Response $response, Route $route ) { if ( $this->bypass === true ) { return false; } $cache = strtoupper($route->getParameter('cache')); $ttl = $route->getParameter('ttl'); $name = self::getCacheName($request); $method = (string)$request->getMethod(); $status = $response->getStatus()->get(); if ( ($cache == 'SERVER' || $cache == 'BOTH') && in_array($method, self::$cachable_methods) && in_array($status, self::$cachable_statuses) ) { $this->getCache() ->setNamespace(self::$cache_namespace) ->set( $name, $response->export(), $ttl === null ? self::DEFAULTTTL : intval($ttl) ); return true; } return false; }
[ "public", "function", "dump", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "Route", "$", "route", ")", "{", "if", "(", "$", "this", "->", "bypass", "===", "true", ")", "{", "return", "false", ";", "}", "$", "cache", "=", "strtoupper", "(", "$", "route", "->", "getParameter", "(", "'cache'", ")", ")", ";", "$", "ttl", "=", "$", "route", "->", "getParameter", "(", "'ttl'", ")", ";", "$", "name", "=", "self", "::", "getCacheName", "(", "$", "request", ")", ";", "$", "method", "=", "(", "string", ")", "$", "request", "->", "getMethod", "(", ")", ";", "$", "status", "=", "$", "response", "->", "getStatus", "(", ")", "->", "get", "(", ")", ";", "if", "(", "(", "$", "cache", "==", "'SERVER'", "||", "$", "cache", "==", "'BOTH'", ")", "&&", "in_array", "(", "$", "method", ",", "self", "::", "$", "cachable_methods", ")", "&&", "in_array", "(", "$", "status", ",", "self", "::", "$", "cachable_statuses", ")", ")", "{", "$", "this", "->", "getCache", "(", ")", "->", "setNamespace", "(", "self", "::", "$", "cache_namespace", ")", "->", "set", "(", "$", "name", ",", "$", "response", "->", "export", "(", ")", ",", "$", "ttl", "===", "null", "?", "self", "::", "DEFAULTTTL", ":", "intval", "(", "$", "ttl", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Dump the full request object in the cache @param Request $request The request model (to extract cache definition) @param Response $response The response object that will be cached @param Route $route The route model (to extract cache parameters) @return bool
[ "Dump", "the", "full", "request", "object", "in", "the", "cache" ]
5093297dcb7441a8d8f79cbb2429c93232e16d1c
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Cache/ServerCache.php#L101-L134
15,731
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Cache/ServerCache.php
ServerCache.getCacheName
private static function getCacheName(Request $request) { return md5((string)$request->getMethod().(string)$request->getUri()); }
php
private static function getCacheName(Request $request) { return md5((string)$request->getMethod().(string)$request->getUri()); }
[ "private", "static", "function", "getCacheName", "(", "Request", "$", "request", ")", "{", "return", "md5", "(", "(", "string", ")", "$", "request", "->", "getMethod", "(", ")", ".", "(", "string", ")", "$", "request", "->", "getUri", "(", ")", ")", ";", "}" ]
Extract and compute the cache object name @param Request $request The request model @return string
[ "Extract", "and", "compute", "the", "cache", "object", "name" ]
5093297dcb7441a8d8f79cbb2429c93232e16d1c
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Cache/ServerCache.php#L155-L159
15,732
czim/laravel-pxlcms
src/Generator/Writer/Model/Steps/StubReplaceDocBlock.php
StubReplaceDocBlock.getDocBlockReplace
protected function getDocBlockReplace() { // For now, docblocks will only contain the ide-helper content if ( ! $this->isDocBlockRequired()) return ''; $rows = $this->collectDocBlockPropertyRows(); if ( ! count($rows)) return ''; $replace = "/**\n" . $this->getDocBlockIntro(); foreach ($rows as $row) { $replace .= ' * ' . "@{$row['tag']} " . "{$row['type']} " . "{$row['name']}\n"; } $replace .= " */\n"; return $replace; }
php
protected function getDocBlockReplace() { // For now, docblocks will only contain the ide-helper content if ( ! $this->isDocBlockRequired()) return ''; $rows = $this->collectDocBlockPropertyRows(); if ( ! count($rows)) return ''; $replace = "/**\n" . $this->getDocBlockIntro(); foreach ($rows as $row) { $replace .= ' * ' . "@{$row['tag']} " . "{$row['type']} " . "{$row['name']}\n"; } $replace .= " */\n"; return $replace; }
[ "protected", "function", "getDocBlockReplace", "(", ")", "{", "// For now, docblocks will only contain the ide-helper content", "if", "(", "!", "$", "this", "->", "isDocBlockRequired", "(", ")", ")", "return", "''", ";", "$", "rows", "=", "$", "this", "->", "collectDocBlockPropertyRows", "(", ")", ";", "if", "(", "!", "count", "(", "$", "rows", ")", ")", "return", "''", ";", "$", "replace", "=", "\"/**\\n\"", ".", "$", "this", "->", "getDocBlockIntro", "(", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "replace", ".=", "' * '", ".", "\"@{$row['tag']} \"", ".", "\"{$row['type']} \"", ".", "\"{$row['name']}\\n\"", ";", "}", "$", "replace", ".=", "\" */\\n\"", ";", "return", "$", "replace", ";", "}" ]
Returns the replacement for the docblock placeholder @return string
[ "Returns", "the", "replacement", "for", "the", "docblock", "placeholder" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceDocBlock.php#L27-L52
15,733
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/EntityCollectionIterator.php
EntityCollectionIterator.dataAvailable
public function dataAvailable() { return ($this->position >= $this->collection->getStartIndex() and $this->position <= $this->collection->getEndIndex()); }
php
public function dataAvailable() { return ($this->position >= $this->collection->getStartIndex() and $this->position <= $this->collection->getEndIndex()); }
[ "public", "function", "dataAvailable", "(", ")", "{", "return", "(", "$", "this", "->", "position", ">=", "$", "this", "->", "collection", "->", "getStartIndex", "(", ")", "and", "$", "this", "->", "position", "<=", "$", "this", "->", "collection", "->", "getEndIndex", "(", ")", ")", ";", "}" ]
True if data for the current position has been loaded from the server and is locally available. @return boolean
[ "True", "if", "data", "for", "the", "current", "position", "has", "been", "loaded", "from", "the", "server", "and", "is", "locally", "available", "." ]
a020149ffde815be17634542010814cf854c3d5f
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/EntityCollectionIterator.php#L84-L88
15,734
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/EntityCollectionIterator.php
EntityCollectionIterator.nextDataAvailable
public function nextDataAvailable() { return ($this->position+1 >= $this->collection->getStartIndex() and $this->position+1 <= $this->collection->getEndIndex()); }
php
public function nextDataAvailable() { return ($this->position+1 >= $this->collection->getStartIndex() and $this->position+1 <= $this->collection->getEndIndex()); }
[ "public", "function", "nextDataAvailable", "(", ")", "{", "return", "(", "$", "this", "->", "position", "+", "1", ">=", "$", "this", "->", "collection", "->", "getStartIndex", "(", ")", "and", "$", "this", "->", "position", "+", "1", "<=", "$", "this", "->", "collection", "->", "getEndIndex", "(", ")", ")", ";", "}" ]
True if data for the next position has been loaded from the server and is locally available. This is useful in foreach loops to determine whether the next iteration will issue a HTTP request. @return boolean
[ "True", "if", "data", "for", "the", "next", "position", "has", "been", "loaded", "from", "the", "server", "and", "is", "locally", "available", ".", "This", "is", "useful", "in", "foreach", "loops", "to", "determine", "whether", "the", "next", "iteration", "will", "issue", "a", "HTTP", "request", "." ]
a020149ffde815be17634542010814cf854c3d5f
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/EntityCollectionIterator.php#L96-L100
15,735
stubbles/stubbles-webapp-core
src/main/php/session/WebSession.php
WebSession.hasValue
public function hasValue(string $key): bool { if (!$this->isValid()) { return false; } return $this->storage->hasValue($key); }
php
public function hasValue(string $key): bool { if (!$this->isValid()) { return false; } return $this->storage->hasValue($key); }
[ "public", "function", "hasValue", "(", "string", "$", "key", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "isValid", "(", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "storage", "->", "hasValue", "(", "$", "key", ")", ";", "}" ]
checks whether a value associated with key exists @param string $key key where value is stored under @return bool
[ "checks", "whether", "a", "value", "associated", "with", "key", "exists" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/session/WebSession.php#L169-L176
15,736
crossjoin/Css
src/Crossjoin/Css/Format/Rule/TraitConditions.php
TraitConditions.setConditions
public function setConditions($conditions) { $this->conditions = []; if (!is_array($conditions)) { $conditions = [$conditions]; } foreach ($conditions as $condition) { $this->addCondition($condition); } return $this; }
php
public function setConditions($conditions) { $this->conditions = []; if (!is_array($conditions)) { $conditions = [$conditions]; } foreach ($conditions as $condition) { $this->addCondition($condition); } return $this; }
[ "public", "function", "setConditions", "(", "$", "conditions", ")", "{", "$", "this", "->", "conditions", "=", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "conditions", ")", ")", "{", "$", "conditions", "=", "[", "$", "conditions", "]", ";", "}", "foreach", "(", "$", "conditions", "as", "$", "condition", ")", "{", "$", "this", "->", "addCondition", "(", "$", "condition", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the conditions. @param ConditionAbstract[]|ConditionAbstract $conditions @return $this
[ "Sets", "the", "conditions", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitConditions.php#L17-L28
15,737
datasift/datasift-php
lib/DataSift/Source.php
DataSift_Source.get
public static function get(DataSift_User $user, $id) { $params = array('id' => $id); return new self($user, $user->post('source/get', $params)); }
php
public static function get(DataSift_User $user, $id) { $params = array('id' => $id); return new self($user, $user->post('source/get', $params)); }
[ "public", "static", "function", "get", "(", "DataSift_User", "$", "user", ",", "$", "id", ")", "{", "$", "params", "=", "array", "(", "'id'", "=>", "$", "id", ")", ";", "return", "new", "self", "(", "$", "user", ",", "$", "user", "->", "post", "(", "'source/get'", ",", "$", "params", ")", ")", ";", "}" ]
Gets a single DataSift_Source object by ID @param DataSift_User $user The user making the request. @param string $id The id of the Source to fetch @return DataSift_Source @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Gets", "a", "single", "DataSift_Source", "object", "by", "ID" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Source.php#L105-L109
15,738
datasift/datasift-php
lib/DataSift/Source.php
DataSift_Source.save
public function save($validate = true) { if ($this->getValidate() != $validate) { $this->setValidate($validate); } $endpoint = ($this->getId() ? 'source/update' : 'source/create'); $this->fromArray($this->getUser()->post($endpoint, $this->toArray())); return $this; }
php
public function save($validate = true) { if ($this->getValidate() != $validate) { $this->setValidate($validate); } $endpoint = ($this->getId() ? 'source/update' : 'source/create'); $this->fromArray($this->getUser()->post($endpoint, $this->toArray())); return $this; }
[ "public", "function", "save", "(", "$", "validate", "=", "true", ")", "{", "if", "(", "$", "this", "->", "getValidate", "(", ")", "!=", "$", "validate", ")", "{", "$", "this", "->", "setValidate", "(", "$", "validate", ")", ";", "}", "$", "endpoint", "=", "(", "$", "this", "->", "getId", "(", ")", "?", "'source/update'", ":", "'source/create'", ")", ";", "$", "this", "->", "fromArray", "(", "$", "this", "->", "getUser", "(", ")", "->", "post", "(", "$", "endpoint", ",", "$", "this", "->", "toArray", "(", ")", ")", ")", ";", "return", "$", "this", ";", "}" ]
Save this Source @param boolean $validate @return DataSift_Source @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Save", "this", "Source" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Source.php#L453-L463
15,739
datasift/datasift-php
lib/DataSift/Source.php
DataSift_Source.delete
public function delete() { $this->getUser()->post('source/delete', array('id' => $this->getId())); $this->setStatus(self::STATUS_DELETED); return $this; }
php
public function delete() { $this->getUser()->post('source/delete', array('id' => $this->getId())); $this->setStatus(self::STATUS_DELETED); return $this; }
[ "public", "function", "delete", "(", ")", "{", "$", "this", "->", "getUser", "(", ")", "->", "post", "(", "'source/delete'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "getId", "(", ")", ")", ")", ";", "$", "this", "->", "setStatus", "(", "self", "::", "STATUS_DELETED", ")", ";", "return", "$", "this", ";", "}" ]
Delete this Source. @return DataSift_Source @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Delete", "this", "Source", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Source.php#L501-L507
15,740
datasift/datasift-php
lib/DataSift/Source.php
DataSift_Source.getLogs
public function getLogs($page = 1, $perPage = 20) { return $this->getUser()->post( 'source/log', array('id' => $this->getId(), 'page' => $page, 'per_page' => $perPage) ); }
php
public function getLogs($page = 1, $perPage = 20) { return $this->getUser()->post( 'source/log', array('id' => $this->getId(), 'page' => $page, 'per_page' => $perPage) ); }
[ "public", "function", "getLogs", "(", "$", "page", "=", "1", ",", "$", "perPage", "=", "20", ")", "{", "return", "$", "this", "->", "getUser", "(", ")", "->", "post", "(", "'source/log'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'page'", "=>", "$", "page", ",", "'per_page'", "=>", "$", "perPage", ")", ")", ";", "}" ]
Returns the logs for this source @return array @param integer $page @param integer $perPage
[ "Returns", "the", "logs", "for", "this", "source" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Source.php#L518-L524
15,741
datasift/datasift-php
lib/DataSift/Source.php
DataSift_Source.fromArray
public function fromArray(array $data) { $map = array( 'id' => 'setId', 'name' => 'setName', 'source_type' => 'setSourceType', 'status' => 'setStatus', 'parameters' => 'setParameters', 'auth' => 'setAuth', 'resources' => 'setResources', 'created_at' => 'setCreatedAt', 'validate' => 'setValidate' ); foreach ($map as $key => $setter) { if (isset($data[$key])) { $this->$setter($data[$key]); } } return $this; }
php
public function fromArray(array $data) { $map = array( 'id' => 'setId', 'name' => 'setName', 'source_type' => 'setSourceType', 'status' => 'setStatus', 'parameters' => 'setParameters', 'auth' => 'setAuth', 'resources' => 'setResources', 'created_at' => 'setCreatedAt', 'validate' => 'setValidate' ); foreach ($map as $key => $setter) { if (isset($data[$key])) { $this->$setter($data[$key]); } } return $this; }
[ "public", "function", "fromArray", "(", "array", "$", "data", ")", "{", "$", "map", "=", "array", "(", "'id'", "=>", "'setId'", ",", "'name'", "=>", "'setName'", ",", "'source_type'", "=>", "'setSourceType'", ",", "'status'", "=>", "'setStatus'", ",", "'parameters'", "=>", "'setParameters'", ",", "'auth'", "=>", "'setAuth'", ",", "'resources'", "=>", "'setResources'", ",", "'created_at'", "=>", "'setCreatedAt'", ",", "'validate'", "=>", "'setValidate'", ")", ";", "foreach", "(", "$", "map", "as", "$", "key", "=>", "$", "setter", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "$", "setter", "(", "$", "data", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Hydrates this Source from an array of API responses @param array $data @return DataSift_Source
[ "Hydrates", "this", "Source", "from", "an", "array", "of", "API", "responses" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Source.php#L533-L554
15,742
fuelphp/display
src/Parser/Handlebars.php
Handlebars.setupEngine
protected function setupEngine() { $this->engine = new HandlebarsEngine; $loader = new HandlebarsLoader($this->viewManager); $partialLoader = new HandlebarsLoader($this->viewManager); $partialLoader->setPrefix('_'); $this->engine->setLoader($loader); $this->engine->setPartialsLoader($partialLoader); }
php
protected function setupEngine() { $this->engine = new HandlebarsEngine; $loader = new HandlebarsLoader($this->viewManager); $partialLoader = new HandlebarsLoader($this->viewManager); $partialLoader->setPrefix('_'); $this->engine->setLoader($loader); $this->engine->setPartialsLoader($partialLoader); }
[ "protected", "function", "setupEngine", "(", ")", "{", "$", "this", "->", "engine", "=", "new", "HandlebarsEngine", ";", "$", "loader", "=", "new", "HandlebarsLoader", "(", "$", "this", "->", "viewManager", ")", ";", "$", "partialLoader", "=", "new", "HandlebarsLoader", "(", "$", "this", "->", "viewManager", ")", ";", "$", "partialLoader", "->", "setPrefix", "(", "'_'", ")", ";", "$", "this", "->", "engine", "->", "setLoader", "(", "$", "loader", ")", ";", "$", "this", "->", "engine", "->", "setPartialsLoader", "(", "$", "partialLoader", ")", ";", "}" ]
Sets HandlebarsEngine up
[ "Sets", "HandlebarsEngine", "up" ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/Parser/Handlebars.php#L51-L62
15,743
goblindegook/Syllables
src/Template/Loader.php
Loader.filter
public function filter( $template ) { $this->_prepare_filter(); return $this->_should_load_template() ? $this->_get_template( $template ) : $template; }
php
public function filter( $template ) { $this->_prepare_filter(); return $this->_should_load_template() ? $this->_get_template( $template ) : $template; }
[ "public", "function", "filter", "(", "$", "template", ")", "{", "$", "this", "->", "_prepare_filter", "(", ")", ";", "return", "$", "this", "->", "_should_load_template", "(", ")", "?", "$", "this", "->", "_get_template", "(", "$", "template", ")", ":", "$", "template", ";", "}" ]
Filters a template file path and replaces it with a template provided by the plugin. @param string $template Full path to the default template file. @return string Filtered full path to template file @access public @see http://codex.wordpress.org/Plugin_API/Filter_Reference/template_include
[ "Filters", "a", "template", "file", "path", "and", "replaces", "it", "with", "a", "template", "provided", "by", "the", "plugin", "." ]
1a98cd15e37595a85b242242f88fee38c4e36acc
https://github.com/goblindegook/Syllables/blob/1a98cd15e37595a85b242242f88fee38c4e36acc/src/Template/Loader.php#L57-L60
15,744
mayoturis/properties-ini
src/RepositoryFactory.php
RepositoryFactory.make
public static function make($filePath) { $variableProcessor = new VariableProcessor(); $fileSaver = new FileSaver($variableProcessor); $fileLoader = new FileLoader($variableProcessor); return new Repository($fileLoader, $fileSaver, $filePath); }
php
public static function make($filePath) { $variableProcessor = new VariableProcessor(); $fileSaver = new FileSaver($variableProcessor); $fileLoader = new FileLoader($variableProcessor); return new Repository($fileLoader, $fileSaver, $filePath); }
[ "public", "static", "function", "make", "(", "$", "filePath", ")", "{", "$", "variableProcessor", "=", "new", "VariableProcessor", "(", ")", ";", "$", "fileSaver", "=", "new", "FileSaver", "(", "$", "variableProcessor", ")", ";", "$", "fileLoader", "=", "new", "FileLoader", "(", "$", "variableProcessor", ")", ";", "return", "new", "Repository", "(", "$", "fileLoader", ",", "$", "fileSaver", ",", "$", "filePath", ")", ";", "}" ]
Create repository instance @param string $filePath File where configuration is stored @return Repository
[ "Create", "repository", "instance" ]
79d56d8174637b1124eb90a41ffa3dca4c4a4e93
https://github.com/mayoturis/properties-ini/blob/79d56d8174637b1124eb90a41ffa3dca4c4a4e93/src/RepositoryFactory.php#L11-L18
15,745
EcomDev/magento-psr6-bridge
src/Model/CacheType.php
CacheType._getFrontend
protected function _getFrontend() { // @codingStandardsIgnoreEnd $frontend = parent::_getFrontend(); if ($frontend === null) { $frontend = $this->frontendPool->get(self::CACHE_TYPE); } return $frontend; }
php
protected function _getFrontend() { // @codingStandardsIgnoreEnd $frontend = parent::_getFrontend(); if ($frontend === null) { $frontend = $this->frontendPool->get(self::CACHE_TYPE); } return $frontend; }
[ "protected", "function", "_getFrontend", "(", ")", "{", "// @codingStandardsIgnoreEnd", "$", "frontend", "=", "parent", "::", "_getFrontend", "(", ")", ";", "if", "(", "$", "frontend", "===", "null", ")", "{", "$", "frontend", "=", "$", "this", "->", "frontendPool", "->", "get", "(", "self", "::", "CACHE_TYPE", ")", ";", "}", "return", "$", "frontend", ";", "}" ]
Returns a frontend on a first call to frontend interface methods @SuppressWarnings(PHPMD.CamelCaseMethodName) @return FrontendInterface
[ "Returns", "a", "frontend", "on", "a", "first", "call", "to", "frontend", "interface", "methods" ]
405c5b455f239fe8dc1b710df5fe9438f09d4715
https://github.com/EcomDev/magento-psr6-bridge/blob/405c5b455f239fe8dc1b710df5fe9438f09d4715/src/Model/CacheType.php#L71-L81
15,746
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/CustomActions.php
CustomActions.setCustomActions
public function setCustomActions($name, $data = null) { $actions = is_array($name) ? $name : [$name => $data]; foreach ($actions as $key => $value) { $this->customActions[$key] = $value; } return $this; }
php
public function setCustomActions($name, $data = null) { $actions = is_array($name) ? $name : [$name => $data]; foreach ($actions as $key => $value) { $this->customActions[$key] = $value; } return $this; }
[ "public", "function", "setCustomActions", "(", "$", "name", ",", "$", "data", "=", "null", ")", "{", "$", "actions", "=", "is_array", "(", "$", "name", ")", "?", "$", "name", ":", "[", "$", "name", "=>", "$", "data", "]", ";", "foreach", "(", "$", "actions", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "customActions", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Sets the Custom actions. @param string|array $name @param array $data = null @return self
[ "Sets", "the", "Custom", "actions", "." ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/CustomActions.php#L32-L41
15,747
FrenchFrogs/framework
src/Table/Column/Strainer/Strainerable.php
Strainerable.setStrainerSelect
public function setStrainerSelect($options = [], $callable = null, $attr = []) { // if callable is a string , it's a field if (is_string($callable) || $callable instanceof Expression) { $field = $callable; $callable = null; } // create the strainer $strainer = new Select($this, $options, $callable, $attr); //if a fields is set, we configure the strainer if (isset($field)) { $strainer->setField($field); } return $this->setStrainer($strainer); }
php
public function setStrainerSelect($options = [], $callable = null, $attr = []) { // if callable is a string , it's a field if (is_string($callable) || $callable instanceof Expression) { $field = $callable; $callable = null; } // create the strainer $strainer = new Select($this, $options, $callable, $attr); //if a fields is set, we configure the strainer if (isset($field)) { $strainer->setField($field); } return $this->setStrainer($strainer); }
[ "public", "function", "setStrainerSelect", "(", "$", "options", "=", "[", "]", ",", "$", "callable", "=", "null", ",", "$", "attr", "=", "[", "]", ")", "{", "// if callable is a string , it's a field", "if", "(", "is_string", "(", "$", "callable", ")", "||", "$", "callable", "instanceof", "Expression", ")", "{", "$", "field", "=", "$", "callable", ";", "$", "callable", "=", "null", ";", "}", "// create the strainer", "$", "strainer", "=", "new", "Select", "(", "$", "this", ",", "$", "options", ",", "$", "callable", ",", "$", "attr", ")", ";", "//if a fields is set, we configure the strainer", "if", "(", "isset", "(", "$", "field", ")", ")", "{", "$", "strainer", "->", "setField", "(", "$", "field", ")", ";", "}", "return", "$", "this", "->", "setStrainer", "(", "$", "strainer", ")", ";", "}" ]
Set Strainer as a select form element @param array $options @param array $attr @return \FrenchFrogs\Table\Column\Strainer\Strainerable
[ "Set", "Strainer", "as", "a", "select", "form", "element" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Column/Strainer/Strainerable.php#L69-L88
15,748
FrenchFrogs/framework
src/Table/Column/Strainer/Strainerable.php
Strainerable.setStrainerBoolean
public function setStrainerBoolean($callable = null, $attr = []) { // if callable is a string , it's a field if (is_string($callable) || $callable instanceof Expression) { $field = $callable; $callable = null; } // create the strainer $strainer = new Boolean($this, $callable, $attr); //if a fields is set, we configure the strainer if (isset($field)) { $strainer->setField($field); } return $this->setStrainer($strainer); }
php
public function setStrainerBoolean($callable = null, $attr = []) { // if callable is a string , it's a field if (is_string($callable) || $callable instanceof Expression) { $field = $callable; $callable = null; } // create the strainer $strainer = new Boolean($this, $callable, $attr); //if a fields is set, we configure the strainer if (isset($field)) { $strainer->setField($field); } return $this->setStrainer($strainer); }
[ "public", "function", "setStrainerBoolean", "(", "$", "callable", "=", "null", ",", "$", "attr", "=", "[", "]", ")", "{", "// if callable is a string , it's a field", "if", "(", "is_string", "(", "$", "callable", ")", "||", "$", "callable", "instanceof", "Expression", ")", "{", "$", "field", "=", "$", "callable", ";", "$", "callable", "=", "null", ";", "}", "// create the strainer", "$", "strainer", "=", "new", "Boolean", "(", "$", "this", ",", "$", "callable", ",", "$", "attr", ")", ";", "//if a fields is set, we configure the strainer", "if", "(", "isset", "(", "$", "field", ")", ")", "{", "$", "strainer", "->", "setField", "(", "$", "field", ")", ";", "}", "return", "$", "this", "->", "setStrainer", "(", "$", "strainer", ")", ";", "}" ]
Set strainer as a Boolean @param null $callable @param array $attr @return $this
[ "Set", "strainer", "as", "a", "Boolean" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Column/Strainer/Strainerable.php#L118-L135
15,749
FrenchFrogs/framework
src/Table/Column/Strainer/Strainerable.php
Strainerable.setStrainerDateRange
public function setStrainerDateRange($callable = null, $attr = []) { // if callable is a string , it's a field if (is_string($callable) || $callable instanceof Expression) { $field = $callable; $callable = null; } // create the strainer $strainer = new DateRange($this, $callable, $attr); //if a fields is set, we configure the strainer if (isset($field)) { $strainer->setField($field); } return $this->setStrainer($strainer); }
php
public function setStrainerDateRange($callable = null, $attr = []) { // if callable is a string , it's a field if (is_string($callable) || $callable instanceof Expression) { $field = $callable; $callable = null; } // create the strainer $strainer = new DateRange($this, $callable, $attr); //if a fields is set, we configure the strainer if (isset($field)) { $strainer->setField($field); } return $this->setStrainer($strainer); }
[ "public", "function", "setStrainerDateRange", "(", "$", "callable", "=", "null", ",", "$", "attr", "=", "[", "]", ")", "{", "// if callable is a string , it's a field", "if", "(", "is_string", "(", "$", "callable", ")", "||", "$", "callable", "instanceof", "Expression", ")", "{", "$", "field", "=", "$", "callable", ";", "$", "callable", "=", "null", ";", "}", "// create the strainer", "$", "strainer", "=", "new", "DateRange", "(", "$", "this", ",", "$", "callable", ",", "$", "attr", ")", ";", "//if a fields is set, we configure the strainer", "if", "(", "isset", "(", "$", "field", ")", ")", "{", "$", "strainer", "->", "setField", "(", "$", "field", ")", ";", "}", "return", "$", "this", "->", "setStrainer", "(", "$", "strainer", ")", ";", "}" ]
Set a strainer as date from to @param null $callable @param array $attr @return $this
[ "Set", "a", "strainer", "as", "date", "from", "to" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Column/Strainer/Strainerable.php#L145-L163
15,750
pageon/SlackWebhookMonolog
src/Slack/EmojiIcon.php
EmojiIcon.setEmoji
private function setEmoji($emoji) { // remove the whitespace $emoji = trim($emoji); $emojiValidationRegex = '_^:[\w-+]+:$_iuS'; if (!preg_match($emojiValidationRegex, $emoji)) { throw new InvalidEmojiException( sprintf( 'The emoji: "%s" is not a valid emoji. An emoji should always be a string starting and ending with ":".', $emoji ), 400 ); } $this->emoji = $emoji; return $this; }
php
private function setEmoji($emoji) { // remove the whitespace $emoji = trim($emoji); $emojiValidationRegex = '_^:[\w-+]+:$_iuS'; if (!preg_match($emojiValidationRegex, $emoji)) { throw new InvalidEmojiException( sprintf( 'The emoji: "%s" is not a valid emoji. An emoji should always be a string starting and ending with ":".', $emoji ), 400 ); } $this->emoji = $emoji; return $this; }
[ "private", "function", "setEmoji", "(", "$", "emoji", ")", "{", "// remove the whitespace", "$", "emoji", "=", "trim", "(", "$", "emoji", ")", ";", "$", "emojiValidationRegex", "=", "'_^:[\\w-+]+:$_iuS'", ";", "if", "(", "!", "preg_match", "(", "$", "emojiValidationRegex", ",", "$", "emoji", ")", ")", "{", "throw", "new", "InvalidEmojiException", "(", "sprintf", "(", "'The emoji: \"%s\" is not a valid emoji.\n An emoji should always be a string starting and ending with \":\".'", ",", "$", "emoji", ")", ",", "400", ")", ";", "}", "$", "this", "->", "emoji", "=", "$", "emoji", ";", "return", "$", "this", ";", "}" ]
This will set the emoji if it is valid. @param string $emoji @throws InvalidEmojiException Thrown when the emoji is not valid @return $this
[ "This", "will", "set", "the", "emoji", "if", "it", "is", "valid", "." ]
6755060ddd6429620fd4c7decbb95f05463fc36b
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/EmojiIcon.php#L40-L59
15,751
FrenchFrogs/framework
src/Container/Javascript.php
Javascript.build
public function build($selector, $function, ...$params) { $attributes = []; foreach($params as $p) { $attributes[] = $this->encode($p); } //n concatenation du json $attributes = implode(',', $attributes); // gestion des functions $attributes = preg_replace('#\"(function\([^\{]+{.*\})\",#', '$1,', $attributes); return sprintf('$("%s").%s(%s);', $selector, $function, $attributes); }
php
public function build($selector, $function, ...$params) { $attributes = []; foreach($params as $p) { $attributes[] = $this->encode($p); } //n concatenation du json $attributes = implode(',', $attributes); // gestion des functions $attributes = preg_replace('#\"(function\([^\{]+{.*\})\",#', '$1,', $attributes); return sprintf('$("%s").%s(%s);', $selector, $function, $attributes); }
[ "public", "function", "build", "(", "$", "selector", ",", "$", "function", ",", "...", "$", "params", ")", "{", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "p", ")", "{", "$", "attributes", "[", "]", "=", "$", "this", "->", "encode", "(", "$", "p", ")", ";", "}", "//n concatenation du json", "$", "attributes", "=", "implode", "(", "','", ",", "$", "attributes", ")", ";", "// gestion des functions", "$", "attributes", "=", "preg_replace", "(", "'#\\\"(function\\([^\\{]+{.*\\})\\\",#'", ",", "'$1,'", ",", "$", "attributes", ")", ";", "return", "sprintf", "(", "'$(\"%s\").%s(%s);'", ",", "$", "selector", ",", "$", "function", ",", "$", "attributes", ")", ";", "}" ]
Build a jquery call javascript code @param $selector @param $function @param ...$params @return string
[ "Build", "a", "jquery", "call", "javascript", "code" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Container/Javascript.php#L75-L91
15,752
FrenchFrogs/framework
src/Container/Javascript.php
Javascript.warning
public function warning($body = '', $title = '') { $body = empty($body) ? configurator()->get('toastr.warning.default') : $body; $this->append([static::TYPE_INLINE, sprintf('toastr.warning("%s", "%s");', $body, $title)]); return $this; }
php
public function warning($body = '', $title = '') { $body = empty($body) ? configurator()->get('toastr.warning.default') : $body; $this->append([static::TYPE_INLINE, sprintf('toastr.warning("%s", "%s");', $body, $title)]); return $this; }
[ "public", "function", "warning", "(", "$", "body", "=", "''", ",", "$", "title", "=", "''", ")", "{", "$", "body", "=", "empty", "(", "$", "body", ")", "?", "configurator", "(", ")", "->", "get", "(", "'toastr.warning.default'", ")", ":", "$", "body", ";", "$", "this", "->", "append", "(", "[", "static", "::", "TYPE_INLINE", ",", "sprintf", "(", "'toastr.warning(\"%s\", \"%s\");'", ",", "$", "body", ",", "$", "title", ")", "]", ")", ";", "return", "$", "this", ";", "}" ]
Add toastr warning message @param $body @param string $title @return $this
[ "Add", "toastr", "warning", "message" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Container/Javascript.php#L155-L160
15,753
fuzz-productions/laravel-api-data
src/Eloquent/Model.php
Model.accessibleAttributesToArray
public function accessibleAttributesToArray() { $filtered = []; $attributes = $this->attributesToArray(); foreach ($attributes as $key => $attribute) { $accessible = $this->access_authorizer->canAccess($key); if ($accessible) { $filtered[$key] = $attribute; } } return array_merge($filtered, $this->accessibleRelationsToArray()); }
php
public function accessibleAttributesToArray() { $filtered = []; $attributes = $this->attributesToArray(); foreach ($attributes as $key => $attribute) { $accessible = $this->access_authorizer->canAccess($key); if ($accessible) { $filtered[$key] = $attribute; } } return array_merge($filtered, $this->accessibleRelationsToArray()); }
[ "public", "function", "accessibleAttributesToArray", "(", ")", "{", "$", "filtered", "=", "[", "]", ";", "$", "attributes", "=", "$", "this", "->", "attributesToArray", "(", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "attribute", ")", "{", "$", "accessible", "=", "$", "this", "->", "access_authorizer", "->", "canAccess", "(", "$", "key", ")", ";", "if", "(", "$", "accessible", ")", "{", "$", "filtered", "[", "$", "key", "]", "=", "$", "attribute", ";", "}", "}", "return", "array_merge", "(", "$", "filtered", ",", "$", "this", "->", "accessibleRelationsToArray", "(", ")", ")", ";", "}" ]
Filter attributes which can and can't be accessed by the user @return array
[ "Filter", "attributes", "which", "can", "and", "can", "t", "be", "accessed", "by", "the", "user" ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Eloquent/Model.php#L124-L138
15,754
fuzz-productions/laravel-api-data
src/Eloquent/Model.php
Model.accessibleRelationsToArray
public function accessibleRelationsToArray() { $filtered = []; $relations = $this->getArrayableRelations(); /** * @var $related \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Relations\Pivot */ foreach ($relations as $key => $related_collection) { if (! $this->access_authorizer->canAccess($key)) { continue; } if ($related_collection instanceof Pivot) { // Access test done above $filtered[$key] = $related_collection; continue; } // Many relation if ($related_collection instanceof Collection) { foreach ($related_collection as $index => $related) { $filtered[$key][$index] = $related->accessibleAttributesToArray(); } } elseif ($related_collection instanceof LaravelModel) { // Single relation $filtered[$key] = $related_collection->accessibleAttributesToArray(); } } return $filtered; }
php
public function accessibleRelationsToArray() { $filtered = []; $relations = $this->getArrayableRelations(); /** * @var $related \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Relations\Pivot */ foreach ($relations as $key => $related_collection) { if (! $this->access_authorizer->canAccess($key)) { continue; } if ($related_collection instanceof Pivot) { // Access test done above $filtered[$key] = $related_collection; continue; } // Many relation if ($related_collection instanceof Collection) { foreach ($related_collection as $index => $related) { $filtered[$key][$index] = $related->accessibleAttributesToArray(); } } elseif ($related_collection instanceof LaravelModel) { // Single relation $filtered[$key] = $related_collection->accessibleAttributesToArray(); } } return $filtered; }
[ "public", "function", "accessibleRelationsToArray", "(", ")", "{", "$", "filtered", "=", "[", "]", ";", "$", "relations", "=", "$", "this", "->", "getArrayableRelations", "(", ")", ";", "/**\n\t\t * @var $related \\Illuminate\\Database\\Eloquent\\Collection|\\Illuminate\\Database\\Eloquent\\Relations\\Pivot\n\t\t */", "foreach", "(", "$", "relations", "as", "$", "key", "=>", "$", "related_collection", ")", "{", "if", "(", "!", "$", "this", "->", "access_authorizer", "->", "canAccess", "(", "$", "key", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "related_collection", "instanceof", "Pivot", ")", "{", "// Access test done above", "$", "filtered", "[", "$", "key", "]", "=", "$", "related_collection", ";", "continue", ";", "}", "// Many relation", "if", "(", "$", "related_collection", "instanceof", "Collection", ")", "{", "foreach", "(", "$", "related_collection", "as", "$", "index", "=>", "$", "related", ")", "{", "$", "filtered", "[", "$", "key", "]", "[", "$", "index", "]", "=", "$", "related", "->", "accessibleAttributesToArray", "(", ")", ";", "}", "}", "elseif", "(", "$", "related_collection", "instanceof", "LaravelModel", ")", "{", "// Single relation", "$", "filtered", "[", "$", "key", "]", "=", "$", "related_collection", "->", "accessibleAttributesToArray", "(", ")", ";", "}", "}", "return", "$", "filtered", ";", "}" ]
Filter relations which can and can't be accessed by the user @return array
[ "Filter", "relations", "which", "can", "and", "can", "t", "be", "accessed", "by", "the", "user" ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Eloquent/Model.php#L145-L176
15,755
fuzz-productions/laravel-api-data
src/Eloquent/Model.php
Model.addAppends
public function addAppends($appends) { if (is_string($appends)) { $appends = func_get_args(); } $this->appends = array_merge($this->appends, $appends); return $this; }
php
public function addAppends($appends) { if (is_string($appends)) { $appends = func_get_args(); } $this->appends = array_merge($this->appends, $appends); return $this; }
[ "public", "function", "addAppends", "(", "$", "appends", ")", "{", "if", "(", "is_string", "(", "$", "appends", ")", ")", "{", "$", "appends", "=", "func_get_args", "(", ")", ";", "}", "$", "this", "->", "appends", "=", "array_merge", "(", "$", "this", "->", "appends", ",", "$", "appends", ")", ";", "return", "$", "this", ";", "}" ]
Add additional appended properties to the model via a public interface. @param string|array $appends @return static
[ "Add", "additional", "appended", "properties", "to", "the", "model", "via", "a", "public", "interface", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Eloquent/Model.php#L184-L193
15,756
fuzz-productions/laravel-api-data
src/Eloquent/Model.php
Model.removeAppends
public function removeAppends($appends) { if (is_string($appends)) { $appends = func_get_args(); } $this->appends = array_diff($this->appends, $appends); return $this; }
php
public function removeAppends($appends) { if (is_string($appends)) { $appends = func_get_args(); } $this->appends = array_diff($this->appends, $appends); return $this; }
[ "public", "function", "removeAppends", "(", "$", "appends", ")", "{", "if", "(", "is_string", "(", "$", "appends", ")", ")", "{", "$", "appends", "=", "func_get_args", "(", ")", ";", "}", "$", "this", "->", "appends", "=", "array_diff", "(", "$", "this", "->", "appends", ",", "$", "appends", ")", ";", "return", "$", "this", ";", "}" ]
Remove appended properties to the model via a public interface. @param string|array $appends @return static
[ "Remove", "appended", "properties", "to", "the", "model", "via", "a", "public", "interface", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Eloquent/Model.php#L201-L210
15,757
fuzz-productions/laravel-api-data
src/Eloquent/Model.php
Model.removeHidden
public function removeHidden($hidden) { if (is_string($hidden)) { $hidden = func_get_args(); } $this->hidden = array_diff($this->hidden, $hidden); return $this; }
php
public function removeHidden($hidden) { if (is_string($hidden)) { $hidden = func_get_args(); } $this->hidden = array_diff($this->hidden, $hidden); return $this; }
[ "public", "function", "removeHidden", "(", "$", "hidden", ")", "{", "if", "(", "is_string", "(", "$", "hidden", ")", ")", "{", "$", "hidden", "=", "func_get_args", "(", ")", ";", "}", "$", "this", "->", "hidden", "=", "array_diff", "(", "$", "this", "->", "hidden", ",", "$", "hidden", ")", ";", "return", "$", "this", ";", "}" ]
Unhide hidden properties from the model via a public interface. @param string|array $hidden @return static
[ "Unhide", "hidden", "properties", "from", "the", "model", "via", "a", "public", "interface", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Eloquent/Model.php#L218-L227
15,758
fuzz-productions/laravel-api-data
src/Eloquent/Model.php
Model.mutateDateTimeAttribute
final protected function mutateDateTimeAttribute($date, $attribute) { if (is_numeric($date)) { return $this->attributes[$attribute] = Carbon::createFromTimestamp($date); } return $this->attributes[$attribute] = Carbon::parse($date)->toDateTimeString(); }
php
final protected function mutateDateTimeAttribute($date, $attribute) { if (is_numeric($date)) { return $this->attributes[$attribute] = Carbon::createFromTimestamp($date); } return $this->attributes[$attribute] = Carbon::parse($date)->toDateTimeString(); }
[ "final", "protected", "function", "mutateDateTimeAttribute", "(", "$", "date", ",", "$", "attribute", ")", "{", "if", "(", "is_numeric", "(", "$", "date", ")", ")", "{", "return", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "=", "Carbon", "::", "createFromTimestamp", "(", "$", "date", ")", ";", "}", "return", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "=", "Carbon", "::", "parse", "(", "$", "date", ")", "->", "toDateTimeString", "(", ")", ";", "}" ]
Mutator for datetime attributes. @param string /int $date A parsable datetime string or timestamp @param string $attribute The name of the attribute we're setting @return \Carbon\Carbon
[ "Mutator", "for", "datetime", "attributes", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Eloquent/Model.php#L290-L297
15,759
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/Trans.php
Trans.setTrans
public function setTrans($attr, $trans = null) { $transList = is_array($attr) ? $attr : [$attr => $trans]; foreach ($transList as $key => $value) $this->trans[$key] = $value; return $this; }
php
public function setTrans($attr, $trans = null) { $transList = is_array($attr) ? $attr : [$attr => $trans]; foreach ($transList as $key => $value) $this->trans[$key] = $value; return $this; }
[ "public", "function", "setTrans", "(", "$", "attr", ",", "$", "trans", "=", "null", ")", "{", "$", "transList", "=", "is_array", "(", "$", "attr", ")", "?", "$", "attr", ":", "[", "$", "attr", "=>", "$", "trans", "]", ";", "foreach", "(", "$", "transList", "as", "$", "key", "=>", "$", "value", ")", "$", "this", "->", "trans", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets the Model trans. @param string|array $attr @param array $trans = null @return self
[ "Sets", "the", "Model", "trans", "." ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/Trans.php#L32-L42
15,760
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Chat.php
Chat.fetch
public function fetch($limit=null) { $data = Base::query('bf2cc serverchatbuffer'); $spl = explode("\r\r", $data); $result = array(); $i = 0; foreach ($spl as $chat) { $ex = explode("\t", $chat); if(count($ex) < 2) continue; list($index, $origin, $team, $type, $time, $message) = $ex; if (!$limit or $limit > count($spl)-$i) { $result[] = (object) array ( 'origin' => $origin, 'type' => $type, 'team' => $team, 'time' => substr($time, 1, -1), 'message' => $message, 'index' => $index ); } ++$i; } return $result; }
php
public function fetch($limit=null) { $data = Base::query('bf2cc serverchatbuffer'); $spl = explode("\r\r", $data); $result = array(); $i = 0; foreach ($spl as $chat) { $ex = explode("\t", $chat); if(count($ex) < 2) continue; list($index, $origin, $team, $type, $time, $message) = $ex; if (!$limit or $limit > count($spl)-$i) { $result[] = (object) array ( 'origin' => $origin, 'type' => $type, 'team' => $team, 'time' => substr($time, 1, -1), 'message' => $message, 'index' => $index ); } ++$i; } return $result; }
[ "public", "function", "fetch", "(", "$", "limit", "=", "null", ")", "{", "$", "data", "=", "Base", "::", "query", "(", "'bf2cc serverchatbuffer'", ")", ";", "$", "spl", "=", "explode", "(", "\"\\r\\r\"", ",", "$", "data", ")", ";", "$", "result", "=", "array", "(", ")", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "spl", "as", "$", "chat", ")", "{", "$", "ex", "=", "explode", "(", "\"\\t\"", ",", "$", "chat", ")", ";", "if", "(", "count", "(", "$", "ex", ")", "<", "2", ")", "continue", ";", "list", "(", "$", "index", ",", "$", "origin", ",", "$", "team", ",", "$", "type", ",", "$", "time", ",", "$", "message", ")", "=", "$", "ex", ";", "if", "(", "!", "$", "limit", "or", "$", "limit", ">", "count", "(", "$", "spl", ")", "-", "$", "i", ")", "{", "$", "result", "[", "]", "=", "(", "object", ")", "array", "(", "'origin'", "=>", "$", "origin", ",", "'type'", "=>", "$", "type", ",", "'team'", "=>", "$", "team", ",", "'time'", "=>", "substr", "(", "$", "time", ",", "1", ",", "-", "1", ")", ",", "'message'", "=>", "$", "message", ",", "'index'", "=>", "$", "index", ")", ";", "}", "++", "$", "i", ";", "}", "return", "$", "result", ";", "}" ]
Fetches current Chat-Buffer @param int $limit = null @return array
[ "Fetches", "current", "Chat", "-", "Buffer" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Chat.php#L29-L60
15,761
stubbles/stubbles-webapp-core
src/main/php/routing/Routes.php
Routes.match
public function match(CalledUri $calledUri): MatchingRoutes { $allowedMethods = []; $matching = []; foreach ($this->routes as $route) { /* @var $route \stubbles\webapp\routing\Route */ if ($route->matches($calledUri)) { return new MatchingRoutes( ['exact' => $route], $route->allowedRequestMethods() ); } elseif ($route->matchesPath($calledUri)) { $matching[] = $route; $allowedMethods = array_merge( $allowedMethods, $route->allowedRequestMethods() ); } } return new MatchingRoutes($matching, array_unique($allowedMethods)); }
php
public function match(CalledUri $calledUri): MatchingRoutes { $allowedMethods = []; $matching = []; foreach ($this->routes as $route) { /* @var $route \stubbles\webapp\routing\Route */ if ($route->matches($calledUri)) { return new MatchingRoutes( ['exact' => $route], $route->allowedRequestMethods() ); } elseif ($route->matchesPath($calledUri)) { $matching[] = $route; $allowedMethods = array_merge( $allowedMethods, $route->allowedRequestMethods() ); } } return new MatchingRoutes($matching, array_unique($allowedMethods)); }
[ "public", "function", "match", "(", "CalledUri", "$", "calledUri", ")", ":", "MatchingRoutes", "{", "$", "allowedMethods", "=", "[", "]", ";", "$", "matching", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "/* @var $route \\stubbles\\webapp\\routing\\Route */", "if", "(", "$", "route", "->", "matches", "(", "$", "calledUri", ")", ")", "{", "return", "new", "MatchingRoutes", "(", "[", "'exact'", "=>", "$", "route", "]", ",", "$", "route", "->", "allowedRequestMethods", "(", ")", ")", ";", "}", "elseif", "(", "$", "route", "->", "matchesPath", "(", "$", "calledUri", ")", ")", "{", "$", "matching", "[", "]", "=", "$", "route", ";", "$", "allowedMethods", "=", "array_merge", "(", "$", "allowedMethods", ",", "$", "route", "->", "allowedRequestMethods", "(", ")", ")", ";", "}", "}", "return", "new", "MatchingRoutes", "(", "$", "matching", ",", "array_unique", "(", "$", "allowedMethods", ")", ")", ";", "}" ]
finds route based on called uri @param \stubbles\webapp\routing\CalledUri $calledUri @return \stubbles\webapp\routing\MatchingRoutes
[ "finds", "route", "based", "on", "called", "uri" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routes.php#L44-L65
15,762
stubbles/stubbles-webapp-core
src/main/php/routing/Routes.php
Routes.getIterator
public function getIterator(): \Traversable { $routes = $this->routes; usort( $routes, function(Route $a, Route $b) { return strnatcmp($a->configuredPath(), $b->configuredPath()); } ); return new \ArrayIterator($routes); }
php
public function getIterator(): \Traversable { $routes = $this->routes; usort( $routes, function(Route $a, Route $b) { return strnatcmp($a->configuredPath(), $b->configuredPath()); } ); return new \ArrayIterator($routes); }
[ "public", "function", "getIterator", "(", ")", ":", "\\", "Traversable", "{", "$", "routes", "=", "$", "this", "->", "routes", ";", "usort", "(", "$", "routes", ",", "function", "(", "Route", "$", "a", ",", "Route", "$", "b", ")", "{", "return", "strnatcmp", "(", "$", "a", "->", "configuredPath", "(", ")", ",", "$", "b", "->", "configuredPath", "(", ")", ")", ";", "}", ")", ";", "return", "new", "\\", "ArrayIterator", "(", "$", "routes", ")", ";", "}" ]
allows iteration over all configured routes @return \Traversable @since 6.1.0
[ "allows", "iteration", "over", "all", "configured", "routes" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routes.php#L73-L84
15,763
jasny/router
src/Router/ControllerFactory.php
ControllerFactory.assertClass
protected function assertClass($class) { if (!preg_match('/^([a-zA-Z_]\w*\\\\)*[a-zA-Z_]\w*$/', $class)) { throw new \UnexpectedValueException("Can't route to controller '$class': invalid classname"); } if (!class_exists($class)) { throw new \UnexpectedValueException("Can't route to controller '$class': class not exists"); } $refl = new \ReflectionClass($class); $realClass = $refl->getName(); if ($realClass !== $class) { throw new \UnexpectedValueException("Can't route to controller '$class': case mismatch with '$realClass'"); } }
php
protected function assertClass($class) { if (!preg_match('/^([a-zA-Z_]\w*\\\\)*[a-zA-Z_]\w*$/', $class)) { throw new \UnexpectedValueException("Can't route to controller '$class': invalid classname"); } if (!class_exists($class)) { throw new \UnexpectedValueException("Can't route to controller '$class': class not exists"); } $refl = new \ReflectionClass($class); $realClass = $refl->getName(); if ($realClass !== $class) { throw new \UnexpectedValueException("Can't route to controller '$class': case mismatch with '$realClass'"); } }
[ "protected", "function", "assertClass", "(", "$", "class", ")", "{", "if", "(", "!", "preg_match", "(", "'/^([a-zA-Z_]\\w*\\\\\\\\)*[a-zA-Z_]\\w*$/'", ",", "$", "class", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Can't route to controller '$class': invalid classname\"", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Can't route to controller '$class': class not exists\"", ")", ";", "}", "$", "refl", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "realClass", "=", "$", "refl", "->", "getName", "(", ")", ";", "if", "(", "$", "realClass", "!==", "$", "class", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Can't route to controller '$class': case mismatch with '$realClass'\"", ")", ";", "}", "}" ]
Assert that a class exists and will provide a callable object @throws FactoryException
[ "Assert", "that", "a", "class", "exists", "and", "will", "provide", "a", "callable", "object" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/ControllerFactory.php#L38-L54
15,764
jasny/router
src/Router/ControllerFactory.php
ControllerFactory.studlyCase
protected function studlyCase($string) { return preg_replace_callback('/(?:^|(\w)-)(\w)/', function($match) { return $match[1] . strtoupper($match[2]); }, strtolower(addcslashes($string, '\\'))); }
php
protected function studlyCase($string) { return preg_replace_callback('/(?:^|(\w)-)(\w)/', function($match) { return $match[1] . strtoupper($match[2]); }, strtolower(addcslashes($string, '\\'))); }
[ "protected", "function", "studlyCase", "(", "$", "string", ")", "{", "return", "preg_replace_callback", "(", "'/(?:^|(\\w)-)(\\w)/'", ",", "function", "(", "$", "match", ")", "{", "return", "$", "match", "[", "1", "]", ".", "strtoupper", "(", "$", "match", "[", "2", "]", ")", ";", "}", ",", "strtolower", "(", "addcslashes", "(", "$", "string", ",", "'\\\\'", ")", ")", ")", ";", "}" ]
Turn kabab-case into StudlyCase. @internal Jasny\studlycase isn't used because it's to tolerent, which might lead to security issues. @param string $string @return string
[ "Turn", "kabab", "-", "case", "into", "StudlyCase", "." ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/ControllerFactory.php#L64-L69
15,765
comelyio/comely
src/Comely/IO/Yaml/Parser.php
Parser.setYamlPath
private function setYamlPath(string $yamlPath): void { $chars = preg_quote(':._-\/\\\\', '#'); $pattern = '#^[\w' . $chars . ']+\.(yaml|yml)$#'; if (!preg_match($pattern, $yamlPath)) { throw new ParserException('Given path to YAML file is invalid'); } // Get absolute path to file, resolve symbolic links (if any) $givenPath = $yamlPath; $yamlPath = realpath($yamlPath); if (!$yamlPath) { throw new ParserException( sprintf('YAML file "%s" not found in directory "%s"', basename($givenPath), dirname($givenPath)) ); } $this->yamlPath = $yamlPath; $this->baseDirectory = dirname($this->yamlPath); }
php
private function setYamlPath(string $yamlPath): void { $chars = preg_quote(':._-\/\\\\', '#'); $pattern = '#^[\w' . $chars . ']+\.(yaml|yml)$#'; if (!preg_match($pattern, $yamlPath)) { throw new ParserException('Given path to YAML file is invalid'); } // Get absolute path to file, resolve symbolic links (if any) $givenPath = $yamlPath; $yamlPath = realpath($yamlPath); if (!$yamlPath) { throw new ParserException( sprintf('YAML file "%s" not found in directory "%s"', basename($givenPath), dirname($givenPath)) ); } $this->yamlPath = $yamlPath; $this->baseDirectory = dirname($this->yamlPath); }
[ "private", "function", "setYamlPath", "(", "string", "$", "yamlPath", ")", ":", "void", "{", "$", "chars", "=", "preg_quote", "(", "':._-\\/\\\\\\\\'", ",", "'#'", ")", ";", "$", "pattern", "=", "'#^[\\w'", ".", "$", "chars", ".", "']+\\.(yaml|yml)$#'", ";", "if", "(", "!", "preg_match", "(", "$", "pattern", ",", "$", "yamlPath", ")", ")", "{", "throw", "new", "ParserException", "(", "'Given path to YAML file is invalid'", ")", ";", "}", "// Get absolute path to file, resolve symbolic links (if any)", "$", "givenPath", "=", "$", "yamlPath", ";", "$", "yamlPath", "=", "realpath", "(", "$", "yamlPath", ")", ";", "if", "(", "!", "$", "yamlPath", ")", "{", "throw", "new", "ParserException", "(", "sprintf", "(", "'YAML file \"%s\" not found in directory \"%s\"'", ",", "basename", "(", "$", "givenPath", ")", ",", "dirname", "(", "$", "givenPath", ")", ")", ")", ";", "}", "$", "this", "->", "yamlPath", "=", "$", "yamlPath", ";", "$", "this", "->", "baseDirectory", "=", "dirname", "(", "$", "this", "->", "yamlPath", ")", ";", "}" ]
Validates path, checks if starting Yaml file exists @param string $yamlPath @throws ParserException
[ "Validates", "path", "checks", "if", "starting", "Yaml", "file", "exists" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Yaml/Parser.php#L54-L73
15,766
comelyio/comely
src/Comely/IO/Yaml/Parser.php
Parser.setEOL
public function setEOL(string $eol = PHP_EOL): self { if (!in_array($eol, ["\n", "\r\n"])) { throw new ParserException('Invalid EOL character'); } $this->eolChar = $eol; return $this; }
php
public function setEOL(string $eol = PHP_EOL): self { if (!in_array($eol, ["\n", "\r\n"])) { throw new ParserException('Invalid EOL character'); } $this->eolChar = $eol; return $this; }
[ "public", "function", "setEOL", "(", "string", "$", "eol", "=", "PHP_EOL", ")", ":", "self", "{", "if", "(", "!", "in_array", "(", "$", "eol", ",", "[", "\"\\n\"", ",", "\"\\r\\n\"", "]", ")", ")", "{", "throw", "new", "ParserException", "(", "'Invalid EOL character'", ")", ";", "}", "$", "this", "->", "eolChar", "=", "$", "eol", ";", "return", "$", "this", ";", "}" ]
Set EOL character @param string $eol @return Parser
[ "Set", "EOL", "character" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Yaml/Parser.php#L95-L103
15,767
acasademont/wurfl
WURFL/Request/UserAgentNormalizer.php
WURFL_Request_UserAgentNormalizer.addUserAgentNormalizer
public function addUserAgentNormalizer(WURFL_Request_UserAgentNormalizer_Interface $normalizer) { $userAgentNormalizers = $this->_userAgentNormalizers; $userAgentNormalizers[] = $normalizer; return new WURFL_Request_UserAgentNormalizer($userAgentNormalizers); }
php
public function addUserAgentNormalizer(WURFL_Request_UserAgentNormalizer_Interface $normalizer) { $userAgentNormalizers = $this->_userAgentNormalizers; $userAgentNormalizers[] = $normalizer; return new WURFL_Request_UserAgentNormalizer($userAgentNormalizers); }
[ "public", "function", "addUserAgentNormalizer", "(", "WURFL_Request_UserAgentNormalizer_Interface", "$", "normalizer", ")", "{", "$", "userAgentNormalizers", "=", "$", "this", "->", "_userAgentNormalizers", ";", "$", "userAgentNormalizers", "[", "]", "=", "$", "normalizer", ";", "return", "new", "WURFL_Request_UserAgentNormalizer", "(", "$", "userAgentNormalizers", ")", ";", "}" ]
Adds a new UserAgent Normalizer to the chain @param WURFL_Request_UserAgentNormalizer_Interface $normalizer @return WURFL_Request_UserAgentNormalizer
[ "Adds", "a", "new", "UserAgent", "Normalizer", "to", "the", "chain" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Request/UserAgentNormalizer.php#L47-L52
15,768
drpdigital/json-api-parser
src/Collection.php
Collection.get
public function get($key) { $items = Arr::get($this->items, $key); return $this->firstOrAll($items); }
php
public function get($key) { $items = Arr::get($this->items, $key); return $this->firstOrAll($items); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "items", "=", "Arr", "::", "get", "(", "$", "this", "->", "items", ",", "$", "key", ")", ";", "return", "$", "this", "->", "firstOrAll", "(", "$", "items", ")", ";", "}" ]
Get the resolved resource by key. This will return an array of that resource if multiple resources are contained with the key. If only 1 item in the array then that 1 item will be returned instead. @param string $key @return mixed|array
[ "Get", "the", "resolved", "resource", "by", "key", "." ]
b1ceefc0c19ec326129126253114c121e97ca943
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/Collection.php#L27-L32
15,769
comelyio/comely
src/Comely/Kernel/Toolkit/Number.php
Number.Range
public static function Range(int $num, int $from, int $to): bool { return ($num >= $from && $num <= $to) ? true : false; }
php
public static function Range(int $num, int $from, int $to): bool { return ($num >= $from && $num <= $to) ? true : false; }
[ "public", "static", "function", "Range", "(", "int", "$", "num", ",", "int", "$", "from", ",", "int", "$", "to", ")", ":", "bool", "{", "return", "(", "$", "num", ">=", "$", "from", "&&", "$", "num", "<=", "$", "to", ")", "?", "true", ":", "false", ";", "}" ]
Check if specified number is with in specified range @param int $num @param int $from @param int $to @return bool
[ "Check", "if", "specified", "number", "is", "with", "in", "specified", "range" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/Kernel/Toolkit/Number.php#L31-L34
15,770
delboy1978uk/form
src/Renderer/HorizontalFormRenderer.php
HorizontalFormRenderer.surroundInDiv
private function surroundInDiv(DOMNode $element, $class) { $div = $this->createElement('div'); $div->setAttribute('class', $class); $div->appendChild($element); return $div; }
php
private function surroundInDiv(DOMNode $element, $class) { $div = $this->createElement('div'); $div->setAttribute('class', $class); $div->appendChild($element); return $div; }
[ "private", "function", "surroundInDiv", "(", "DOMNode", "$", "element", ",", "$", "class", ")", "{", "$", "div", "=", "$", "this", "->", "createElement", "(", "'div'", ")", ";", "$", "div", "->", "setAttribute", "(", "'class'", ",", "$", "class", ")", ";", "$", "div", "->", "appendChild", "(", "$", "element", ")", ";", "return", "$", "div", ";", "}" ]
Surround an element in a div with a given class @param DOMNode $element @param $class @return DOMElement
[ "Surround", "an", "element", "in", "a", "div", "with", "a", "given", "class" ]
fbbb042d95deef4603a19edf08c0497f720398a6
https://github.com/delboy1978uk/form/blob/fbbb042d95deef4603a19edf08c0497f720398a6/src/Renderer/HorizontalFormRenderer.php#L93-L99
15,771
puli/discovery
src/Api/Type/BindingNotAcceptedException.php
BindingNotAcceptedException.forBindingClass
public static function forBindingClass($typeName, $bindingClass, Exception $cause = null) { return new static(sprintf( 'The type "%s" does accept bindings of class "%s".', $typeName, $bindingClass ), 0, $cause); }
php
public static function forBindingClass($typeName, $bindingClass, Exception $cause = null) { return new static(sprintf( 'The type "%s" does accept bindings of class "%s".', $typeName, $bindingClass ), 0, $cause); }
[ "public", "static", "function", "forBindingClass", "(", "$", "typeName", ",", "$", "bindingClass", ",", "Exception", "$", "cause", "=", "null", ")", "{", "return", "new", "static", "(", "sprintf", "(", "'The type \"%s\" does accept bindings of class \"%s\".'", ",", "$", "typeName", ",", "$", "bindingClass", ")", ",", "0", ",", "$", "cause", ")", ";", "}" ]
Creates a new exception. @param string $typeName The name of the binding type. @param string $bindingClass The class name of the binding. @param Exception|null $cause The exception that caused this exception. @return static The created exception.
[ "Creates", "a", "new", "exception", "." ]
975f5e099563f1096bfabc17fbe4d1816408ad98
https://github.com/puli/discovery/blob/975f5e099563f1096bfabc17fbe4d1816408ad98/src/Api/Type/BindingNotAcceptedException.php#L36-L43
15,772
blast-project/CoreBundle
src/Admin/Traits/CollectionsManager.php
CollectionsManager.addManagedCollections
public function addManagedCollections($collections) { if (!is_array($collections)) { $collections = array($collections); } $this->managedCollections = array_merge($this->managedCollections, $collections); return $this; }
php
public function addManagedCollections($collections) { if (!is_array($collections)) { $collections = array($collections); } $this->managedCollections = array_merge($this->managedCollections, $collections); return $this; }
[ "public", "function", "addManagedCollections", "(", "$", "collections", ")", "{", "if", "(", "!", "is_array", "(", "$", "collections", ")", ")", "{", "$", "collections", "=", "array", "(", "$", "collections", ")", ";", "}", "$", "this", "->", "managedCollections", "=", "array_merge", "(", "$", "this", "->", "managedCollections", ",", "$", "collections", ")", ";", "return", "$", "this", ";", "}" ]
function addManagedCollections. @param $collections array or string, describing the collections to manage @return CoreAdmin $this
[ "function", "addManagedCollections", "." ]
7a0832758ca14e5bc5d65515532c1220df3930ae
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/Traits/CollectionsManager.php#L38-L46
15,773
gregorybesson/PlaygroundCore
src/Service/ShortenUrl.php
ShortenUrl.shortenUrl
public function shortenUrl($url) { if ($this->getOptions()->getBitlyApiKey() && $this->getOptions()->getBitlyUsername()) { $client = new \Zend\Http\Client($this->getOptions()->getBitlyUrl()); $client->setParameterGet(array( 'format' => 'json', 'longUrl' => $url, 'login' => $this->getOptions()->getBitlyUsername(), 'apiKey' => $this->getOptions()->getBitlyApiKey(), )); $result = $client->send(); if ($result) { $jsonResult = \Zend\Json\Json::decode($result->getBody()); if ($jsonResult->status_code == 200) { return $jsonResult->data->url; } } } return $url; }
php
public function shortenUrl($url) { if ($this->getOptions()->getBitlyApiKey() && $this->getOptions()->getBitlyUsername()) { $client = new \Zend\Http\Client($this->getOptions()->getBitlyUrl()); $client->setParameterGet(array( 'format' => 'json', 'longUrl' => $url, 'login' => $this->getOptions()->getBitlyUsername(), 'apiKey' => $this->getOptions()->getBitlyApiKey(), )); $result = $client->send(); if ($result) { $jsonResult = \Zend\Json\Json::decode($result->getBody()); if ($jsonResult->status_code == 200) { return $jsonResult->data->url; } } } return $url; }
[ "public", "function", "shortenUrl", "(", "$", "url", ")", "{", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getBitlyApiKey", "(", ")", "&&", "$", "this", "->", "getOptions", "(", ")", "->", "getBitlyUsername", "(", ")", ")", "{", "$", "client", "=", "new", "\\", "Zend", "\\", "Http", "\\", "Client", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getBitlyUrl", "(", ")", ")", ";", "$", "client", "->", "setParameterGet", "(", "array", "(", "'format'", "=>", "'json'", ",", "'longUrl'", "=>", "$", "url", ",", "'login'", "=>", "$", "this", "->", "getOptions", "(", ")", "->", "getBitlyUsername", "(", ")", ",", "'apiKey'", "=>", "$", "this", "->", "getOptions", "(", ")", "->", "getBitlyApiKey", "(", ")", ",", ")", ")", ";", "$", "result", "=", "$", "client", "->", "send", "(", ")", ";", "if", "(", "$", "result", ")", "{", "$", "jsonResult", "=", "\\", "Zend", "\\", "Json", "\\", "Json", "::", "decode", "(", "$", "result", "->", "getBody", "(", ")", ")", ";", "if", "(", "$", "jsonResult", "->", "status_code", "==", "200", ")", "{", "return", "$", "jsonResult", "->", "data", "->", "url", ";", "}", "}", "}", "return", "$", "url", ";", "}" ]
This method call Bit.ly to shorten a given URL. @param unknown_type $url @return unknown
[ "This", "method", "call", "Bit", ".", "ly", "to", "shorten", "a", "given", "URL", "." ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Service/ShortenUrl.php#L36-L57
15,774
jan-dolata/crude-crud
src/Engine/Traits/WithValidationTrait.php
WithValidationTrait.setValidationRules
public function setValidationRules($attr, $validationRules = null) { $rules = is_array($attr) ? $attr : [$attr => $validationRules]; $this->validationRules = array_merge($this->validationRules, $rules); return $this; }
php
public function setValidationRules($attr, $validationRules = null) { $rules = is_array($attr) ? $attr : [$attr => $validationRules]; $this->validationRules = array_merge($this->validationRules, $rules); return $this; }
[ "public", "function", "setValidationRules", "(", "$", "attr", ",", "$", "validationRules", "=", "null", ")", "{", "$", "rules", "=", "is_array", "(", "$", "attr", ")", "?", "$", "attr", ":", "[", "$", "attr", "=>", "$", "validationRules", "]", ";", "$", "this", "->", "validationRules", "=", "array_merge", "(", "$", "this", "->", "validationRules", ",", "$", "rules", ")", ";", "return", "$", "this", ";", "}" ]
Set validation rules array @param string|array $attr @param string $validationRules = null @return self
[ "Set", "validation", "rules", "array" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Traits/WithValidationTrait.php#L64-L73
15,775
darkwebdesign/doctrine-unit-testing
src/Mocks/EntityManagerMock.php
EntityManagerMock.create
public static function create($conn, Configuration $config = null, EventManager $eventManager = null) { if (null === $config) { $config = new Configuration(); $config->setProxyDir(__DIR__ . '/../Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([], true)); } if (null === $eventManager) { $eventManager = new EventManager(); } return new EntityManagerMock($conn, $config, $eventManager); }
php
public static function create($conn, Configuration $config = null, EventManager $eventManager = null) { if (null === $config) { $config = new Configuration(); $config->setProxyDir(__DIR__ . '/../Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([], true)); } if (null === $eventManager) { $eventManager = new EventManager(); } return new EntityManagerMock($conn, $config, $eventManager); }
[ "public", "static", "function", "create", "(", "$", "conn", ",", "Configuration", "$", "config", "=", "null", ",", "EventManager", "$", "eventManager", "=", "null", ")", "{", "if", "(", "null", "===", "$", "config", ")", "{", "$", "config", "=", "new", "Configuration", "(", ")", ";", "$", "config", "->", "setProxyDir", "(", "__DIR__", ".", "'/../Proxies'", ")", ";", "$", "config", "->", "setProxyNamespace", "(", "'Doctrine\\Tests\\Proxies'", ")", ";", "$", "config", "->", "setMetadataDriverImpl", "(", "$", "config", "->", "newDefaultAnnotationDriver", "(", "[", "]", ",", "true", ")", ")", ";", "}", "if", "(", "null", "===", "$", "eventManager", ")", "{", "$", "eventManager", "=", "new", "EventManager", "(", ")", ";", "}", "return", "new", "EntityManagerMock", "(", "$", "conn", ",", "$", "config", ",", "$", "eventManager", ")", ";", "}" ]
Mock factory method to create an EntityManager. {@inheritdoc}
[ "Mock", "factory", "method", "to", "create", "an", "EntityManager", "." ]
0daf50359563bc0679925e573a7105d6cd57168a
https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/EntityManagerMock.php#L69-L82
15,776
heyday/heystack
src/DependencyInjection/SilverStripe/HeystackSilverStripeContainerBuilder.php
HeystackSilverStripeContainerBuilder.has
public function has($id) { if ($this->isSilverStripeServiceRequest($id)) { return (bool) $this->getSilverStripeService($id); } else { return parent::has($id); } }
php
public function has($id) { if ($this->isSilverStripeServiceRequest($id)) { return (bool) $this->getSilverStripeService($id); } else { return parent::has($id); } }
[ "public", "function", "has", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "isSilverStripeServiceRequest", "(", "$", "id", ")", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "getSilverStripeService", "(", "$", "id", ")", ";", "}", "else", "{", "return", "parent", "::", "has", "(", "$", "id", ")", ";", "}", "}" ]
Return true if the service requested is a SilverStripe service and it exists in the SS container @param string $id @return bool
[ "Return", "true", "if", "the", "service", "requested", "is", "a", "SilverStripe", "service", "and", "it", "exists", "in", "the", "SS", "container" ]
2c051933f8c532d0a9a23be6ee1ff5c619e47dfe
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/DependencyInjection/SilverStripe/HeystackSilverStripeContainerBuilder.php#L28-L35
15,777
Atlantic18/CoralCoreBundle
Utility/JsonParser.php
JsonParser.importString
public function importString($content, $isMandatory = true) { if(empty($content) && $isMandatory) { throw new JsonException("Json content mandatory but none found."); } $this->params = array(); if (!empty($content)) { $this->params = @json_decode($content, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new JsonException("Error parsing json content: '$content'. Error: " . json_last_error_msg()); } if(null === $this->params) { // @codeCoverageIgnoreStart throw new JsonException("Error parsing json content: '$content'"); // @codeCoverageIgnoreEnd } } return $this->params; }
php
public function importString($content, $isMandatory = true) { if(empty($content) && $isMandatory) { throw new JsonException("Json content mandatory but none found."); } $this->params = array(); if (!empty($content)) { $this->params = @json_decode($content, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new JsonException("Error parsing json content: '$content'. Error: " . json_last_error_msg()); } if(null === $this->params) { // @codeCoverageIgnoreStart throw new JsonException("Error parsing json content: '$content'"); // @codeCoverageIgnoreEnd } } return $this->params; }
[ "public", "function", "importString", "(", "$", "content", ",", "$", "isMandatory", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "content", ")", "&&", "$", "isMandatory", ")", "{", "throw", "new", "JsonException", "(", "\"Json content mandatory but none found.\"", ")", ";", "}", "$", "this", "->", "params", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "$", "this", "->", "params", "=", "@", "json_decode", "(", "$", "content", ",", "true", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "JsonException", "(", "\"Error parsing json content: '$content'. Error: \"", ".", "json_last_error_msg", "(", ")", ")", ";", "}", "if", "(", "null", "===", "$", "this", "->", "params", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "JsonException", "(", "\"Error parsing json content: '$content'\"", ")", ";", "// @codeCoverageIgnoreEnd", "}", "}", "return", "$", "this", "->", "params", ";", "}" ]
Import string json and parse @param string $content string json @param boolean $isMandatory content is mandatory or can be empty - false @return array parsed json string
[ "Import", "string", "json", "and", "parse" ]
7d74ffaf51046ad13cbfc2b0b69d656a499f38ab
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Utility/JsonParser.php#L23-L47
15,778
Atlantic18/CoralCoreBundle
Utility/JsonParser.php
JsonParser.translatePathElement
private function translatePathElement($path, &$paramsRef) { $dotPos = strpos($path, '.'); $currPath = $path; if($dotPos !== false) { $currPath = substr($path, 0, $dotPos); } if($currPath == '*') { //Hell begins if($dotPos !== false) { //create a new copy and merge everything from one level up $newParamsRef = array(); foreach ($paramsRef as $subArray) { if(is_array($subArray)) { foreach ($subArray as $key => $value) { if(isset($newParamsRef[$key])) { $newParamsRef[$key][] = $value; } else { if(is_array($value)) { $newParamsRef[$key] = $value; } else { $newParamsRef[$key] = array($value); } } } } } return $this->translatePathElement(substr($path, $dotPos + 1), $newParamsRef); } else { return $paramsRef; } } if(($lbracktePos = strpos($currPath, '[')) !== false) { $subPath = substr($currPath, 0, $lbracktePos); $index = intval(substr($currPath, $lbracktePos+1, -1)); if(isset($paramsRef[$subPath]) && is_array($paramsRef[$subPath]) && isset($paramsRef[$subPath][$index])) { if($dotPos === false) { return $paramsRef[$subPath][$index]; } else { return $this->translatePathElement(substr($path, $dotPos + 1), $paramsRef[$subPath][$index]); } } } else { if(isset($paramsRef[$currPath])) { if($dotPos === false) { return $paramsRef[$currPath]; } else { return $this->translatePathElement(substr($path, $dotPos + 1), $paramsRef[$currPath]); } } } return null; }
php
private function translatePathElement($path, &$paramsRef) { $dotPos = strpos($path, '.'); $currPath = $path; if($dotPos !== false) { $currPath = substr($path, 0, $dotPos); } if($currPath == '*') { //Hell begins if($dotPos !== false) { //create a new copy and merge everything from one level up $newParamsRef = array(); foreach ($paramsRef as $subArray) { if(is_array($subArray)) { foreach ($subArray as $key => $value) { if(isset($newParamsRef[$key])) { $newParamsRef[$key][] = $value; } else { if(is_array($value)) { $newParamsRef[$key] = $value; } else { $newParamsRef[$key] = array($value); } } } } } return $this->translatePathElement(substr($path, $dotPos + 1), $newParamsRef); } else { return $paramsRef; } } if(($lbracktePos = strpos($currPath, '[')) !== false) { $subPath = substr($currPath, 0, $lbracktePos); $index = intval(substr($currPath, $lbracktePos+1, -1)); if(isset($paramsRef[$subPath]) && is_array($paramsRef[$subPath]) && isset($paramsRef[$subPath][$index])) { if($dotPos === false) { return $paramsRef[$subPath][$index]; } else { return $this->translatePathElement(substr($path, $dotPos + 1), $paramsRef[$subPath][$index]); } } } else { if(isset($paramsRef[$currPath])) { if($dotPos === false) { return $paramsRef[$currPath]; } else { return $this->translatePathElement(substr($path, $dotPos + 1), $paramsRef[$currPath]); } } } return null; }
[ "private", "function", "translatePathElement", "(", "$", "path", ",", "&", "$", "paramsRef", ")", "{", "$", "dotPos", "=", "strpos", "(", "$", "path", ",", "'.'", ")", ";", "$", "currPath", "=", "$", "path", ";", "if", "(", "$", "dotPos", "!==", "false", ")", "{", "$", "currPath", "=", "substr", "(", "$", "path", ",", "0", ",", "$", "dotPos", ")", ";", "}", "if", "(", "$", "currPath", "==", "'*'", ")", "{", "//Hell begins", "if", "(", "$", "dotPos", "!==", "false", ")", "{", "//create a new copy and merge everything from one level up", "$", "newParamsRef", "=", "array", "(", ")", ";", "foreach", "(", "$", "paramsRef", "as", "$", "subArray", ")", "{", "if", "(", "is_array", "(", "$", "subArray", ")", ")", "{", "foreach", "(", "$", "subArray", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "newParamsRef", "[", "$", "key", "]", ")", ")", "{", "$", "newParamsRef", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "}", "else", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "newParamsRef", "[", "$", "key", "]", "=", "$", "value", ";", "}", "else", "{", "$", "newParamsRef", "[", "$", "key", "]", "=", "array", "(", "$", "value", ")", ";", "}", "}", "}", "}", "}", "return", "$", "this", "->", "translatePathElement", "(", "substr", "(", "$", "path", ",", "$", "dotPos", "+", "1", ")", ",", "$", "newParamsRef", ")", ";", "}", "else", "{", "return", "$", "paramsRef", ";", "}", "}", "if", "(", "(", "$", "lbracktePos", "=", "strpos", "(", "$", "currPath", ",", "'['", ")", ")", "!==", "false", ")", "{", "$", "subPath", "=", "substr", "(", "$", "currPath", ",", "0", ",", "$", "lbracktePos", ")", ";", "$", "index", "=", "intval", "(", "substr", "(", "$", "currPath", ",", "$", "lbracktePos", "+", "1", ",", "-", "1", ")", ")", ";", "if", "(", "isset", "(", "$", "paramsRef", "[", "$", "subPath", "]", ")", "&&", "is_array", "(", "$", "paramsRef", "[", "$", "subPath", "]", ")", "&&", "isset", "(", "$", "paramsRef", "[", "$", "subPath", "]", "[", "$", "index", "]", ")", ")", "{", "if", "(", "$", "dotPos", "===", "false", ")", "{", "return", "$", "paramsRef", "[", "$", "subPath", "]", "[", "$", "index", "]", ";", "}", "else", "{", "return", "$", "this", "->", "translatePathElement", "(", "substr", "(", "$", "path", ",", "$", "dotPos", "+", "1", ")", ",", "$", "paramsRef", "[", "$", "subPath", "]", "[", "$", "index", "]", ")", ";", "}", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "paramsRef", "[", "$", "currPath", "]", ")", ")", "{", "if", "(", "$", "dotPos", "===", "false", ")", "{", "return", "$", "paramsRef", "[", "$", "currPath", "]", ";", "}", "else", "{", "return", "$", "this", "->", "translatePathElement", "(", "substr", "(", "$", "path", ",", "$", "dotPos", "+", "1", ")", ",", "$", "paramsRef", "[", "$", "currPath", "]", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Traverse through params according to path. This is a recursive function. @param string $path path to traverse @param array $paramsRef reference to the traversed array @return mixed found value/s
[ "Traverse", "through", "params", "according", "to", "path", ".", "This", "is", "a", "recursive", "function", "." ]
7d74ffaf51046ad13cbfc2b0b69d656a499f38ab
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Utility/JsonParser.php#L86-L164
15,779
Atlantic18/CoralCoreBundle
Utility/JsonParser.php
JsonParser.getMandatoryParam
public function getMandatoryParam($path) { $this->validatePath($path); $value = $this->translatePathElement($path, $this->params); if(null === $value) { throw new JsonException("Json mandatory param '$path' not found found."); } return $value; }
php
public function getMandatoryParam($path) { $this->validatePath($path); $value = $this->translatePathElement($path, $this->params); if(null === $value) { throw new JsonException("Json mandatory param '$path' not found found."); } return $value; }
[ "public", "function", "getMandatoryParam", "(", "$", "path", ")", "{", "$", "this", "->", "validatePath", "(", "$", "path", ")", ";", "$", "value", "=", "$", "this", "->", "translatePathElement", "(", "$", "path", ",", "$", "this", "->", "params", ")", ";", "if", "(", "null", "===", "$", "value", ")", "{", "throw", "new", "JsonException", "(", "\"Json mandatory param '$path' not found found.\"", ")", ";", "}", "return", "$", "value", ";", "}" ]
Returns json key value or throws exception if key doesn't exist @throws JsonException If key doesn't exist @param string $path key @return mixed value
[ "Returns", "json", "key", "value", "or", "throws", "exception", "if", "key", "doesn", "t", "exist" ]
7d74ffaf51046ad13cbfc2b0b69d656a499f38ab
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Utility/JsonParser.php#L173-L184
15,780
Atlantic18/CoralCoreBundle
Utility/JsonParser.php
JsonParser.hasParam
public function hasParam($path) { $this->validatePath($path); $value = $this->translatePathElement($path, $this->params); return (null === $value) ? false : true; }
php
public function hasParam($path) { $this->validatePath($path); $value = $this->translatePathElement($path, $this->params); return (null === $value) ? false : true; }
[ "public", "function", "hasParam", "(", "$", "path", ")", "{", "$", "this", "->", "validatePath", "(", "$", "path", ")", ";", "$", "value", "=", "$", "this", "->", "translatePathElement", "(", "$", "path", ",", "$", "this", "->", "params", ")", ";", "return", "(", "null", "===", "$", "value", ")", "?", "false", ":", "true", ";", "}" ]
Returns json true if path exists @param string $path json path @return boolean true if path exists
[ "Returns", "json", "true", "if", "path", "exists" ]
7d74ffaf51046ad13cbfc2b0b69d656a499f38ab
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Utility/JsonParser.php#L192-L199
15,781
Atlantic18/CoralCoreBundle
Utility/JsonParser.php
JsonParser.getOptionalParam
public function getOptionalParam($path, $default = false) { $this->validatePath($path); $value = $this->translatePathElement($path, $this->params); if(null === $value) { return (null === $default) ? null : $default; } return $value; }
php
public function getOptionalParam($path, $default = false) { $this->validatePath($path); $value = $this->translatePathElement($path, $this->params); if(null === $value) { return (null === $default) ? null : $default; } return $value; }
[ "public", "function", "getOptionalParam", "(", "$", "path", ",", "$", "default", "=", "false", ")", "{", "$", "this", "->", "validatePath", "(", "$", "path", ")", ";", "$", "value", "=", "$", "this", "->", "translatePathElement", "(", "$", "path", ",", "$", "this", "->", "params", ")", ";", "if", "(", "null", "===", "$", "value", ")", "{", "return", "(", "null", "===", "$", "default", ")", "?", "null", ":", "$", "default", ";", "}", "return", "$", "value", ";", "}" ]
Returns json key value or false if key doesn't exist @param string $path json key @param string $default default value to be returned @return mixed value
[ "Returns", "json", "key", "value", "or", "false", "if", "key", "doesn", "t", "exist" ]
7d74ffaf51046ad13cbfc2b0b69d656a499f38ab
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Utility/JsonParser.php#L208-L220
15,782
matthiasbayer/datadog-client
src/Bayer/DataDogClient/Client.php
Client.sendSeries
public function sendSeries(Series $series) { $metrics = $series->getMetrics(); if (empty($metrics)) { throw new EmptySeriesException('The series must contain metric data to send'); } $this->send( self::ENDPOINT_SERIES . $this->getApiKey(), $series->toArray() ); return $this; }
php
public function sendSeries(Series $series) { $metrics = $series->getMetrics(); if (empty($metrics)) { throw new EmptySeriesException('The series must contain metric data to send'); } $this->send( self::ENDPOINT_SERIES . $this->getApiKey(), $series->toArray() ); return $this; }
[ "public", "function", "sendSeries", "(", "Series", "$", "series", ")", "{", "$", "metrics", "=", "$", "series", "->", "getMetrics", "(", ")", ";", "if", "(", "empty", "(", "$", "metrics", ")", ")", "{", "throw", "new", "EmptySeriesException", "(", "'The series must contain metric data to send'", ")", ";", "}", "$", "this", "->", "send", "(", "self", "::", "ENDPOINT_SERIES", ".", "$", "this", "->", "getApiKey", "(", ")", ",", "$", "series", "->", "toArray", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Send a Series object to datadog @param Series $series @throws Client\EmptySeriesException @return Client
[ "Send", "a", "Series", "object", "to", "datadog" ]
e625132c34bf36f783077c9ee4ed3214633cd272
https://github.com/matthiasbayer/datadog-client/blob/e625132c34bf36f783077c9ee4ed3214633cd272/src/Bayer/DataDogClient/Client.php#L97-L109
15,783
matthiasbayer/datadog-client
src/Bayer/DataDogClient/Client.php
Client.sendMetric
public function sendMetric(Metric $metric) { $points = $metric->getPoints(); if (empty($points)) { throw new EmptyMetricException('The metric must contain points to send'); } $this->sendSeries(new Series($metric)); return $this; }
php
public function sendMetric(Metric $metric) { $points = $metric->getPoints(); if (empty($points)) { throw new EmptyMetricException('The metric must contain points to send'); } $this->sendSeries(new Series($metric)); return $this; }
[ "public", "function", "sendMetric", "(", "Metric", "$", "metric", ")", "{", "$", "points", "=", "$", "metric", "->", "getPoints", "(", ")", ";", "if", "(", "empty", "(", "$", "points", ")", ")", "{", "throw", "new", "EmptyMetricException", "(", "'The metric must contain points to send'", ")", ";", "}", "$", "this", "->", "sendSeries", "(", "new", "Series", "(", "$", "metric", ")", ")", ";", "return", "$", "this", ";", "}" ]
Send a Metric object to datadog The metric object will be encapsulated into a dummy series, as the datadog API requires. @param Metric $metric @throws EmptyMetricException @return Client
[ "Send", "a", "Metric", "object", "to", "datadog" ]
e625132c34bf36f783077c9ee4ed3214633cd272
https://github.com/matthiasbayer/datadog-client/blob/e625132c34bf36f783077c9ee4ed3214633cd272/src/Bayer/DataDogClient/Client.php#L122-L131
15,784
matthiasbayer/datadog-client
src/Bayer/DataDogClient/Client.php
Client.metric
public function metric($name, array $points, array $options = array()) { return $this->sendMetric( Factory::buildMetric($name, $points, $options) ); }
php
public function metric($name, array $points, array $options = array()) { return $this->sendMetric( Factory::buildMetric($name, $points, $options) ); }
[ "public", "function", "metric", "(", "$", "name", ",", "array", "$", "points", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "sendMetric", "(", "Factory", "::", "buildMetric", "(", "$", "name", ",", "$", "points", ",", "$", "options", ")", ")", ";", "}" ]
Send metric data to datadog The given values will be used to create a new Metric object, encapsulated it into a Series and sent. @param string $name @param array $points @param array $options @return Client
[ "Send", "metric", "data", "to", "datadog" ]
e625132c34bf36f783077c9ee4ed3214633cd272
https://github.com/matthiasbayer/datadog-client/blob/e625132c34bf36f783077c9ee4ed3214633cd272/src/Bayer/DataDogClient/Client.php#L145-L149
15,785
matthiasbayer/datadog-client
src/Bayer/DataDogClient/Client.php
Client.event
public function event($text, $title = '', array $options = array()) { return $this->sendEvent( Factory::buildEvent($text, $title, $options) ); }
php
public function event($text, $title = '', array $options = array()) { return $this->sendEvent( Factory::buildEvent($text, $title, $options) ); }
[ "public", "function", "event", "(", "$", "text", ",", "$", "title", "=", "''", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "sendEvent", "(", "Factory", "::", "buildEvent", "(", "$", "text", ",", "$", "title", ",", "$", "options", ")", ")", ";", "}" ]
Send an event to datadog The given values will be used to create a new Event object which will be sent. @param string $text @param string $title @param array $options @return Client
[ "Send", "an", "event", "to", "datadog" ]
e625132c34bf36f783077c9ee4ed3214633cd272
https://github.com/matthiasbayer/datadog-client/blob/e625132c34bf36f783077c9ee4ed3214633cd272/src/Bayer/DataDogClient/Client.php#L163-L167
15,786
matthiasbayer/datadog-client
src/Bayer/DataDogClient/Client.php
Client.sendEvent
public function sendEvent(Event $event) { $this->send( self::ENDPOINT_EVENT . $this->getApiKey(), $event->toArray() ); return $this; }
php
public function sendEvent(Event $event) { $this->send( self::ENDPOINT_EVENT . $this->getApiKey(), $event->toArray() ); return $this; }
[ "public", "function", "sendEvent", "(", "Event", "$", "event", ")", "{", "$", "this", "->", "send", "(", "self", "::", "ENDPOINT_EVENT", ".", "$", "this", "->", "getApiKey", "(", ")", ",", "$", "event", "->", "toArray", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Send an Event object to datadog @param Event $event @return Client
[ "Send", "an", "Event", "object", "to", "datadog" ]
e625132c34bf36f783077c9ee4ed3214633cd272
https://github.com/matthiasbayer/datadog-client/blob/e625132c34bf36f783077c9ee4ed3214633cd272/src/Bayer/DataDogClient/Client.php#L176-L183
15,787
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/CoreBundle/Manager/OrderAddressManager.php
OrderAddressManager.getContactData
public function getContactData($addressData, Contact $contact = null) { $result = array(); // if account is set, take account's name if ($addressData && isset($addressData['firstName']) && isset($addressData['lastName'])) { $result['firstName'] = $addressData['firstName']; $result['lastName'] = $addressData['lastName']; $result['fullName'] = $result['firstName'] . ' ' . $result['lastName']; if (isset($addressData['title'])) { $result['title'] = $addressData['title']; } if (isset($addressData['salutation'])) { $result['salutation'] = $addressData['salutation']; } } elseif ($contact) { $result['firstName'] = $contact->getFirstName(); $result['lastName'] = $contact->getLastName(); $result['fullName'] = $contact->getFullName(); $result['salutation'] = $contact->getFormOfAddress(); if ($contact->getTitle() !== null) { $result['title'] = $contact->getTitle()->getTitle(); } } else { throw new MissingAttributeException('firstName, lastName or contact'); } return $result; }
php
public function getContactData($addressData, Contact $contact = null) { $result = array(); // if account is set, take account's name if ($addressData && isset($addressData['firstName']) && isset($addressData['lastName'])) { $result['firstName'] = $addressData['firstName']; $result['lastName'] = $addressData['lastName']; $result['fullName'] = $result['firstName'] . ' ' . $result['lastName']; if (isset($addressData['title'])) { $result['title'] = $addressData['title']; } if (isset($addressData['salutation'])) { $result['salutation'] = $addressData['salutation']; } } elseif ($contact) { $result['firstName'] = $contact->getFirstName(); $result['lastName'] = $contact->getLastName(); $result['fullName'] = $contact->getFullName(); $result['salutation'] = $contact->getFormOfAddress(); if ($contact->getTitle() !== null) { $result['title'] = $contact->getTitle()->getTitle(); } } else { throw new MissingAttributeException('firstName, lastName or contact'); } return $result; }
[ "public", "function", "getContactData", "(", "$", "addressData", ",", "Contact", "$", "contact", "=", "null", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// if account is set, take account's name", "if", "(", "$", "addressData", "&&", "isset", "(", "$", "addressData", "[", "'firstName'", "]", ")", "&&", "isset", "(", "$", "addressData", "[", "'lastName'", "]", ")", ")", "{", "$", "result", "[", "'firstName'", "]", "=", "$", "addressData", "[", "'firstName'", "]", ";", "$", "result", "[", "'lastName'", "]", "=", "$", "addressData", "[", "'lastName'", "]", ";", "$", "result", "[", "'fullName'", "]", "=", "$", "result", "[", "'firstName'", "]", ".", "' '", ".", "$", "result", "[", "'lastName'", "]", ";", "if", "(", "isset", "(", "$", "addressData", "[", "'title'", "]", ")", ")", "{", "$", "result", "[", "'title'", "]", "=", "$", "addressData", "[", "'title'", "]", ";", "}", "if", "(", "isset", "(", "$", "addressData", "[", "'salutation'", "]", ")", ")", "{", "$", "result", "[", "'salutation'", "]", "=", "$", "addressData", "[", "'salutation'", "]", ";", "}", "}", "elseif", "(", "$", "contact", ")", "{", "$", "result", "[", "'firstName'", "]", "=", "$", "contact", "->", "getFirstName", "(", ")", ";", "$", "result", "[", "'lastName'", "]", "=", "$", "contact", "->", "getLastName", "(", ")", ";", "$", "result", "[", "'fullName'", "]", "=", "$", "contact", "->", "getFullName", "(", ")", ";", "$", "result", "[", "'salutation'", "]", "=", "$", "contact", "->", "getFormOfAddress", "(", ")", ";", "if", "(", "$", "contact", "->", "getTitle", "(", ")", "!==", "null", ")", "{", "$", "result", "[", "'title'", "]", "=", "$", "contact", "->", "getTitle", "(", ")", "->", "getTitle", "(", ")", ";", "}", "}", "else", "{", "throw", "new", "MissingAttributeException", "(", "'firstName, lastName or contact'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns contact data as an array. either by provided address or contact @param array $addressData @param Contact $contact @throws MissingAttributeException @return array
[ "Returns", "contact", "data", "as", "an", "array", ".", "either", "by", "provided", "address", "or", "contact" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Manager/OrderAddressManager.php#L226-L253
15,788
FrenchFrogs/framework
src/Table/Table/Datatable.php
Datatable.addDatatableButtonExport
public function addDatatableButtonExport($text = 'Export CSV') { $this->hasToken() ?: $this->generateToken(); $this->addDatatableButtonLink($text, route('datatable-export', ['token' => $this->getToken()])); return $this; }
php
public function addDatatableButtonExport($text = 'Export CSV') { $this->hasToken() ?: $this->generateToken(); $this->addDatatableButtonLink($text, route('datatable-export', ['token' => $this->getToken()])); return $this; }
[ "public", "function", "addDatatableButtonExport", "(", "$", "text", "=", "'Export CSV'", ")", "{", "$", "this", "->", "hasToken", "(", ")", "?", ":", "$", "this", "->", "generateToken", "(", ")", ";", "$", "this", "->", "addDatatableButtonLink", "(", "$", "text", ",", "route", "(", "'datatable-export'", ",", "[", "'token'", "=>", "$", "this", "->", "getToken", "(", ")", "]", ")", ")", ";", "return", "$", "this", ";", "}" ]
Ajoute un Bouton d'export @param $text @param $url @return $this
[ "Ajoute", "un", "Bouton", "d", "export" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Datatable.php#L99-L104
15,789
FrenchFrogs/framework
src/Table/Table/Datatable.php
Datatable.save
public function save() { if(!$this->hasToken()) { if (static::hasSingleToken()) { $this->setToken(static::getSingleToken()); } else { $this->generateToken(); } } if (!$this->hasConstructor()) { $this->setConstructor(static::class); } Session::push($this->getToken(), json_encode(['constructor' => $this->getConstructor()])); return $this; }
php
public function save() { if(!$this->hasToken()) { if (static::hasSingleToken()) { $this->setToken(static::getSingleToken()); } else { $this->generateToken(); } } if (!$this->hasConstructor()) { $this->setConstructor(static::class); } Session::push($this->getToken(), json_encode(['constructor' => $this->getConstructor()])); return $this; }
[ "public", "function", "save", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasToken", "(", ")", ")", "{", "if", "(", "static", "::", "hasSingleToken", "(", ")", ")", "{", "$", "this", "->", "setToken", "(", "static", "::", "getSingleToken", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "generateToken", "(", ")", ";", "}", "}", "if", "(", "!", "$", "this", "->", "hasConstructor", "(", ")", ")", "{", "$", "this", "->", "setConstructor", "(", "static", "::", "class", ")", ";", "}", "Session", "::", "push", "(", "$", "this", "->", "getToken", "(", ")", ",", "json_encode", "(", "[", "'constructor'", "=>", "$", "this", "->", "getConstructor", "(", ")", "]", ")", ")", ";", "return", "$", "this", ";", "}" ]
Save the Table configuration in Session
[ "Save", "the", "Table", "configuration", "in", "Session" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Datatable.php#L411-L427
15,790
FrenchFrogs/framework
src/Table/Table/Datatable.php
Datatable.load
static public function load($token = null) { // if single token is set, we keep it if (is_null($token) && static::hasSingleToken()) { $token = static::getSingleToken(); } // if no session are set, we set a new one only is class has a singleToken if (!Session::has($token)){ if (static::hasSingleToken()) { Session::push($token, json_encode(['constructor' => static::class])); } else { throw new \InvalidArgumentException('Token "' . $token . '" is not valid'); } } // load configuration $config = Session::get($token); $config = json_decode($config[0], true); $constructor = $config['constructor']; // construct Table polliwog if (preg_match('#(?<class>.+)::(?<method>.+)#', $constructor, $match)) { $method = $match['method']; // extract parameters $params = []; if (preg_match('#(?<method>[^:]+):(?<params>.+)#', $method, $params)) { $method = $params['method']; $params = explode(',', $params['params']); } $table = call_user_func_array([$match['class'], $method], $params); } else { $instance = new \ReflectionClass($config->constructor); $table = $instance->newInstance(); } // validate that instance is viable if (!($table instanceof static)) { throw new \Exception('Loaded instance is not viable'); } return $table; }
php
static public function load($token = null) { // if single token is set, we keep it if (is_null($token) && static::hasSingleToken()) { $token = static::getSingleToken(); } // if no session are set, we set a new one only is class has a singleToken if (!Session::has($token)){ if (static::hasSingleToken()) { Session::push($token, json_encode(['constructor' => static::class])); } else { throw new \InvalidArgumentException('Token "' . $token . '" is not valid'); } } // load configuration $config = Session::get($token); $config = json_decode($config[0], true); $constructor = $config['constructor']; // construct Table polliwog if (preg_match('#(?<class>.+)::(?<method>.+)#', $constructor, $match)) { $method = $match['method']; // extract parameters $params = []; if (preg_match('#(?<method>[^:]+):(?<params>.+)#', $method, $params)) { $method = $params['method']; $params = explode(',', $params['params']); } $table = call_user_func_array([$match['class'], $method], $params); } else { $instance = new \ReflectionClass($config->constructor); $table = $instance->newInstance(); } // validate that instance is viable if (!($table instanceof static)) { throw new \Exception('Loaded instance is not viable'); } return $table; }
[ "static", "public", "function", "load", "(", "$", "token", "=", "null", ")", "{", "// if single token is set, we keep it", "if", "(", "is_null", "(", "$", "token", ")", "&&", "static", "::", "hasSingleToken", "(", ")", ")", "{", "$", "token", "=", "static", "::", "getSingleToken", "(", ")", ";", "}", "// if no session are set, we set a new one only is class has a singleToken", "if", "(", "!", "Session", "::", "has", "(", "$", "token", ")", ")", "{", "if", "(", "static", "::", "hasSingleToken", "(", ")", ")", "{", "Session", "::", "push", "(", "$", "token", ",", "json_encode", "(", "[", "'constructor'", "=>", "static", "::", "class", "]", ")", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Token \"'", ".", "$", "token", ".", "'\" is not valid'", ")", ";", "}", "}", "// load configuration", "$", "config", "=", "Session", "::", "get", "(", "$", "token", ")", ";", "$", "config", "=", "json_decode", "(", "$", "config", "[", "0", "]", ",", "true", ")", ";", "$", "constructor", "=", "$", "config", "[", "'constructor'", "]", ";", "// construct Table polliwog", "if", "(", "preg_match", "(", "'#(?<class>.+)::(?<method>.+)#'", ",", "$", "constructor", ",", "$", "match", ")", ")", "{", "$", "method", "=", "$", "match", "[", "'method'", "]", ";", "// extract parameters", "$", "params", "=", "[", "]", ";", "if", "(", "preg_match", "(", "'#(?<method>[^:]+):(?<params>.+)#'", ",", "$", "method", ",", "$", "params", ")", ")", "{", "$", "method", "=", "$", "params", "[", "'method'", "]", ";", "$", "params", "=", "explode", "(", "','", ",", "$", "params", "[", "'params'", "]", ")", ";", "}", "$", "table", "=", "call_user_func_array", "(", "[", "$", "match", "[", "'class'", "]", ",", "$", "method", "]", ",", "$", "params", ")", ";", "}", "else", "{", "$", "instance", "=", "new", "\\", "ReflectionClass", "(", "$", "config", "->", "constructor", ")", ";", "$", "table", "=", "$", "instance", "->", "newInstance", "(", ")", ";", "}", "// validate that instance is viable", "if", "(", "!", "(", "$", "table", "instanceof", "static", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Loaded instance is not viable'", ")", ";", "}", "return", "$", "table", ";", "}" ]
Load a datable from a token @param $token @return Table
[ "Load", "a", "datable", "from", "a", "token" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Datatable.php#L436-L480
15,791
VDMi/Guzzle-oAuth
src/GuzzleOauth/BaseConsumerOauth1.php
BaseConsumerOauth1.getRequestToken
public function getRequestToken($callback_uri = NULL) { // set callback_uri $this->getOauthPlugin()->setCallbackUri($callback_uri); //Get request token $response = $this->get($this->getConfig('request_token_path'))->send(); $request_token = array(); parse_str($response->getBody(), $request_token); // Throw exception if the callback isn't confirmed if (!isset($request_token['oauth_callback_confirmed']) || !in_array($request_token['oauth_callback_confirmed'], array(true, "true"))) { throw new \Exception("There was an error regarding the callback confirmation"); } // Return RequestToken return $request_token; }
php
public function getRequestToken($callback_uri = NULL) { // set callback_uri $this->getOauthPlugin()->setCallbackUri($callback_uri); //Get request token $response = $this->get($this->getConfig('request_token_path'))->send(); $request_token = array(); parse_str($response->getBody(), $request_token); // Throw exception if the callback isn't confirmed if (!isset($request_token['oauth_callback_confirmed']) || !in_array($request_token['oauth_callback_confirmed'], array(true, "true"))) { throw new \Exception("There was an error regarding the callback confirmation"); } // Return RequestToken return $request_token; }
[ "public", "function", "getRequestToken", "(", "$", "callback_uri", "=", "NULL", ")", "{", "// set callback_uri", "$", "this", "->", "getOauthPlugin", "(", ")", "->", "setCallbackUri", "(", "$", "callback_uri", ")", ";", "//Get request token", "$", "response", "=", "$", "this", "->", "get", "(", "$", "this", "->", "getConfig", "(", "'request_token_path'", ")", ")", "->", "send", "(", ")", ";", "$", "request_token", "=", "array", "(", ")", ";", "parse_str", "(", "$", "response", "->", "getBody", "(", ")", ",", "$", "request_token", ")", ";", "// Throw exception if the callback isn't confirmed", "if", "(", "!", "isset", "(", "$", "request_token", "[", "'oauth_callback_confirmed'", "]", ")", "||", "!", "in_array", "(", "$", "request_token", "[", "'oauth_callback_confirmed'", "]", ",", "array", "(", "true", ",", "\"true\"", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"There was an error regarding the callback confirmation\"", ")", ";", "}", "// Return RequestToken", "return", "$", "request_token", ";", "}" ]
Get a Request Token.
[ "Get", "a", "Request", "Token", "." ]
e2b2561e4e402e13ba605082bf768b29942f90cb
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth1.php#L59-L76
15,792
VDMi/Guzzle-oAuth
src/GuzzleOauth/BaseConsumerOauth1.php
BaseConsumerOauth1.getAuthorizeUrl
public function getAuthorizeUrl($request_token, $callback_uri = NULL, $state = NULL) { $request_token = array( 'oauth_token' => is_array($request_token) ? $request_token['oauth_token'] : $request_token, ); // authorize $url = Url::factory($this->getConfig('base_url')); $url->addPath($this->getConfig('authorize_path')); $url->setQuery($request_token); return (string)$url; }
php
public function getAuthorizeUrl($request_token, $callback_uri = NULL, $state = NULL) { $request_token = array( 'oauth_token' => is_array($request_token) ? $request_token['oauth_token'] : $request_token, ); // authorize $url = Url::factory($this->getConfig('base_url')); $url->addPath($this->getConfig('authorize_path')); $url->setQuery($request_token); return (string)$url; }
[ "public", "function", "getAuthorizeUrl", "(", "$", "request_token", ",", "$", "callback_uri", "=", "NULL", ",", "$", "state", "=", "NULL", ")", "{", "$", "request_token", "=", "array", "(", "'oauth_token'", "=>", "is_array", "(", "$", "request_token", ")", "?", "$", "request_token", "[", "'oauth_token'", "]", ":", "$", "request_token", ",", ")", ";", "// authorize", "$", "url", "=", "Url", "::", "factory", "(", "$", "this", "->", "getConfig", "(", "'base_url'", ")", ")", ";", "$", "url", "->", "addPath", "(", "$", "this", "->", "getConfig", "(", "'authorize_path'", ")", ")", ";", "$", "url", "->", "setQuery", "(", "$", "request_token", ")", ";", "return", "(", "string", ")", "$", "url", ";", "}" ]
Return a authorize url.
[ "Return", "a", "authorize", "url", "." ]
e2b2561e4e402e13ba605082bf768b29942f90cb
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth1.php#L81-L90
15,793
codeburnerframework/router
src/Group.php
Group.set
public function set($route) { if ($route instanceof Group) { foreach ($route->all() as $r) $this->routes[] = $r; } else $this->routes[] = $route; return $this; }
php
public function set($route) { if ($route instanceof Group) { foreach ($route->all() as $r) $this->routes[] = $r; } else $this->routes[] = $route; return $this; }
[ "public", "function", "set", "(", "$", "route", ")", "{", "if", "(", "$", "route", "instanceof", "Group", ")", "{", "foreach", "(", "$", "route", "->", "all", "(", ")", "as", "$", "r", ")", "$", "this", "->", "routes", "[", "]", "=", "$", "r", ";", "}", "else", "$", "this", "->", "routes", "[", "]", "=", "$", "route", ";", "return", "$", "this", ";", "}" ]
Set a new Route or merge an existing group of routes. @param Group|Route $route @return self
[ "Set", "a", "new", "Route", "or", "merge", "an", "existing", "group", "of", "routes", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L37-L44
15,794
codeburnerframework/router
src/Group.php
Group.setMethod
public function setMethod($method) { foreach ($this->routes as $route) $route->setMethod($method); return $this; }
php
public function setMethod($method) { foreach ($this->routes as $route) $route->setMethod($method); return $this; }
[ "public", "function", "setMethod", "(", "$", "method", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "$", "route", "->", "setMethod", "(", "$", "method", ")", ";", "return", "$", "this", ";", "}" ]
Set one HTTP method to all grouped routes. @param string $method The HTTP Method @return self
[ "Set", "one", "HTTP", "method", "to", "all", "grouped", "routes", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L105-L110
15,795
codeburnerframework/router
src/Group.php
Group.setAction
public function setAction($action) { foreach ($this->routes as $route) $route->setAction($action); return $this; }
php
public function setAction($action) { foreach ($this->routes as $route) $route->setAction($action); return $this; }
[ "public", "function", "setAction", "(", "$", "action", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "$", "route", "->", "setAction", "(", "$", "action", ")", ";", "return", "$", "this", ";", "}" ]
Set one action to all grouped routes. @param string $action @return self
[ "Set", "one", "action", "to", "all", "grouped", "routes", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L119-L124
15,796
codeburnerframework/router
src/Group.php
Group.setPrefix
public function setPrefix($prefix) { $prefix = "/" . ltrim($prefix, "/"); $routes = []; foreach ($this->routes as $route) $routes[] = $route->setPattern(rtrim($prefix . $route->getPattern(), "/")); $this->routes = $routes; return $this; }
php
public function setPrefix($prefix) { $prefix = "/" . ltrim($prefix, "/"); $routes = []; foreach ($this->routes as $route) $routes[] = $route->setPattern(rtrim($prefix . $route->getPattern(), "/")); $this->routes = $routes; return $this; }
[ "public", "function", "setPrefix", "(", "$", "prefix", ")", "{", "$", "prefix", "=", "\"/\"", ".", "ltrim", "(", "$", "prefix", ",", "\"/\"", ")", ";", "$", "routes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "$", "routes", "[", "]", "=", "$", "route", "->", "setPattern", "(", "rtrim", "(", "$", "prefix", ".", "$", "route", "->", "getPattern", "(", ")", ",", "\"/\"", ")", ")", ";", "$", "this", "->", "routes", "=", "$", "routes", ";", "return", "$", "this", ";", "}" ]
Add a prefix to all grouped routes pattern. @param string $prefix @return self
[ "Add", "a", "prefix", "to", "all", "grouped", "routes", "pattern", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L147-L155
15,797
codeburnerframework/router
src/Group.php
Group.setMetadata
public function setMetadata($key, $value) { foreach ($this->routes as $route) $route->setMetadata($key, $value); return $this; }
php
public function setMetadata($key, $value) { foreach ($this->routes as $route) $route->setMetadata($key, $value); return $this; }
[ "public", "function", "setMetadata", "(", "$", "key", ",", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "$", "route", "->", "setMetadata", "(", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Set metadata to all grouped routes. @param string $key @param string $value @return $this
[ "Set", "metadata", "to", "all", "grouped", "routes", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L166-L171
15,798
codeburnerframework/router
src/Group.php
Group.setMetadataArray
public function setMetadataArray(array $metadata) { foreach ($this->routes as $route) $route->setMetadataArray($metadata); return $this; }
php
public function setMetadataArray(array $metadata) { foreach ($this->routes as $route) $route->setMetadataArray($metadata); return $this; }
[ "public", "function", "setMetadataArray", "(", "array", "$", "metadata", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "$", "route", "->", "setMetadataArray", "(", "$", "metadata", ")", ";", "return", "$", "this", ";", "}" ]
Set a bunch of metadata to all grouped routes. @param mixed[] $metadata @return $this
[ "Set", "a", "bunch", "of", "metadata", "to", "all", "grouped", "routes", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L180-L185
15,799
codeburnerframework/router
src/Group.php
Group.setDefaults
public function setDefaults(array $defaults) { foreach ($this->routes as $route) $route->setDefaults($defaults); return $this; }
php
public function setDefaults(array $defaults) { foreach ($this->routes as $route) $route->setDefaults($defaults); return $this; }
[ "public", "function", "setDefaults", "(", "array", "$", "defaults", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "$", "route", "->", "setDefaults", "(", "$", "defaults", ")", ";", "return", "$", "this", ";", "}" ]
Set default parameters to all grouped routes. @param mixed[] $defaults @return $this
[ "Set", "default", "parameters", "to", "all", "grouped", "routes", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Group.php#L194-L199