repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
yuncms/framework
src/admin/UserItemController.php
UserItemController.actionIndex
public function actionIndex() { $searchModel = new UserAuthItemSearch(['type' => $this->type]); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
php
public function actionIndex() { $searchModel = new UserAuthItemSearch(['type' => $this->type]); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "new", "UserAuthItemSearch", "(", "[", "'type'", "=>", "$", "this", "->", "type", "]", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "getQueryParams", "(", ")", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'dataProvider'", "=>", "$", "dataProvider", ",", "'searchModel'", "=>", "$", "searchModel", ",", "]", ")", ";", "}" ]
Lists all AuthItem models. @return mixed @throws \yii\base\InvalidConfigException
[ "Lists", "all", "AuthItem", "models", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/UserItemController.php#L48-L57
yuncms/framework
src/admin/UserItemController.php
UserItemController.actionCreate
public function actionCreate() { $model = new UserAuthItem(null); $model->type = $this->type; if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('yuncms','Create success.')); return $this->redirect(['view', 'id' => $model->name]); } else { return $this->render('create', ['model' => $model]); } }
php
public function actionCreate() { $model = new UserAuthItem(null); $model->type = $this->type; if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('yuncms','Create success.')); return $this->redirect(['view', 'id' => $model->name]); } else { return $this->render('create', ['model' => $model]); } }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "model", "=", "new", "UserAuthItem", "(", "null", ")", ";", "$", "model", "->", "type", "=", "$", "this", "->", "type", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "setFlash", "(", "'success'", ",", "Yii", "::", "t", "(", "'yuncms'", ",", "'Create success.'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'view'", ",", "'id'", "=>", "$", "model", "->", "name", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "render", "(", "'create'", ",", "[", "'model'", "=>", "$", "model", "]", ")", ";", "}", "}" ]
Creates a new AuthItem model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed @throws \Exception
[ "Creates", "a", "new", "AuthItem", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/UserItemController.php#L79-L89
yuncms/framework
src/admin/UserItemController.php
UserItemController.actionDelete
public function actionDelete($id) { $model = $this->findModel($id); Yii::$app->getUserAuthManager()->remove($model->item); UserRBACHelper::invalidate(); return $this->redirect(['index']); }
php
public function actionDelete($id) { $model = $this->findModel($id); Yii::$app->getUserAuthManager()->remove($model->item); UserRBACHelper::invalidate(); return $this->redirect(['index']); }
[ "public", "function", "actionDelete", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "Yii", "::", "$", "app", "->", "getUserAuthManager", "(", ")", "->", "remove", "(", "$", "model", "->", "item", ")", ";", "UserRBACHelper", "::", "invalidate", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}" ]
Deletes an existing AuthItem model. If deletion is successful, the browser will be redirected to the 'index' page. @param string $id @return mixed @throws NotFoundHttpException @throws \yii\base\InvalidConfigException
[ "Deletes", "an", "existing", "AuthItem", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "index", "page", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/UserItemController.php#L117-L123
yuncms/framework
src/admin/UserItemController.php
UserItemController.findModel
protected function findModel($id) { $auth = Yii::$app->getUserAuthManager(); $item = $this->type === Item::TYPE_ROLE ? $auth->getRole($id) : $auth->getPermission($id); if ($item) { return new UserAuthItem($item); } else { throw new NotFoundHttpException(Yii::t('yuncms', 'The requested page does not exist.')); } }
php
protected function findModel($id) { $auth = Yii::$app->getUserAuthManager(); $item = $this->type === Item::TYPE_ROLE ? $auth->getRole($id) : $auth->getPermission($id); if ($item) { return new UserAuthItem($item); } else { throw new NotFoundHttpException(Yii::t('yuncms', 'The requested page does not exist.')); } }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "$", "auth", "=", "Yii", "::", "$", "app", "->", "getUserAuthManager", "(", ")", ";", "$", "item", "=", "$", "this", "->", "type", "===", "Item", "::", "TYPE_ROLE", "?", "$", "auth", "->", "getRole", "(", "$", "id", ")", ":", "$", "auth", "->", "getPermission", "(", "$", "id", ")", ";", "if", "(", "$", "item", ")", "{", "return", "new", "UserAuthItem", "(", "$", "item", ")", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "Yii", "::", "t", "(", "'yuncms'", ",", "'The requested page does not exist.'", ")", ")", ";", "}", "}" ]
Finds the AuthItem model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param string $id @return UserAuthItem the loaded model @throws NotFoundHttpException if the model cannot be found @throws \yii\base\InvalidConfigException
[ "Finds", "the", "AuthItem", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/UserItemController.php#L191-L200
phug-php/formatter
src/Phug/Formatter/Element/AbstractMarkupElement.php
AbstractMarkupElement.belongsTo
public function belongsTo(array $tagList) { if (is_string($this->getName())) { return in_array(strtolower($this->getName()), $tagList); } return false; }
php
public function belongsTo(array $tagList) { if (is_string($this->getName())) { return in_array(strtolower($this->getName()), $tagList); } return false; }
[ "public", "function", "belongsTo", "(", "array", "$", "tagList", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "getName", "(", ")", ")", ")", "{", "return", "in_array", "(", "strtolower", "(", "$", "this", "->", "getName", "(", ")", ")", ",", "$", "tagList", ")", ";", "}", "return", "false", ";", "}" ]
Return true if the tag name is in the given list. @param array $tagList @return bool
[ "Return", "true", "if", "the", "tag", "name", "is", "in", "the", "given", "list", "." ]
train
https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter/Element/AbstractMarkupElement.php#L19-L26
qcubed/orm
src/Database/Mysqli5/MysqliRow.php
MysqliRow.getColumn
public function getColumn($strColumnName, $strColumnType = null) { if (!isset($this->strColumnArray[$strColumnName])) { return null; } $strColumnValue = $this->strColumnArray[$strColumnName]; switch ($strColumnType) { case FieldType::BIT: // Account for single bit value $chrBit = $strColumnValue; if ((strlen($chrBit) == 1) && (ord($chrBit) == 0)) { return false; } // Otherwise, use PHP conditional to determine true or false return ($strColumnValue) ? true : false; case FieldType::BLOB: case FieldType::CHAR: case FieldType::VAR_CHAR: return Type::cast($strColumnValue, Type::STRING); case FieldType::DATE: return new QDateTime($strColumnValue, null, QDateTime::DATE_ONLY_TYPE); case FieldType::DATE_TIME: return new QDateTime($strColumnValue, null, QDateTime::DATE_AND_TIME_TYPE); case FieldType::TIME: return new QDateTime($strColumnValue, null, QDateTime::TIME_ONLY_TYPE); case FieldType::FLOAT: return Type::cast($strColumnValue, Type::FLOAT); case FieldType::INTEGER: return Type::cast($strColumnValue, Type::INTEGER); default: return $strColumnValue; } }
php
public function getColumn($strColumnName, $strColumnType = null) { if (!isset($this->strColumnArray[$strColumnName])) { return null; } $strColumnValue = $this->strColumnArray[$strColumnName]; switch ($strColumnType) { case FieldType::BIT: // Account for single bit value $chrBit = $strColumnValue; if ((strlen($chrBit) == 1) && (ord($chrBit) == 0)) { return false; } // Otherwise, use PHP conditional to determine true or false return ($strColumnValue) ? true : false; case FieldType::BLOB: case FieldType::CHAR: case FieldType::VAR_CHAR: return Type::cast($strColumnValue, Type::STRING); case FieldType::DATE: return new QDateTime($strColumnValue, null, QDateTime::DATE_ONLY_TYPE); case FieldType::DATE_TIME: return new QDateTime($strColumnValue, null, QDateTime::DATE_AND_TIME_TYPE); case FieldType::TIME: return new QDateTime($strColumnValue, null, QDateTime::TIME_ONLY_TYPE); case FieldType::FLOAT: return Type::cast($strColumnValue, Type::FLOAT); case FieldType::INTEGER: return Type::cast($strColumnValue, Type::INTEGER); default: return $strColumnValue; } }
[ "public", "function", "getColumn", "(", "$", "strColumnName", ",", "$", "strColumnType", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "strColumnArray", "[", "$", "strColumnName", "]", ")", ")", "{", "return", "null", ";", "}", "$", "strColumnValue", "=", "$", "this", "->", "strColumnArray", "[", "$", "strColumnName", "]", ";", "switch", "(", "$", "strColumnType", ")", "{", "case", "FieldType", "::", "BIT", ":", "// Account for single bit value", "$", "chrBit", "=", "$", "strColumnValue", ";", "if", "(", "(", "strlen", "(", "$", "chrBit", ")", "==", "1", ")", "&&", "(", "ord", "(", "$", "chrBit", ")", "==", "0", ")", ")", "{", "return", "false", ";", "}", "// Otherwise, use PHP conditional to determine true or false", "return", "(", "$", "strColumnValue", ")", "?", "true", ":", "false", ";", "case", "FieldType", "::", "BLOB", ":", "case", "FieldType", "::", "CHAR", ":", "case", "FieldType", "::", "VAR_CHAR", ":", "return", "Type", "::", "cast", "(", "$", "strColumnValue", ",", "Type", "::", "STRING", ")", ";", "case", "FieldType", "::", "DATE", ":", "return", "new", "QDateTime", "(", "$", "strColumnValue", ",", "null", ",", "QDateTime", "::", "DATE_ONLY_TYPE", ")", ";", "case", "FieldType", "::", "DATE_TIME", ":", "return", "new", "QDateTime", "(", "$", "strColumnValue", ",", "null", ",", "QDateTime", "::", "DATE_AND_TIME_TYPE", ")", ";", "case", "FieldType", "::", "TIME", ":", "return", "new", "QDateTime", "(", "$", "strColumnValue", ",", "null", ",", "QDateTime", "::", "TIME_ONLY_TYPE", ")", ";", "case", "FieldType", "::", "FLOAT", ":", "return", "Type", "::", "cast", "(", "$", "strColumnValue", ",", "Type", "::", "FLOAT", ")", ";", "case", "FieldType", "::", "INTEGER", ":", "return", "Type", "::", "cast", "(", "$", "strColumnValue", ",", "Type", "::", "INTEGER", ")", ";", "default", ":", "return", "$", "strColumnValue", ";", "}", "}" ]
Gets the value of a column from a result row returned by the database @param string $strColumnName Name of the column @param null|string $strColumnType A FieldType string @return mixed
[ "Gets", "the", "value", "of", "a", "column", "from", "a", "result", "row", "returned", "by", "the", "database" ]
train
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/Mysqli5/MysqliRow.php#L39-L78
shrink0r/workflux
src/Builder/StateMachineSchema.php
StateMachineSchema.getStateSchema
private function getStateSchema(): array { return [ "type" => "assoc" , "required" => false, "properties" => [ "class" => [ "type" => "fqcn", "required" => false ], "initial" => [ "type" => "bool", "required" => false ], "final" => [ "type" => "bool", "required" => false ], "interactive" => [ "type" => "bool", "required" => false ], "output" => [ "type" => "assoc", "required" => false, "properties" => [ ":any_name:" => [ "type" => "any" ] ] ], "input_schema" => [ "type" => "assoc", "required" => false, "properties" => [ ":any_name:" => [ "type" => "any" ] ] ], "output_schema" => [ "type" => "assoc", "required" => false, "properties" => [ ":any_name:" => [ "type" => "any" ] ] ], "settings" => [ "type" => "assoc", "required" => false, "properties" => [ ":any_name:" => [ "type" => "any" ] ] ], "transitions" => [ "type" => "assoc", "required" => true, "properties" => [ ":any_name:" => [ "type" => "enum" , "required" => false, "one_of" => [ "string", "&transition" ] ] ] ] ] ]; }
php
private function getStateSchema(): array { return [ "type" => "assoc" , "required" => false, "properties" => [ "class" => [ "type" => "fqcn", "required" => false ], "initial" => [ "type" => "bool", "required" => false ], "final" => [ "type" => "bool", "required" => false ], "interactive" => [ "type" => "bool", "required" => false ], "output" => [ "type" => "assoc", "required" => false, "properties" => [ ":any_name:" => [ "type" => "any" ] ] ], "input_schema" => [ "type" => "assoc", "required" => false, "properties" => [ ":any_name:" => [ "type" => "any" ] ] ], "output_schema" => [ "type" => "assoc", "required" => false, "properties" => [ ":any_name:" => [ "type" => "any" ] ] ], "settings" => [ "type" => "assoc", "required" => false, "properties" => [ ":any_name:" => [ "type" => "any" ] ] ], "transitions" => [ "type" => "assoc", "required" => true, "properties" => [ ":any_name:" => [ "type" => "enum" , "required" => false, "one_of" => [ "string", "&transition" ] ] ] ] ] ]; }
[ "private", "function", "getStateSchema", "(", ")", ":", "array", "{", "return", "[", "\"type\"", "=>", "\"assoc\"", ",", "\"required\"", "=>", "false", ",", "\"properties\"", "=>", "[", "\"class\"", "=>", "[", "\"type\"", "=>", "\"fqcn\"", ",", "\"required\"", "=>", "false", "]", ",", "\"initial\"", "=>", "[", "\"type\"", "=>", "\"bool\"", ",", "\"required\"", "=>", "false", "]", ",", "\"final\"", "=>", "[", "\"type\"", "=>", "\"bool\"", ",", "\"required\"", "=>", "false", "]", ",", "\"interactive\"", "=>", "[", "\"type\"", "=>", "\"bool\"", ",", "\"required\"", "=>", "false", "]", ",", "\"output\"", "=>", "[", "\"type\"", "=>", "\"assoc\"", ",", "\"required\"", "=>", "false", ",", "\"properties\"", "=>", "[", "\":any_name:\"", "=>", "[", "\"type\"", "=>", "\"any\"", "]", "]", "]", ",", "\"input_schema\"", "=>", "[", "\"type\"", "=>", "\"assoc\"", ",", "\"required\"", "=>", "false", ",", "\"properties\"", "=>", "[", "\":any_name:\"", "=>", "[", "\"type\"", "=>", "\"any\"", "]", "]", "]", ",", "\"output_schema\"", "=>", "[", "\"type\"", "=>", "\"assoc\"", ",", "\"required\"", "=>", "false", ",", "\"properties\"", "=>", "[", "\":any_name:\"", "=>", "[", "\"type\"", "=>", "\"any\"", "]", "]", "]", ",", "\"settings\"", "=>", "[", "\"type\"", "=>", "\"assoc\"", ",", "\"required\"", "=>", "false", ",", "\"properties\"", "=>", "[", "\":any_name:\"", "=>", "[", "\"type\"", "=>", "\"any\"", "]", "]", "]", ",", "\"transitions\"", "=>", "[", "\"type\"", "=>", "\"assoc\"", ",", "\"required\"", "=>", "true", ",", "\"properties\"", "=>", "[", "\":any_name:\"", "=>", "[", "\"type\"", "=>", "\"enum\"", ",", "\"required\"", "=>", "false", ",", "\"one_of\"", "=>", "[", "\"string\"", ",", "\"&transition\"", "]", "]", "]", "]", "]", "]", ";", "}" ]
Return php-schema definition that reflects the structural expectations towards state (yaml)data. @return mixed[]
[ "Return", "php", "-", "schema", "definition", "that", "reflects", "the", "structural", "expectations", "towards", "state", "(", "yaml", ")", "data", "." ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Builder/StateMachineSchema.php#L101-L161
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.getDtCall
public function getDtCall($format = null) { if ($this->dt_call === null) { return null; } if ($this->dt_call === '0000-00-00 00:00:00') { // while technically this is not a default value of null, // this seems to be closest in meaning. return null; } try { $dt = new DateTime($this->dt_call); } catch (Exception $x) { throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->dt_call, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; } if (strpos($format, '%') !== false) { return strftime($format, $dt->format('U')); } return $dt->format($format); }
php
public function getDtCall($format = null) { if ($this->dt_call === null) { return null; } if ($this->dt_call === '0000-00-00 00:00:00') { // while technically this is not a default value of null, // this seems to be closest in meaning. return null; } try { $dt = new DateTime($this->dt_call); } catch (Exception $x) { throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->dt_call, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; } if (strpos($format, '%') !== false) { return strftime($format, $dt->format('U')); } return $dt->format($format); }
[ "public", "function", "getDtCall", "(", "$", "format", "=", "null", ")", "{", "if", "(", "$", "this", "->", "dt_call", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "dt_call", "===", "'0000-00-00 00:00:00'", ")", "{", "// while technically this is not a default value of null,", "// this seems to be closest in meaning.", "return", "null", ";", "}", "try", "{", "$", "dt", "=", "new", "DateTime", "(", "$", "this", "->", "dt_call", ")", ";", "}", "catch", "(", "Exception", "$", "x", ")", "{", "throw", "new", "PropelException", "(", "\"Internally stored date/time/timestamp value could not be converted to DateTime: \"", ".", "var_export", "(", "$", "this", "->", "dt_call", ",", "true", ")", ",", "$", "x", ")", ";", "}", "if", "(", "$", "format", "===", "null", ")", "{", "// Because propel.useDateTimeClass is true, we return a DateTime object.", "return", "$", "dt", ";", "}", "if", "(", "strpos", "(", "$", "format", ",", "'%'", ")", "!==", "false", ")", "{", "return", "strftime", "(", "$", "format", ",", "$", "dt", "->", "format", "(", "'U'", ")", ")", ";", "}", "return", "$", "dt", "->", "format", "(", "$", "format", ")", ";", "}" ]
Get the [optionally formatted] temporal [dt_call] column value. @param string $format The date/time format string (either date()-style or strftime()-style). If format is null, then the raw DateTime object will be returned. @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 @throws PropelException - if unable to parse/validate the date/time value.
[ "Get", "the", "[", "optionally", "formatted", "]", "temporal", "[", "dt_call", "]", "column", "value", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L118-L147
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.setDtCall
public function setDtCall($v) { $dt = PropelDateTime::newInstance($v, null, 'DateTime'); if ($this->dt_call !== null || $dt !== null) { $currentDateAsString = ($this->dt_call !== null && $tmpDt = new DateTime($this->dt_call)) ? $tmpDt->format('Y-m-d H:i:s') : null; $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; if ($currentDateAsString !== $newDateAsString) { $this->dt_call = $newDateAsString; $this->modifiedColumns[] = ApiLogPeer::DT_CALL; } } // if either are not null return $this; }
php
public function setDtCall($v) { $dt = PropelDateTime::newInstance($v, null, 'DateTime'); if ($this->dt_call !== null || $dt !== null) { $currentDateAsString = ($this->dt_call !== null && $tmpDt = new DateTime($this->dt_call)) ? $tmpDt->format('Y-m-d H:i:s') : null; $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; if ($currentDateAsString !== $newDateAsString) { $this->dt_call = $newDateAsString; $this->modifiedColumns[] = ApiLogPeer::DT_CALL; } } // if either are not null return $this; }
[ "public", "function", "setDtCall", "(", "$", "v", ")", "{", "$", "dt", "=", "PropelDateTime", "::", "newInstance", "(", "$", "v", ",", "null", ",", "'DateTime'", ")", ";", "if", "(", "$", "this", "->", "dt_call", "!==", "null", "||", "$", "dt", "!==", "null", ")", "{", "$", "currentDateAsString", "=", "(", "$", "this", "->", "dt_call", "!==", "null", "&&", "$", "tmpDt", "=", "new", "DateTime", "(", "$", "this", "->", "dt_call", ")", ")", "?", "$", "tmpDt", "->", "format", "(", "'Y-m-d H:i:s'", ")", ":", "null", ";", "$", "newDateAsString", "=", "$", "dt", "?", "$", "dt", "->", "format", "(", "'Y-m-d H:i:s'", ")", ":", "null", ";", "if", "(", "$", "currentDateAsString", "!==", "$", "newDateAsString", ")", "{", "$", "this", "->", "dt_call", "=", "$", "newDateAsString", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "ApiLogPeer", "::", "DT_CALL", ";", "}", "}", "// if either are not null", "return", "$", "this", ";", "}" ]
Sets the value of [dt_call] column to a normalized version of the date/time value specified. @param mixed $v string, integer (timestamp), or DateTime value. Empty strings are treated as null. @return ApiLog The current object (for fluent API support)
[ "Sets", "the", "value", "of", "[", "dt_call", "]", "column", "to", "a", "normalized", "version", "of", "the", "date", "/", "time", "value", "specified", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L210-L224
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.setLastResponse
public function setLastResponse($v) { // Because BLOB columns are streams in PDO we have to assume that they are // always modified when a new value is passed in. For example, the contents // of the stream itself may have changed externally. if (!is_resource($v) && $v !== null) { $this->last_response = fopen('php://memory', 'r+'); fwrite($this->last_response, $v); rewind($this->last_response); } else { // it's already a stream $this->last_response = $v; } $this->modifiedColumns[] = ApiLogPeer::LAST_RESPONSE; return $this; }
php
public function setLastResponse($v) { // Because BLOB columns are streams in PDO we have to assume that they are // always modified when a new value is passed in. For example, the contents // of the stream itself may have changed externally. if (!is_resource($v) && $v !== null) { $this->last_response = fopen('php://memory', 'r+'); fwrite($this->last_response, $v); rewind($this->last_response); } else { // it's already a stream $this->last_response = $v; } $this->modifiedColumns[] = ApiLogPeer::LAST_RESPONSE; return $this; }
[ "public", "function", "setLastResponse", "(", "$", "v", ")", "{", "// Because BLOB columns are streams in PDO we have to assume that they are", "// always modified when a new value is passed in. For example, the contents", "// of the stream itself may have changed externally.", "if", "(", "!", "is_resource", "(", "$", "v", ")", "&&", "$", "v", "!==", "null", ")", "{", "$", "this", "->", "last_response", "=", "fopen", "(", "'php://memory'", ",", "'r+'", ")", ";", "fwrite", "(", "$", "this", "->", "last_response", ",", "$", "v", ")", ";", "rewind", "(", "$", "this", "->", "last_response", ")", ";", "}", "else", "{", "// it's already a stream", "$", "this", "->", "last_response", "=", "$", "v", ";", "}", "$", "this", "->", "modifiedColumns", "[", "]", "=", "ApiLogPeer", "::", "LAST_RESPONSE", ";", "return", "$", "this", ";", "}" ]
Set the value of [last_response] column. @param resource $v new value @return ApiLog The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "last_response", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L278-L294
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.hydrate
public function hydrate($row, $startcol = 0, $rehydrate = false) { try { $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->dt_call = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->remote_app_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; $this->statuscode = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; if ($row[$startcol + 4] !== null) { $this->last_response = fopen('php://memory', 'r+'); fwrite($this->last_response, $row[$startcol + 4]); rewind($this->last_response); } else { $this->last_response = null; } $this->resetModified(); $this->setNew(false); if ($rehydrate) { $this->ensureConsistency(); } $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = ApiLogPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating ApiLog object", $e); } }
php
public function hydrate($row, $startcol = 0, $rehydrate = false) { try { $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->dt_call = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->remote_app_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; $this->statuscode = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; if ($row[$startcol + 4] !== null) { $this->last_response = fopen('php://memory', 'r+'); fwrite($this->last_response, $row[$startcol + 4]); rewind($this->last_response); } else { $this->last_response = null; } $this->resetModified(); $this->setNew(false); if ($rehydrate) { $this->ensureConsistency(); } $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = ApiLogPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating ApiLog object", $e); } }
[ "public", "function", "hydrate", "(", "$", "row", ",", "$", "startcol", "=", "0", ",", "$", "rehydrate", "=", "false", ")", "{", "try", "{", "$", "this", "->", "id", "=", "(", "$", "row", "[", "$", "startcol", "+", "0", "]", "!==", "null", ")", "?", "(", "int", ")", "$", "row", "[", "$", "startcol", "+", "0", "]", ":", "null", ";", "$", "this", "->", "dt_call", "=", "(", "$", "row", "[", "$", "startcol", "+", "1", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "1", "]", ":", "null", ";", "$", "this", "->", "remote_app_id", "=", "(", "$", "row", "[", "$", "startcol", "+", "2", "]", "!==", "null", ")", "?", "(", "int", ")", "$", "row", "[", "$", "startcol", "+", "2", "]", ":", "null", ";", "$", "this", "->", "statuscode", "=", "(", "$", "row", "[", "$", "startcol", "+", "3", "]", "!==", "null", ")", "?", "(", "int", ")", "$", "row", "[", "$", "startcol", "+", "3", "]", ":", "null", ";", "if", "(", "$", "row", "[", "$", "startcol", "+", "4", "]", "!==", "null", ")", "{", "$", "this", "->", "last_response", "=", "fopen", "(", "'php://memory'", ",", "'r+'", ")", ";", "fwrite", "(", "$", "this", "->", "last_response", ",", "$", "row", "[", "$", "startcol", "+", "4", "]", ")", ";", "rewind", "(", "$", "this", "->", "last_response", ")", ";", "}", "else", "{", "$", "this", "->", "last_response", "=", "null", ";", "}", "$", "this", "->", "resetModified", "(", ")", ";", "$", "this", "->", "setNew", "(", "false", ")", ";", "if", "(", "$", "rehydrate", ")", "{", "$", "this", "->", "ensureConsistency", "(", ")", ";", "}", "$", "this", "->", "postHydrate", "(", "$", "row", ",", "$", "startcol", ",", "$", "rehydrate", ")", ";", "return", "$", "startcol", "+", "5", ";", "// 5 = ApiLogPeer::NUM_HYDRATE_COLUMNS.", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "PropelException", "(", "\"Error populating ApiLog object\"", ",", "$", "e", ")", ";", "}", "}" ]
Hydrates (populates) the object variables with values from the database resultset. An offset (0-based "start column") is specified so that objects can be hydrated with a subset of the columns in the resultset rows. This is needed, for example, for results of JOIN queries where the resultset row includes columns from two or more tables. @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) @param int $startcol 0-based offset column which indicates which resultset column to start with. @param boolean $rehydrate Whether this object is being re-hydrated from the database. @return int next starting column @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
[ "Hydrates", "(", "populates", ")", "the", "object", "variables", "with", "values", "from", "the", "database", "resultset", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L324-L353
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.reload
public function reload($deep = false, PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); } if ($this->isNew()) { throw new PropelException("Cannot reload an unsaved object."); } if ($con === null) { $con = Propel::getConnection(ApiLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. $stmt = ApiLogPeer::doSelectStmt($this->buildPkeyCriteria(), $con); $row = $stmt->fetch(PDO::FETCH_NUM); $stmt->closeCursor(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } $this->hydrate($row, 0, true); // rehydrate if ($deep) { // also de-associate any related objects? $this->aRemoteApp = null; } // if (deep) }
php
public function reload($deep = false, PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); } if ($this->isNew()) { throw new PropelException("Cannot reload an unsaved object."); } if ($con === null) { $con = Propel::getConnection(ApiLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. $stmt = ApiLogPeer::doSelectStmt($this->buildPkeyCriteria(), $con); $row = $stmt->fetch(PDO::FETCH_NUM); $stmt->closeCursor(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } $this->hydrate($row, 0, true); // rehydrate if ($deep) { // also de-associate any related objects? $this->aRemoteApp = null; } // if (deep) }
[ "public", "function", "reload", "(", "$", "deep", "=", "false", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isDeleted", "(", ")", ")", "{", "throw", "new", "PropelException", "(", "\"Cannot reload a deleted object.\"", ")", ";", "}", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "throw", "new", "PropelException", "(", "\"Cannot reload an unsaved object.\"", ")", ";", "}", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "ApiLogPeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_READ", ")", ";", "}", "// We don't need to alter the object instance pool; we're just modifying this instance", "// already in the pool.", "$", "stmt", "=", "ApiLogPeer", "::", "doSelectStmt", "(", "$", "this", "->", "buildPkeyCriteria", "(", ")", ",", "$", "con", ")", ";", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "PDO", "::", "FETCH_NUM", ")", ";", "$", "stmt", "->", "closeCursor", "(", ")", ";", "if", "(", "!", "$", "row", ")", "{", "throw", "new", "PropelException", "(", "'Cannot find matching row in the database to reload object values.'", ")", ";", "}", "$", "this", "->", "hydrate", "(", "$", "row", ",", "0", ",", "true", ")", ";", "// rehydrate", "if", "(", "$", "deep", ")", "{", "// also de-associate any related objects?", "$", "this", "->", "aRemoteApp", "=", "null", ";", "}", "// if (deep)", "}" ]
Reloads this object from datastore based on primary key and (optionally) resets all associated objects. This will only work if the object has been saved and has a valid primary key set. @param boolean $deep (optional) Whether to also de-associated any related objects. @param PropelPDO $con (optional) The PropelPDO connection to use. @return void @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
[ "Reloads", "this", "object", "from", "datastore", "based", "on", "primary", "key", "and", "(", "optionally", ")", "resets", "all", "associated", "objects", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L386-L415
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.delete
public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(ApiLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ApiLogQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
php
public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(ApiLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ApiLogQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
[ "public", "function", "delete", "(", "PropelPDO", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isDeleted", "(", ")", ")", "{", "throw", "new", "PropelException", "(", "\"This object has already been deleted.\"", ")", ";", "}", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "ApiLogPeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_WRITE", ")", ";", "}", "$", "con", "->", "beginTransaction", "(", ")", ";", "try", "{", "$", "deleteQuery", "=", "ApiLogQuery", "::", "create", "(", ")", "->", "filterByPrimaryKey", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ")", ";", "$", "ret", "=", "$", "this", "->", "preDelete", "(", "$", "con", ")", ";", "if", "(", "$", "ret", ")", "{", "$", "deleteQuery", "->", "delete", "(", "$", "con", ")", ";", "$", "this", "->", "postDelete", "(", "$", "con", ")", ";", "$", "con", "->", "commit", "(", ")", ";", "$", "this", "->", "setDeleted", "(", "true", ")", ";", "}", "else", "{", "$", "con", "->", "commit", "(", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "con", "->", "rollBack", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
Removes this object from datastore and sets delete attribute. @param PropelPDO $con @return void @throws PropelException @throws Exception @see BaseObject::setDeleted() @see BaseObject::isDeleted()
[ "Removes", "this", "object", "from", "datastore", "and", "sets", "delete", "attribute", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L427-L454
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.save
public function save(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("You cannot save an object that has been deleted."); } if ($con === null) { $con = Propel::getConnection(ApiLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); $isInsert = $this->isNew(); try { $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); } else { $ret = $ret && $this->preUpdate($con); } if ($ret) { $affectedRows = $this->doSave($con); if ($isInsert) { $this->postInsert($con); } else { $this->postUpdate($con); } $this->postSave($con); ApiLogPeer::addInstanceToPool($this); } else { $affectedRows = 0; } $con->commit(); return $affectedRows; } catch (Exception $e) { $con->rollBack(); throw $e; } }
php
public function save(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("You cannot save an object that has been deleted."); } if ($con === null) { $con = Propel::getConnection(ApiLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); $isInsert = $this->isNew(); try { $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); } else { $ret = $ret && $this->preUpdate($con); } if ($ret) { $affectedRows = $this->doSave($con); if ($isInsert) { $this->postInsert($con); } else { $this->postUpdate($con); } $this->postSave($con); ApiLogPeer::addInstanceToPool($this); } else { $affectedRows = 0; } $con->commit(); return $affectedRows; } catch (Exception $e) { $con->rollBack(); throw $e; } }
[ "public", "function", "save", "(", "PropelPDO", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isDeleted", "(", ")", ")", "{", "throw", "new", "PropelException", "(", "\"You cannot save an object that has been deleted.\"", ")", ";", "}", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "ApiLogPeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_WRITE", ")", ";", "}", "$", "con", "->", "beginTransaction", "(", ")", ";", "$", "isInsert", "=", "$", "this", "->", "isNew", "(", ")", ";", "try", "{", "$", "ret", "=", "$", "this", "->", "preSave", "(", "$", "con", ")", ";", "if", "(", "$", "isInsert", ")", "{", "$", "ret", "=", "$", "ret", "&&", "$", "this", "->", "preInsert", "(", "$", "con", ")", ";", "}", "else", "{", "$", "ret", "=", "$", "ret", "&&", "$", "this", "->", "preUpdate", "(", "$", "con", ")", ";", "}", "if", "(", "$", "ret", ")", "{", "$", "affectedRows", "=", "$", "this", "->", "doSave", "(", "$", "con", ")", ";", "if", "(", "$", "isInsert", ")", "{", "$", "this", "->", "postInsert", "(", "$", "con", ")", ";", "}", "else", "{", "$", "this", "->", "postUpdate", "(", "$", "con", ")", ";", "}", "$", "this", "->", "postSave", "(", "$", "con", ")", ";", "ApiLogPeer", "::", "addInstanceToPool", "(", "$", "this", ")", ";", "}", "else", "{", "$", "affectedRows", "=", "0", ";", "}", "$", "con", "->", "commit", "(", ")", ";", "return", "$", "affectedRows", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "con", "->", "rollBack", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
Persists this object to the database. If the object is new, it inserts it; otherwise an update is performed. All modified related objects will also be persisted in the doSave() method. This method wraps all precipitate database operations in a single transaction. @param PropelPDO $con @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. @throws PropelException @throws Exception @see doSave()
[ "Persists", "this", "object", "to", "the", "database", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L470-L508
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.doInsert
protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = ApiLogPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . ApiLogPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ApiLogPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ApiLogPeer::DT_CALL)) { $modifiedColumns[':p' . $index++] = '`dt_call`'; } if ($this->isColumnModified(ApiLogPeer::REMOTE_APP_ID)) { $modifiedColumns[':p' . $index++] = '`remote_app_id`'; } if ($this->isColumnModified(ApiLogPeer::STATUSCODE)) { $modifiedColumns[':p' . $index++] = '`statuscode`'; } if ($this->isColumnModified(ApiLogPeer::LAST_RESPONSE)) { $modifiedColumns[':p' . $index++] = '`last_response`'; } $sql = sprintf( 'INSERT INTO `api_log` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; case '`dt_call`': $stmt->bindValue($identifier, $this->dt_call, PDO::PARAM_STR); break; case '`remote_app_id`': $stmt->bindValue($identifier, $this->remote_app_id, PDO::PARAM_INT); break; case '`statuscode`': $stmt->bindValue($identifier, $this->statuscode, PDO::PARAM_INT); break; case '`last_response`': if (is_resource($this->last_response)) { rewind($this->last_response); } $stmt->bindValue($identifier, $this->last_response, PDO::PARAM_LOB); break; } } $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
php
protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = ApiLogPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . ApiLogPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ApiLogPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ApiLogPeer::DT_CALL)) { $modifiedColumns[':p' . $index++] = '`dt_call`'; } if ($this->isColumnModified(ApiLogPeer::REMOTE_APP_ID)) { $modifiedColumns[':p' . $index++] = '`remote_app_id`'; } if ($this->isColumnModified(ApiLogPeer::STATUSCODE)) { $modifiedColumns[':p' . $index++] = '`statuscode`'; } if ($this->isColumnModified(ApiLogPeer::LAST_RESPONSE)) { $modifiedColumns[':p' . $index++] = '`last_response`'; } $sql = sprintf( 'INSERT INTO `api_log` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; case '`dt_call`': $stmt->bindValue($identifier, $this->dt_call, PDO::PARAM_STR); break; case '`remote_app_id`': $stmt->bindValue($identifier, $this->remote_app_id, PDO::PARAM_INT); break; case '`statuscode`': $stmt->bindValue($identifier, $this->statuscode, PDO::PARAM_INT); break; case '`last_response`': if (is_resource($this->last_response)) { rewind($this->last_response); } $stmt->bindValue($identifier, $this->last_response, PDO::PARAM_LOB); break; } } $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
[ "protected", "function", "doInsert", "(", "PropelPDO", "$", "con", ")", "{", "$", "modifiedColumns", "=", "array", "(", ")", ";", "$", "index", "=", "0", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "ApiLogPeer", "::", "ID", ";", "if", "(", "null", "!==", "$", "this", "->", "id", ")", "{", "throw", "new", "PropelException", "(", "'Cannot insert a value for auto-increment primary key ('", ".", "ApiLogPeer", "::", "ID", ".", "')'", ")", ";", "}", "// check the columns in natural order for more readable SQL queries", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "ID", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`id`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "DT_CALL", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`dt_call`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "REMOTE_APP_ID", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`remote_app_id`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "STATUSCODE", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`statuscode`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "LAST_RESPONSE", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`last_response`'", ";", "}", "$", "sql", "=", "sprintf", "(", "'INSERT INTO `api_log` (%s) VALUES (%s)'", ",", "implode", "(", "', '", ",", "$", "modifiedColumns", ")", ",", "implode", "(", "', '", ",", "array_keys", "(", "$", "modifiedColumns", ")", ")", ")", ";", "try", "{", "$", "stmt", "=", "$", "con", "->", "prepare", "(", "$", "sql", ")", ";", "foreach", "(", "$", "modifiedColumns", "as", "$", "identifier", "=>", "$", "columnName", ")", "{", "switch", "(", "$", "columnName", ")", "{", "case", "'`id`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "id", ",", "PDO", "::", "PARAM_INT", ")", ";", "break", ";", "case", "'`dt_call`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "dt_call", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`remote_app_id`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "remote_app_id", ",", "PDO", "::", "PARAM_INT", ")", ";", "break", ";", "case", "'`statuscode`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "statuscode", ",", "PDO", "::", "PARAM_INT", ")", ";", "break", ";", "case", "'`last_response`'", ":", "if", "(", "is_resource", "(", "$", "this", "->", "last_response", ")", ")", "{", "rewind", "(", "$", "this", "->", "last_response", ")", ";", "}", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "last_response", ",", "PDO", "::", "PARAM_LOB", ")", ";", "break", ";", "}", "}", "$", "stmt", "->", "execute", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "Propel", "::", "log", "(", "$", "e", "->", "getMessage", "(", ")", ",", "Propel", "::", "LOG_ERR", ")", ";", "throw", "new", "PropelException", "(", "sprintf", "(", "'Unable to execute INSERT statement [%s]'", ",", "$", "sql", ")", ",", "$", "e", ")", ";", "}", "try", "{", "$", "pk", "=", "$", "con", "->", "lastInsertId", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "PropelException", "(", "'Unable to get autoincrement id.'", ",", "$", "e", ")", ";", "}", "$", "this", "->", "setId", "(", "$", "pk", ")", ";", "$", "this", "->", "setNew", "(", "false", ")", ";", "}" ]
Insert the row in the database. @param PropelPDO $con @throws PropelException @see doSave()
[ "Insert", "the", "row", "in", "the", "database", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L570-L641
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.doValidate
protected function doValidate($columns = null) { if (!$this->alreadyInValidation) { $this->alreadyInValidation = true; $retval = null; $failureMap = array(); // We call the validate method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aRemoteApp !== null) { if (!$this->aRemoteApp->validate($columns)) { $failureMap = array_merge($failureMap, $this->aRemoteApp->getValidationFailures()); } } if (($retval = ApiLogPeer::doValidate($this, $columns)) !== true) { $failureMap = array_merge($failureMap, $retval); } $this->alreadyInValidation = false; } return (!empty($failureMap) ? $failureMap : true); }
php
protected function doValidate($columns = null) { if (!$this->alreadyInValidation) { $this->alreadyInValidation = true; $retval = null; $failureMap = array(); // We call the validate method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aRemoteApp !== null) { if (!$this->aRemoteApp->validate($columns)) { $failureMap = array_merge($failureMap, $this->aRemoteApp->getValidationFailures()); } } if (($retval = ApiLogPeer::doValidate($this, $columns)) !== true) { $failureMap = array_merge($failureMap, $retval); } $this->alreadyInValidation = false; } return (!empty($failureMap) ? $failureMap : true); }
[ "protected", "function", "doValidate", "(", "$", "columns", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "alreadyInValidation", ")", "{", "$", "this", "->", "alreadyInValidation", "=", "true", ";", "$", "retval", "=", "null", ";", "$", "failureMap", "=", "array", "(", ")", ";", "// We call the validate method on the following object(s) if they", "// were passed to this object by their corresponding set", "// method. This object relates to these object(s) by a", "// foreign key reference.", "if", "(", "$", "this", "->", "aRemoteApp", "!==", "null", ")", "{", "if", "(", "!", "$", "this", "->", "aRemoteApp", "->", "validate", "(", "$", "columns", ")", ")", "{", "$", "failureMap", "=", "array_merge", "(", "$", "failureMap", ",", "$", "this", "->", "aRemoteApp", "->", "getValidationFailures", "(", ")", ")", ";", "}", "}", "if", "(", "(", "$", "retval", "=", "ApiLogPeer", "::", "doValidate", "(", "$", "this", ",", "$", "columns", ")", ")", "!==", "true", ")", "{", "$", "failureMap", "=", "array_merge", "(", "$", "failureMap", ",", "$", "retval", ")", ";", "}", "$", "this", "->", "alreadyInValidation", "=", "false", ";", "}", "return", "(", "!", "empty", "(", "$", "failureMap", ")", "?", "$", "failureMap", ":", "true", ")", ";", "}" ]
This function performs the validation work for complex object models. In addition to checking the current object, all related objects will also be validated. If all pass then <code>true</code> is returned; otherwise an aggregated array of ValidationFailed objects will be returned. @param array $columns Array of column names to validate. @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise.
[ "This", "function", "performs", "the", "validation", "work", "for", "complex", "object", "models", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L710-L741
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.getByPosition
public function getByPosition($pos) { switch ($pos) { case 0: return $this->getId(); break; case 1: return $this->getDtCall(); break; case 2: return $this->getRemoteAppId(); break; case 3: return $this->getStatuscode(); break; case 4: return $this->getLastResponse(); break; default: return null; break; } // switch() }
php
public function getByPosition($pos) { switch ($pos) { case 0: return $this->getId(); break; case 1: return $this->getDtCall(); break; case 2: return $this->getRemoteAppId(); break; case 3: return $this->getStatuscode(); break; case 4: return $this->getLastResponse(); break; default: return null; break; } // switch() }
[ "public", "function", "getByPosition", "(", "$", "pos", ")", "{", "switch", "(", "$", "pos", ")", "{", "case", "0", ":", "return", "$", "this", "->", "getId", "(", ")", ";", "break", ";", "case", "1", ":", "return", "$", "this", "->", "getDtCall", "(", ")", ";", "break", ";", "case", "2", ":", "return", "$", "this", "->", "getRemoteAppId", "(", ")", ";", "break", ";", "case", "3", ":", "return", "$", "this", "->", "getStatuscode", "(", ")", ";", "break", ";", "case", "4", ":", "return", "$", "this", "->", "getLastResponse", "(", ")", ";", "break", ";", "default", ":", "return", "null", ";", "break", ";", "}", "// switch()", "}" ]
Retrieves a field from the object by Position as specified in the xml schema. Zero-based. @param int $pos position in xml schema @return mixed Value of field at $pos
[ "Retrieves", "a", "field", "from", "the", "object", "by", "Position", "as", "specified", "in", "the", "xml", "schema", ".", "Zero", "-", "based", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L768-L790
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.toArray
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['ApiLog'][$this->getPrimaryKey()])) { return '*RECURSION*'; } $alreadyDumpedObjects['ApiLog'][$this->getPrimaryKey()] = true; $keys = ApiLogPeer::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getDtCall(), $keys[2] => $this->getRemoteAppId(), $keys[3] => $this->getStatuscode(), $keys[4] => $this->getLastResponse(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aRemoteApp) { $result['RemoteApp'] = $this->aRemoteApp->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } return $result; }
php
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['ApiLog'][$this->getPrimaryKey()])) { return '*RECURSION*'; } $alreadyDumpedObjects['ApiLog'][$this->getPrimaryKey()] = true; $keys = ApiLogPeer::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getDtCall(), $keys[2] => $this->getRemoteAppId(), $keys[3] => $this->getStatuscode(), $keys[4] => $this->getLastResponse(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aRemoteApp) { $result['RemoteApp'] = $this->aRemoteApp->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } return $result; }
[ "public", "function", "toArray", "(", "$", "keyType", "=", "BasePeer", "::", "TYPE_PHPNAME", ",", "$", "includeLazyLoadColumns", "=", "true", ",", "$", "alreadyDumpedObjects", "=", "array", "(", ")", ",", "$", "includeForeignObjects", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "alreadyDumpedObjects", "[", "'ApiLog'", "]", "[", "$", "this", "->", "getPrimaryKey", "(", ")", "]", ")", ")", "{", "return", "'*RECURSION*'", ";", "}", "$", "alreadyDumpedObjects", "[", "'ApiLog'", "]", "[", "$", "this", "->", "getPrimaryKey", "(", ")", "]", "=", "true", ";", "$", "keys", "=", "ApiLogPeer", "::", "getFieldNames", "(", "$", "keyType", ")", ";", "$", "result", "=", "array", "(", "$", "keys", "[", "0", "]", "=>", "$", "this", "->", "getId", "(", ")", ",", "$", "keys", "[", "1", "]", "=>", "$", "this", "->", "getDtCall", "(", ")", ",", "$", "keys", "[", "2", "]", "=>", "$", "this", "->", "getRemoteAppId", "(", ")", ",", "$", "keys", "[", "3", "]", "=>", "$", "this", "->", "getStatuscode", "(", ")", ",", "$", "keys", "[", "4", "]", "=>", "$", "this", "->", "getLastResponse", "(", ")", ",", ")", ";", "$", "virtualColumns", "=", "$", "this", "->", "virtualColumns", ";", "foreach", "(", "$", "virtualColumns", "as", "$", "key", "=>", "$", "virtualColumn", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "virtualColumn", ";", "}", "if", "(", "$", "includeForeignObjects", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "aRemoteApp", ")", "{", "$", "result", "[", "'RemoteApp'", "]", "=", "$", "this", "->", "aRemoteApp", "->", "toArray", "(", "$", "keyType", ",", "$", "includeLazyLoadColumns", ",", "$", "alreadyDumpedObjects", ",", "true", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Exports the object as an array. You can specify the key type of the array by passing one of the class type constants. @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME. @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. @param array $alreadyDumpedObjects List of objects to skip to avoid recursion @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. @return array an associative array containing the field names (as keys) and field values
[ "Exports", "the", "object", "as", "an", "array", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L807-L833
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.setByPosition
public function setByPosition($pos, $value) { switch ($pos) { case 0: $this->setId($value); break; case 1: $this->setDtCall($value); break; case 2: $this->setRemoteAppId($value); break; case 3: $this->setStatuscode($value); break; case 4: $this->setLastResponse($value); break; } // switch() }
php
public function setByPosition($pos, $value) { switch ($pos) { case 0: $this->setId($value); break; case 1: $this->setDtCall($value); break; case 2: $this->setRemoteAppId($value); break; case 3: $this->setStatuscode($value); break; case 4: $this->setLastResponse($value); break; } // switch() }
[ "public", "function", "setByPosition", "(", "$", "pos", ",", "$", "value", ")", "{", "switch", "(", "$", "pos", ")", "{", "case", "0", ":", "$", "this", "->", "setId", "(", "$", "value", ")", ";", "break", ";", "case", "1", ":", "$", "this", "->", "setDtCall", "(", "$", "value", ")", ";", "break", ";", "case", "2", ":", "$", "this", "->", "setRemoteAppId", "(", "$", "value", ")", ";", "break", ";", "case", "3", ":", "$", "this", "->", "setStatuscode", "(", "$", "value", ")", ";", "break", ";", "case", "4", ":", "$", "this", "->", "setLastResponse", "(", "$", "value", ")", ";", "break", ";", "}", "// switch()", "}" ]
Sets a field from the object by Position as specified in the xml schema. Zero-based. @param int $pos position in xml schema @param mixed $value field value @return void
[ "Sets", "a", "field", "from", "the", "object", "by", "Position", "as", "specified", "in", "the", "xml", "schema", ".", "Zero", "-", "based", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L861-L880
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.fromArray
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = ApiLogPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setDtCall($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setRemoteAppId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setStatuscode($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setLastResponse($arr[$keys[4]]); }
php
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = ApiLogPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setDtCall($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setRemoteAppId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setStatuscode($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setLastResponse($arr[$keys[4]]); }
[ "public", "function", "fromArray", "(", "$", "arr", ",", "$", "keyType", "=", "BasePeer", "::", "TYPE_PHPNAME", ")", "{", "$", "keys", "=", "ApiLogPeer", "::", "getFieldNames", "(", "$", "keyType", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "0", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setId", "(", "$", "arr", "[", "$", "keys", "[", "0", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "1", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setDtCall", "(", "$", "arr", "[", "$", "keys", "[", "1", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "2", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setRemoteAppId", "(", "$", "arr", "[", "$", "keys", "[", "2", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "3", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setStatuscode", "(", "$", "arr", "[", "$", "keys", "[", "3", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "4", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setLastResponse", "(", "$", "arr", "[", "$", "keys", "[", "4", "]", "]", ")", ";", "}" ]
Populates the object using an array. This is particularly useful when populating an object from one of the request arrays (e.g. $_POST). This method goes through the column names, checking to see whether a matching key exists in populated array. If so the setByName() method is called for that column. You can specify the key type of the array by additionally passing one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. The default key type is the column's BasePeer::TYPE_PHPNAME @param array $arr An array to populate the object from. @param string $keyType The type of keys the array uses. @return void
[ "Populates", "the", "object", "using", "an", "array", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L899-L908
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.buildCriteria
public function buildCriteria() { $criteria = new Criteria(ApiLogPeer::DATABASE_NAME); if ($this->isColumnModified(ApiLogPeer::ID)) $criteria->add(ApiLogPeer::ID, $this->id); if ($this->isColumnModified(ApiLogPeer::DT_CALL)) $criteria->add(ApiLogPeer::DT_CALL, $this->dt_call); if ($this->isColumnModified(ApiLogPeer::REMOTE_APP_ID)) $criteria->add(ApiLogPeer::REMOTE_APP_ID, $this->remote_app_id); if ($this->isColumnModified(ApiLogPeer::STATUSCODE)) $criteria->add(ApiLogPeer::STATUSCODE, $this->statuscode); if ($this->isColumnModified(ApiLogPeer::LAST_RESPONSE)) $criteria->add(ApiLogPeer::LAST_RESPONSE, $this->last_response); return $criteria; }
php
public function buildCriteria() { $criteria = new Criteria(ApiLogPeer::DATABASE_NAME); if ($this->isColumnModified(ApiLogPeer::ID)) $criteria->add(ApiLogPeer::ID, $this->id); if ($this->isColumnModified(ApiLogPeer::DT_CALL)) $criteria->add(ApiLogPeer::DT_CALL, $this->dt_call); if ($this->isColumnModified(ApiLogPeer::REMOTE_APP_ID)) $criteria->add(ApiLogPeer::REMOTE_APP_ID, $this->remote_app_id); if ($this->isColumnModified(ApiLogPeer::STATUSCODE)) $criteria->add(ApiLogPeer::STATUSCODE, $this->statuscode); if ($this->isColumnModified(ApiLogPeer::LAST_RESPONSE)) $criteria->add(ApiLogPeer::LAST_RESPONSE, $this->last_response); return $criteria; }
[ "public", "function", "buildCriteria", "(", ")", "{", "$", "criteria", "=", "new", "Criteria", "(", "ApiLogPeer", "::", "DATABASE_NAME", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "ID", ")", ")", "$", "criteria", "->", "add", "(", "ApiLogPeer", "::", "ID", ",", "$", "this", "->", "id", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "DT_CALL", ")", ")", "$", "criteria", "->", "add", "(", "ApiLogPeer", "::", "DT_CALL", ",", "$", "this", "->", "dt_call", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "REMOTE_APP_ID", ")", ")", "$", "criteria", "->", "add", "(", "ApiLogPeer", "::", "REMOTE_APP_ID", ",", "$", "this", "->", "remote_app_id", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "STATUSCODE", ")", ")", "$", "criteria", "->", "add", "(", "ApiLogPeer", "::", "STATUSCODE", ",", "$", "this", "->", "statuscode", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "ApiLogPeer", "::", "LAST_RESPONSE", ")", ")", "$", "criteria", "->", "add", "(", "ApiLogPeer", "::", "LAST_RESPONSE", ",", "$", "this", "->", "last_response", ")", ";", "return", "$", "criteria", ";", "}" ]
Build a Criteria object containing the values of all modified columns in this object. @return Criteria The Criteria object containing all modified values.
[ "Build", "a", "Criteria", "object", "containing", "the", "values", "of", "all", "modified", "columns", "in", "this", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L915-L926
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.copyInto
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setDtCall($this->getDtCall()); $copyObj->setRemoteAppId($this->getRemoteAppId()); $copyObj->setStatuscode($this->getStatuscode()); $copyObj->setLastResponse($this->getLastResponse()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); // store object hash to prevent cycle $this->startCopy = true; //unflag object copy $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } }
php
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setDtCall($this->getDtCall()); $copyObj->setRemoteAppId($this->getRemoteAppId()); $copyObj->setStatuscode($this->getStatuscode()); $copyObj->setLastResponse($this->getLastResponse()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); // store object hash to prevent cycle $this->startCopy = true; //unflag object copy $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } }
[ "public", "function", "copyInto", "(", "$", "copyObj", ",", "$", "deepCopy", "=", "false", ",", "$", "makeNew", "=", "true", ")", "{", "$", "copyObj", "->", "setDtCall", "(", "$", "this", "->", "getDtCall", "(", ")", ")", ";", "$", "copyObj", "->", "setRemoteAppId", "(", "$", "this", "->", "getRemoteAppId", "(", ")", ")", ";", "$", "copyObj", "->", "setStatuscode", "(", "$", "this", "->", "getStatuscode", "(", ")", ")", ";", "$", "copyObj", "->", "setLastResponse", "(", "$", "this", "->", "getLastResponse", "(", ")", ")", ";", "if", "(", "$", "deepCopy", "&&", "!", "$", "this", "->", "startCopy", ")", "{", "// important: temporarily setNew(false) because this affects the behavior of", "// the getter/setter methods for fkey referrer objects.", "$", "copyObj", "->", "setNew", "(", "false", ")", ";", "// store object hash to prevent cycle", "$", "this", "->", "startCopy", "=", "true", ";", "//unflag object copy", "$", "this", "->", "startCopy", "=", "false", ";", "}", "// if ($deepCopy)", "if", "(", "$", "makeNew", ")", "{", "$", "copyObj", "->", "setNew", "(", "true", ")", ";", "$", "copyObj", "->", "setId", "(", "NULL", ")", ";", "// this is a auto-increment column, so set to default value", "}", "}" ]
Sets contents of passed object to values from current object. If desired, this method can also make copies of all associated (fkey referrers) objects. @param object $copyObj An object of ApiLog (or compatible) type. @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. @throws PropelException
[ "Sets", "contents", "of", "passed", "object", "to", "values", "from", "current", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L985-L1007
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.setRemoteApp
public function setRemoteApp(RemoteApp $v = null) { if ($v === null) { $this->setRemoteAppId(NULL); } else { $this->setRemoteAppId($v->getId()); } $this->aRemoteApp = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the RemoteApp object, it will not be re-added. if ($v !== null) { $v->addApiLog($this); } return $this; }
php
public function setRemoteApp(RemoteApp $v = null) { if ($v === null) { $this->setRemoteAppId(NULL); } else { $this->setRemoteAppId($v->getId()); } $this->aRemoteApp = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the RemoteApp object, it will not be re-added. if ($v !== null) { $v->addApiLog($this); } return $this; }
[ "public", "function", "setRemoteApp", "(", "RemoteApp", "$", "v", "=", "null", ")", "{", "if", "(", "$", "v", "===", "null", ")", "{", "$", "this", "->", "setRemoteAppId", "(", "NULL", ")", ";", "}", "else", "{", "$", "this", "->", "setRemoteAppId", "(", "$", "v", "->", "getId", "(", ")", ")", ";", "}", "$", "this", "->", "aRemoteApp", "=", "$", "v", ";", "// Add binding for other direction of this n:n relationship.", "// If this object has already been added to the RemoteApp object, it will not be re-added.", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "->", "addApiLog", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Declares an association between this object and a RemoteApp object. @param RemoteApp $v @return ApiLog The current object (for fluent API support) @throws PropelException
[ "Declares", "an", "association", "between", "this", "object", "and", "a", "RemoteApp", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L1056-L1074
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.getRemoteApp
public function getRemoteApp(PropelPDO $con = null, $doQuery = true) { if ($this->aRemoteApp === null && ($this->remote_app_id !== null) && $doQuery) { $this->aRemoteApp = RemoteAppQuery::create()->findPk($this->remote_app_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aRemoteApp->addApiLogs($this); */ } return $this->aRemoteApp; }
php
public function getRemoteApp(PropelPDO $con = null, $doQuery = true) { if ($this->aRemoteApp === null && ($this->remote_app_id !== null) && $doQuery) { $this->aRemoteApp = RemoteAppQuery::create()->findPk($this->remote_app_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aRemoteApp->addApiLogs($this); */ } return $this->aRemoteApp; }
[ "public", "function", "getRemoteApp", "(", "PropelPDO", "$", "con", "=", "null", ",", "$", "doQuery", "=", "true", ")", "{", "if", "(", "$", "this", "->", "aRemoteApp", "===", "null", "&&", "(", "$", "this", "->", "remote_app_id", "!==", "null", ")", "&&", "$", "doQuery", ")", "{", "$", "this", "->", "aRemoteApp", "=", "RemoteAppQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "this", "->", "remote_app_id", ",", "$", "con", ")", ";", "/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aRemoteApp->addApiLogs($this);\n */", "}", "return", "$", "this", "->", "aRemoteApp", ";", "}" ]
Get the associated RemoteApp object @param PropelPDO $con Optional Connection object. @param $doQuery Executes a query to get the object if required @return RemoteApp The associated RemoteApp object. @throws PropelException
[ "Get", "the", "associated", "RemoteApp", "object" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L1085-L1099
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLog.php
BaseApiLog.clear
public function clear() { $this->id = null; $this->dt_call = null; $this->remote_app_id = null; $this->statuscode = null; $this->last_response = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
php
public function clear() { $this->id = null; $this->dt_call = null; $this->remote_app_id = null; $this->statuscode = null; $this->last_response = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "id", "=", "null", ";", "$", "this", "->", "dt_call", "=", "null", ";", "$", "this", "->", "remote_app_id", "=", "null", ";", "$", "this", "->", "statuscode", "=", "null", ";", "$", "this", "->", "last_response", "=", "null", ";", "$", "this", "->", "alreadyInSave", "=", "false", ";", "$", "this", "->", "alreadyInValidation", "=", "false", ";", "$", "this", "->", "alreadyInClearAllReferencesDeep", "=", "false", ";", "$", "this", "->", "clearAllReferences", "(", ")", ";", "$", "this", "->", "resetModified", "(", ")", ";", "$", "this", "->", "setNew", "(", "true", ")", ";", "$", "this", "->", "setDeleted", "(", "false", ")", ";", "}" ]
Clears the current object and sets all attributes to their default values
[ "Clears", "the", "current", "object", "and", "sets", "all", "attributes", "to", "their", "default", "values" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLog.php#L1104-L1118
PeekAndPoke/psi
src/Operation/FullSet/UserKeySortOperation.php
UserKeySortOperation.apply
public function apply(\Iterator $set) { $data = iterator_to_array($set); uksort($data, $this->function); return new \ArrayIterator($data); }
php
public function apply(\Iterator $set) { $data = iterator_to_array($set); uksort($data, $this->function); return new \ArrayIterator($data); }
[ "public", "function", "apply", "(", "\\", "Iterator", "$", "set", ")", "{", "$", "data", "=", "iterator_to_array", "(", "$", "set", ")", ";", "uksort", "(", "$", "data", ",", "$", "this", "->", "function", ")", ";", "return", "new", "\\", "ArrayIterator", "(", "$", "data", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/PeekAndPoke/psi/blob/cfd45d995d3a2c2ea6ba5b1ce7b5fcc71179456f/src/Operation/FullSet/UserKeySortOperation.php#L23-L30
krzysztofmazur/php-object-mapper
src/KrzysztofMazur/ObjectMapper/Util/PropertyNameConverter.php
PropertyNameConverter.getPropertyName
public function getPropertyName($methodName) { $this->checkMethodName($methodName); return lcfirst($this->removeAllPrefixes(self::ACCESSOR_PREFIXES, $methodName)); }
php
public function getPropertyName($methodName) { $this->checkMethodName($methodName); return lcfirst($this->removeAllPrefixes(self::ACCESSOR_PREFIXES, $methodName)); }
[ "public", "function", "getPropertyName", "(", "$", "methodName", ")", "{", "$", "this", "->", "checkMethodName", "(", "$", "methodName", ")", ";", "return", "lcfirst", "(", "$", "this", "->", "removeAllPrefixes", "(", "self", "::", "ACCESSOR_PREFIXES", ",", "$", "methodName", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/Util/PropertyNameConverter.php#L21-L26
krzysztofmazur/php-object-mapper
src/KrzysztofMazur/ObjectMapper/Util/PropertyNameConverter.php
PropertyNameConverter.getGetterName
public function getGetterName($propertyName, $boolean = false) { $this->checkPropertyName($propertyName); return sprintf("%s%s", $boolean ? 'is' : 'get', ucfirst($propertyName)); }
php
public function getGetterName($propertyName, $boolean = false) { $this->checkPropertyName($propertyName); return sprintf("%s%s", $boolean ? 'is' : 'get', ucfirst($propertyName)); }
[ "public", "function", "getGetterName", "(", "$", "propertyName", ",", "$", "boolean", "=", "false", ")", "{", "$", "this", "->", "checkPropertyName", "(", "$", "propertyName", ")", ";", "return", "sprintf", "(", "\"%s%s\"", ",", "$", "boolean", "?", "'is'", ":", "'get'", ",", "ucfirst", "(", "$", "propertyName", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/Util/PropertyNameConverter.php#L31-L36
apioo/psx-sandbox
src/Parser.php
Parser.parse
public function parse($code) { $parser = $this->parserFactory->create($this->parserType); try { $ast = $parser->parse($code); } catch (Error $error) { throw new ParseException($error->getMessage(), 0, $error); } $printer = new Printer($this->securityManager); return $printer->prettyPrintFile($ast); }
php
public function parse($code) { $parser = $this->parserFactory->create($this->parserType); try { $ast = $parser->parse($code); } catch (Error $error) { throw new ParseException($error->getMessage(), 0, $error); } $printer = new Printer($this->securityManager); return $printer->prettyPrintFile($ast); }
[ "public", "function", "parse", "(", "$", "code", ")", "{", "$", "parser", "=", "$", "this", "->", "parserFactory", "->", "create", "(", "$", "this", "->", "parserType", ")", ";", "try", "{", "$", "ast", "=", "$", "parser", "->", "parse", "(", "$", "code", ")", ";", "}", "catch", "(", "Error", "$", "error", ")", "{", "throw", "new", "ParseException", "(", "$", "error", "->", "getMessage", "(", ")", ",", "0", ",", "$", "error", ")", ";", "}", "$", "printer", "=", "new", "Printer", "(", "$", "this", "->", "securityManager", ")", ";", "return", "$", "printer", "->", "prettyPrintFile", "(", "$", "ast", ")", ";", "}" ]
Parses untrusted PHP code and returns a secure version which only contains safe calls. Throws an exception in case the code contains untrusted calls @throws \PSX\Sandbox\SecurityException @throws \PSX\Sandbox\ParseException @param string $code @return string
[ "Parses", "untrusted", "PHP", "code", "and", "returns", "a", "secure", "version", "which", "only", "contains", "safe", "calls", ".", "Throws", "an", "exception", "in", "case", "the", "code", "contains", "untrusted", "calls" ]
train
https://github.com/apioo/psx-sandbox/blob/5d136a398da375056e6526bbbc85d7f5d3df9441/src/Parser.php#L67-L79
djgadd/themosis-illuminate
src/Mail/Transport/WpMailTransport.php
WpMailTransport.send
public function send(Swift_Mime_Message $msg, &$failedRecipients = null) { $this->beforeSendPerformed($msg); // Send the message using wp_mail if (wp_mail(array_keys($msg->getTo()), $msg->getSubject(), $msg->toString(), $msg->getHeaders()->toString(), [])) { $this->sendPerformed($msg); } return $this->numberOfRecipients($msg); }
php
public function send(Swift_Mime_Message $msg, &$failedRecipients = null) { $this->beforeSendPerformed($msg); // Send the message using wp_mail if (wp_mail(array_keys($msg->getTo()), $msg->getSubject(), $msg->toString(), $msg->getHeaders()->toString(), [])) { $this->sendPerformed($msg); } return $this->numberOfRecipients($msg); }
[ "public", "function", "send", "(", "Swift_Mime_Message", "$", "msg", ",", "&", "$", "failedRecipients", "=", "null", ")", "{", "$", "this", "->", "beforeSendPerformed", "(", "$", "msg", ")", ";", "// Send the message using wp_mail", "if", "(", "wp_mail", "(", "array_keys", "(", "$", "msg", "->", "getTo", "(", ")", ")", ",", "$", "msg", "->", "getSubject", "(", ")", ",", "$", "msg", "->", "toString", "(", ")", ",", "$", "msg", "->", "getHeaders", "(", ")", "->", "toString", "(", ")", ",", "[", "]", ")", ")", "{", "$", "this", "->", "sendPerformed", "(", "$", "msg", ")", ";", "}", "return", "$", "this", "->", "numberOfRecipients", "(", "$", "msg", ")", ";", "}" ]
Send the given Message. Recipient/sender data will be retrieved from the Message API. The return value is the number of recipients who were accepted for delivery. @param Swift_Mime_Message $msg @param string[] $failedRecipients An array of failures by-reference @return int
[ "Send", "the", "given", "Message", "." ]
train
https://github.com/djgadd/themosis-illuminate/blob/13ee4c3413cddd85a2f262ac361f35c81da0c53c/src/Mail/Transport/WpMailTransport.php#L21-L31
fubhy/graphql-php
src/Language/Lexer.php
Lexer.positionAfterWhitespace
protected function positionAfterWhitespace($start) { $position = $start; $length = $this->source->getLength(); while ($start < $length) { $code = $this->charCodeAt($position); // Skip whitespace. if ( $code === 32 || // space $code === 44 || // comma $code === 160 || // '\xa0' $code === 0x2028 || // line separator $code === 0x2029 || // paragraph separator $code > 8 && $code < 14 // whitespace ) { ++$position; // Skip comments. } elseif ($code === 35) { // # ++$position; while ( $position < $length && ($code = $this->charCodeAt($position)) && $code !== 10 && $code !== 13 && $code !== 0x2028 && $code !== 0x2029 ) { ++$position; } } else { break; } } return $position; }
php
protected function positionAfterWhitespace($start) { $position = $start; $length = $this->source->getLength(); while ($start < $length) { $code = $this->charCodeAt($position); // Skip whitespace. if ( $code === 32 || // space $code === 44 || // comma $code === 160 || // '\xa0' $code === 0x2028 || // line separator $code === 0x2029 || // paragraph separator $code > 8 && $code < 14 // whitespace ) { ++$position; // Skip comments. } elseif ($code === 35) { // # ++$position; while ( $position < $length && ($code = $this->charCodeAt($position)) && $code !== 10 && $code !== 13 && $code !== 0x2028 && $code !== 0x2029 ) { ++$position; } } else { break; } } return $position; }
[ "protected", "function", "positionAfterWhitespace", "(", "$", "start", ")", "{", "$", "position", "=", "$", "start", ";", "$", "length", "=", "$", "this", "->", "source", "->", "getLength", "(", ")", ";", "while", "(", "$", "start", "<", "$", "length", ")", "{", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "$", "position", ")", ";", "// Skip whitespace.", "if", "(", "$", "code", "===", "32", "||", "// space", "$", "code", "===", "44", "||", "// comma", "$", "code", "===", "160", "||", "// '\\xa0'", "$", "code", "===", "0x2028", "||", "// line separator", "$", "code", "===", "0x2029", "||", "// paragraph separator", "$", "code", ">", "8", "&&", "$", "code", "<", "14", "// whitespace", ")", "{", "++", "$", "position", ";", "// Skip comments.", "}", "elseif", "(", "$", "code", "===", "35", ")", "{", "// #", "++", "$", "position", ";", "while", "(", "$", "position", "<", "$", "length", "&&", "(", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "$", "position", ")", ")", "&&", "$", "code", "!==", "10", "&&", "$", "code", "!==", "13", "&&", "$", "code", "!==", "0x2028", "&&", "$", "code", "!==", "0x2029", ")", "{", "++", "$", "position", ";", "}", "}", "else", "{", "break", ";", "}", "}", "return", "$", "position", ";", "}" ]
Reads from body starting at startPosition until it finds a non-whitespace or commented character, then returns the position of that character for lexing. @param int $start @return int
[ "Reads", "from", "body", "starting", "at", "startPosition", "until", "it", "finds", "a", "non", "-", "whitespace", "or", "commented", "character", "then", "returns", "the", "position", "of", "that", "character", "for", "lexing", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Lexer.php#L28-L63
fubhy/graphql-php
src/Language/Lexer.php
Lexer.readToken
public function readToken($start) { $length = $this->source->getLength(); $position = $this->positionAfterWhitespace($start); if ($position >= $length) { return new Token(Token::EOF_TYPE, $length, $length); } $code = $this->charCodeAt($position); switch ($code) { // ! case 33: return new Token(Token::BANG_TYPE, $position, $position + 1); // $ case 36: return new Token(Token::DOLLAR_TYPE, $position, $position + 1); // ( case 40: return new Token(Token::PAREN_L_TYPE, $position, $position + 1); // ) case 41: return new Token(Token::PAREN_R_TYPE, $position, $position + 1); // . case 46: if ($this->charCodeAt($position + 1) === 46 && $this->charCodeAt($position + 2) === 46) { return new Token(Token::SPREAD_TYPE, $position, $position + 3); } break; // : case 58: return new Token(Token::COLON_TYPE, $position, $position + 1); // = case 61: return new Token(Token::EQUALS_TYPE, $position, $position + 1); // @ case 64: return new Token(Token::AT_TYPE, $position, $position + 1); // [ case 91: return new Token(Token::BRACKET_L_TYPE, $position, $position + 1); // ] case 93: return new Token(Token::BRACKET_R_TYPE, $position, $position + 1); // { case 123: return new Token(Token::BRACE_L_TYPE, $position, $position + 1); // | case 124: return new Token(Token::PIPE_TYPE, $position, $position + 1); // } case 125: return new Token(Token::BRACE_R_TYPE, $position, $position + 1); // A-Z case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: case 90: // _ case 95: // a-z case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: case 120: case 121: case 122: return $this->readName($position); // - case 45: // 0-9 case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: return $this->readNumber($position, $code); // " case 34: return $this->readString($position); } // @todo Throw proper exception. throw new \Exception('Unexpected character.'); }
php
public function readToken($start) { $length = $this->source->getLength(); $position = $this->positionAfterWhitespace($start); if ($position >= $length) { return new Token(Token::EOF_TYPE, $length, $length); } $code = $this->charCodeAt($position); switch ($code) { // ! case 33: return new Token(Token::BANG_TYPE, $position, $position + 1); // $ case 36: return new Token(Token::DOLLAR_TYPE, $position, $position + 1); // ( case 40: return new Token(Token::PAREN_L_TYPE, $position, $position + 1); // ) case 41: return new Token(Token::PAREN_R_TYPE, $position, $position + 1); // . case 46: if ($this->charCodeAt($position + 1) === 46 && $this->charCodeAt($position + 2) === 46) { return new Token(Token::SPREAD_TYPE, $position, $position + 3); } break; // : case 58: return new Token(Token::COLON_TYPE, $position, $position + 1); // = case 61: return new Token(Token::EQUALS_TYPE, $position, $position + 1); // @ case 64: return new Token(Token::AT_TYPE, $position, $position + 1); // [ case 91: return new Token(Token::BRACKET_L_TYPE, $position, $position + 1); // ] case 93: return new Token(Token::BRACKET_R_TYPE, $position, $position + 1); // { case 123: return new Token(Token::BRACE_L_TYPE, $position, $position + 1); // | case 124: return new Token(Token::PIPE_TYPE, $position, $position + 1); // } case 125: return new Token(Token::BRACE_R_TYPE, $position, $position + 1); // A-Z case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: case 90: // _ case 95: // a-z case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: case 120: case 121: case 122: return $this->readName($position); // - case 45: // 0-9 case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: return $this->readNumber($position, $code); // " case 34: return $this->readString($position); } // @todo Throw proper exception. throw new \Exception('Unexpected character.'); }
[ "public", "function", "readToken", "(", "$", "start", ")", "{", "$", "length", "=", "$", "this", "->", "source", "->", "getLength", "(", ")", ";", "$", "position", "=", "$", "this", "->", "positionAfterWhitespace", "(", "$", "start", ")", ";", "if", "(", "$", "position", ">=", "$", "length", ")", "{", "return", "new", "Token", "(", "Token", "::", "EOF_TYPE", ",", "$", "length", ",", "$", "length", ")", ";", "}", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "$", "position", ")", ";", "switch", "(", "$", "code", ")", "{", "// !", "case", "33", ":", "return", "new", "Token", "(", "Token", "::", "BANG_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// $", "case", "36", ":", "return", "new", "Token", "(", "Token", "::", "DOLLAR_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// (", "case", "40", ":", "return", "new", "Token", "(", "Token", "::", "PAREN_L_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// )", "case", "41", ":", "return", "new", "Token", "(", "Token", "::", "PAREN_R_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// .", "case", "46", ":", "if", "(", "$", "this", "->", "charCodeAt", "(", "$", "position", "+", "1", ")", "===", "46", "&&", "$", "this", "->", "charCodeAt", "(", "$", "position", "+", "2", ")", "===", "46", ")", "{", "return", "new", "Token", "(", "Token", "::", "SPREAD_TYPE", ",", "$", "position", ",", "$", "position", "+", "3", ")", ";", "}", "break", ";", "// :", "case", "58", ":", "return", "new", "Token", "(", "Token", "::", "COLON_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// =", "case", "61", ":", "return", "new", "Token", "(", "Token", "::", "EQUALS_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// @", "case", "64", ":", "return", "new", "Token", "(", "Token", "::", "AT_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// [", "case", "91", ":", "return", "new", "Token", "(", "Token", "::", "BRACKET_L_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// ]", "case", "93", ":", "return", "new", "Token", "(", "Token", "::", "BRACKET_R_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// {", "case", "123", ":", "return", "new", "Token", "(", "Token", "::", "BRACE_L_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// |", "case", "124", ":", "return", "new", "Token", "(", "Token", "::", "PIPE_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// }", "case", "125", ":", "return", "new", "Token", "(", "Token", "::", "BRACE_R_TYPE", ",", "$", "position", ",", "$", "position", "+", "1", ")", ";", "// A-Z", "case", "65", ":", "case", "66", ":", "case", "67", ":", "case", "68", ":", "case", "69", ":", "case", "70", ":", "case", "71", ":", "case", "72", ":", "case", "73", ":", "case", "74", ":", "case", "75", ":", "case", "76", ":", "case", "77", ":", "case", "78", ":", "case", "79", ":", "case", "80", ":", "case", "81", ":", "case", "82", ":", "case", "83", ":", "case", "84", ":", "case", "85", ":", "case", "86", ":", "case", "87", ":", "case", "88", ":", "case", "89", ":", "case", "90", ":", "// _", "case", "95", ":", "// a-z", "case", "97", ":", "case", "98", ":", "case", "99", ":", "case", "100", ":", "case", "101", ":", "case", "102", ":", "case", "103", ":", "case", "104", ":", "case", "105", ":", "case", "106", ":", "case", "107", ":", "case", "108", ":", "case", "109", ":", "case", "110", ":", "case", "111", ":", "case", "112", ":", "case", "113", ":", "case", "114", ":", "case", "115", ":", "case", "116", ":", "case", "117", ":", "case", "118", ":", "case", "119", ":", "case", "120", ":", "case", "121", ":", "case", "122", ":", "return", "$", "this", "->", "readName", "(", "$", "position", ")", ";", "// -", "case", "45", ":", "// 0-9", "case", "48", ":", "case", "49", ":", "case", "50", ":", "case", "51", ":", "case", "52", ":", "case", "53", ":", "case", "54", ":", "case", "55", ":", "case", "56", ":", "case", "57", ":", "return", "$", "this", "->", "readNumber", "(", "$", "position", ",", "$", "code", ")", ";", "// \"", "case", "34", ":", "return", "$", "this", "->", "readString", "(", "$", "position", ")", ";", "}", "// @todo Throw proper exception.", "throw", "new", "\\", "Exception", "(", "'Unexpected character.'", ")", ";", "}" ]
@param int $start @return \Fubhy\GraphQL\Language\Token @throws \Exception
[ "@param", "int", "$start" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Lexer.php#L72-L152
fubhy/graphql-php
src/Language/Lexer.php
Lexer.readNumber
protected function readNumber($start, $code) { $position = $start; $type = Token::INT_TYPE; if ($code === 45) { // - $code = $this->charCodeAt(++$position); } if ($code === 48) { // 0 $code = $this->charCodeAt(++$position); } elseif ($code >= 49 && $code <= 57) { // 1 - 9 do { $code = $this->charCodeAt(++$position); } while ($code >= 48 && $code <= 57); // 0 - 9 } else { // @todo Throw proper exception. throw new \Exception('Invalid number.'); } if ($code === 46) { // . $type = Token::FLOAT_TYPE; $code = $this->charCodeAt(++$position); if ($code >= 48 && $code <= 57) { // 0 - 9 do { $code = $this->charCodeAt(++$position); } while ($code >= 48 && $code <= 57); // 0 - 9 } else { // @todo Throw proper exception. throw new \Exception('Invalid number.'); } if ($code === 69 || $code === 101) { // E e $code = $this->charCodeAt(++$position); if ($code === 43 || $code === 45) { // + - $code = $this->charCodeAt(++$position); } if ($code >= 48 && $code <= 57) { // 0 - 9 do { $code = $this->charCodeAt(++$position); } while ($code >= 48 && $code <= 57); // 0 - 9 } else { // @todo Throw proper exception. throw new \Exception('Invalid number.'); } } } $body = $this->source->getBody(); $value = mb_substr($body, $start, $position - $start, 'UTF-8'); return new Token($type, $start, $position, $value); }
php
protected function readNumber($start, $code) { $position = $start; $type = Token::INT_TYPE; if ($code === 45) { // - $code = $this->charCodeAt(++$position); } if ($code === 48) { // 0 $code = $this->charCodeAt(++$position); } elseif ($code >= 49 && $code <= 57) { // 1 - 9 do { $code = $this->charCodeAt(++$position); } while ($code >= 48 && $code <= 57); // 0 - 9 } else { // @todo Throw proper exception. throw new \Exception('Invalid number.'); } if ($code === 46) { // . $type = Token::FLOAT_TYPE; $code = $this->charCodeAt(++$position); if ($code >= 48 && $code <= 57) { // 0 - 9 do { $code = $this->charCodeAt(++$position); } while ($code >= 48 && $code <= 57); // 0 - 9 } else { // @todo Throw proper exception. throw new \Exception('Invalid number.'); } if ($code === 69 || $code === 101) { // E e $code = $this->charCodeAt(++$position); if ($code === 43 || $code === 45) { // + - $code = $this->charCodeAt(++$position); } if ($code >= 48 && $code <= 57) { // 0 - 9 do { $code = $this->charCodeAt(++$position); } while ($code >= 48 && $code <= 57); // 0 - 9 } else { // @todo Throw proper exception. throw new \Exception('Invalid number.'); } } } $body = $this->source->getBody(); $value = mb_substr($body, $start, $position - $start, 'UTF-8'); return new Token($type, $start, $position, $value); }
[ "protected", "function", "readNumber", "(", "$", "start", ",", "$", "code", ")", "{", "$", "position", "=", "$", "start", ";", "$", "type", "=", "Token", "::", "INT_TYPE", ";", "if", "(", "$", "code", "===", "45", ")", "{", "// -", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "++", "$", "position", ")", ";", "}", "if", "(", "$", "code", "===", "48", ")", "{", "// 0", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "++", "$", "position", ")", ";", "}", "elseif", "(", "$", "code", ">=", "49", "&&", "$", "code", "<=", "57", ")", "{", "// 1 - 9", "do", "{", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "++", "$", "position", ")", ";", "}", "while", "(", "$", "code", ">=", "48", "&&", "$", "code", "<=", "57", ")", ";", "// 0 - 9", "}", "else", "{", "// @todo Throw proper exception.", "throw", "new", "\\", "Exception", "(", "'Invalid number.'", ")", ";", "}", "if", "(", "$", "code", "===", "46", ")", "{", "// .", "$", "type", "=", "Token", "::", "FLOAT_TYPE", ";", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "++", "$", "position", ")", ";", "if", "(", "$", "code", ">=", "48", "&&", "$", "code", "<=", "57", ")", "{", "// 0 - 9", "do", "{", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "++", "$", "position", ")", ";", "}", "while", "(", "$", "code", ">=", "48", "&&", "$", "code", "<=", "57", ")", ";", "// 0 - 9", "}", "else", "{", "// @todo Throw proper exception.", "throw", "new", "\\", "Exception", "(", "'Invalid number.'", ")", ";", "}", "if", "(", "$", "code", "===", "69", "||", "$", "code", "===", "101", ")", "{", "// E e", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "++", "$", "position", ")", ";", "if", "(", "$", "code", "===", "43", "||", "$", "code", "===", "45", ")", "{", "// + -", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "++", "$", "position", ")", ";", "}", "if", "(", "$", "code", ">=", "48", "&&", "$", "code", "<=", "57", ")", "{", "// 0 - 9", "do", "{", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "++", "$", "position", ")", ";", "}", "while", "(", "$", "code", ">=", "48", "&&", "$", "code", "<=", "57", ")", ";", "// 0 - 9", "}", "else", "{", "// @todo Throw proper exception.", "throw", "new", "\\", "Exception", "(", "'Invalid number.'", ")", ";", "}", "}", "}", "$", "body", "=", "$", "this", "->", "source", "->", "getBody", "(", ")", ";", "$", "value", "=", "mb_substr", "(", "$", "body", ",", "$", "start", ",", "$", "position", "-", "$", "start", ",", "'UTF-8'", ")", ";", "return", "new", "Token", "(", "$", "type", ",", "$", "start", ",", "$", "position", ",", "$", "value", ")", ";", "}" ]
Reads a number token from the source file, either a float or an int depending on whether a decimal point appears. Int: -?(0|[1-9][0-9]*) Float: -?(0|[1-9][0-9]*)\.[0-9]+(e-?[0-9]+)? @param int $start @param int $code @return \Fubhy\GraphQL\Language\Token @throws \Exception
[ "Reads", "a", "number", "token", "from", "the", "source", "file", "either", "a", "float", "or", "an", "int", "depending", "on", "whether", "a", "decimal", "point", "appears", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Lexer.php#L168-L220
fubhy/graphql-php
src/Language/Lexer.php
Lexer.readString
protected function readString($start) { $position = $start + 1; $chunk = $position; $length = $this->source->getLength(); $body = $this->source->getBody(); $code = NULL; $value = ''; while ( $position < $length && ($code = $this->charCodeAt($position)) && $code !== 34 && $code !== 10 && $code !== 13 && $code !== 0x2028 && $code !== 0x2029 ) { ++$position; if ($code === 92) { // \ $value .= mb_substr($body, $chunk, $position - 1 - $chunk, 'UTF-8'); $code = $this->charCodeAt($position); switch ($code) { case 34: $value .= '"'; break; case 47: $value .= '\/'; break; case 92: $value .= '\\'; break; case 98: $value .= '\b'; break; case 102: $value .= '\f'; break; case 110: $value .= '\n'; break; case 114: $value .= '\r'; break; case 116: $value .= '\t'; break; case 117: $charCode = $this->uniCharCode( $this->charCodeAt($position + 1), $this->charCodeAt($position + 2), $this->charCodeAt($position + 3), $this->charCodeAt($position + 4) ); if ($charCode < 0) { // @todo Throw proper exception. throw new \Exception('Bad character escape sequence.'); } $value .= $this->fromCharCode($charCode); $position += 4; break; default: // @todo Throw proper exception. throw new \Exception('Bad character escape sequence.'); } ++$position; $chunk = $position; } } if ($code !== 34) { // @todo Throw proper exception. throw new \Exception('Unterminated string.'); } $value .= mb_substr($body, $chunk, $position - $chunk, 'UTF-8'); return new Token(Token::STRING_TYPE, $start, $position + 1, $value); }
php
protected function readString($start) { $position = $start + 1; $chunk = $position; $length = $this->source->getLength(); $body = $this->source->getBody(); $code = NULL; $value = ''; while ( $position < $length && ($code = $this->charCodeAt($position)) && $code !== 34 && $code !== 10 && $code !== 13 && $code !== 0x2028 && $code !== 0x2029 ) { ++$position; if ($code === 92) { // \ $value .= mb_substr($body, $chunk, $position - 1 - $chunk, 'UTF-8'); $code = $this->charCodeAt($position); switch ($code) { case 34: $value .= '"'; break; case 47: $value .= '\/'; break; case 92: $value .= '\\'; break; case 98: $value .= '\b'; break; case 102: $value .= '\f'; break; case 110: $value .= '\n'; break; case 114: $value .= '\r'; break; case 116: $value .= '\t'; break; case 117: $charCode = $this->uniCharCode( $this->charCodeAt($position + 1), $this->charCodeAt($position + 2), $this->charCodeAt($position + 3), $this->charCodeAt($position + 4) ); if ($charCode < 0) { // @todo Throw proper exception. throw new \Exception('Bad character escape sequence.'); } $value .= $this->fromCharCode($charCode); $position += 4; break; default: // @todo Throw proper exception. throw new \Exception('Bad character escape sequence.'); } ++$position; $chunk = $position; } } if ($code !== 34) { // @todo Throw proper exception. throw new \Exception('Unterminated string.'); } $value .= mb_substr($body, $chunk, $position - $chunk, 'UTF-8'); return new Token(Token::STRING_TYPE, $start, $position + 1, $value); }
[ "protected", "function", "readString", "(", "$", "start", ")", "{", "$", "position", "=", "$", "start", "+", "1", ";", "$", "chunk", "=", "$", "position", ";", "$", "length", "=", "$", "this", "->", "source", "->", "getLength", "(", ")", ";", "$", "body", "=", "$", "this", "->", "source", "->", "getBody", "(", ")", ";", "$", "code", "=", "NULL", ";", "$", "value", "=", "''", ";", "while", "(", "$", "position", "<", "$", "length", "&&", "(", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "$", "position", ")", ")", "&&", "$", "code", "!==", "34", "&&", "$", "code", "!==", "10", "&&", "$", "code", "!==", "13", "&&", "$", "code", "!==", "0x2028", "&&", "$", "code", "!==", "0x2029", ")", "{", "++", "$", "position", ";", "if", "(", "$", "code", "===", "92", ")", "{", "// \\", "$", "value", ".=", "mb_substr", "(", "$", "body", ",", "$", "chunk", ",", "$", "position", "-", "1", "-", "$", "chunk", ",", "'UTF-8'", ")", ";", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "$", "position", ")", ";", "switch", "(", "$", "code", ")", "{", "case", "34", ":", "$", "value", ".=", "'\"'", ";", "break", ";", "case", "47", ":", "$", "value", ".=", "'\\/'", ";", "break", ";", "case", "92", ":", "$", "value", ".=", "'\\\\'", ";", "break", ";", "case", "98", ":", "$", "value", ".=", "'\\b'", ";", "break", ";", "case", "102", ":", "$", "value", ".=", "'\\f'", ";", "break", ";", "case", "110", ":", "$", "value", ".=", "'\\n'", ";", "break", ";", "case", "114", ":", "$", "value", ".=", "'\\r'", ";", "break", ";", "case", "116", ":", "$", "value", ".=", "'\\t'", ";", "break", ";", "case", "117", ":", "$", "charCode", "=", "$", "this", "->", "uniCharCode", "(", "$", "this", "->", "charCodeAt", "(", "$", "position", "+", "1", ")", ",", "$", "this", "->", "charCodeAt", "(", "$", "position", "+", "2", ")", ",", "$", "this", "->", "charCodeAt", "(", "$", "position", "+", "3", ")", ",", "$", "this", "->", "charCodeAt", "(", "$", "position", "+", "4", ")", ")", ";", "if", "(", "$", "charCode", "<", "0", ")", "{", "// @todo Throw proper exception.", "throw", "new", "\\", "Exception", "(", "'Bad character escape sequence.'", ")", ";", "}", "$", "value", ".=", "$", "this", "->", "fromCharCode", "(", "$", "charCode", ")", ";", "$", "position", "+=", "4", ";", "break", ";", "default", ":", "// @todo Throw proper exception.", "throw", "new", "\\", "Exception", "(", "'Bad character escape sequence.'", ")", ";", "}", "++", "$", "position", ";", "$", "chunk", "=", "$", "position", ";", "}", "}", "if", "(", "$", "code", "!==", "34", ")", "{", "// @todo Throw proper exception.", "throw", "new", "\\", "Exception", "(", "'Unterminated string.'", ")", ";", "}", "$", "value", ".=", "mb_substr", "(", "$", "body", ",", "$", "chunk", ",", "$", "position", "-", "$", "chunk", ",", "'UTF-8'", ")", ";", "return", "new", "Token", "(", "Token", "::", "STRING_TYPE", ",", "$", "start", ",", "$", "position", "+", "1", ",", "$", "value", ")", ";", "}" ]
@param int $start @return \Fubhy\GraphQL\Language\Token @throws \Exception
[ "@param", "int", "$start" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Lexer.php#L229-L308
fubhy/graphql-php
src/Language/Lexer.php
Lexer.readName
protected function readName($position) { $end = $position + 1; $length = $this->source->getLength(); $body = $this->source->getBody(); while ( $end < $length && ($code = $this->charCodeAt($end)) && ( $code === 95 || // _ $code >= 48 && $code <= 57 || // 0-9 $code >= 65 && $code <= 90 || // A-Z $code >= 97 && $code <= 122 // a-z ) ) { ++$end; } $value = mb_substr($body, $position, $end - $position, 'UTF-8'); return new Token(Token::NAME_TYPE, $position, $end, $value); }
php
protected function readName($position) { $end = $position + 1; $length = $this->source->getLength(); $body = $this->source->getBody(); while ( $end < $length && ($code = $this->charCodeAt($end)) && ( $code === 95 || // _ $code >= 48 && $code <= 57 || // 0-9 $code >= 65 && $code <= 90 || // A-Z $code >= 97 && $code <= 122 // a-z ) ) { ++$end; } $value = mb_substr($body, $position, $end - $position, 'UTF-8'); return new Token(Token::NAME_TYPE, $position, $end, $value); }
[ "protected", "function", "readName", "(", "$", "position", ")", "{", "$", "end", "=", "$", "position", "+", "1", ";", "$", "length", "=", "$", "this", "->", "source", "->", "getLength", "(", ")", ";", "$", "body", "=", "$", "this", "->", "source", "->", "getBody", "(", ")", ";", "while", "(", "$", "end", "<", "$", "length", "&&", "(", "$", "code", "=", "$", "this", "->", "charCodeAt", "(", "$", "end", ")", ")", "&&", "(", "$", "code", "===", "95", "||", "// _", "$", "code", ">=", "48", "&&", "$", "code", "<=", "57", "||", "// 0-9", "$", "code", ">=", "65", "&&", "$", "code", "<=", "90", "||", "// A-Z", "$", "code", ">=", "97", "&&", "$", "code", "<=", "122", "// a-z", ")", ")", "{", "++", "$", "end", ";", "}", "$", "value", "=", "mb_substr", "(", "$", "body", ",", "$", "position", ",", "$", "end", "-", "$", "position", ",", "'UTF-8'", ")", ";", "return", "new", "Token", "(", "Token", "::", "NAME_TYPE", ",", "$", "position", ",", "$", "end", ",", "$", "value", ")", ";", "}" ]
Reads an alphanumeric + underscore name from the source. [_A-Za-z][_0-9A-Za-z]* @param int $position @return \Fubhy\GraphQL\Language\Token
[ "Reads", "an", "alphanumeric", "+", "underscore", "name", "from", "the", "source", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Lexer.php#L319-L340
fubhy/graphql-php
src/Language/Lexer.php
Lexer.charCodeAt
protected function charCodeAt($index) { $body = $this->source->getBody(); $char = mb_substr($body, $index, 1, 'UTF-8'); if (mb_check_encoding($char, 'UTF-8')) { return hexdec(bin2hex(mb_convert_encoding($char, 'UTF-32BE', 'UTF-8'))); } else { return NULL; } }
php
protected function charCodeAt($index) { $body = $this->source->getBody(); $char = mb_substr($body, $index, 1, 'UTF-8'); if (mb_check_encoding($char, 'UTF-8')) { return hexdec(bin2hex(mb_convert_encoding($char, 'UTF-32BE', 'UTF-8'))); } else { return NULL; } }
[ "protected", "function", "charCodeAt", "(", "$", "index", ")", "{", "$", "body", "=", "$", "this", "->", "source", "->", "getBody", "(", ")", ";", "$", "char", "=", "mb_substr", "(", "$", "body", ",", "$", "index", ",", "1", ",", "'UTF-8'", ")", ";", "if", "(", "mb_check_encoding", "(", "$", "char", ",", "'UTF-8'", ")", ")", "{", "return", "hexdec", "(", "bin2hex", "(", "mb_convert_encoding", "(", "$", "char", ",", "'UTF-32BE'", ",", "'UTF-8'", ")", ")", ")", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Implementation of JavaScript's String.prototype.charCodeAt function. @param int $index @return null|number
[ "Implementation", "of", "JavaScript", "s", "String", ".", "prototype", ".", "charCodeAt", "function", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Lexer.php#L349-L359
fubhy/graphql-php
src/Language/Lexer.php
Lexer.uniCharCode
protected function uniCharCode($a, $b, $c, $d) { return $this->char2hex($a) << 12 | $this->char2hex($b) << 8 | $this->char2hex($c) << 4 | $this->char2hex($d); }
php
protected function uniCharCode($a, $b, $c, $d) { return $this->char2hex($a) << 12 | $this->char2hex($b) << 8 | $this->char2hex($c) << 4 | $this->char2hex($d); }
[ "protected", "function", "uniCharCode", "(", "$", "a", ",", "$", "b", ",", "$", "c", ",", "$", "d", ")", "{", "return", "$", "this", "->", "char2hex", "(", "$", "a", ")", "<<", "12", "|", "$", "this", "->", "char2hex", "(", "$", "b", ")", "<<", "8", "|", "$", "this", "->", "char2hex", "(", "$", "c", ")", "<<", "4", "|", "$", "this", "->", "char2hex", "(", "$", "d", ")", ";", "}" ]
Converts four hexadecimal chars to the integer that the string represents. For example, uniCharCode('0','0','0','f') will return 15, and uniCharCode('0','0','f','f') returns 255. Returns a negative number on error, if a char was invalid. This is implemented by noting that char2hex() returns -1 on error, which means the result of ORing the char2hex() will also be negative. @param $a @param $b @param $c @param $d @return int
[ "Converts", "four", "hexadecimal", "chars", "to", "the", "integer", "that", "the", "string", "represents", ".", "For", "example", "uniCharCode", "(", "0", "0", "0", "f", ")", "will", "return", "15", "and", "uniCharCode", "(", "0", "0", "f", "f", ")", "returns", "255", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Lexer.php#L391-L394
fubhy/graphql-php
src/Language/Lexer.php
Lexer.char2hex
protected function char2hex($a) { return $a >= 48 && $a <= 57 ? $a - 48 : // 0-9 ($a >= 65 && $a <= 70 ? $a - 55 : // A-F ($a >= 97 && $a <= 102 ? $a - 87 : -1)); // a-f }
php
protected function char2hex($a) { return $a >= 48 && $a <= 57 ? $a - 48 : // 0-9 ($a >= 65 && $a <= 70 ? $a - 55 : // A-F ($a >= 97 && $a <= 102 ? $a - 87 : -1)); // a-f }
[ "protected", "function", "char2hex", "(", "$", "a", ")", "{", "return", "$", "a", ">=", "48", "&&", "$", "a", "<=", "57", "?", "$", "a", "-", "48", ":", "// 0-9", "(", "$", "a", ">=", "65", "&&", "$", "a", "<=", "70", "?", "$", "a", "-", "55", ":", "// A-F", "(", "$", "a", ">=", "97", "&&", "$", "a", "<=", "102", "?", "$", "a", "-", "87", ":", "-", "1", ")", ")", ";", "// a-f", "}" ]
Converts a hex character to its integer value. '0' becomes 0, '9' becomes 9 'A' becomes 10, 'F' becomes 15 'a' becomes 10, 'f' becomes 15 Returns -1 on error. @param $a @return int
[ "Converts", "a", "hex", "character", "to", "its", "integer", "value", ".", "0", "becomes", "0", "9", "becomes", "9", "A", "becomes", "10", "F", "becomes", "15", "a", "becomes", "10", "f", "becomes", "15" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Lexer.php#L408-L414
xicrow/php-debug
src/Timer.php
Timer.output
public static function output($data) { if (!self::$output || !is_string($data)) { return; } if (php_sapi_name() != 'cli') { echo sprintf(self::$style['called_from_format'], Debugger::getCalledFrom(2)); echo sprintf(self::$style['output_format'], $data); echo '<style type="text/css">.xicrow-php-debug-timer:hover{ ' . self::$style['hover_style'] . ' }</style>'; } else { echo Debugger::getCalledFrom(2); echo "\n"; echo $data; } }
php
public static function output($data) { if (!self::$output || !is_string($data)) { return; } if (php_sapi_name() != 'cli') { echo sprintf(self::$style['called_from_format'], Debugger::getCalledFrom(2)); echo sprintf(self::$style['output_format'], $data); echo '<style type="text/css">.xicrow-php-debug-timer:hover{ ' . self::$style['hover_style'] . ' }</style>'; } else { echo Debugger::getCalledFrom(2); echo "\n"; echo $data; } }
[ "public", "static", "function", "output", "(", "$", "data", ")", "{", "if", "(", "!", "self", "::", "$", "output", "||", "!", "is_string", "(", "$", "data", ")", ")", "{", "return", ";", "}", "if", "(", "php_sapi_name", "(", ")", "!=", "'cli'", ")", "{", "echo", "sprintf", "(", "self", "::", "$", "style", "[", "'called_from_format'", "]", ",", "Debugger", "::", "getCalledFrom", "(", "2", ")", ")", ";", "echo", "sprintf", "(", "self", "::", "$", "style", "[", "'output_format'", "]", ",", "$", "data", ")", ";", "echo", "'<style type=\"text/css\">.xicrow-php-debug-timer:hover{ '", ".", "self", "::", "$", "style", "[", "'hover_style'", "]", ".", "' }</style>'", ";", "}", "else", "{", "echo", "Debugger", "::", "getCalledFrom", "(", "2", ")", ";", "echo", "\"\\n\"", ";", "echo", "$", "data", ";", "}", "}" ]
@param string $data @codeCoverageIgnore
[ "@param", "string", "$data" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L59-L74
xicrow/php-debug
src/Timer.php
Timer.add
public static function add($key = null, $data = []) { // If no key is given if (is_null($key)) { // Set key to file and line $key = Debugger::getCalledFrom(2); } // If key is allready in use if (isset(self::$collection[$key])) { // Get original item $item = self::$collection[$key]; // Set new item count $itemCount = (isset($item['count']) ? ($item['count'] + 1) : 2); // Set correct key for the original item if (strpos($item['key'], '#') === false) { self::$collection[$key] = array_merge($item, [ 'key' => $key . ' #1', 'count' => $itemCount, ]); } else { self::$collection[$key] = array_merge($item, [ 'count' => $itemCount, ]); } // Set new key $key = $key . ' #' . $itemCount; } // Make sure various options are set if (!isset($data['key'])) { $data['key'] = $key; } if (!isset($data['parent'])) { $data['parent'] = self::$currentItem; } if (!isset($data['level'])) { $data['level'] = 0; if (isset($data['parent']) && isset(self::$collection[$data['parent']])) { $data['level'] = (self::$collection[$data['parent']]['level'] + 1); } } // Add item to collection self::$collection[$key] = $data; return $key; }
php
public static function add($key = null, $data = []) { // If no key is given if (is_null($key)) { // Set key to file and line $key = Debugger::getCalledFrom(2); } // If key is allready in use if (isset(self::$collection[$key])) { // Get original item $item = self::$collection[$key]; // Set new item count $itemCount = (isset($item['count']) ? ($item['count'] + 1) : 2); // Set correct key for the original item if (strpos($item['key'], '#') === false) { self::$collection[$key] = array_merge($item, [ 'key' => $key . ' #1', 'count' => $itemCount, ]); } else { self::$collection[$key] = array_merge($item, [ 'count' => $itemCount, ]); } // Set new key $key = $key . ' #' . $itemCount; } // Make sure various options are set if (!isset($data['key'])) { $data['key'] = $key; } if (!isset($data['parent'])) { $data['parent'] = self::$currentItem; } if (!isset($data['level'])) { $data['level'] = 0; if (isset($data['parent']) && isset(self::$collection[$data['parent']])) { $data['level'] = (self::$collection[$data['parent']]['level'] + 1); } } // Add item to collection self::$collection[$key] = $data; return $key; }
[ "public", "static", "function", "add", "(", "$", "key", "=", "null", ",", "$", "data", "=", "[", "]", ")", "{", "// If no key is given", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "// Set key to file and line", "$", "key", "=", "Debugger", "::", "getCalledFrom", "(", "2", ")", ";", "}", "// If key is allready in use", "if", "(", "isset", "(", "self", "::", "$", "collection", "[", "$", "key", "]", ")", ")", "{", "// Get original item", "$", "item", "=", "self", "::", "$", "collection", "[", "$", "key", "]", ";", "// Set new item count", "$", "itemCount", "=", "(", "isset", "(", "$", "item", "[", "'count'", "]", ")", "?", "(", "$", "item", "[", "'count'", "]", "+", "1", ")", ":", "2", ")", ";", "// Set correct key for the original item", "if", "(", "strpos", "(", "$", "item", "[", "'key'", "]", ",", "'#'", ")", "===", "false", ")", "{", "self", "::", "$", "collection", "[", "$", "key", "]", "=", "array_merge", "(", "$", "item", ",", "[", "'key'", "=>", "$", "key", ".", "' #1'", ",", "'count'", "=>", "$", "itemCount", ",", "]", ")", ";", "}", "else", "{", "self", "::", "$", "collection", "[", "$", "key", "]", "=", "array_merge", "(", "$", "item", ",", "[", "'count'", "=>", "$", "itemCount", ",", "]", ")", ";", "}", "// Set new key", "$", "key", "=", "$", "key", ".", "' #'", ".", "$", "itemCount", ";", "}", "// Make sure various options are set", "if", "(", "!", "isset", "(", "$", "data", "[", "'key'", "]", ")", ")", "{", "$", "data", "[", "'key'", "]", "=", "$", "key", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'parent'", "]", ")", ")", "{", "$", "data", "[", "'parent'", "]", "=", "self", "::", "$", "currentItem", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'level'", "]", ")", ")", "{", "$", "data", "[", "'level'", "]", "=", "0", ";", "if", "(", "isset", "(", "$", "data", "[", "'parent'", "]", ")", "&&", "isset", "(", "self", "::", "$", "collection", "[", "$", "data", "[", "'parent'", "]", "]", ")", ")", "{", "$", "data", "[", "'level'", "]", "=", "(", "self", "::", "$", "collection", "[", "$", "data", "[", "'parent'", "]", "]", "[", "'level'", "]", "+", "1", ")", ";", "}", "}", "// Add item to collection", "self", "::", "$", "collection", "[", "$", "key", "]", "=", "$", "data", ";", "return", "$", "key", ";", "}" ]
@param string|null $key @param array $data @return string
[ "@param", "string|null", "$key", "@param", "array", "$data" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L92-L142
xicrow/php-debug
src/Timer.php
Timer.start
public static function start($key = null) { // Add new item $key = self::add($key, [ 'start' => microtime(true), ]); // Set current item self::$currentItem = $key; // Add to running items self::$runningItems[$key] = true; return $key; }
php
public static function start($key = null) { // Add new item $key = self::add($key, [ 'start' => microtime(true), ]); // Set current item self::$currentItem = $key; // Add to running items self::$runningItems[$key] = true; return $key; }
[ "public", "static", "function", "start", "(", "$", "key", "=", "null", ")", "{", "// Add new item", "$", "key", "=", "self", "::", "add", "(", "$", "key", ",", "[", "'start'", "=>", "microtime", "(", "true", ")", ",", "]", ")", ";", "// Set current item", "self", "::", "$", "currentItem", "=", "$", "key", ";", "// Add to running items", "self", "::", "$", "runningItems", "[", "$", "key", "]", "=", "true", ";", "return", "$", "key", ";", "}" ]
@param string|null $key @return string
[ "@param", "string|null", "$key" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L149-L163
xicrow/php-debug
src/Timer.php
Timer.stop
public static function stop($key = null) { // If no key is given if (is_null($key)) { // Get key of the last started item end(self::$runningItems); $key = key(self::$runningItems); } // Check for key duplicates, and find the last one not stopped if (isset(self::$collection[$key]) && isset(self::$collection[$key . ' #2'])) { $lastNotStopped = false; $currentKey = $key; $currentIndex = 1; while (isset(self::$collection[$currentKey])) { if (!isset(self::$collection[$currentKey]['stop'])) { $lastNotStopped = $currentKey; } $currentIndex++; $currentKey = $key . ' #' . $currentIndex; } if ($lastNotStopped) { $key = $lastNotStopped; } } // If item exists in collection if (isset(self::$collection[$key])) { // Update the item self::$collection[$key]['stop'] = microtime(true); self::$currentItem = self::$collection[$key]['parent']; } if (isset(self::$runningItems[$key])) { unset(self::$runningItems[$key]); } return $key; }
php
public static function stop($key = null) { // If no key is given if (is_null($key)) { // Get key of the last started item end(self::$runningItems); $key = key(self::$runningItems); } // Check for key duplicates, and find the last one not stopped if (isset(self::$collection[$key]) && isset(self::$collection[$key . ' #2'])) { $lastNotStopped = false; $currentKey = $key; $currentIndex = 1; while (isset(self::$collection[$currentKey])) { if (!isset(self::$collection[$currentKey]['stop'])) { $lastNotStopped = $currentKey; } $currentIndex++; $currentKey = $key . ' #' . $currentIndex; } if ($lastNotStopped) { $key = $lastNotStopped; } } // If item exists in collection if (isset(self::$collection[$key])) { // Update the item self::$collection[$key]['stop'] = microtime(true); self::$currentItem = self::$collection[$key]['parent']; } if (isset(self::$runningItems[$key])) { unset(self::$runningItems[$key]); } return $key; }
[ "public", "static", "function", "stop", "(", "$", "key", "=", "null", ")", "{", "// If no key is given", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "// Get key of the last started item", "end", "(", "self", "::", "$", "runningItems", ")", ";", "$", "key", "=", "key", "(", "self", "::", "$", "runningItems", ")", ";", "}", "// Check for key duplicates, and find the last one not stopped", "if", "(", "isset", "(", "self", "::", "$", "collection", "[", "$", "key", "]", ")", "&&", "isset", "(", "self", "::", "$", "collection", "[", "$", "key", ".", "' #2'", "]", ")", ")", "{", "$", "lastNotStopped", "=", "false", ";", "$", "currentKey", "=", "$", "key", ";", "$", "currentIndex", "=", "1", ";", "while", "(", "isset", "(", "self", "::", "$", "collection", "[", "$", "currentKey", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "collection", "[", "$", "currentKey", "]", "[", "'stop'", "]", ")", ")", "{", "$", "lastNotStopped", "=", "$", "currentKey", ";", "}", "$", "currentIndex", "++", ";", "$", "currentKey", "=", "$", "key", ".", "' #'", ".", "$", "currentIndex", ";", "}", "if", "(", "$", "lastNotStopped", ")", "{", "$", "key", "=", "$", "lastNotStopped", ";", "}", "}", "// If item exists in collection", "if", "(", "isset", "(", "self", "::", "$", "collection", "[", "$", "key", "]", ")", ")", "{", "// Update the item", "self", "::", "$", "collection", "[", "$", "key", "]", "[", "'stop'", "]", "=", "microtime", "(", "true", ")", ";", "self", "::", "$", "currentItem", "=", "self", "::", "$", "collection", "[", "$", "key", "]", "[", "'parent'", "]", ";", "}", "if", "(", "isset", "(", "self", "::", "$", "runningItems", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "runningItems", "[", "$", "key", "]", ")", ";", "}", "return", "$", "key", ";", "}" ]
@param string|null $key @return string
[ "@param", "string|null", "$key" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L170-L211
xicrow/php-debug
src/Timer.php
Timer.custom
public static function custom($key = null, $start = null, $stop = null) { // Add new item self::add($key, [ 'start' => $start, 'stop' => $stop, ]); // If no stop value is given if (is_null($stop)) { // Set current item self::$currentItem = $key; // Add to running items self::$runningItems[$key] = true; } return $key; }
php
public static function custom($key = null, $start = null, $stop = null) { // Add new item self::add($key, [ 'start' => $start, 'stop' => $stop, ]); // If no stop value is given if (is_null($stop)) { // Set current item self::$currentItem = $key; // Add to running items self::$runningItems[$key] = true; } return $key; }
[ "public", "static", "function", "custom", "(", "$", "key", "=", "null", ",", "$", "start", "=", "null", ",", "$", "stop", "=", "null", ")", "{", "// Add new item", "self", "::", "add", "(", "$", "key", ",", "[", "'start'", "=>", "$", "start", ",", "'stop'", "=>", "$", "stop", ",", "]", ")", ";", "// If no stop value is given", "if", "(", "is_null", "(", "$", "stop", ")", ")", "{", "// Set current item", "self", "::", "$", "currentItem", "=", "$", "key", ";", "// Add to running items", "self", "::", "$", "runningItems", "[", "$", "key", "]", "=", "true", ";", "}", "return", "$", "key", ";", "}" ]
@param string|null $key @param int|float|null $start @param int|float|null $stop @return string
[ "@param", "string|null", "$key", "@param", "int|float|null", "$start", "@param", "int|float|null", "$stop" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L220-L238
xicrow/php-debug
src/Timer.php
Timer.callback
public static function callback($key = null, $callback) { // Get parameters for callback $callbackParams = func_get_args(); unset($callbackParams[0], $callbackParams[1]); $callbackParams = array_values($callbackParams); // Get key if no key is given if (is_null($key)) { if (is_string($callback)) { $key = $callback; } elseif (is_array($callback)) { $keyArr = []; foreach ($callback as $k => $v) { if (is_string($v)) { $keyArr[] = $v; } elseif (is_object($v)) { $keyArr[] = get_class($v); } } $key = implode('', $keyArr); if (count($keyArr) > 1) { $method = array_pop($keyArr); $key = implode('/', $keyArr); $key .= '::' . $method; } unset($keyArr, $method); } elseif (is_object($callback) && $callback instanceof \Closure) { $key = 'closure'; } $key = 'callback: ' . $key; } // Set default return value $returnValue = true; // Set error handler, to convert errors to exceptions set_error_handler(function ($errno, $errstr, $errfile, $errline, array $errcontext) { throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }); try { // Start output buffer to capture any output ob_start(); // Start profiler self::start($key); // Execute callback, and get result $callbackResult = call_user_func_array($callback, $callbackParams); // Stop profiler self::stop($key); // Get and clean output buffer $callbackOutput = ob_get_clean(); } catch (\ErrorException $callbackException) { // Stop and clean output buffer ob_end_clean(); // Show error message self::output('Invalid callback sent to Timer::callback: ' . str_replace('callback: ', '', $key)); // Clear the item from the collection unset(self::$collection[$key]); // Clear callback result and output unset($callbackResult, $callbackOutput); // Set return value to false $returnValue = false; } // Restore error handler restore_error_handler(); // Return result, output or true return (isset($callbackResult) ? $callbackResult : (!empty($callbackOutput) ? $callbackOutput : $returnValue)); }
php
public static function callback($key = null, $callback) { // Get parameters for callback $callbackParams = func_get_args(); unset($callbackParams[0], $callbackParams[1]); $callbackParams = array_values($callbackParams); // Get key if no key is given if (is_null($key)) { if (is_string($callback)) { $key = $callback; } elseif (is_array($callback)) { $keyArr = []; foreach ($callback as $k => $v) { if (is_string($v)) { $keyArr[] = $v; } elseif (is_object($v)) { $keyArr[] = get_class($v); } } $key = implode('', $keyArr); if (count($keyArr) > 1) { $method = array_pop($keyArr); $key = implode('/', $keyArr); $key .= '::' . $method; } unset($keyArr, $method); } elseif (is_object($callback) && $callback instanceof \Closure) { $key = 'closure'; } $key = 'callback: ' . $key; } // Set default return value $returnValue = true; // Set error handler, to convert errors to exceptions set_error_handler(function ($errno, $errstr, $errfile, $errline, array $errcontext) { throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }); try { // Start output buffer to capture any output ob_start(); // Start profiler self::start($key); // Execute callback, and get result $callbackResult = call_user_func_array($callback, $callbackParams); // Stop profiler self::stop($key); // Get and clean output buffer $callbackOutput = ob_get_clean(); } catch (\ErrorException $callbackException) { // Stop and clean output buffer ob_end_clean(); // Show error message self::output('Invalid callback sent to Timer::callback: ' . str_replace('callback: ', '', $key)); // Clear the item from the collection unset(self::$collection[$key]); // Clear callback result and output unset($callbackResult, $callbackOutput); // Set return value to false $returnValue = false; } // Restore error handler restore_error_handler(); // Return result, output or true return (isset($callbackResult) ? $callbackResult : (!empty($callbackOutput) ? $callbackOutput : $returnValue)); }
[ "public", "static", "function", "callback", "(", "$", "key", "=", "null", ",", "$", "callback", ")", "{", "// Get parameters for callback", "$", "callbackParams", "=", "func_get_args", "(", ")", ";", "unset", "(", "$", "callbackParams", "[", "0", "]", ",", "$", "callbackParams", "[", "1", "]", ")", ";", "$", "callbackParams", "=", "array_values", "(", "$", "callbackParams", ")", ";", "// Get key if no key is given", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "if", "(", "is_string", "(", "$", "callback", ")", ")", "{", "$", "key", "=", "$", "callback", ";", "}", "elseif", "(", "is_array", "(", "$", "callback", ")", ")", "{", "$", "keyArr", "=", "[", "]", ";", "foreach", "(", "$", "callback", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_string", "(", "$", "v", ")", ")", "{", "$", "keyArr", "[", "]", "=", "$", "v", ";", "}", "elseif", "(", "is_object", "(", "$", "v", ")", ")", "{", "$", "keyArr", "[", "]", "=", "get_class", "(", "$", "v", ")", ";", "}", "}", "$", "key", "=", "implode", "(", "''", ",", "$", "keyArr", ")", ";", "if", "(", "count", "(", "$", "keyArr", ")", ">", "1", ")", "{", "$", "method", "=", "array_pop", "(", "$", "keyArr", ")", ";", "$", "key", "=", "implode", "(", "'/'", ",", "$", "keyArr", ")", ";", "$", "key", ".=", "'::'", ".", "$", "method", ";", "}", "unset", "(", "$", "keyArr", ",", "$", "method", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "callback", ")", "&&", "$", "callback", "instanceof", "\\", "Closure", ")", "{", "$", "key", "=", "'closure'", ";", "}", "$", "key", "=", "'callback: '", ".", "$", "key", ";", "}", "// Set default return value", "$", "returnValue", "=", "true", ";", "// Set error handler, to convert errors to exceptions", "set_error_handler", "(", "function", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ",", "array", "$", "errcontext", ")", "{", "throw", "new", "\\", "ErrorException", "(", "$", "errstr", ",", "0", ",", "$", "errno", ",", "$", "errfile", ",", "$", "errline", ")", ";", "}", ")", ";", "try", "{", "// Start output buffer to capture any output", "ob_start", "(", ")", ";", "// Start profiler", "self", "::", "start", "(", "$", "key", ")", ";", "// Execute callback, and get result", "$", "callbackResult", "=", "call_user_func_array", "(", "$", "callback", ",", "$", "callbackParams", ")", ";", "// Stop profiler", "self", "::", "stop", "(", "$", "key", ")", ";", "// Get and clean output buffer", "$", "callbackOutput", "=", "ob_get_clean", "(", ")", ";", "}", "catch", "(", "\\", "ErrorException", "$", "callbackException", ")", "{", "// Stop and clean output buffer", "ob_end_clean", "(", ")", ";", "// Show error message", "self", "::", "output", "(", "'Invalid callback sent to Timer::callback: '", ".", "str_replace", "(", "'callback: '", ",", "''", ",", "$", "key", ")", ")", ";", "// Clear the item from the collection", "unset", "(", "self", "::", "$", "collection", "[", "$", "key", "]", ")", ";", "// Clear callback result and output", "unset", "(", "$", "callbackResult", ",", "$", "callbackOutput", ")", ";", "// Set return value to false", "$", "returnValue", "=", "false", ";", "}", "// Restore error handler", "restore_error_handler", "(", ")", ";", "// Return result, output or true", "return", "(", "isset", "(", "$", "callbackResult", ")", "?", "$", "callbackResult", ":", "(", "!", "empty", "(", "$", "callbackOutput", ")", "?", "$", "callbackOutput", ":", "$", "returnValue", ")", ")", ";", "}" ]
@param string|null $key @param string|array|\Closure $callback @return mixed
[ "@param", "string|null", "$key", "@param", "string|array|", "\\", "Closure", "$callback" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L246-L326
xicrow/php-debug
src/Timer.php
Timer.show
public static function show($key = null, $options = []) { $output = self::getStats($key, $options); if (!empty($output)) { self::output($output); } }
php
public static function show($key = null, $options = []) { $output = self::getStats($key, $options); if (!empty($output)) { self::output($output); } }
[ "public", "static", "function", "show", "(", "$", "key", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "output", "=", "self", "::", "getStats", "(", "$", "key", ",", "$", "options", ")", ";", "if", "(", "!", "empty", "(", "$", "output", ")", ")", "{", "self", "::", "output", "(", "$", "output", ")", ";", "}", "}" ]
@param string|null $key @param array $options @codeCoverageIgnore
[ "@param", "string|null", "$key", "@param", "array", "$options" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L334-L341
xicrow/php-debug
src/Timer.php
Timer.showAll
public static function showAll($options = []) { // Stop started items if (count(self::$runningItems)) { foreach (self::$runningItems as $key => $value) { self::stop($key); } } // Output items $output = ''; $itemCount = 1; foreach (self::$collection as $key => $item) { $stats = self::getStats($key, $options); if (php_sapi_name() == 'cli') { $output .= (!empty($output) ? "\n" : '') . $stats; } else { $output .= '<div class="xicrow-php-debug-timer">'; $output .= $stats; $output .= '</div>'; } $itemCount++; unset($stats); } unset($itemCount); self::output($output); }
php
public static function showAll($options = []) { // Stop started items if (count(self::$runningItems)) { foreach (self::$runningItems as $key => $value) { self::stop($key); } } // Output items $output = ''; $itemCount = 1; foreach (self::$collection as $key => $item) { $stats = self::getStats($key, $options); if (php_sapi_name() == 'cli') { $output .= (!empty($output) ? "\n" : '') . $stats; } else { $output .= '<div class="xicrow-php-debug-timer">'; $output .= $stats; $output .= '</div>'; } $itemCount++; unset($stats); } unset($itemCount); self::output($output); }
[ "public", "static", "function", "showAll", "(", "$", "options", "=", "[", "]", ")", "{", "// Stop started items", "if", "(", "count", "(", "self", "::", "$", "runningItems", ")", ")", "{", "foreach", "(", "self", "::", "$", "runningItems", "as", "$", "key", "=>", "$", "value", ")", "{", "self", "::", "stop", "(", "$", "key", ")", ";", "}", "}", "// Output items", "$", "output", "=", "''", ";", "$", "itemCount", "=", "1", ";", "foreach", "(", "self", "::", "$", "collection", "as", "$", "key", "=>", "$", "item", ")", "{", "$", "stats", "=", "self", "::", "getStats", "(", "$", "key", ",", "$", "options", ")", ";", "if", "(", "php_sapi_name", "(", ")", "==", "'cli'", ")", "{", "$", "output", ".=", "(", "!", "empty", "(", "$", "output", ")", "?", "\"\\n\"", ":", "''", ")", ".", "$", "stats", ";", "}", "else", "{", "$", "output", ".=", "'<div class=\"xicrow-php-debug-timer\">'", ";", "$", "output", ".=", "$", "stats", ";", "$", "output", ".=", "'</div>'", ";", "}", "$", "itemCount", "++", ";", "unset", "(", "$", "stats", ")", ";", "}", "unset", "(", "$", "itemCount", ")", ";", "self", "::", "output", "(", "$", "output", ")", ";", "}" ]
@param array $options @codeCoverageIgnore
[ "@param", "array", "$options" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L348-L378
xicrow/php-debug
src/Timer.php
Timer.getStats
public static function getStats($key, $options = []) { // Merge options with default options $options = array_merge([ // Show nested (boolean) 'nested' => true, // Prefix for nested items (string) 'nested_prefix' => '|-- ', // Max key length (int) 'max_key_length' => 100, ], $options); // If item does not exist if (!isset(self::$collection[$key])) { return 'Unknow item in with key: ' . $key; } // Get item $item = self::$collection[$key]; // Get item result $itemResult = 'N/A'; $itemResultFormatted = 'N/A'; if (isset($item['start']) && isset($item['stop'])) { $itemResult = (($item['stop'] - $item['start']) * 1000); $itemResultFormatted = self::formatMiliseconds($itemResult, 4, self::$forceDisplayUnit); } // Variable for output $output = ''; // Prep key for output $outputName = ''; $outputName .= ($options['nested'] ? str_repeat($options['nested_prefix'], $item['level']) : ''); $outputName .= $item['key']; if (mb_strlen($outputName) > $options['max_key_length']) { $outputName = '~' . mb_substr($item['key'], -($options['max_key_length'] - 1)); } // Add item stats $output .= str_pad($outputName, ($options['max_key_length'] + (strlen($outputName) - mb_strlen($outputName))), ' '); $output .= ' | '; $output .= str_pad($itemResultFormatted, 20, ' ', ($itemResult == 'N/A' ? STR_PAD_RIGHT : STR_PAD_LEFT)); if (php_sapi_name() != 'cli' && is_array(self::$colorThreshold) && count(self::$colorThreshold)) { krsort(self::$colorThreshold); foreach (self::$colorThreshold as $value => $color) { if (is_numeric($itemResult) && $itemResult >= $value) { $output = '<span style="color: ' . $color . ';">' . $output . '</span>'; } } } return $output; }
php
public static function getStats($key, $options = []) { // Merge options with default options $options = array_merge([ // Show nested (boolean) 'nested' => true, // Prefix for nested items (string) 'nested_prefix' => '|-- ', // Max key length (int) 'max_key_length' => 100, ], $options); // If item does not exist if (!isset(self::$collection[$key])) { return 'Unknow item in with key: ' . $key; } // Get item $item = self::$collection[$key]; // Get item result $itemResult = 'N/A'; $itemResultFormatted = 'N/A'; if (isset($item['start']) && isset($item['stop'])) { $itemResult = (($item['stop'] - $item['start']) * 1000); $itemResultFormatted = self::formatMiliseconds($itemResult, 4, self::$forceDisplayUnit); } // Variable for output $output = ''; // Prep key for output $outputName = ''; $outputName .= ($options['nested'] ? str_repeat($options['nested_prefix'], $item['level']) : ''); $outputName .= $item['key']; if (mb_strlen($outputName) > $options['max_key_length']) { $outputName = '~' . mb_substr($item['key'], -($options['max_key_length'] - 1)); } // Add item stats $output .= str_pad($outputName, ($options['max_key_length'] + (strlen($outputName) - mb_strlen($outputName))), ' '); $output .= ' | '; $output .= str_pad($itemResultFormatted, 20, ' ', ($itemResult == 'N/A' ? STR_PAD_RIGHT : STR_PAD_LEFT)); if (php_sapi_name() != 'cli' && is_array(self::$colorThreshold) && count(self::$colorThreshold)) { krsort(self::$colorThreshold); foreach (self::$colorThreshold as $value => $color) { if (is_numeric($itemResult) && $itemResult >= $value) { $output = '<span style="color: ' . $color . ';">' . $output . '</span>'; } } } return $output; }
[ "public", "static", "function", "getStats", "(", "$", "key", ",", "$", "options", "=", "[", "]", ")", "{", "// Merge options with default options", "$", "options", "=", "array_merge", "(", "[", "// Show nested (boolean)", "'nested'", "=>", "true", ",", "// Prefix for nested items (string)", "'nested_prefix'", "=>", "'|-- '", ",", "// Max key length (int)", "'max_key_length'", "=>", "100", ",", "]", ",", "$", "options", ")", ";", "// If item does not exist", "if", "(", "!", "isset", "(", "self", "::", "$", "collection", "[", "$", "key", "]", ")", ")", "{", "return", "'Unknow item in with key: '", ".", "$", "key", ";", "}", "// Get item", "$", "item", "=", "self", "::", "$", "collection", "[", "$", "key", "]", ";", "// Get item result", "$", "itemResult", "=", "'N/A'", ";", "$", "itemResultFormatted", "=", "'N/A'", ";", "if", "(", "isset", "(", "$", "item", "[", "'start'", "]", ")", "&&", "isset", "(", "$", "item", "[", "'stop'", "]", ")", ")", "{", "$", "itemResult", "=", "(", "(", "$", "item", "[", "'stop'", "]", "-", "$", "item", "[", "'start'", "]", ")", "*", "1000", ")", ";", "$", "itemResultFormatted", "=", "self", "::", "formatMiliseconds", "(", "$", "itemResult", ",", "4", ",", "self", "::", "$", "forceDisplayUnit", ")", ";", "}", "// Variable for output", "$", "output", "=", "''", ";", "// Prep key for output", "$", "outputName", "=", "''", ";", "$", "outputName", ".=", "(", "$", "options", "[", "'nested'", "]", "?", "str_repeat", "(", "$", "options", "[", "'nested_prefix'", "]", ",", "$", "item", "[", "'level'", "]", ")", ":", "''", ")", ";", "$", "outputName", ".=", "$", "item", "[", "'key'", "]", ";", "if", "(", "mb_strlen", "(", "$", "outputName", ")", ">", "$", "options", "[", "'max_key_length'", "]", ")", "{", "$", "outputName", "=", "'~'", ".", "mb_substr", "(", "$", "item", "[", "'key'", "]", ",", "-", "(", "$", "options", "[", "'max_key_length'", "]", "-", "1", ")", ")", ";", "}", "// Add item stats", "$", "output", ".=", "str_pad", "(", "$", "outputName", ",", "(", "$", "options", "[", "'max_key_length'", "]", "+", "(", "strlen", "(", "$", "outputName", ")", "-", "mb_strlen", "(", "$", "outputName", ")", ")", ")", ",", "' '", ")", ";", "$", "output", ".=", "' | '", ";", "$", "output", ".=", "str_pad", "(", "$", "itemResultFormatted", ",", "20", ",", "' '", ",", "(", "$", "itemResult", "==", "'N/A'", "?", "STR_PAD_RIGHT", ":", "STR_PAD_LEFT", ")", ")", ";", "if", "(", "php_sapi_name", "(", ")", "!=", "'cli'", "&&", "is_array", "(", "self", "::", "$", "colorThreshold", ")", "&&", "count", "(", "self", "::", "$", "colorThreshold", ")", ")", "{", "krsort", "(", "self", "::", "$", "colorThreshold", ")", ";", "foreach", "(", "self", "::", "$", "colorThreshold", "as", "$", "value", "=>", "$", "color", ")", "{", "if", "(", "is_numeric", "(", "$", "itemResult", ")", "&&", "$", "itemResult", ">=", "$", "value", ")", "{", "$", "output", "=", "'<span style=\"color: '", ".", "$", "color", ".", "';\">'", ".", "$", "output", ".", "'</span>'", ";", "}", "}", "}", "return", "$", "output", ";", "}" ]
@param string|null $key @param array $options @return string
[ "@param", "string|null", "$key", "@param", "array", "$options" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L386-L440
xicrow/php-debug
src/Timer.php
Timer.formatMiliseconds
public static function formatMiliseconds($number = 0, $precision = 2, $forceUnit = null) { $units = [ 'MS' => 1, 'S' => 1000, 'M' => 60, 'H' => 60, 'D' => 24, 'W' => 7, ]; if (is_null($forceUnit)) { $forceUnit = self::$forceDisplayUnit; } $value = $number; if (!empty($forceUnit) && array_key_exists($forceUnit, $units)) { $unit = $forceUnit; foreach ($units as $k => $v) { $value = ($value / $v); if ($k == $unit) { break; } } } else { $unit = ''; foreach ($units as $k => $v) { if (empty($unit) || ($value / $v) > 1) { $value = ($value / $v); $unit = $k; } else { break; } } } return sprintf('%0.' . $precision . 'f', $value) . ' ' . str_pad($unit, 2, ' ', STR_PAD_RIGHT); }
php
public static function formatMiliseconds($number = 0, $precision = 2, $forceUnit = null) { $units = [ 'MS' => 1, 'S' => 1000, 'M' => 60, 'H' => 60, 'D' => 24, 'W' => 7, ]; if (is_null($forceUnit)) { $forceUnit = self::$forceDisplayUnit; } $value = $number; if (!empty($forceUnit) && array_key_exists($forceUnit, $units)) { $unit = $forceUnit; foreach ($units as $k => $v) { $value = ($value / $v); if ($k == $unit) { break; } } } else { $unit = ''; foreach ($units as $k => $v) { if (empty($unit) || ($value / $v) > 1) { $value = ($value / $v); $unit = $k; } else { break; } } } return sprintf('%0.' . $precision . 'f', $value) . ' ' . str_pad($unit, 2, ' ', STR_PAD_RIGHT); }
[ "public", "static", "function", "formatMiliseconds", "(", "$", "number", "=", "0", ",", "$", "precision", "=", "2", ",", "$", "forceUnit", "=", "null", ")", "{", "$", "units", "=", "[", "'MS'", "=>", "1", ",", "'S'", "=>", "1000", ",", "'M'", "=>", "60", ",", "'H'", "=>", "60", ",", "'D'", "=>", "24", ",", "'W'", "=>", "7", ",", "]", ";", "if", "(", "is_null", "(", "$", "forceUnit", ")", ")", "{", "$", "forceUnit", "=", "self", "::", "$", "forceDisplayUnit", ";", "}", "$", "value", "=", "$", "number", ";", "if", "(", "!", "empty", "(", "$", "forceUnit", ")", "&&", "array_key_exists", "(", "$", "forceUnit", ",", "$", "units", ")", ")", "{", "$", "unit", "=", "$", "forceUnit", ";", "foreach", "(", "$", "units", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "value", "=", "(", "$", "value", "/", "$", "v", ")", ";", "if", "(", "$", "k", "==", "$", "unit", ")", "{", "break", ";", "}", "}", "}", "else", "{", "$", "unit", "=", "''", ";", "foreach", "(", "$", "units", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "empty", "(", "$", "unit", ")", "||", "(", "$", "value", "/", "$", "v", ")", ">", "1", ")", "{", "$", "value", "=", "(", "$", "value", "/", "$", "v", ")", ";", "$", "unit", "=", "$", "k", ";", "}", "else", "{", "break", ";", "}", "}", "}", "return", "sprintf", "(", "'%0.'", ".", "$", "precision", ".", "'f'", ",", "$", "value", ")", ".", "' '", ".", "str_pad", "(", "$", "unit", ",", "2", ",", "' '", ",", "STR_PAD_RIGHT", ")", ";", "}" ]
@param int|float $number @param int $precision @param null|string $forceUnit @return string
[ "@param", "int|float", "$number", "@param", "int", "$precision", "@param", "null|string", "$forceUnit" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Timer.php#L449-L486
nikolaposa/disqus-helper
src/Disqus.php
Disqus.create
public static function create( string $shortName, WidgetLocatorInterface $widgetLocator = null ) : Disqus { $disqusHelper = new self(); $disqusHelper->shortName = $shortName; $disqusHelper->widgetLocator = $widgetLocator ?? WidgetManager::createWithDefaultWidgets(); $disqusHelper->code = Code::create($shortName); return $disqusHelper; }
php
public static function create( string $shortName, WidgetLocatorInterface $widgetLocator = null ) : Disqus { $disqusHelper = new self(); $disqusHelper->shortName = $shortName; $disqusHelper->widgetLocator = $widgetLocator ?? WidgetManager::createWithDefaultWidgets(); $disqusHelper->code = Code::create($shortName); return $disqusHelper; }
[ "public", "static", "function", "create", "(", "string", "$", "shortName", ",", "WidgetLocatorInterface", "$", "widgetLocator", "=", "null", ")", ":", "Disqus", "{", "$", "disqusHelper", "=", "new", "self", "(", ")", ";", "$", "disqusHelper", "->", "shortName", "=", "$", "shortName", ";", "$", "disqusHelper", "->", "widgetLocator", "=", "$", "widgetLocator", "??", "WidgetManager", "::", "createWithDefaultWidgets", "(", ")", ";", "$", "disqusHelper", "->", "code", "=", "Code", "::", "create", "(", "$", "shortName", ")", ";", "return", "$", "disqusHelper", ";", "}" ]
@param string $shortName Unique identifier of some Disqus website. @param WidgetLocatorInterface $widgetLocator OPTIONAL @return Disqus
[ "@param", "string", "$shortName", "Unique", "identifier", "of", "some", "Disqus", "website", ".", "@param", "WidgetLocatorInterface", "$widgetLocator", "OPTIONAL" ]
train
https://github.com/nikolaposa/disqus-helper/blob/1e224aa84c00c4c87bff9eef4e33ad01c6f60704/src/Disqus.php#L51-L64
webforge-labs/psc-cms
lib/Psc/CMS/EntityGridPanel.php
EntityGridPanel.addProperty
public function addProperty($propertyName, $flags = 0x000000, Closure $htmlConverter = NULL) { $property = $this->entityMeta->getPropertyMeta($propertyName, $this->labeler); if ($flags & self::TCI_BUTTON) { $entityMeta = $this->entityMeta; return $this->createColumn($property->getName(), $property->getType(), $property->getLabel(), array($property->getName(),'tci'), function (Entity $entity) use ($property, $entityMeta, $htmlConverter) { $adapter = $entityMeta->getAdapter($entity, EntityMeta::CONTEXT_GRID); $adapter->setButtonMode(\Psc\CMS\Item\Buttonable::CLICK | \Psc\CMS\Item\Buttonable::DRAG); $button = $adapter->getTabButton(); if (isset($htmlConverter)) { return $htmlConverter($button, $entity, $property, $entityMeta); } return $button; } ); } else { $column = $this->createColumn($property->getName(), $property->getType(), $property->getLabel()); $valueConverter = $this->getDefaultConverter($column); $column->setConverter( // ein wrapper um den value converter herum // somit geben wir den wert des properties des entities an die zelle function (Entity $entity) use ($property, $column, $valueConverter, $htmlConverter) { if ($htmlConverter) { return $htmlConverter($entity->callGetter($property->getName()), $entity, $property); } else { return $valueConverter($entity->callGetter($property->getName()), $column); } } ); return $column; } }
php
public function addProperty($propertyName, $flags = 0x000000, Closure $htmlConverter = NULL) { $property = $this->entityMeta->getPropertyMeta($propertyName, $this->labeler); if ($flags & self::TCI_BUTTON) { $entityMeta = $this->entityMeta; return $this->createColumn($property->getName(), $property->getType(), $property->getLabel(), array($property->getName(),'tci'), function (Entity $entity) use ($property, $entityMeta, $htmlConverter) { $adapter = $entityMeta->getAdapter($entity, EntityMeta::CONTEXT_GRID); $adapter->setButtonMode(\Psc\CMS\Item\Buttonable::CLICK | \Psc\CMS\Item\Buttonable::DRAG); $button = $adapter->getTabButton(); if (isset($htmlConverter)) { return $htmlConverter($button, $entity, $property, $entityMeta); } return $button; } ); } else { $column = $this->createColumn($property->getName(), $property->getType(), $property->getLabel()); $valueConverter = $this->getDefaultConverter($column); $column->setConverter( // ein wrapper um den value converter herum // somit geben wir den wert des properties des entities an die zelle function (Entity $entity) use ($property, $column, $valueConverter, $htmlConverter) { if ($htmlConverter) { return $htmlConverter($entity->callGetter($property->getName()), $entity, $property); } else { return $valueConverter($entity->callGetter($property->getName()), $column); } } ); return $column; } }
[ "public", "function", "addProperty", "(", "$", "propertyName", ",", "$", "flags", "=", "0x000000", ",", "Closure", "$", "htmlConverter", "=", "NULL", ")", "{", "$", "property", "=", "$", "this", "->", "entityMeta", "->", "getPropertyMeta", "(", "$", "propertyName", ",", "$", "this", "->", "labeler", ")", ";", "if", "(", "$", "flags", "&", "self", "::", "TCI_BUTTON", ")", "{", "$", "entityMeta", "=", "$", "this", "->", "entityMeta", ";", "return", "$", "this", "->", "createColumn", "(", "$", "property", "->", "getName", "(", ")", ",", "$", "property", "->", "getType", "(", ")", ",", "$", "property", "->", "getLabel", "(", ")", ",", "array", "(", "$", "property", "->", "getName", "(", ")", ",", "'tci'", ")", ",", "function", "(", "Entity", "$", "entity", ")", "use", "(", "$", "property", ",", "$", "entityMeta", ",", "$", "htmlConverter", ")", "{", "$", "adapter", "=", "$", "entityMeta", "->", "getAdapter", "(", "$", "entity", ",", "EntityMeta", "::", "CONTEXT_GRID", ")", ";", "$", "adapter", "->", "setButtonMode", "(", "\\", "Psc", "\\", "CMS", "\\", "Item", "\\", "Buttonable", "::", "CLICK", "|", "\\", "Psc", "\\", "CMS", "\\", "Item", "\\", "Buttonable", "::", "DRAG", ")", ";", "$", "button", "=", "$", "adapter", "->", "getTabButton", "(", ")", ";", "if", "(", "isset", "(", "$", "htmlConverter", ")", ")", "{", "return", "$", "htmlConverter", "(", "$", "button", ",", "$", "entity", ",", "$", "property", ",", "$", "entityMeta", ")", ";", "}", "return", "$", "button", ";", "}", ")", ";", "}", "else", "{", "$", "column", "=", "$", "this", "->", "createColumn", "(", "$", "property", "->", "getName", "(", ")", ",", "$", "property", "->", "getType", "(", ")", ",", "$", "property", "->", "getLabel", "(", ")", ")", ";", "$", "valueConverter", "=", "$", "this", "->", "getDefaultConverter", "(", "$", "column", ")", ";", "$", "column", "->", "setConverter", "(", "// ein wrapper um den value converter herum", "// somit geben wir den wert des properties des entities an die zelle", "function", "(", "Entity", "$", "entity", ")", "use", "(", "$", "property", ",", "$", "column", ",", "$", "valueConverter", ",", "$", "htmlConverter", ")", "{", "if", "(", "$", "htmlConverter", ")", "{", "return", "$", "htmlConverter", "(", "$", "entity", "->", "callGetter", "(", "$", "property", "->", "getName", "(", ")", ")", ",", "$", "entity", ",", "$", "property", ")", ";", "}", "else", "{", "return", "$", "valueConverter", "(", "$", "entity", "->", "callGetter", "(", "$", "property", "->", "getName", "(", ")", ")", ",", "$", "column", ")", ";", "}", "}", ")", ";", "return", "$", "column", ";", "}", "}" ]
Fügt ein Property des Entities als Spalte dem Grid hinzu flags: TCI_BUTTON stellt den Inhalt des Properties in einen Button dar, der das Entity als Button repräsentiert. wenn mit dem Grid Tabs geöffnet werden sollen, muss mindestens ein Property ein TCI_BUTTON flag haben @param bitmap $flags @param Closure $htmlConverter für tci: function ($button, $entity, $property, $entityMeta), normal: function ($propertyValue, $entity, $property) @return Psc\CMS\FormPanelColumn
[ "Fügt", "ein", "Property", "des", "Entities", "als", "Spalte", "dem", "Grid", "hinzu" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityGridPanel.php#L78-L115
webforge-labs/psc-cms
lib/Psc/CMS/EntityGridPanel.php
EntityGridPanel.addEntities
public function addEntities($entities) { foreach ($entities as $entity) { $row = array(); foreach ($this->columns as $columnName => $column) { $converter = $column->getConverter(); $row[] = $converter($entity, $column); } $this->addRow($row); } return $this; }
php
public function addEntities($entities) { foreach ($entities as $entity) { $row = array(); foreach ($this->columns as $columnName => $column) { $converter = $column->getConverter(); $row[] = $converter($entity, $column); } $this->addRow($row); } return $this; }
[ "public", "function", "addEntities", "(", "$", "entities", ")", "{", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "$", "row", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "columns", "as", "$", "columnName", "=>", "$", "column", ")", "{", "$", "converter", "=", "$", "column", "->", "getConverter", "(", ")", ";", "$", "row", "[", "]", "=", "$", "converter", "(", "$", "entity", ",", "$", "column", ")", ";", "}", "$", "this", "->", "addRow", "(", "$", "row", ")", ";", "}", "return", "$", "this", ";", "}" ]
Fügt mehrere Entities dem Grid hinzu
[ "Fügt", "mehrere", "Entities", "dem", "Grid", "hinzu" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityGridPanel.php#L120-L130
webforge-labs/psc-cms
lib/Psc/Doctrine/NestedSetFixture.php
NestedSetFixture.load
public function load(ObjectManager $em) { $bridge = new DoctrineBridge($em); $bridge->beginTransaction(); $nodes = $this->convertNodes($this->example->toParentPointerArray(), $em); foreach($nodes as $node) { $bridge->persist($node); } $bridge->commit(); $em->flush(); }
php
public function load(ObjectManager $em) { $bridge = new DoctrineBridge($em); $bridge->beginTransaction(); $nodes = $this->convertNodes($this->example->toParentPointerArray(), $em); foreach($nodes as $node) { $bridge->persist($node); } $bridge->commit(); $em->flush(); }
[ "public", "function", "load", "(", "ObjectManager", "$", "em", ")", "{", "$", "bridge", "=", "new", "DoctrineBridge", "(", "$", "em", ")", ";", "$", "bridge", "->", "beginTransaction", "(", ")", ";", "$", "nodes", "=", "$", "this", "->", "convertNodes", "(", "$", "this", "->", "example", "->", "toParentPointerArray", "(", ")", ",", "$", "em", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "bridge", "->", "persist", "(", "$", "node", ")", ";", "}", "$", "bridge", "->", "commit", "(", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}" ]
Load data fixtures with the passed EntityManager @param Doctrine\Common\Persistence\ObjectManager $manager
[ "Load", "data", "fixtures", "with", "the", "passed", "EntityManager" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/NestedSetFixture.php#L30-L42
webforge-labs/psc-cms
lib/Psc/Doctrine/NestedSetFixture.php
NestedSetFixture.convertNodes
protected function convertNodes(Array $nodes, $em) { // our test project (this) is defined to have only de as i18n but dont get confused, these are english wordings $navigationNodes = array(); foreach ($nodes as $node) { $node = (object) $node; $navigationNode = $this->createNode(array('de'=>$node->title)); $navigationNode->setContext($this->context); $navigationNode->generateSlugs(); $page = $this->createPage($navigationNode->getSlug('de')); $page->setActive(TRUE); $em->persist($page); $navigationNode->setPage($page); $navigationNodes[$navigationNode->getTitle('de')] = $navigationNode; } foreach ($nodes as $node) { $node = (object) $node; if (isset($node->parent)) { $navigationNodes[$node->title]->setParent($navigationNodes[$node->parent]); } } return $navigationNodes; }
php
protected function convertNodes(Array $nodes, $em) { // our test project (this) is defined to have only de as i18n but dont get confused, these are english wordings $navigationNodes = array(); foreach ($nodes as $node) { $node = (object) $node; $navigationNode = $this->createNode(array('de'=>$node->title)); $navigationNode->setContext($this->context); $navigationNode->generateSlugs(); $page = $this->createPage($navigationNode->getSlug('de')); $page->setActive(TRUE); $em->persist($page); $navigationNode->setPage($page); $navigationNodes[$navigationNode->getTitle('de')] = $navigationNode; } foreach ($nodes as $node) { $node = (object) $node; if (isset($node->parent)) { $navigationNodes[$node->title]->setParent($navigationNodes[$node->parent]); } } return $navigationNodes; }
[ "protected", "function", "convertNodes", "(", "Array", "$", "nodes", ",", "$", "em", ")", "{", "// our test project (this) is defined to have only de as i18n but dont get confused, these are english wordings", "$", "navigationNodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "node", "=", "(", "object", ")", "$", "node", ";", "$", "navigationNode", "=", "$", "this", "->", "createNode", "(", "array", "(", "'de'", "=>", "$", "node", "->", "title", ")", ")", ";", "$", "navigationNode", "->", "setContext", "(", "$", "this", "->", "context", ")", ";", "$", "navigationNode", "->", "generateSlugs", "(", ")", ";", "$", "page", "=", "$", "this", "->", "createPage", "(", "$", "navigationNode", "->", "getSlug", "(", "'de'", ")", ")", ";", "$", "page", "->", "setActive", "(", "TRUE", ")", ";", "$", "em", "->", "persist", "(", "$", "page", ")", ";", "$", "navigationNode", "->", "setPage", "(", "$", "page", ")", ";", "$", "navigationNodes", "[", "$", "navigationNode", "->", "getTitle", "(", "'de'", ")", "]", "=", "$", "navigationNode", ";", "}", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "node", "=", "(", "object", ")", "$", "node", ";", "if", "(", "isset", "(", "$", "node", "->", "parent", ")", ")", "{", "$", "navigationNodes", "[", "$", "node", "->", "title", "]", "->", "setParent", "(", "$", "navigationNodes", "[", "$", "node", "->", "parent", "]", ")", ";", "}", "}", "return", "$", "navigationNodes", ";", "}" ]
we elevate every node to an entity and set parent pointers
[ "we", "elevate", "every", "node", "to", "an", "entity", "and", "set", "parent", "pointers" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/NestedSetFixture.php#L47-L75
periaptio/empress-generator
src/Commands/MigrationMakeCommand.php
MigrationMakeCommand.handle
public function handle() { parent::handle(); $this->comment('Generating migrations for: '. implode(', ', $this->tables)); $migrationGenerator = new MigrationGenerator($this); $migrationGenerator->generate(); }
php
public function handle() { parent::handle(); $this->comment('Generating migrations for: '. implode(', ', $this->tables)); $migrationGenerator = new MigrationGenerator($this); $migrationGenerator->generate(); }
[ "public", "function", "handle", "(", ")", "{", "parent", "::", "handle", "(", ")", ";", "$", "this", "->", "comment", "(", "'Generating migrations for: '", ".", "implode", "(", "', '", ",", "$", "this", "->", "tables", ")", ")", ";", "$", "migrationGenerator", "=", "new", "MigrationGenerator", "(", "$", "this", ")", ";", "$", "migrationGenerator", "->", "generate", "(", ")", ";", "}" ]
Execute the command. @return void
[ "Execute", "the", "command", "." ]
train
https://github.com/periaptio/empress-generator/blob/749fb4b12755819e9c97377ebfb446ee0822168a/src/Commands/MigrationMakeCommand.php#L41-L49
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/MorphOne.php
MorphOne.setDefaultOptions
protected function setDefaultOptions(array $options=[]) { parent::setDefaultOptions($options); $this->defaultOptions['primary_key'] = $this->toModel->getKeyName(); }
php
protected function setDefaultOptions(array $options=[]) { parent::setDefaultOptions($options); $this->defaultOptions['primary_key'] = $this->toModel->getKeyName(); }
[ "protected", "function", "setDefaultOptions", "(", "array", "$", "options", "=", "[", "]", ")", "{", "parent", "::", "setDefaultOptions", "(", "$", "options", ")", ";", "$", "this", "->", "defaultOptions", "[", "'primary_key'", "]", "=", "$", "this", "->", "toModel", "->", "getKeyName", "(", ")", ";", "}" ]
set default options @param $options @return void
[ "set", "default", "options" ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/MorphOne.php#L29-L35
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/MorphOne.php
MorphOne.stylingText
protected function stylingText() { parent::stylingText(); $this->text['table'] = "[".$this->command->paintString($this->model->getTable(), 'green')."]"; $this->text['primary_key'] = "[".$this->command->paintString($this->defaultOptions['primary_key'], 'green')."]"; $this->text['primary_text'] = $this->command->paintString('primary key', 'brown'); }
php
protected function stylingText() { parent::stylingText(); $this->text['table'] = "[".$this->command->paintString($this->model->getTable(), 'green')."]"; $this->text['primary_key'] = "[".$this->command->paintString($this->defaultOptions['primary_key'], 'green')."]"; $this->text['primary_text'] = $this->command->paintString('primary key', 'brown'); }
[ "protected", "function", "stylingText", "(", ")", "{", "parent", "::", "stylingText", "(", ")", ";", "$", "this", "->", "text", "[", "'table'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "$", "this", "->", "model", "->", "getTable", "(", ")", ",", "'green'", ")", ".", "\"]\"", ";", "$", "this", "->", "text", "[", "'primary_key'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "$", "this", "->", "defaultOptions", "[", "'primary_key'", "]", ",", "'green'", ")", ".", "\"]\"", ";", "$", "this", "->", "text", "[", "'primary_text'", "]", "=", "$", "this", "->", "command", "->", "paintString", "(", "'primary key'", ",", "'brown'", ")", ";", "}" ]
styling text @return void
[ "styling", "text" ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/MorphOne.php#L42-L49
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/MorphOne.php
MorphOne.setConnectedRelationOptions
protected function setConnectedRelationOptions() { parent::setConnectedRelationOptions(); if (! $this->db->isFieldExists($table = $this->model->getTable(), $this->defaultOptions['primary_key'])) { $this->options['primary_key'] = $this->command->choice( "Can't find field {$this->text['primary_key']} in the table {$this->text['table']} as {$this->text['primary_text']}, choice one!", $this->getFields($table) ); } }
php
protected function setConnectedRelationOptions() { parent::setConnectedRelationOptions(); if (! $this->db->isFieldExists($table = $this->model->getTable(), $this->defaultOptions['primary_key'])) { $this->options['primary_key'] = $this->command->choice( "Can't find field {$this->text['primary_key']} in the table {$this->text['table']} as {$this->text['primary_text']}, choice one!", $this->getFields($table) ); } }
[ "protected", "function", "setConnectedRelationOptions", "(", ")", "{", "parent", "::", "setConnectedRelationOptions", "(", ")", ";", "if", "(", "!", "$", "this", "->", "db", "->", "isFieldExists", "(", "$", "table", "=", "$", "this", "->", "model", "->", "getTable", "(", ")", ",", "$", "this", "->", "defaultOptions", "[", "'primary_key'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'primary_key'", "]", "=", "$", "this", "->", "command", "->", "choice", "(", "\"Can't find field {$this->text['primary_key']} in the table {$this->text['table']} as {$this->text['primary_text']}, choice one!\"", ",", "$", "this", "->", "getFields", "(", "$", "table", ")", ")", ";", "}", "}" ]
set connected db relation options @return void
[ "set", "connected", "db", "relation", "options" ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/MorphOne.php#L56-L66
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/MorphOne.php
MorphOne.askToUseCustomeOptions
protected function askToUseCustomeOptions() { parent::askToUseCustomeOptions(); $this->options['primary_key'] = $this->command->ask( "The {$this->text['primary_text']} of the table {$this->text['table']} will be?", $this->defaultOptions['primary_key'] ); }
php
protected function askToUseCustomeOptions() { parent::askToUseCustomeOptions(); $this->options['primary_key'] = $this->command->ask( "The {$this->text['primary_text']} of the table {$this->text['table']} will be?", $this->defaultOptions['primary_key'] ); }
[ "protected", "function", "askToUseCustomeOptions", "(", ")", "{", "parent", "::", "askToUseCustomeOptions", "(", ")", ";", "$", "this", "->", "options", "[", "'primary_key'", "]", "=", "$", "this", "->", "command", "->", "ask", "(", "\"The {$this->text['primary_text']} of the table {$this->text['table']} will be?\"", ",", "$", "this", "->", "defaultOptions", "[", "'primary_key'", "]", ")", ";", "}" ]
ask to use custome options @return void
[ "ask", "to", "use", "custome", "options" ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/MorphOne.php#L98-L106
inpsyde/inpsyde-filter
src/WordPress/SanitizeFileName.php
SanitizeFileName.filter
public function filter( $value ) { if ( ! is_string( $value ) || empty( $value ) ) { do_action( 'inpsyde.filter.error', 'The given value is not string or empty.', [ 'method' => __METHOD__, 'value' => $value ] ); return $value; } return sanitize_file_name( $value ); }
php
public function filter( $value ) { if ( ! is_string( $value ) || empty( $value ) ) { do_action( 'inpsyde.filter.error', 'The given value is not string or empty.', [ 'method' => __METHOD__, 'value' => $value ] ); return $value; } return sanitize_file_name( $value ); }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", ")", "{", "do_action", "(", "'inpsyde.filter.error'", ",", "'The given value is not string or empty.'", ",", "[", "'method'", "=>", "__METHOD__", ",", "'value'", "=>", "$", "value", "]", ")", ";", "return", "$", "value", ";", "}", "return", "sanitize_file_name", "(", "$", "value", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/WordPress/SanitizeFileName.php#L17-L26
vorbind/influx-analytics
src/Mapper/AnalyticsMapper.php
AnalyticsMapper.getRpPoints
public function getRpPoints($rp, $metric, $tags, $granularity, $startDt = null, $endDt = null, $timezone = 'utc') { if (null == $rp || null == $metric) { return []; } $where = []; $query = $this->db->getQueryBuilder() ->retentionPolicy($rp) ->sum('value') ->from($metric); if (isset($endDt)) { $where[] = "time <= '" . $endDt . "'"; } if (isset($startDt)) { $where[] = "time >= '" . $startDt . "'"; } foreach ($tags as $key => $val) { $where[] = "$key = '" . $val . "'"; } $query->where($where); $groupBy = "time(1d) tz('" . $timezone . "')"; if ($granularity == self::GRANULARITY_HOURLY) { //timeoffset doesn't work hourly $groupBy = "time(1h) tz('" . $timezone . "')"; } else if ($granularity == self::GRANULARITY_DAILY) { $groupBy = "time(1d) tz('" . $timezone . "')"; } else if ($granularity == self::GRANULARITY_WEEKLY) { $groupBy = "time(1w) tz('" . $timezone . "')"; } $query->groupBy($groupBy); return $query->getResultSet()->getPoints(); }
php
public function getRpPoints($rp, $metric, $tags, $granularity, $startDt = null, $endDt = null, $timezone = 'utc') { if (null == $rp || null == $metric) { return []; } $where = []; $query = $this->db->getQueryBuilder() ->retentionPolicy($rp) ->sum('value') ->from($metric); if (isset($endDt)) { $where[] = "time <= '" . $endDt . "'"; } if (isset($startDt)) { $where[] = "time >= '" . $startDt . "'"; } foreach ($tags as $key => $val) { $where[] = "$key = '" . $val . "'"; } $query->where($where); $groupBy = "time(1d) tz('" . $timezone . "')"; if ($granularity == self::GRANULARITY_HOURLY) { //timeoffset doesn't work hourly $groupBy = "time(1h) tz('" . $timezone . "')"; } else if ($granularity == self::GRANULARITY_DAILY) { $groupBy = "time(1d) tz('" . $timezone . "')"; } else if ($granularity == self::GRANULARITY_WEEKLY) { $groupBy = "time(1w) tz('" . $timezone . "')"; } $query->groupBy($groupBy); return $query->getResultSet()->getPoints(); }
[ "public", "function", "getRpPoints", "(", "$", "rp", ",", "$", "metric", ",", "$", "tags", ",", "$", "granularity", ",", "$", "startDt", "=", "null", ",", "$", "endDt", "=", "null", ",", "$", "timezone", "=", "'utc'", ")", "{", "if", "(", "null", "==", "$", "rp", "||", "null", "==", "$", "metric", ")", "{", "return", "[", "]", ";", "}", "$", "where", "=", "[", "]", ";", "$", "query", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "retentionPolicy", "(", "$", "rp", ")", "->", "sum", "(", "'value'", ")", "->", "from", "(", "$", "metric", ")", ";", "if", "(", "isset", "(", "$", "endDt", ")", ")", "{", "$", "where", "[", "]", "=", "\"time <= '\"", ".", "$", "endDt", ".", "\"'\"", ";", "}", "if", "(", "isset", "(", "$", "startDt", ")", ")", "{", "$", "where", "[", "]", "=", "\"time >= '\"", ".", "$", "startDt", ".", "\"'\"", ";", "}", "foreach", "(", "$", "tags", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "where", "[", "]", "=", "\"$key = '\"", ".", "$", "val", ".", "\"'\"", ";", "}", "$", "query", "->", "where", "(", "$", "where", ")", ";", "$", "groupBy", "=", "\"time(1d) tz('\"", ".", "$", "timezone", ".", "\"')\"", ";", "if", "(", "$", "granularity", "==", "self", "::", "GRANULARITY_HOURLY", ")", "{", "//timeoffset doesn't work hourly", "$", "groupBy", "=", "\"time(1h) tz('\"", ".", "$", "timezone", ".", "\"')\"", ";", "}", "else", "if", "(", "$", "granularity", "==", "self", "::", "GRANULARITY_DAILY", ")", "{", "$", "groupBy", "=", "\"time(1d) tz('\"", ".", "$", "timezone", ".", "\"')\"", ";", "}", "else", "if", "(", "$", "granularity", "==", "self", "::", "GRANULARITY_WEEKLY", ")", "{", "$", "groupBy", "=", "\"time(1w) tz('\"", ".", "$", "timezone", ".", "\"')\"", ";", "}", "$", "query", "->", "groupBy", "(", "$", "groupBy", ")", ";", "return", "$", "query", "->", "getResultSet", "(", ")", "->", "getPoints", "(", ")", ";", "}" ]
Get points from retention policy @param string $rp @param string $metric @param array $tags @param string $granularity @param string $startDt @param string $endDt @param string $timezone @return array
[ "Get", "points", "from", "retention", "policy" ]
train
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Mapper/AnalyticsMapper.php#L57-L96
vorbind/influx-analytics
src/Mapper/AnalyticsMapper.php
AnalyticsMapper.getPoints
public function getPoints($metric, $tags, $granularity, $endDt, $timezone = 'utc') { if ( null == $metric ) { return []; } $where = []; $now = $this->normalizeUTC(date("Y-m-d H:i:s")); $min = intval(date('i')); $minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') ); $lastHourDt = date("Y-m-d") . "T" . date('H') . ":$minutes:00Z"; if (strtotime($endDt) < strtotime($lastHourDt)) { return []; } $where[] = "time >= '" . $lastHourDt . "' AND time <= '" . $now . "'"; foreach ($tags as $key => $val) { $where[] = "$key = '" . $val . "'"; } $query = $this->db->getQueryBuilder() ->sum('value') ->from($metric) ->where($where); $groupBy = "time(1d) tz('" . $timezone . "')"; if ($granularity == self::GRANULARITY_HOURLY) { $groupBy = "time(1h) tz('" . $timezone . "')"; } else if ($granularity == self::GRANULARITY_DAILY) { $groupBy = "time(1d) tz('" . $timezone . "')"; } else if ($granularity == self::GRANULARITY_WEEKLY) { $groupBy = "time(1w) tz('" . $timezone . "')"; } $query->groupBy($groupBy); return $query->getResultSet()->getPoints(); }
php
public function getPoints($metric, $tags, $granularity, $endDt, $timezone = 'utc') { if ( null == $metric ) { return []; } $where = []; $now = $this->normalizeUTC(date("Y-m-d H:i:s")); $min = intval(date('i')); $minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') ); $lastHourDt = date("Y-m-d") . "T" . date('H') . ":$minutes:00Z"; if (strtotime($endDt) < strtotime($lastHourDt)) { return []; } $where[] = "time >= '" . $lastHourDt . "' AND time <= '" . $now . "'"; foreach ($tags as $key => $val) { $where[] = "$key = '" . $val . "'"; } $query = $this->db->getQueryBuilder() ->sum('value') ->from($metric) ->where($where); $groupBy = "time(1d) tz('" . $timezone . "')"; if ($granularity == self::GRANULARITY_HOURLY) { $groupBy = "time(1h) tz('" . $timezone . "')"; } else if ($granularity == self::GRANULARITY_DAILY) { $groupBy = "time(1d) tz('" . $timezone . "')"; } else if ($granularity == self::GRANULARITY_WEEKLY) { $groupBy = "time(1w) tz('" . $timezone . "')"; } $query->groupBy($groupBy); return $query->getResultSet()->getPoints(); }
[ "public", "function", "getPoints", "(", "$", "metric", ",", "$", "tags", ",", "$", "granularity", ",", "$", "endDt", ",", "$", "timezone", "=", "'utc'", ")", "{", "if", "(", "null", "==", "$", "metric", ")", "{", "return", "[", "]", ";", "}", "$", "where", "=", "[", "]", ";", "$", "now", "=", "$", "this", "->", "normalizeUTC", "(", "date", "(", "\"Y-m-d H:i:s\"", ")", ")", ";", "$", "min", "=", "intval", "(", "date", "(", "'i'", ")", ")", ";", "$", "minutes", "=", "$", "min", ">", "45", "?", "45", ":", "(", "$", "min", ">", "30", "?", "30", ":", "(", "$", "min", ">", "15", "?", "15", ":", "'00'", ")", ")", ";", "$", "lastHourDt", "=", "date", "(", "\"Y-m-d\"", ")", ".", "\"T\"", ".", "date", "(", "'H'", ")", ".", "\":$minutes:00Z\"", ";", "if", "(", "strtotime", "(", "$", "endDt", ")", "<", "strtotime", "(", "$", "lastHourDt", ")", ")", "{", "return", "[", "]", ";", "}", "$", "where", "[", "]", "=", "\"time >= '\"", ".", "$", "lastHourDt", ".", "\"' AND time <= '\"", ".", "$", "now", ".", "\"'\"", ";", "foreach", "(", "$", "tags", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "where", "[", "]", "=", "\"$key = '\"", ".", "$", "val", ".", "\"'\"", ";", "}", "$", "query", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "sum", "(", "'value'", ")", "->", "from", "(", "$", "metric", ")", "->", "where", "(", "$", "where", ")", ";", "$", "groupBy", "=", "\"time(1d) tz('\"", ".", "$", "timezone", ".", "\"')\"", ";", "if", "(", "$", "granularity", "==", "self", "::", "GRANULARITY_HOURLY", ")", "{", "$", "groupBy", "=", "\"time(1h) tz('\"", ".", "$", "timezone", ".", "\"')\"", ";", "}", "else", "if", "(", "$", "granularity", "==", "self", "::", "GRANULARITY_DAILY", ")", "{", "$", "groupBy", "=", "\"time(1d) tz('\"", ".", "$", "timezone", ".", "\"')\"", ";", "}", "else", "if", "(", "$", "granularity", "==", "self", "::", "GRANULARITY_WEEKLY", ")", "{", "$", "groupBy", "=", "\"time(1w) tz('\"", ".", "$", "timezone", ".", "\"')\"", ";", "}", "$", "query", "->", "groupBy", "(", "$", "groupBy", ")", ";", "return", "$", "query", "->", "getResultSet", "(", ")", "->", "getPoints", "(", ")", ";", "}" ]
Get points from default retention policy @param string $metric @param array $tags @param string $granularity @param string $endDt @param string $timezone @return array
[ "Get", "points", "from", "default", "retention", "policy" ]
train
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Mapper/AnalyticsMapper.php#L108-L147
vorbind/influx-analytics
src/Mapper/AnalyticsMapper.php
AnalyticsMapper.getRpSum
public function getRpSum($rp, $metric, $tags, $startDt = null, $endDt = null) { if (null == $rp || null == $metric) { return 0; } $where = []; if (isset($startDt)) { $where[] = "time >= '" . $startDt . "'"; } if (!isset($endDt)) { $endDt = '2100-01-01T00:00:00Z'; } $where[] = "time <= '" . $endDt . "'"; foreach ($tags as $key => $val) { $where[] = "$key = '" . $val . "'"; } $points = $this->db->getQueryBuilder() ->retentionPolicy($rp) ->from($metric) ->where($where) ->sum('value') ->getResultSet() ->getPoints(); return isset($points[0]) && isset($points[0]["sum"]) ? $points[0]["sum"] : 0; }
php
public function getRpSum($rp, $metric, $tags, $startDt = null, $endDt = null) { if (null == $rp || null == $metric) { return 0; } $where = []; if (isset($startDt)) { $where[] = "time >= '" . $startDt . "'"; } if (!isset($endDt)) { $endDt = '2100-01-01T00:00:00Z'; } $where[] = "time <= '" . $endDt . "'"; foreach ($tags as $key => $val) { $where[] = "$key = '" . $val . "'"; } $points = $this->db->getQueryBuilder() ->retentionPolicy($rp) ->from($metric) ->where($where) ->sum('value') ->getResultSet() ->getPoints(); return isset($points[0]) && isset($points[0]["sum"]) ? $points[0]["sum"] : 0; }
[ "public", "function", "getRpSum", "(", "$", "rp", ",", "$", "metric", ",", "$", "tags", ",", "$", "startDt", "=", "null", ",", "$", "endDt", "=", "null", ")", "{", "if", "(", "null", "==", "$", "rp", "||", "null", "==", "$", "metric", ")", "{", "return", "0", ";", "}", "$", "where", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "startDt", ")", ")", "{", "$", "where", "[", "]", "=", "\"time >= '\"", ".", "$", "startDt", ".", "\"'\"", ";", "}", "if", "(", "!", "isset", "(", "$", "endDt", ")", ")", "{", "$", "endDt", "=", "'2100-01-01T00:00:00Z'", ";", "}", "$", "where", "[", "]", "=", "\"time <= '\"", ".", "$", "endDt", ".", "\"'\"", ";", "foreach", "(", "$", "tags", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "where", "[", "]", "=", "\"$key = '\"", ".", "$", "val", ".", "\"'\"", ";", "}", "$", "points", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "retentionPolicy", "(", "$", "rp", ")", "->", "from", "(", "$", "metric", ")", "->", "where", "(", "$", "where", ")", "->", "sum", "(", "'value'", ")", "->", "getResultSet", "(", ")", "->", "getPoints", "(", ")", ";", "return", "isset", "(", "$", "points", "[", "0", "]", ")", "&&", "isset", "(", "$", "points", "[", "0", "]", "[", "\"sum\"", "]", ")", "?", "$", "points", "[", "0", "]", "[", "\"sum\"", "]", ":", "0", ";", "}" ]
Get total from retention policy @param string $rp @param string $metric @param array $tags @param string $startDt @param string $endDt @return int
[ "Get", "total", "from", "retention", "policy" ]
train
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Mapper/AnalyticsMapper.php#L159-L188
vorbind/influx-analytics
src/Mapper/AnalyticsMapper.php
AnalyticsMapper.getSum
public function getSum($metric, $tags, $endDt = null) { if (null == $metric) { return 0; } $min = intval(date('i')); $minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') ); $lastHourDt = date("Y-m-d") . "T" . date('H') . ":$minutes:00Z"; $where = []; if (!isset($endDt)) { $endDt = '2100-01-01T00:00:00Z'; } if (strtotime($endDt) < strtotime($lastHourDt)) { return 0; } $where[] = "time >= '" . $lastHourDt . "' AND time <= '" . $endDt . "'"; foreach ($tags as $key => $val) { $where[] = "$key = '" . $val . "'"; } $points = $this->db->getQueryBuilder() ->from($metric) ->where($where) ->sum('value') ->getResultSet() ->getPoints(); return isset($points[0]) && isset($points[0]["sum"]) ? $points[0]["sum"] : 0; }
php
public function getSum($metric, $tags, $endDt = null) { if (null == $metric) { return 0; } $min = intval(date('i')); $minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') ); $lastHourDt = date("Y-m-d") . "T" . date('H') . ":$minutes:00Z"; $where = []; if (!isset($endDt)) { $endDt = '2100-01-01T00:00:00Z'; } if (strtotime($endDt) < strtotime($lastHourDt)) { return 0; } $where[] = "time >= '" . $lastHourDt . "' AND time <= '" . $endDt . "'"; foreach ($tags as $key => $val) { $where[] = "$key = '" . $val . "'"; } $points = $this->db->getQueryBuilder() ->from($metric) ->where($where) ->sum('value') ->getResultSet() ->getPoints(); return isset($points[0]) && isset($points[0]["sum"]) ? $points[0]["sum"] : 0; }
[ "public", "function", "getSum", "(", "$", "metric", ",", "$", "tags", ",", "$", "endDt", "=", "null", ")", "{", "if", "(", "null", "==", "$", "metric", ")", "{", "return", "0", ";", "}", "$", "min", "=", "intval", "(", "date", "(", "'i'", ")", ")", ";", "$", "minutes", "=", "$", "min", ">", "45", "?", "45", ":", "(", "$", "min", ">", "30", "?", "30", ":", "(", "$", "min", ">", "15", "?", "15", ":", "'00'", ")", ")", ";", "$", "lastHourDt", "=", "date", "(", "\"Y-m-d\"", ")", ".", "\"T\"", ".", "date", "(", "'H'", ")", ".", "\":$minutes:00Z\"", ";", "$", "where", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "endDt", ")", ")", "{", "$", "endDt", "=", "'2100-01-01T00:00:00Z'", ";", "}", "if", "(", "strtotime", "(", "$", "endDt", ")", "<", "strtotime", "(", "$", "lastHourDt", ")", ")", "{", "return", "0", ";", "}", "$", "where", "[", "]", "=", "\"time >= '\"", ".", "$", "lastHourDt", ".", "\"' AND time <= '\"", ".", "$", "endDt", ".", "\"'\"", ";", "foreach", "(", "$", "tags", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "where", "[", "]", "=", "\"$key = '\"", ".", "$", "val", ".", "\"'\"", ";", "}", "$", "points", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "from", "(", "$", "metric", ")", "->", "where", "(", "$", "where", ")", "->", "sum", "(", "'value'", ")", "->", "getResultSet", "(", ")", "->", "getPoints", "(", ")", ";", "return", "isset", "(", "$", "points", "[", "0", "]", ")", "&&", "isset", "(", "$", "points", "[", "0", "]", "[", "\"sum\"", "]", ")", "?", "$", "points", "[", "0", "]", "[", "\"sum\"", "]", ":", "0", ";", "}" ]
Get total from default retention policy @param string $metric @param array $tags @param string $endDt @return int
[ "Get", "total", "from", "default", "retention", "policy" ]
train
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Mapper/AnalyticsMapper.php#L198-L231
vorbind/influx-analytics
src/Mapper/AnalyticsMapper.php
AnalyticsMapper.save
public function save($metric, $tags = array(), $value = 1, $date = null, $rp = null) { try { $command = isset($date) ? " -d '" . $this->normalizeUTC($date) . "'" : ""; // Time precision is in nanaoseconds $timeNs = exec("date $command +%s%N"); $fields = array(); $points = array( new Point( $metric, $value, $tags, $fields, $timeNs ) ); return $this->db->writePoints($points, InfluxDB::PRECISION_NANOSECONDS, $rp); } catch (Exception $e) { throw new AnalyticsException("Error saving analytics data", 0, $e); } }
php
public function save($metric, $tags = array(), $value = 1, $date = null, $rp = null) { try { $command = isset($date) ? " -d '" . $this->normalizeUTC($date) . "'" : ""; // Time precision is in nanaoseconds $timeNs = exec("date $command +%s%N"); $fields = array(); $points = array( new Point( $metric, $value, $tags, $fields, $timeNs ) ); return $this->db->writePoints($points, InfluxDB::PRECISION_NANOSECONDS, $rp); } catch (Exception $e) { throw new AnalyticsException("Error saving analytics data", 0, $e); } }
[ "public", "function", "save", "(", "$", "metric", ",", "$", "tags", "=", "array", "(", ")", ",", "$", "value", "=", "1", ",", "$", "date", "=", "null", ",", "$", "rp", "=", "null", ")", "{", "try", "{", "$", "command", "=", "isset", "(", "$", "date", ")", "?", "\" -d '\"", ".", "$", "this", "->", "normalizeUTC", "(", "$", "date", ")", ".", "\"'\"", ":", "\"\"", ";", "// Time precision is in nanaoseconds", "$", "timeNs", "=", "exec", "(", "\"date $command +%s%N\"", ")", ";", "$", "fields", "=", "array", "(", ")", ";", "$", "points", "=", "array", "(", "new", "Point", "(", "$", "metric", ",", "$", "value", ",", "$", "tags", ",", "$", "fields", ",", "$", "timeNs", ")", ")", ";", "return", "$", "this", "->", "db", "->", "writePoints", "(", "$", "points", ",", "InfluxDB", "::", "PRECISION_NANOSECONDS", ",", "$", "rp", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "AnalyticsException", "(", "\"Error saving analytics data\"", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Save analytics @param string $metric @param array $tags @param int $value @param string $date @param string $rp @return void @throws AnalyticsException
[ "Save", "analytics" ]
train
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Mapper/AnalyticsMapper.php#L244-L264
ppetermann/king23
src/Http/Application.php
Application.run
public function run() { /** @var ResponseInterface $response */ $response = $this->queue->handle($this->request); // http status $reasonPhrase = $response->getReasonPhrase(); $reasonPhrase = ($reasonPhrase ? ' '.$reasonPhrase : ''); header(sprintf('HTTP/%s %d%s', $response->getProtocolVersion(), $response->getStatusCode(), $reasonPhrase)); // additional headers foreach ($response->getHeaders() as $header => $values) { $first = true; foreach ($values as $value) { header(sprintf('%s: %s', $header, $value), $first); $first = false; } } echo $response->getBody(); }
php
public function run() { /** @var ResponseInterface $response */ $response = $this->queue->handle($this->request); // http status $reasonPhrase = $response->getReasonPhrase(); $reasonPhrase = ($reasonPhrase ? ' '.$reasonPhrase : ''); header(sprintf('HTTP/%s %d%s', $response->getProtocolVersion(), $response->getStatusCode(), $reasonPhrase)); // additional headers foreach ($response->getHeaders() as $header => $values) { $first = true; foreach ($values as $value) { header(sprintf('%s: %s', $header, $value), $first); $first = false; } } echo $response->getBody(); }
[ "public", "function", "run", "(", ")", "{", "/** @var ResponseInterface $response */", "$", "response", "=", "$", "this", "->", "queue", "->", "handle", "(", "$", "this", "->", "request", ")", ";", "// http status", "$", "reasonPhrase", "=", "$", "response", "->", "getReasonPhrase", "(", ")", ";", "$", "reasonPhrase", "=", "(", "$", "reasonPhrase", "?", "' '", ".", "$", "reasonPhrase", ":", "''", ")", ";", "header", "(", "sprintf", "(", "'HTTP/%s %d%s'", ",", "$", "response", "->", "getProtocolVersion", "(", ")", ",", "$", "response", "->", "getStatusCode", "(", ")", ",", "$", "reasonPhrase", ")", ")", ";", "// additional headers", "foreach", "(", "$", "response", "->", "getHeaders", "(", ")", "as", "$", "header", "=>", "$", "values", ")", "{", "$", "first", "=", "true", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "header", "(", "sprintf", "(", "'%s: %s'", ",", "$", "header", ",", "$", "value", ")", ",", "$", "first", ")", ";", "$", "first", "=", "false", ";", "}", "}", "echo", "$", "response", "->", "getBody", "(", ")", ";", "}" ]
run a http based application
[ "run", "a", "http", "based", "application" ]
train
https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Http/Application.php#L66-L85
RobinDumontChaponet/TransitiveCore
src/simple/View.php
View.cacheBust
public static function cacheBust(string $src): string { if(!file_exists($src)) return $src; $path = pathinfo($src); return $path['dirname'].'/'.$path['filename'].'.'.filemtime($src).'.'.$path['extension']; }
php
public static function cacheBust(string $src): string { if(!file_exists($src)) return $src; $path = pathinfo($src); return $path['dirname'].'/'.$path['filename'].'.'.filemtime($src).'.'.$path['extension']; }
[ "public", "static", "function", "cacheBust", "(", "string", "$", "src", ")", ":", "string", "{", "if", "(", "!", "file_exists", "(", "$", "src", ")", ")", "return", "$", "src", ";", "$", "path", "=", "pathinfo", "(", "$", "src", ")", ";", "return", "$", "path", "[", "'dirname'", "]", ".", "'/'", ".", "$", "path", "[", "'filename'", "]", ".", "'.'", ".", "filemtime", "(", "$", "src", ")", ".", "'.'", ".", "$", "path", "[", "'extension'", "]", ";", "}" ]
cacheBust function. @param string $src @return string
[ "cacheBust", "function", "." ]
train
https://github.com/RobinDumontChaponet/TransitiveCore/blob/b83dd6fe0e49b8773de0f60861e5a5c306e2a38d/src/simple/View.php#L37-L45
RobinDumontChaponet/TransitiveCore
src/simple/View.php
View.getTitle
public function getTitle(string $prefix = '', string $separator = ' | ', string $sufix = ''): string { if(empty($this->getTitleValue())) $separator = ''; return $prefix.$separator.$this->getTitleValue().$sufix; }
php
public function getTitle(string $prefix = '', string $separator = ' | ', string $sufix = ''): string { if(empty($this->getTitleValue())) $separator = ''; return $prefix.$separator.$this->getTitleValue().$sufix; }
[ "public", "function", "getTitle", "(", "string", "$", "prefix", "=", "''", ",", "string", "$", "separator", "=", "' | '", ",", "string", "$", "sufix", "=", "''", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "this", "->", "getTitleValue", "(", ")", ")", ")", "$", "separator", "=", "''", ";", "return", "$", "prefix", ".", "$", "separator", ".", "$", "this", "->", "getTitleValue", "(", ")", ".", "$", "sufix", ";", "}" ]
Get the view's title.
[ "Get", "the", "view", "s", "title", "." ]
train
https://github.com/RobinDumontChaponet/TransitiveCore/blob/b83dd6fe0e49b8773de0f60861e5a5c306e2a38d/src/simple/View.php#L78-L84
RobinDumontChaponet/TransitiveCore
src/simple/View.php
View.hasContent
public function hasContent(?string $contentType = null, ?string $contentKey = null): bool { return isset($this->content[$contentType][$contentKey]); }
php
public function hasContent(?string $contentType = null, ?string $contentKey = null): bool { return isset($this->content[$contentType][$contentKey]); }
[ "public", "function", "hasContent", "(", "?", "string", "$", "contentType", "=", "null", ",", "?", "string", "$", "contentKey", "=", "null", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "content", "[", "$", "contentType", "]", "[", "$", "contentKey", "]", ")", ";", "}" ]
@param string $key = null @return bool
[ "@param", "string", "$key", "=", "null" ]
train
https://github.com/RobinDumontChaponet/TransitiveCore/blob/b83dd6fe0e49b8773de0f60861e5a5c306e2a38d/src/simple/View.php#L101-L104
RobinDumontChaponet/TransitiveCore
src/simple/View.php
View._getContent
protected function _getContent($content) { if(!isset($content)) return; if(is_array($content)) return array_map( function ($value) { return $this->_getContent($value); }, $content ); switch(gettype($content)) { case 'string': case 'integer': case 'double': case 'float': return $content; break; case 'object': if('Closure' == get_class($content)) { ob_start(); ob_clean(); $returned = $content($this->data); $output = ob_get_clean(); if(isset($returned)) return $returned; else return $output; } elseif(isset($content->content)) return $content->content; break; default: throw new \InvalidArgumentException('wrong view content type : '.gettype($content)); } }
php
protected function _getContent($content) { if(!isset($content)) return; if(is_array($content)) return array_map( function ($value) { return $this->_getContent($value); }, $content ); switch(gettype($content)) { case 'string': case 'integer': case 'double': case 'float': return $content; break; case 'object': if('Closure' == get_class($content)) { ob_start(); ob_clean(); $returned = $content($this->data); $output = ob_get_clean(); if(isset($returned)) return $returned; else return $output; } elseif(isset($content->content)) return $content->content; break; default: throw new \InvalidArgumentException('wrong view content type : '.gettype($content)); } }
[ "protected", "function", "_getContent", "(", "$", "content", ")", "{", "if", "(", "!", "isset", "(", "$", "content", ")", ")", "return", ";", "if", "(", "is_array", "(", "$", "content", ")", ")", "return", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "$", "this", "->", "_getContent", "(", "$", "value", ")", ";", "}", ",", "$", "content", ")", ";", "switch", "(", "gettype", "(", "$", "content", ")", ")", "{", "case", "'string'", ":", "case", "'integer'", ":", "case", "'double'", ":", "case", "'float'", ":", "return", "$", "content", ";", "break", ";", "case", "'object'", ":", "if", "(", "'Closure'", "==", "get_class", "(", "$", "content", ")", ")", "{", "ob_start", "(", ")", ";", "ob_clean", "(", ")", ";", "$", "returned", "=", "$", "content", "(", "$", "this", "->", "data", ")", ";", "$", "output", "=", "ob_get_clean", "(", ")", ";", "if", "(", "isset", "(", "$", "returned", ")", ")", "return", "$", "returned", ";", "else", "return", "$", "output", ";", "}", "elseif", "(", "isset", "(", "$", "content", "->", "content", ")", ")", "return", "$", "content", "->", "content", ";", "break", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'wrong view content type : '", ".", "gettype", "(", "$", "content", ")", ")", ";", "}", "}" ]
@param mixed content @return mixed
[ "@param", "mixed", "content" ]
train
https://github.com/RobinDumontChaponet/TransitiveCore/blob/b83dd6fe0e49b8773de0f60861e5a5c306e2a38d/src/simple/View.php#L111-L143
RobinDumontChaponet/TransitiveCore
src/simple/View.php
View.getContent
public function getContent(?string $contentType = null, ?string $contentKey = null): Core\ViewResource { return new Core\ViewResource($this->_getContent(@$this->content[$contentType][$contentKey])); }
php
public function getContent(?string $contentType = null, ?string $contentKey = null): Core\ViewResource { return new Core\ViewResource($this->_getContent(@$this->content[$contentType][$contentKey])); }
[ "public", "function", "getContent", "(", "?", "string", "$", "contentType", "=", "null", ",", "?", "string", "$", "contentKey", "=", "null", ")", ":", "Core", "\\", "ViewResource", "{", "return", "new", "Core", "\\", "ViewResource", "(", "$", "this", "->", "_getContent", "(", "@", "$", "this", "->", "content", "[", "$", "contentType", "]", "[", "$", "contentKey", "]", ")", ")", ";", "}" ]
@param string $key = null @param string $contentType = null @return Core\ViewResource
[ "@param", "string", "$key", "=", "null", "@param", "string", "$contentType", "=", "null" ]
train
https://github.com/RobinDumontChaponet/TransitiveCore/blob/b83dd6fe0e49b8773de0f60861e5a5c306e2a38d/src/simple/View.php#L151-L154
RobinDumontChaponet/TransitiveCore
src/simple/View.php
View.getDocument
public function getDocument(?string $contentType = null, ?string $contentKey = null): Core\ViewResource { return new Core\ViewResource(array( 'head' => $this->getHead()->asArray, 'content' => $this->getContent($contentKey, $contentType)->asArray, ), 'asJSON'); }
php
public function getDocument(?string $contentType = null, ?string $contentKey = null): Core\ViewResource { return new Core\ViewResource(array( 'head' => $this->getHead()->asArray, 'content' => $this->getContent($contentKey, $contentType)->asArray, ), 'asJSON'); }
[ "public", "function", "getDocument", "(", "?", "string", "$", "contentType", "=", "null", ",", "?", "string", "$", "contentKey", "=", "null", ")", ":", "Core", "\\", "ViewResource", "{", "return", "new", "Core", "\\", "ViewResource", "(", "array", "(", "'head'", "=>", "$", "this", "->", "getHead", "(", ")", "->", "asArray", ",", "'content'", "=>", "$", "this", "->", "getContent", "(", "$", "contentKey", ",", "$", "contentType", ")", "->", "asArray", ",", ")", ",", "'asJSON'", ")", ";", "}" ]
/* @param string $content = null @param string $contentType = null @return Core\ViewResource
[ "/", "*" ]
train
https://github.com/RobinDumontChaponet/TransitiveCore/blob/b83dd6fe0e49b8773de0f60861e5a5c306e2a38d/src/simple/View.php#L235-L241
RobinDumontChaponet/TransitiveCore
src/simple/View.php
View.getAllDocument
public function getAllDocument(): Core\ViewResource { return new Core\ViewResource(array( 'head' => $this->getHead()->asArray, 'content' => $this->getAllContent()->asArray, ), 'asJSON'); }
php
public function getAllDocument(): Core\ViewResource { return new Core\ViewResource(array( 'head' => $this->getHead()->asArray, 'content' => $this->getAllContent()->asArray, ), 'asJSON'); }
[ "public", "function", "getAllDocument", "(", ")", ":", "Core", "\\", "ViewResource", "{", "return", "new", "Core", "\\", "ViewResource", "(", "array", "(", "'head'", "=>", "$", "this", "->", "getHead", "(", ")", "->", "asArray", ",", "'content'", "=>", "$", "this", "->", "getAllContent", "(", ")", "->", "asArray", ",", ")", ",", "'asJSON'", ")", ";", "}" ]
/* @param string $content = null @return Core\ViewResource
[ "/", "*" ]
train
https://github.com/RobinDumontChaponet/TransitiveCore/blob/b83dd6fe0e49b8773de0f60861e5a5c306e2a38d/src/simple/View.php#L247-L253
leedavis81/altr-ego
library/AltrEgo/Adapter/Php53.php
Php53._call
public function _call($name, $arguments) { $object = $this->getObject(); try { $method = new \ReflectionMethod($object, $name); } catch (\Exception $e) { if (method_exists($object, '__call')) { return call_user_func_array(array($object, '__call'), (array) $arguments); } else { throw new \Exception('Unable to invoke method ' . $name . ' on object of class ' . get_class($object)); } return null; } $method->setAccessible(true); return $method->invokeArgs($object, $arguments); }
php
public function _call($name, $arguments) { $object = $this->getObject(); try { $method = new \ReflectionMethod($object, $name); } catch (\Exception $e) { if (method_exists($object, '__call')) { return call_user_func_array(array($object, '__call'), (array) $arguments); } else { throw new \Exception('Unable to invoke method ' . $name . ' on object of class ' . get_class($object)); } return null; } $method->setAccessible(true); return $method->invokeArgs($object, $arguments); }
[ "public", "function", "_call", "(", "$", "name", ",", "$", "arguments", ")", "{", "$", "object", "=", "$", "this", "->", "getObject", "(", ")", ";", "try", "{", "$", "method", "=", "new", "\\", "ReflectionMethod", "(", "$", "object", ",", "$", "name", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "method_exists", "(", "$", "object", ",", "'__call'", ")", ")", "{", "return", "call_user_func_array", "(", "array", "(", "$", "object", ",", "'__call'", ")", ",", "(", "array", ")", "$", "arguments", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Unable to invoke method '", ".", "$", "name", ".", "' on object of class '", ".", "get_class", "(", "$", "object", ")", ")", ";", "}", "return", "null", ";", "}", "$", "method", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "method", "->", "invokeArgs", "(", "$", "object", ",", "$", "arguments", ")", ";", "}" ]
(non-PHPdoc) @see AltrEgo\Adapter.AdapterInterface::_call()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/Adapter/Php53.php#L47-L67
leedavis81/altr-ego
library/AltrEgo/Adapter/Php53.php
Php53._get
public function _get($name) { $object = $this->getObject(); $property = $this->getReflectionProperty($name); $value = $property->getValue($this->getObject()); if (is_array($value)) { $property->setValue($object, new \ArrayObject($value)); } return $property->getValue($this->getObject()); }
php
public function _get($name) { $object = $this->getObject(); $property = $this->getReflectionProperty($name); $value = $property->getValue($this->getObject()); if (is_array($value)) { $property->setValue($object, new \ArrayObject($value)); } return $property->getValue($this->getObject()); }
[ "public", "function", "_get", "(", "$", "name", ")", "{", "$", "object", "=", "$", "this", "->", "getObject", "(", ")", ";", "$", "property", "=", "$", "this", "->", "getReflectionProperty", "(", "$", "name", ")", ";", "$", "value", "=", "$", "property", "->", "getValue", "(", "$", "this", "->", "getObject", "(", ")", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "property", "->", "setValue", "(", "$", "object", ",", "new", "\\", "ArrayObject", "(", "$", "value", ")", ")", ";", "}", "return", "$", "property", "->", "getValue", "(", "$", "this", "->", "getObject", "(", ")", ")", ";", "}" ]
(non-PHPdoc) @see AltrEgo\Adapter.AdapterInterface::_get()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/Adapter/Php53.php#L72-L84
leedavis81/altr-ego
library/AltrEgo/Adapter/Php53.php
Php53._set
public function _set($name, $value) { $property = $this->getReflectionProperty($name); return $property->setValue($this->getObject(), $value); }
php
public function _set($name, $value) { $property = $this->getReflectionProperty($name); return $property->setValue($this->getObject(), $value); }
[ "public", "function", "_set", "(", "$", "name", ",", "$", "value", ")", "{", "$", "property", "=", "$", "this", "->", "getReflectionProperty", "(", "$", "name", ")", ";", "return", "$", "property", "->", "setValue", "(", "$", "this", "->", "getObject", "(", ")", ",", "$", "value", ")", ";", "}" ]
(non-PHPdoc) @see AltrEgo\Adapter.AdapterInterface::_set()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/Adapter/Php53.php#L89-L93
leedavis81/altr-ego
library/AltrEgo/Adapter/Php53.php
Php53._callStatic
public static function _callStatic($object, $name, $arguments) { if (is_object($object)) { $object = ($object instanceof AltrEgo) ? $object->getObject() : $object; } elseif (!class_exists($object)) { throw new \Exception('Static call (callStatic) to AltrEgo must be passed either an object or an accessible class name'); } try { $method = new \ReflectionMethod($object, $name); if ($method->isStatic()) { $method->setAccessible(true); return $method->invokeArgs($object, (array) $arguments); } } catch (\Exception $e) { } throw new \Exception('Unable to call static method "' . $name . '" on class ' . get_class($object)); }
php
public static function _callStatic($object, $name, $arguments) { if (is_object($object)) { $object = ($object instanceof AltrEgo) ? $object->getObject() : $object; } elseif (!class_exists($object)) { throw new \Exception('Static call (callStatic) to AltrEgo must be passed either an object or an accessible class name'); } try { $method = new \ReflectionMethod($object, $name); if ($method->isStatic()) { $method->setAccessible(true); return $method->invokeArgs($object, (array) $arguments); } } catch (\Exception $e) { } throw new \Exception('Unable to call static method "' . $name . '" on class ' . get_class($object)); }
[ "public", "static", "function", "_callStatic", "(", "$", "object", ",", "$", "name", ",", "$", "arguments", ")", "{", "if", "(", "is_object", "(", "$", "object", ")", ")", "{", "$", "object", "=", "(", "$", "object", "instanceof", "AltrEgo", ")", "?", "$", "object", "->", "getObject", "(", ")", ":", "$", "object", ";", "}", "elseif", "(", "!", "class_exists", "(", "$", "object", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Static call (callStatic) to AltrEgo must be passed either an object or an accessible class name'", ")", ";", "}", "try", "{", "$", "method", "=", "new", "\\", "ReflectionMethod", "(", "$", "object", ",", "$", "name", ")", ";", "if", "(", "$", "method", "->", "isStatic", "(", ")", ")", "{", "$", "method", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "method", "->", "invokeArgs", "(", "$", "object", ",", "(", "array", ")", "$", "arguments", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "throw", "new", "\\", "Exception", "(", "'Unable to call static method \"'", ".", "$", "name", ".", "'\" on class '", ".", "get_class", "(", "$", "object", ")", ")", ";", "}" ]
(non-PHPdoc) @see AltrEgo\Adapter.AdapterInterface::_callStatic()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/Adapter/Php53.php#L114-L136
leedavis81/altr-ego
library/AltrEgo/Adapter/Php53.php
Php53.getReflectionProperty
protected function getReflectionProperty($name) { do { $reflClass = (!isset($reflClass)) ? new \ReflectionClass($this->getObject()) : $reflClass; $property = $reflClass->getProperty($name); if (isset($property)) { break; } } while (($reflClass = $reflClass->getParentClass()) !== null); if ($property instanceof \ReflectionProperty) { $property->setAccessible(true); return $property; } else { throw new \Exception('Property ' . $name . ' doesn\'t exist on object of class ' . get_class($this->getObject())); } }
php
protected function getReflectionProperty($name) { do { $reflClass = (!isset($reflClass)) ? new \ReflectionClass($this->getObject()) : $reflClass; $property = $reflClass->getProperty($name); if (isset($property)) { break; } } while (($reflClass = $reflClass->getParentClass()) !== null); if ($property instanceof \ReflectionProperty) { $property->setAccessible(true); return $property; } else { throw new \Exception('Property ' . $name . ' doesn\'t exist on object of class ' . get_class($this->getObject())); } }
[ "protected", "function", "getReflectionProperty", "(", "$", "name", ")", "{", "do", "{", "$", "reflClass", "=", "(", "!", "isset", "(", "$", "reflClass", ")", ")", "?", "new", "\\", "ReflectionClass", "(", "$", "this", "->", "getObject", "(", ")", ")", ":", "$", "reflClass", ";", "$", "property", "=", "$", "reflClass", "->", "getProperty", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "property", ")", ")", "{", "break", ";", "}", "}", "while", "(", "(", "$", "reflClass", "=", "$", "reflClass", "->", "getParentClass", "(", ")", ")", "!==", "null", ")", ";", "if", "(", "$", "property", "instanceof", "\\", "ReflectionProperty", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "property", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Property '", ".", "$", "name", ".", "' doesn\\'t exist on object of class '", ".", "get_class", "(", "$", "this", "->", "getObject", "(", ")", ")", ")", ";", "}", "}" ]
Get a reflection property - may need to iterate through class parents @param string $name
[ "Get", "a", "reflection", "property", "-", "may", "need", "to", "iterate", "through", "class", "parents" ]
train
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/Adapter/Php53.php#L142-L162
webforge-labs/psc-cms
lib/Psc/Doctrine/Entities/BasicUploadedFile.php
BasicUploadedFile.export
public function export() { $export = parent::export(); $export->url = $this->getURL(); // url für die response hinzufügen $export->size = $this->getFile()->getSize(); unset($export->file); return $export; }
php
public function export() { $export = parent::export(); $export->url = $this->getURL(); // url für die response hinzufügen $export->size = $this->getFile()->getSize(); unset($export->file); return $export; }
[ "public", "function", "export", "(", ")", "{", "$", "export", "=", "parent", "::", "export", "(", ")", ";", "$", "export", "->", "url", "=", "$", "this", "->", "getURL", "(", ")", ";", "// url für die response hinzufügen", "$", "export", "->", "size", "=", "$", "this", "->", "getFile", "(", ")", "->", "getSize", "(", ")", ";", "unset", "(", "$", "export", "->", "file", ")", ";", "return", "$", "export", ";", "}" ]
Exportiert das Entity für z.B. die Controller Response
[ "Exportiert", "das", "Entity", "für", "z", ".", "B", ".", "die", "Controller", "Response" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/Entities/BasicUploadedFile.php#L81-L88
php-rise/rise
src/Template.php
Template.render
public function render($template = '', $data = []) { if (!isset($this->blocks[$template])) { $this->blocks[$template] = $this->blockFactory->create($template); } $block = $this->blocks[$template]; $block->setData($data); return $block->render(); }
php
public function render($template = '', $data = []) { if (!isset($this->blocks[$template])) { $this->blocks[$template] = $this->blockFactory->create($template); } $block = $this->blocks[$template]; $block->setData($data); return $block->render(); }
[ "public", "function", "render", "(", "$", "template", "=", "''", ",", "$", "data", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "blocks", "[", "$", "template", "]", ")", ")", "{", "$", "this", "->", "blocks", "[", "$", "template", "]", "=", "$", "this", "->", "blockFactory", "->", "create", "(", "$", "template", ")", ";", "}", "$", "block", "=", "$", "this", "->", "blocks", "[", "$", "template", "]", ";", "$", "block", "->", "setData", "(", "$", "data", ")", ";", "return", "$", "block", "->", "render", "(", ")", ";", "}" ]
Render a block. @param string $template @param array $data @return string
[ "Render", "a", "block", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Template.php#L32-L39
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php
BaseLicenseQuery.create
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof LicenseQuery) { return $criteria; } $query = new LicenseQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof LicenseQuery) { return $criteria; } $query = new LicenseQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
[ "public", "static", "function", "create", "(", "$", "modelAlias", "=", "null", ",", "$", "criteria", "=", "null", ")", "{", "if", "(", "$", "criteria", "instanceof", "LicenseQuery", ")", "{", "return", "$", "criteria", ";", "}", "$", "query", "=", "new", "LicenseQuery", "(", "null", ",", "null", ",", "$", "modelAlias", ")", ";", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "query", "->", "mergeWith", "(", "$", "criteria", ")", ";", "}", "return", "$", "query", ";", "}" ]
Returns a new LicenseQuery object. @param string $modelAlias The alias of a model in the query @param LicenseQuery|Criteria $criteria Optional Criteria to build the query from @return LicenseQuery
[ "Returns", "a", "new", "LicenseQuery", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php#L76-L88
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php
BaseLicenseQuery.filterByMaxClients
public function filterByMaxClients($maxClients = null, $comparison = null) { if (is_array($maxClients)) { $useMinMax = false; if (isset($maxClients['min'])) { $this->addUsingAlias(LicensePeer::MAX_CLIENTS, $maxClients['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($maxClients['max'])) { $this->addUsingAlias(LicensePeer::MAX_CLIENTS, $maxClients['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(LicensePeer::MAX_CLIENTS, $maxClients, $comparison); }
php
public function filterByMaxClients($maxClients = null, $comparison = null) { if (is_array($maxClients)) { $useMinMax = false; if (isset($maxClients['min'])) { $this->addUsingAlias(LicensePeer::MAX_CLIENTS, $maxClients['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($maxClients['max'])) { $this->addUsingAlias(LicensePeer::MAX_CLIENTS, $maxClients['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(LicensePeer::MAX_CLIENTS, $maxClients, $comparison); }
[ "public", "function", "filterByMaxClients", "(", "$", "maxClients", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "maxClients", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "maxClients", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "LicensePeer", "::", "MAX_CLIENTS", ",", "$", "maxClients", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "maxClients", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "LicensePeer", "::", "MAX_CLIENTS", ",", "$", "maxClients", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LicensePeer", "::", "MAX_CLIENTS", ",", "$", "maxClients", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the max_clients column Example usage: <code> $query->filterByMaxClients(1234); // WHERE max_clients = 1234 $query->filterByMaxClients(array(12, 34)); // WHERE max_clients IN (12, 34) $query->filterByMaxClients(array('min' => 12)); // WHERE max_clients >= 12 $query->filterByMaxClients(array('max' => 12)); // WHERE max_clients <= 12 </code> @param mixed $maxClients The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return LicenseQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "max_clients", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php#L302-L323
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php
BaseLicenseQuery.filterByDomain
public function filterByDomain($domain = null, $comparison = null) { if (null === $comparison) { if (is_array($domain)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $domain)) { $domain = str_replace('*', '%', $domain); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LicensePeer::DOMAIN, $domain, $comparison); }
php
public function filterByDomain($domain = null, $comparison = null) { if (null === $comparison) { if (is_array($domain)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $domain)) { $domain = str_replace('*', '%', $domain); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LicensePeer::DOMAIN, $domain, $comparison); }
[ "public", "function", "filterByDomain", "(", "$", "domain", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "domain", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "domain", ")", ")", "{", "$", "domain", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "domain", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LicensePeer", "::", "DOMAIN", ",", "$", "domain", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the domain column Example usage: <code> $query->filterByDomain('fooValue'); // WHERE domain = 'fooValue' $query->filterByDomain('%fooValue%'); // WHERE domain LIKE '%fooValue%' </code> @param string $domain The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return LicenseQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "domain", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php#L340-L352
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php
BaseLicenseQuery.filterByValidUntil
public function filterByValidUntil($validUntil = null, $comparison = null) { if (null === $comparison) { if (is_array($validUntil)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $validUntil)) { $validUntil = str_replace('*', '%', $validUntil); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LicensePeer::VALID_UNTIL, $validUntil, $comparison); }
php
public function filterByValidUntil($validUntil = null, $comparison = null) { if (null === $comparison) { if (is_array($validUntil)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $validUntil)) { $validUntil = str_replace('*', '%', $validUntil); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LicensePeer::VALID_UNTIL, $validUntil, $comparison); }
[ "public", "function", "filterByValidUntil", "(", "$", "validUntil", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "validUntil", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "validUntil", ")", ")", "{", "$", "validUntil", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "validUntil", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LicensePeer", "::", "VALID_UNTIL", ",", "$", "validUntil", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the valid_until column Example usage: <code> $query->filterByValidUntil('fooValue'); // WHERE valid_until = 'fooValue' $query->filterByValidUntil('%fooValue%'); // WHERE valid_until LIKE '%fooValue%' </code> @param string $validUntil The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return LicenseQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "valid_until", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php#L369-L381
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php
BaseLicenseQuery.filterBySerial
public function filterBySerial($serial = null, $comparison = null) { if (null === $comparison) { if (is_array($serial)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $serial)) { $serial = str_replace('*', '%', $serial); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LicensePeer::SERIAL, $serial, $comparison); }
php
public function filterBySerial($serial = null, $comparison = null) { if (null === $comparison) { if (is_array($serial)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $serial)) { $serial = str_replace('*', '%', $serial); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LicensePeer::SERIAL, $serial, $comparison); }
[ "public", "function", "filterBySerial", "(", "$", "serial", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "serial", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "serial", ")", ")", "{", "$", "serial", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "serial", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LicensePeer", "::", "SERIAL", ",", "$", "serial", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the serial column Example usage: <code> $query->filterBySerial('fooValue'); // WHERE serial = 'fooValue' $query->filterBySerial('%fooValue%'); // WHERE serial LIKE '%fooValue%' </code> @param string $serial The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return LicenseQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "serial", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php#L398-L410
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php
BaseLicenseQuery.prune
public function prune($license = null) { if ($license) { $this->addUsingAlias(LicensePeer::ID, $license->getId(), Criteria::NOT_EQUAL); } return $this; }
php
public function prune($license = null) { if ($license) { $this->addUsingAlias(LicensePeer::ID, $license->getId(), Criteria::NOT_EQUAL); } return $this; }
[ "public", "function", "prune", "(", "$", "license", "=", "null", ")", "{", "if", "(", "$", "license", ")", "{", "$", "this", "->", "addUsingAlias", "(", "LicensePeer", "::", "ID", ",", "$", "license", "->", "getId", "(", ")", ",", "Criteria", "::", "NOT_EQUAL", ")", ";", "}", "return", "$", "this", ";", "}" ]
Exclude object from result @param License $license Object to remove from the list of results @return LicenseQuery The current query, for fluid interface
[ "Exclude", "object", "from", "result" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseLicenseQuery.php#L419-L426
anime-db/world-art-filler-bundle
src/Event/Listener/Refiller.php
Refiller.onAddNewItem
public function onAddNewItem(AddNewItem $event) { $item = $event->getItem(); if (!$event->getFillers()->contains($this->filler) && ($url = $this->refiller->getSourceForFill($item))) { $new_item = $this->filler->fill(['url' => $url]); // fill item if (!$item->getCountry()) { $item->setCountry($new_item->getCountry()); } if (!$item->getDateEnd()) { $item->setDateEnd($new_item->getDateEnd()); } if (!$item->getDatePremiere()) { $item->setDatePremiere($new_item->getDatePremiere()); } if (!$item->getDuration()) { $item->setDuration($new_item->getDuration()); } if (!$item->getEpisodes()) { $item->setEpisodes($new_item->getEpisodes()); } if (!$item->getEpisodesNumber()) { $item->setEpisodesNumber($new_item->getEpisodesNumber()); } if (!$item->getFileInfo()) { $item->setFileInfo($new_item->getFileInfo()); } if (!$item->getSummary()) { $item->setSummary($new_item->getSummary()); } if (!$item->getStudio()) { $item->setStudio($new_item->getStudio()); } if (!$item->getType()) { $item->setType($new_item->getType()); } // remove links $item->getCountry()->removeItem($new_item); $item->getType()->removeItem($new_item); $item->getStudio()->removeItem($new_item); if (!$item->getCover()) { $item->setCover($new_item->getCover()); } foreach ($new_item->getGenres() as $genre) { $item->addGenre($genre->removeItem($new_item)); } // set main name in top of names list $new_names = $new_item->getNames()->toArray(); array_unshift($new_names, (new Name())->setName($new_item->getName())); foreach ($new_names as $new_name) { $item->addName($new_name->setItem(null)); } foreach ($new_item->getSources() as $source) { $item->addSource($source->setItem(null)); } $event->addFiller($this->filler); // resend event $this->dispatcher->dispatch(StoreEvents::ADD_NEW_ITEM, clone $event); $event->stopPropagation(); } }
php
public function onAddNewItem(AddNewItem $event) { $item = $event->getItem(); if (!$event->getFillers()->contains($this->filler) && ($url = $this->refiller->getSourceForFill($item))) { $new_item = $this->filler->fill(['url' => $url]); // fill item if (!$item->getCountry()) { $item->setCountry($new_item->getCountry()); } if (!$item->getDateEnd()) { $item->setDateEnd($new_item->getDateEnd()); } if (!$item->getDatePremiere()) { $item->setDatePremiere($new_item->getDatePremiere()); } if (!$item->getDuration()) { $item->setDuration($new_item->getDuration()); } if (!$item->getEpisodes()) { $item->setEpisodes($new_item->getEpisodes()); } if (!$item->getEpisodesNumber()) { $item->setEpisodesNumber($new_item->getEpisodesNumber()); } if (!$item->getFileInfo()) { $item->setFileInfo($new_item->getFileInfo()); } if (!$item->getSummary()) { $item->setSummary($new_item->getSummary()); } if (!$item->getStudio()) { $item->setStudio($new_item->getStudio()); } if (!$item->getType()) { $item->setType($new_item->getType()); } // remove links $item->getCountry()->removeItem($new_item); $item->getType()->removeItem($new_item); $item->getStudio()->removeItem($new_item); if (!$item->getCover()) { $item->setCover($new_item->getCover()); } foreach ($new_item->getGenres() as $genre) { $item->addGenre($genre->removeItem($new_item)); } // set main name in top of names list $new_names = $new_item->getNames()->toArray(); array_unshift($new_names, (new Name())->setName($new_item->getName())); foreach ($new_names as $new_name) { $item->addName($new_name->setItem(null)); } foreach ($new_item->getSources() as $source) { $item->addSource($source->setItem(null)); } $event->addFiller($this->filler); // resend event $this->dispatcher->dispatch(StoreEvents::ADD_NEW_ITEM, clone $event); $event->stopPropagation(); } }
[ "public", "function", "onAddNewItem", "(", "AddNewItem", "$", "event", ")", "{", "$", "item", "=", "$", "event", "->", "getItem", "(", ")", ";", "if", "(", "!", "$", "event", "->", "getFillers", "(", ")", "->", "contains", "(", "$", "this", "->", "filler", ")", "&&", "(", "$", "url", "=", "$", "this", "->", "refiller", "->", "getSourceForFill", "(", "$", "item", ")", ")", ")", "{", "$", "new_item", "=", "$", "this", "->", "filler", "->", "fill", "(", "[", "'url'", "=>", "$", "url", "]", ")", ";", "// fill item", "if", "(", "!", "$", "item", "->", "getCountry", "(", ")", ")", "{", "$", "item", "->", "setCountry", "(", "$", "new_item", "->", "getCountry", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getDateEnd", "(", ")", ")", "{", "$", "item", "->", "setDateEnd", "(", "$", "new_item", "->", "getDateEnd", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getDatePremiere", "(", ")", ")", "{", "$", "item", "->", "setDatePremiere", "(", "$", "new_item", "->", "getDatePremiere", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getDuration", "(", ")", ")", "{", "$", "item", "->", "setDuration", "(", "$", "new_item", "->", "getDuration", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getEpisodes", "(", ")", ")", "{", "$", "item", "->", "setEpisodes", "(", "$", "new_item", "->", "getEpisodes", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getEpisodesNumber", "(", ")", ")", "{", "$", "item", "->", "setEpisodesNumber", "(", "$", "new_item", "->", "getEpisodesNumber", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getFileInfo", "(", ")", ")", "{", "$", "item", "->", "setFileInfo", "(", "$", "new_item", "->", "getFileInfo", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getSummary", "(", ")", ")", "{", "$", "item", "->", "setSummary", "(", "$", "new_item", "->", "getSummary", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getStudio", "(", ")", ")", "{", "$", "item", "->", "setStudio", "(", "$", "new_item", "->", "getStudio", "(", ")", ")", ";", "}", "if", "(", "!", "$", "item", "->", "getType", "(", ")", ")", "{", "$", "item", "->", "setType", "(", "$", "new_item", "->", "getType", "(", ")", ")", ";", "}", "// remove links", "$", "item", "->", "getCountry", "(", ")", "->", "removeItem", "(", "$", "new_item", ")", ";", "$", "item", "->", "getType", "(", ")", "->", "removeItem", "(", "$", "new_item", ")", ";", "$", "item", "->", "getStudio", "(", ")", "->", "removeItem", "(", "$", "new_item", ")", ";", "if", "(", "!", "$", "item", "->", "getCover", "(", ")", ")", "{", "$", "item", "->", "setCover", "(", "$", "new_item", "->", "getCover", "(", ")", ")", ";", "}", "foreach", "(", "$", "new_item", "->", "getGenres", "(", ")", "as", "$", "genre", ")", "{", "$", "item", "->", "addGenre", "(", "$", "genre", "->", "removeItem", "(", "$", "new_item", ")", ")", ";", "}", "// set main name in top of names list", "$", "new_names", "=", "$", "new_item", "->", "getNames", "(", ")", "->", "toArray", "(", ")", ";", "array_unshift", "(", "$", "new_names", ",", "(", "new", "Name", "(", ")", ")", "->", "setName", "(", "$", "new_item", "->", "getName", "(", ")", ")", ")", ";", "foreach", "(", "$", "new_names", "as", "$", "new_name", ")", "{", "$", "item", "->", "addName", "(", "$", "new_name", "->", "setItem", "(", "null", ")", ")", ";", "}", "foreach", "(", "$", "new_item", "->", "getSources", "(", ")", "as", "$", "source", ")", "{", "$", "item", "->", "addSource", "(", "$", "source", "->", "setItem", "(", "null", ")", ")", ";", "}", "$", "event", "->", "addFiller", "(", "$", "this", "->", "filler", ")", ";", "// resend event", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "StoreEvents", "::", "ADD_NEW_ITEM", ",", "clone", "$", "event", ")", ";", "$", "event", "->", "stopPropagation", "(", ")", ";", "}", "}" ]
On add new item. @param \AnimeDb\Bundle\CatalogBundle\Event\Storage\AddNewItem $event
[ "On", "add", "new", "item", "." ]
train
https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Event/Listener/Refiller.php#L64-L127
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Element.php
Zend_Feed_Element.setDOM
public function setDOM(DOMElement $element) { $this->_element = $this->_element->ownerDocument->importNode($element, true); }
php
public function setDOM(DOMElement $element) { $this->_element = $this->_element->ownerDocument->importNode($element, true); }
[ "public", "function", "setDOM", "(", "DOMElement", "$", "element", ")", "{", "$", "this", "->", "_element", "=", "$", "this", "->", "_element", "->", "ownerDocument", "->", "importNode", "(", "$", "element", ",", "true", ")", ";", "}" ]
Update the object from a DOM element Take a DOMElement object, which may be originally from a call to getDOM() or may be custom created, and use it as the DOM tree for this Zend_Feed_Element. @param DOMElement $element @return void
[ "Update", "the", "object", "from", "a", "DOM", "element" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Element.php#L87-L90
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Element.php
Zend_Feed_Element.ensureAppended
protected function ensureAppended() { if (!$this->_appended) { $this->_parentElement->getDOM()->appendChild($this->_element); $this->_appended = true; $this->_parentElement->ensureAppended(); } }
php
protected function ensureAppended() { if (!$this->_appended) { $this->_parentElement->getDOM()->appendChild($this->_element); $this->_appended = true; $this->_parentElement->ensureAppended(); } }
[ "protected", "function", "ensureAppended", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_appended", ")", "{", "$", "this", "->", "_parentElement", "->", "getDOM", "(", ")", "->", "appendChild", "(", "$", "this", "->", "_element", ")", ";", "$", "this", "->", "_appended", "=", "true", ";", "$", "this", "->", "_parentElement", "->", "ensureAppended", "(", ")", ";", "}", "}" ]
Appends this element to its parent if necessary. @return void
[ "Appends", "this", "element", "to", "its", "parent", "if", "necessary", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Element.php#L111-L118
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Element.php
Zend_Feed_Element.__isset
public function __isset($var) { // Look for access of the form {ns:var}. We don't use // _children() here because we can break out of the loop // immediately once we find something. if (strpos($var, ':') !== false) { list($ns, $elt) = explode(':', $var, 2); foreach ($this->_element->childNodes as $child) { if ($child->localName == $elt && $child->prefix == $ns) { return true; } } } else { foreach ($this->_element->childNodes as $child) { if ($child->localName == $var) { return true; } } } }
php
public function __isset($var) { // Look for access of the form {ns:var}. We don't use // _children() here because we can break out of the loop // immediately once we find something. if (strpos($var, ':') !== false) { list($ns, $elt) = explode(':', $var, 2); foreach ($this->_element->childNodes as $child) { if ($child->localName == $elt && $child->prefix == $ns) { return true; } } } else { foreach ($this->_element->childNodes as $child) { if ($child->localName == $var) { return true; } } } }
[ "public", "function", "__isset", "(", "$", "var", ")", "{", "// Look for access of the form {ns:var}. We don't use", "// _children() here because we can break out of the loop", "// immediately once we find something.", "if", "(", "strpos", "(", "$", "var", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "ns", ",", "$", "elt", ")", "=", "explode", "(", "':'", ",", "$", "var", ",", "2", ")", ";", "foreach", "(", "$", "this", "->", "_element", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "localName", "==", "$", "elt", "&&", "$", "child", "->", "prefix", "==", "$", "ns", ")", "{", "return", "true", ";", "}", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "_element", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "localName", "==", "$", "var", ")", "{", "return", "true", ";", "}", "}", "}", "}" ]
Map isset calls onto the underlying entry representation. @param string $var @return boolean
[ "Map", "isset", "calls", "onto", "the", "underlying", "entry", "representation", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Element.php#L231-L250
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Element.php
Zend_Feed_Element._children
protected function _children($var) { $found = array(); // Look for access of the form {ns:var}. if (strpos($var, ':') !== false) { list($ns, $elt) = explode(':', $var, 2); foreach ($this->_element->childNodes as $child) { if ($child->localName == $elt && $child->prefix == $ns) { $found[] = $child; } } } else { foreach ($this->_element->childNodes as $child) { if ($child->localName == $var) { $found[] = $child; } } } return $found; }
php
protected function _children($var) { $found = array(); // Look for access of the form {ns:var}. if (strpos($var, ':') !== false) { list($ns, $elt) = explode(':', $var, 2); foreach ($this->_element->childNodes as $child) { if ($child->localName == $elt && $child->prefix == $ns) { $found[] = $child; } } } else { foreach ($this->_element->childNodes as $child) { if ($child->localName == $var) { $found[] = $child; } } } return $found; }
[ "protected", "function", "_children", "(", "$", "var", ")", "{", "$", "found", "=", "array", "(", ")", ";", "// Look for access of the form {ns:var}.", "if", "(", "strpos", "(", "$", "var", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "ns", ",", "$", "elt", ")", "=", "explode", "(", "':'", ",", "$", "var", ",", "2", ")", ";", "foreach", "(", "$", "this", "->", "_element", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "localName", "==", "$", "elt", "&&", "$", "child", "->", "prefix", "==", "$", "ns", ")", "{", "$", "found", "[", "]", "=", "$", "child", ";", "}", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "_element", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "localName", "==", "$", "var", ")", "{", "$", "found", "[", "]", "=", "$", "child", ";", "}", "}", "}", "return", "$", "found", ";", "}" ]
Finds children with tagnames matching $var Similar to SimpleXML's children() method. @param string $var Tagname to match, can be either namespace:tagName or just tagName. @return array
[ "Finds", "children", "with", "tagnames", "matching", "$var" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Element.php#L314-L335
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Element.php
Zend_Feed_Element.offsetExists
public function offsetExists($offset) { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->hasAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); } else { return $this->_element->hasAttribute($offset); } }
php
public function offsetExists($offset) { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->hasAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); } else { return $this->_element->hasAttribute($offset); } }
[ "public", "function", "offsetExists", "(", "$", "offset", ")", "{", "if", "(", "strpos", "(", "$", "offset", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "ns", ",", "$", "attr", ")", "=", "explode", "(", "':'", ",", "$", "offset", ",", "2", ")", ";", "return", "$", "this", "->", "_element", "->", "hasAttributeNS", "(", "Zend_Feed", "::", "lookupNamespace", "(", "$", "ns", ")", ",", "$", "attr", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_element", "->", "hasAttribute", "(", "$", "offset", ")", ";", "}", "}" ]
Required by the ArrayAccess interface. @param string $offset @return boolean
[ "Required", "by", "the", "ArrayAccess", "interface", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Element.php#L344-L352
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Element.php
Zend_Feed_Element.offsetGet
public function offsetGet($offset) { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->getAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); } else { return $this->_element->getAttribute($offset); } }
php
public function offsetGet($offset) { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->getAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); } else { return $this->_element->getAttribute($offset); } }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "if", "(", "strpos", "(", "$", "offset", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "ns", ",", "$", "attr", ")", "=", "explode", "(", "':'", ",", "$", "offset", ",", "2", ")", ";", "return", "$", "this", "->", "_element", "->", "getAttributeNS", "(", "Zend_Feed", "::", "lookupNamespace", "(", "$", "ns", ")", ",", "$", "attr", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_element", "->", "getAttribute", "(", "$", "offset", ")", ";", "}", "}" ]
Required by the ArrayAccess interface. @param string $offset @return string
[ "Required", "by", "the", "ArrayAccess", "interface", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Element.php#L361-L369
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Element.php
Zend_Feed_Element.offsetSet
public function offsetSet($offset, $value) { $this->ensureAppended(); if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->setAttributeNS(Zend_Feed::lookupNamespace($ns), $attr, $value); } else { return $this->_element->setAttribute($offset, $value); } }
php
public function offsetSet($offset, $value) { $this->ensureAppended(); if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->setAttributeNS(Zend_Feed::lookupNamespace($ns), $attr, $value); } else { return $this->_element->setAttribute($offset, $value); } }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "$", "this", "->", "ensureAppended", "(", ")", ";", "if", "(", "strpos", "(", "$", "offset", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "ns", ",", "$", "attr", ")", "=", "explode", "(", "':'", ",", "$", "offset", ",", "2", ")", ";", "return", "$", "this", "->", "_element", "->", "setAttributeNS", "(", "Zend_Feed", "::", "lookupNamespace", "(", "$", "ns", ")", ",", "$", "attr", ",", "$", "value", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_element", "->", "setAttribute", "(", "$", "offset", ",", "$", "value", ")", ";", "}", "}" ]
Required by the ArrayAccess interface. @param string $offset @param string $value @return string
[ "Required", "by", "the", "ArrayAccess", "interface", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Element.php#L379-L389
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Element.php
Zend_Feed_Element.offsetUnset
public function offsetUnset($offset) { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->removeAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); } else { return $this->_element->removeAttribute($offset); } }
php
public function offsetUnset($offset) { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->removeAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); } else { return $this->_element->removeAttribute($offset); } }
[ "public", "function", "offsetUnset", "(", "$", "offset", ")", "{", "if", "(", "strpos", "(", "$", "offset", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "ns", ",", "$", "attr", ")", "=", "explode", "(", "':'", ",", "$", "offset", ",", "2", ")", ";", "return", "$", "this", "->", "_element", "->", "removeAttributeNS", "(", "Zend_Feed", "::", "lookupNamespace", "(", "$", "ns", ")", ",", "$", "attr", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_element", "->", "removeAttribute", "(", "$", "offset", ")", ";", "}", "}" ]
Required by the ArrayAccess interface. @param string $offset @return boolean
[ "Required", "by", "the", "ArrayAccess", "interface", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Element.php#L398-L406
CakeCMS/Core
src/View/Widget/MaterializeCss/TextareaWidget.php
TextareaWidget.render
public function render(array $data, ContextInterface $context) { $data = array_merge(['class' => null], $data); $data['class'] .= ' materialize-textarea'; $data['class'] = Str::trim($data['class']); return parent::render($data, $context); }
php
public function render(array $data, ContextInterface $context) { $data = array_merge(['class' => null], $data); $data['class'] .= ' materialize-textarea'; $data['class'] = Str::trim($data['class']); return parent::render($data, $context); }
[ "public", "function", "render", "(", "array", "$", "data", ",", "ContextInterface", "$", "context", ")", "{", "$", "data", "=", "array_merge", "(", "[", "'class'", "=>", "null", "]", ",", "$", "data", ")", ";", "$", "data", "[", "'class'", "]", ".=", "' materialize-textarea'", ";", "$", "data", "[", "'class'", "]", "=", "Str", "::", "trim", "(", "$", "data", "[", "'class'", "]", ")", ";", "return", "parent", "::", "render", "(", "$", "data", ",", "$", "context", ")", ";", "}" ]
Render a text area form widget. Data supports the following keys: - `name` - Set the input name. - `val` - A string of the option to mark as selected. - `escape` - Set to false to disable HTML escaping. All other keys will be converted into HTML attributes. @param array $data The data to build a textarea with. @param \Cake\View\Form\ContextInterface $context The current form context. @return string HTML elements.
[ "Render", "a", "text", "area", "form", "widget", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Widget/MaterializeCss/TextareaWidget.php#L45-L53
webforge-labs/psc-cms
lib/Psc/UI/fHTML.php
fHTML.tag
public static function tag($name, $content = NULL, Array $attributes = NULL) { return \Psc\UI\HTML::tag($name, $content, $attributes); }
php
public static function tag($name, $content = NULL, Array $attributes = NULL) { return \Psc\UI\HTML::tag($name, $content, $attributes); }
[ "public", "static", "function", "tag", "(", "$", "name", ",", "$", "content", "=", "NULL", ",", "Array", "$", "attributes", "=", "NULL", ")", "{", "return", "\\", "Psc", "\\", "UI", "\\", "HTML", "::", "tag", "(", "$", "name", ",", "$", "content", ",", "$", "attributes", ")", ";", "}" ]
Erzeugt ein neues Tag @param string $name @param mixed $content @param Array $attributes @return \Psc\UI\HTMLTag
[ "Erzeugt", "ein", "neues", "Tag" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/fHTML.php#L17-L19
CPSB/Validation-helper
src/Form.php
Form.input
public function input($name, $default = null) { $value = e($this->value($name, $default)); $name = e($name); return "name=\"$name\" value=\"$value\""; }
php
public function input($name, $default = null) { $value = e($this->value($name, $default)); $name = e($name); return "name=\"$name\" value=\"$value\""; }
[ "public", "function", "input", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "e", "(", "$", "this", "->", "value", "(", "$", "name", ",", "$", "default", ")", ")", ";", "$", "name", "=", "e", "(", "$", "name", ")", ";", "return", "\"name=\\\"$name\\\" value=\\\"$value\\\"\"", ";", "}" ]
Get the attributes for an input field. @param string $name @param mixed|null $default @return string
[ "Get", "the", "attributes", "for", "an", "input", "field", "." ]
train
https://github.com/CPSB/Validation-helper/blob/adb91cb42b7e3c1f88be059a8b4f86de5aba64cc/src/Form.php#L64-L69
CPSB/Validation-helper
src/Form.php
Form.checkbox
public function checkbox($name, $inputValue = 1, $checkByDefault = false) { $value = $this->value($name); // Define the state for the checkbox, when $value is null then we // use the $checkByDefault value directly, otherwise the checkbox will // be checked only if the $value is equal to the $inputValue. if (is_null($value)) { $checked = $checkByDefault; } else { $checked = $value == $inputValue; } $name = e($name); $inputValue = e($inputValue); $checked = $checked ? ' checked' : ''; return "name=\"$name\" value=\"$inputValue\"$checked"; }
php
public function checkbox($name, $inputValue = 1, $checkByDefault = false) { $value = $this->value($name); // Define the state for the checkbox, when $value is null then we // use the $checkByDefault value directly, otherwise the checkbox will // be checked only if the $value is equal to the $inputValue. if (is_null($value)) { $checked = $checkByDefault; } else { $checked = $value == $inputValue; } $name = e($name); $inputValue = e($inputValue); $checked = $checked ? ' checked' : ''; return "name=\"$name\" value=\"$inputValue\"$checked"; }
[ "public", "function", "checkbox", "(", "$", "name", ",", "$", "inputValue", "=", "1", ",", "$", "checkByDefault", "=", "false", ")", "{", "$", "value", "=", "$", "this", "->", "value", "(", "$", "name", ")", ";", "// Define the state for the checkbox, when $value is null then we", "// use the $checkByDefault value directly, otherwise the checkbox will", "// be checked only if the $value is equal to the $inputValue.", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "checked", "=", "$", "checkByDefault", ";", "}", "else", "{", "$", "checked", "=", "$", "value", "==", "$", "inputValue", ";", "}", "$", "name", "=", "e", "(", "$", "name", ")", ";", "$", "inputValue", "=", "e", "(", "$", "inputValue", ")", ";", "$", "checked", "=", "$", "checked", "?", "' checked'", ":", "''", ";", "return", "\"name=\\\"$name\\\" value=\\\"$inputValue\\\"$checked\"", ";", "}" ]
Get the attributes for a checkbox. @param string $name @param mixed $inputValue @param bool $checkByDefault @return string
[ "Get", "the", "attributes", "for", "a", "checkbox", "." ]
train
https://github.com/CPSB/Validation-helper/blob/adb91cb42b7e3c1f88be059a8b4f86de5aba64cc/src/Form.php#L79-L95
CPSB/Validation-helper
src/Form.php
Form.radio
public function radio($name, $inputValue = 1, $checkByDefault = false) { return $this->checkbox($name, $inputValue, $checkByDefault); }
php
public function radio($name, $inputValue = 1, $checkByDefault = false) { return $this->checkbox($name, $inputValue, $checkByDefault); }
[ "public", "function", "radio", "(", "$", "name", ",", "$", "inputValue", "=", "1", ",", "$", "checkByDefault", "=", "false", ")", "{", "return", "$", "this", "->", "checkbox", "(", "$", "name", ",", "$", "inputValue", ",", "$", "checkByDefault", ")", ";", "}" ]
Get the attributes for a radio. @param string $name @param mixed $inputValue @param bool $checkByDefault @return string
[ "Get", "the", "attributes", "for", "a", "radio", "." ]
train
https://github.com/CPSB/Validation-helper/blob/adb91cb42b7e3c1f88be059a8b4f86de5aba64cc/src/Form.php#L105-L108
CPSB/Validation-helper
src/Form.php
Form.options
public function options($options, $name, $default = null, $placeholder = null) { $tags = []; // Prepend the placeholder to the options list if needed. if ($placeholder) { $tags[] = '<option value="" selected disabled>'.e($placeholder).'</option>'; } $value = $this->value($name, $default); // Cast $default and $value to an array in order to support selects with // multiple options selected. if (! is_array($value)) { $value = [$value]; } foreach ($options as $key => $text) { $selected = in_array($key, $value) ? ' selected' : ''; $key = e($key); $text = e($text); $tags[] = "<option value=\"$key\"$selected>$text</option>"; } return implode($tags); }
php
public function options($options, $name, $default = null, $placeholder = null) { $tags = []; // Prepend the placeholder to the options list if needed. if ($placeholder) { $tags[] = '<option value="" selected disabled>'.e($placeholder).'</option>'; } $value = $this->value($name, $default); // Cast $default and $value to an array in order to support selects with // multiple options selected. if (! is_array($value)) { $value = [$value]; } foreach ($options as $key => $text) { $selected = in_array($key, $value) ? ' selected' : ''; $key = e($key); $text = e($text); $tags[] = "<option value=\"$key\"$selected>$text</option>"; } return implode($tags); }
[ "public", "function", "options", "(", "$", "options", ",", "$", "name", ",", "$", "default", "=", "null", ",", "$", "placeholder", "=", "null", ")", "{", "$", "tags", "=", "[", "]", ";", "// Prepend the placeholder to the options list if needed.", "if", "(", "$", "placeholder", ")", "{", "$", "tags", "[", "]", "=", "'<option value=\"\" selected disabled>'", ".", "e", "(", "$", "placeholder", ")", ".", "'</option>'", ";", "}", "$", "value", "=", "$", "this", "->", "value", "(", "$", "name", ",", "$", "default", ")", ";", "// Cast $default and $value to an array in order to support selects with", "// multiple options selected.", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "$", "value", "]", ";", "}", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "text", ")", "{", "$", "selected", "=", "in_array", "(", "$", "key", ",", "$", "value", ")", "?", "' selected'", ":", "''", ";", "$", "key", "=", "e", "(", "$", "key", ")", ";", "$", "text", "=", "e", "(", "$", "text", ")", ";", "$", "tags", "[", "]", "=", "\"<option value=\\\"$key\\\"$selected>$text</option>\"", ";", "}", "return", "implode", "(", "$", "tags", ")", ";", "}" ]
Get the options for a select. @param array $options @param string $name @param mixed|null $default @param string|null $placeholder @return string
[ "Get", "the", "options", "for", "a", "select", "." ]
train
https://github.com/CPSB/Validation-helper/blob/adb91cb42b7e3c1f88be059a8b4f86de5aba64cc/src/Form.php#L119-L140