repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionSchedulerLog
public function actionSchedulerLog($model, $pk) { return new ActiveDataProvider([ 'query' => Scheduler::find()->where(['model_class' => $model, 'primary_key' => $pk]), 'sort'=> ['defaultOrder' => ['schedule_timestamp' => SORT_ASC]], 'pagination' => false, ]); }
php
public function actionSchedulerLog($model, $pk) { return new ActiveDataProvider([ 'query' => Scheduler::find()->where(['model_class' => $model, 'primary_key' => $pk]), 'sort'=> ['defaultOrder' => ['schedule_timestamp' => SORT_ASC]], 'pagination' => false, ]); }
[ "public", "function", "actionSchedulerLog", "(", "$", "model", ",", "$", "pk", ")", "{", "return", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "Scheduler", "::", "find", "(", ")", "->", "where", "(", "[", "'model_class'", "=>", "$", "model", ...
Get all log entries for a given scheulder model with primary key. @param string $model The namespace to the model @param integer $pk The primary key @return ActiveDataProvider @since 2.0.0
[ "Get", "all", "log", "entries", "for", "a", "given", "scheulder", "model", "with", "primary", "key", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L44-L51
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionSchedulerAdd
public function actionSchedulerAdd() { $model = new Scheduler(); $model->attributes = Yii::$app->request->bodyParams; if (!$model->hasTriggerPermission($model->model_class)) { throw new ForbiddenHttpException("Unable to schedule a task for the given model."); } if ($model->save()) { $model->pushQueue(); // if its a "now" job, run the internal worker now so the log table is refreshed immediately Yii::$app->adminqueue->run(false); Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time()); return $model; } return $this->sendModelError($model); }
php
public function actionSchedulerAdd() { $model = new Scheduler(); $model->attributes = Yii::$app->request->bodyParams; if (!$model->hasTriggerPermission($model->model_class)) { throw new ForbiddenHttpException("Unable to schedule a task for the given model."); } if ($model->save()) { $model->pushQueue(); // if its a "now" job, run the internal worker now so the log table is refreshed immediately Yii::$app->adminqueue->run(false); Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time()); return $model; } return $this->sendModelError($model); }
[ "public", "function", "actionSchedulerAdd", "(", ")", "{", "$", "model", "=", "new", "Scheduler", "(", ")", ";", "$", "model", "->", "attributes", "=", "Yii", "::", "$", "app", "->", "request", "->", "bodyParams", ";", "if", "(", "!", "$", "model", "...
Add a task to the scheduler. @return array @since 2.0.0
[ "Add", "a", "task", "to", "the", "scheduler", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L59-L78
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionSchedulerDelete
public function actionSchedulerDelete($id) { $job = Scheduler::findOne($id); if ($job) { return $job->delete(); } return false; }
php
public function actionSchedulerDelete($id) { $job = Scheduler::findOne($id); if ($job) { return $job->delete(); } return false; }
[ "public", "function", "actionSchedulerDelete", "(", "$", "id", ")", "{", "$", "job", "=", "Scheduler", "::", "findOne", "(", "$", "id", ")", ";", "if", "(", "$", "job", ")", "{", "return", "$", "job", "->", "delete", "(", ")", ";", "}", "return", ...
Remove a job for a given ID. @return boolean @since 2.0.0
[ "Remove", "a", "job", "for", "a", "given", "ID", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L86-L95
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionNgrestFilter
public function actionNgrestFilter() { $apiEndpoint = Yii::$app->request->getBodyParam('apiEndpoint'); $filterName = Yii::$app->request->getBodyParam('filterName'); return Yii::$app->adminuser->identity->setting->set('ngrestfilter.'.$apiEndpoint, $filterName); }
php
public function actionNgrestFilter() { $apiEndpoint = Yii::$app->request->getBodyParam('apiEndpoint'); $filterName = Yii::$app->request->getBodyParam('filterName'); return Yii::$app->adminuser->identity->setting->set('ngrestfilter.'.$apiEndpoint, $filterName); }
[ "public", "function", "actionNgrestFilter", "(", ")", "{", "$", "apiEndpoint", "=", "Yii", "::", "$", "app", "->", "request", "->", "getBodyParam", "(", "'apiEndpoint'", ")", ";", "$", "filterName", "=", "Yii", "::", "$", "app", "->", "request", "->", "g...
Set the lastest ngrest filter selection in the User Settings. @return boolean
[ "Set", "the", "lastest", "ngrest", "filter", "selection", "in", "the", "User", "Settings", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L115-L121
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionNgrestOrder
public function actionNgrestOrder() { $apiEndpoint = Yii::$app->request->getBodyParam('apiEndpoint'); $sort = Yii::$app->request->getBodyParam('sort'); $field = Yii::$app->request->getBodyParam('field'); if ($sort == '-') { $sort = SORT_DESC; } else { $sort = SORT_ASC; } return Yii::$app->adminuser->identity->setting->set('ngrestorder.'.$apiEndpoint, ['sort' => $sort, 'field' => $field]); }
php
public function actionNgrestOrder() { $apiEndpoint = Yii::$app->request->getBodyParam('apiEndpoint'); $sort = Yii::$app->request->getBodyParam('sort'); $field = Yii::$app->request->getBodyParam('field'); if ($sort == '-') { $sort = SORT_DESC; } else { $sort = SORT_ASC; } return Yii::$app->adminuser->identity->setting->set('ngrestorder.'.$apiEndpoint, ['sort' => $sort, 'field' => $field]); }
[ "public", "function", "actionNgrestOrder", "(", ")", "{", "$", "apiEndpoint", "=", "Yii", "::", "$", "app", "->", "request", "->", "getBodyParam", "(", "'apiEndpoint'", ")", ";", "$", "sort", "=", "Yii", "::", "$", "app", "->", "request", "->", "getBodyP...
Set the lastest ngrest curd list order direction in the User Settings. @return boolean
[ "Set", "the", "lastest", "ngrest", "curd", "list", "order", "direction", "in", "the", "User", "Settings", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L128-L141
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionDataProperties
public function actionDataProperties() { $data = []; foreach (Property::find()->all() as $item) { $object = Property::getObject($item->class_name); $data[] = [ 'id' => $item->id, 'var_name' => $object->varName(), 'option_json' => $object->options(), 'label' => $object->label(), 'type' => $object->type(), 'default_value' => $object->defaultValue(), 'i18n' => $object->i18n, ]; } return $data; }
php
public function actionDataProperties() { $data = []; foreach (Property::find()->all() as $item) { $object = Property::getObject($item->class_name); $data[] = [ 'id' => $item->id, 'var_name' => $object->varName(), 'option_json' => $object->options(), 'label' => $object->label(), 'type' => $object->type(), 'default_value' => $object->defaultValue(), 'i18n' => $object->i18n, ]; } return $data; }
[ "public", "function", "actionDataProperties", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "Property", "::", "find", "(", ")", "->", "all", "(", ")", "as", "$", "item", ")", "{", "$", "object", "=", "Property", "::", "getObject", ...
Get all available administration regisetered properties. @return array Get all properties.
[ "Get", "all", "available", "administration", "regisetered", "properties", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L158-L175
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionCache
public function actionCache() { $this->flushHasCache(); $user = Yii::$app->adminuser->identity; $user->updateAttributes(['force_reload' => false]); Yii::$app->trigger(self::EVENT_FLUSH_CACHE); return true; }
php
public function actionCache() { $this->flushHasCache(); $user = Yii::$app->adminuser->identity; $user->updateAttributes(['force_reload' => false]); Yii::$app->trigger(self::EVENT_FLUSH_CACHE); return true; }
[ "public", "function", "actionCache", "(", ")", "{", "$", "this", "->", "flushHasCache", "(", ")", ";", "$", "user", "=", "Yii", "::", "$", "app", "->", "adminuser", "->", "identity", ";", "$", "user", "->", "updateAttributes", "(", "[", "'force_reload'",...
Triggerable action to flush the application cache and force user reload. @return boolean
[ "Triggerable", "action", "to", "flush", "the", "application", "cache", "and", "force", "user", "reload", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L182-L192
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionDataModules
public function actionDataModules() { $data = []; foreach (Yii::$app->getFrontendModules() as $k => $f) { $data[] = ['value' => $k, 'label' => $k]; } return $data; }
php
public function actionDataModules() { $data = []; foreach (Yii::$app->getFrontendModules() as $k => $f) { $data[] = ['value' => $k, 'label' => $k]; } return $data; }
[ "public", "function", "actionDataModules", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "Yii", "::", "$", "app", "->", "getFrontendModules", "(", ")", "as", "$", "k", "=>", "$", "f", ")", "{", "$", "data", "[", "]", "=", "[", ...
Get a list with all frontend modules, which is used in several dropdowns in the admin ui. @return array An array with all frontend modules.
[ "Get", "a", "list", "with", "all", "frontend", "modules", "which", "is", "used", "in", "several", "dropdowns", "in", "the", "admin", "ui", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L199-L206
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionSaveFilemanagerFolderState
public function actionSaveFilemanagerFolderState() { $folderId = Yii::$app->request->getBodyParam('folderId'); if ($folderId) { return Yii::$app->adminuser->identity->setting->set('filemanagerFolderId', $folderId); } else { return Yii::$app->adminuser->identity->setting->remove('filemanagerFolderId'); } }
php
public function actionSaveFilemanagerFolderState() { $folderId = Yii::$app->request->getBodyParam('folderId'); if ($folderId) { return Yii::$app->adminuser->identity->setting->set('filemanagerFolderId', $folderId); } else { return Yii::$app->adminuser->identity->setting->remove('filemanagerFolderId'); } }
[ "public", "function", "actionSaveFilemanagerFolderState", "(", ")", "{", "$", "folderId", "=", "Yii", "::", "$", "app", "->", "request", "->", "getBodyParam", "(", "'folderId'", ")", ";", "if", "(", "$", "folderId", ")", "{", "return", "Yii", "::", "$", ...
Save the last selected filemanager folder in the user settings. @return boolean
[ "Save", "the", "last", "selected", "filemanager", "folder", "in", "the", "user", "settings", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L213-L222
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionFilemanagerFoldertreeHistory
public function actionFilemanagerFoldertreeHistory() { $this->deleteHasCache('storageApiDataFolders'); $data = Yii::$app->request->getBodyParam('data'); Yii::$app->adminuser->identity->setting->set('foldertree.'.$data['id'], (int) $data['toggle_open']); }
php
public function actionFilemanagerFoldertreeHistory() { $this->deleteHasCache('storageApiDataFolders'); $data = Yii::$app->request->getBodyParam('data'); Yii::$app->adminuser->identity->setting->set('foldertree.'.$data['id'], (int) $data['toggle_open']); }
[ "public", "function", "actionFilemanagerFoldertreeHistory", "(", ")", "{", "$", "this", "->", "deleteHasCache", "(", "'storageApiDataFolders'", ")", ";", "$", "data", "=", "Yii", "::", "$", "app", "->", "request", "->", "getBodyParam", "(", "'data'", ")", ";",...
Store the open and closed folders from the filemanager tree in the user settings. @return boolean
[ "Store", "the", "open", "and", "closed", "folders", "from", "the", "filemanager", "tree", "in", "the", "user", "settings", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L239-L245
train
luyadev/luya-module-admin
src/apis/CommonController.php
CommonController.actionLastLogins
public function actionLastLogins() { return UserLogin::find()->select(['user_id', 'max(timestamp_create) as maxdate'])->joinWith(['user' => function ($q) { $q->select(['id', 'firstname', 'lastname']); }])->limit(10)->groupBy(['user_id'])->orderBy(['maxdate' => SORT_DESC])->asArray()->all(); }
php
public function actionLastLogins() { return UserLogin::find()->select(['user_id', 'max(timestamp_create) as maxdate'])->joinWith(['user' => function ($q) { $q->select(['id', 'firstname', 'lastname']); }])->limit(10)->groupBy(['user_id'])->orderBy(['maxdate' => SORT_DESC])->asArray()->all(); }
[ "public", "function", "actionLastLogins", "(", ")", "{", "return", "UserLogin", "::", "find", "(", ")", "->", "select", "(", "[", "'user_id'", ",", "'max(timestamp_create) as maxdate'", "]", ")", "->", "joinWith", "(", "[", "'user'", "=>", "function", "(", "...
Last User logins @return array|\yii\db\ActiveRecord[]
[ "Last", "User", "logins" ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/CommonController.php#L251-L256
train
luyadev/luya-module-admin
src/models/User.php
User.getSetting
public function getSetting() { if ($this->_setting === null) { $settingsArray = (empty($this->settings)) ? [] : Json::decode($this->settings); $this->_setting = Yii::createObject(['class' => UserSetting::class, 'sender' => $this, 'data' => $settingsArray]); } return $this->_setting; }
php
public function getSetting() { if ($this->_setting === null) { $settingsArray = (empty($this->settings)) ? [] : Json::decode($this->settings); $this->_setting = Yii::createObject(['class' => UserSetting::class, 'sender' => $this, 'data' => $settingsArray]); } return $this->_setting; }
[ "public", "function", "getSetting", "(", ")", "{", "if", "(", "$", "this", "->", "_setting", "===", "null", ")", "{", "$", "settingsArray", "=", "(", "empty", "(", "$", "this", "->", "settings", ")", ")", "?", "[", "]", ":", "Json", "::", "decode",...
Get user settings objects. @return \luya\admin\models\UserSetting
[ "Get", "user", "settings", "objects", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/User.php#L83-L91
train
luyadev/luya-module-admin
src/models/User.php
User.generateToken
private function generateToken($length = 6) { $token = Yii::$app->security->generateRandomString($length); $replace = array_rand(range(2, 9)); return str_replace(['-', '_', 'l', 1], $replace, strtolower($token)); }
php
private function generateToken($length = 6) { $token = Yii::$app->security->generateRandomString($length); $replace = array_rand(range(2, 9)); return str_replace(['-', '_', 'l', 1], $replace, strtolower($token)); }
[ "private", "function", "generateToken", "(", "$", "length", "=", "6", ")", "{", "$", "token", "=", "Yii", "::", "$", "app", "->", "security", "->", "generateRandomString", "(", "$", "length", ")", ";", "$", "replace", "=", "array_rand", "(", "range", "...
Generate an easy readable random token. @param number $length @return mixed @since 1.2.0
[ "Generate", "an", "easy", "readable", "random", "token", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/User.php#L274-L279
train
luyadev/luya-module-admin
src/models/User.php
User.getAndStoreToken
public function getAndStoreToken() { $token = $this->generateToken(6); $this->setAttribute('secure_token', sha1($token)); $this->setAttribute('secure_token_timestamp', time()); $this->update(false); return $token; }
php
public function getAndStoreToken() { $token = $this->generateToken(6); $this->setAttribute('secure_token', sha1($token)); $this->setAttribute('secure_token_timestamp', time()); $this->update(false); return $token; }
[ "public", "function", "getAndStoreToken", "(", ")", "{", "$", "token", "=", "$", "this", "->", "generateToken", "(", "6", ")", ";", "$", "this", "->", "setAttribute", "(", "'secure_token'", ",", "sha1", "(", "$", "token", ")", ")", ";", "$", "this", ...
Generate, store and return the secure Login token. @return string
[ "Generate", "store", "and", "return", "the", "secure", "Login", "token", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/User.php#L286-L295
train
luyadev/luya-module-admin
src/models/User.php
User.encodePassword
public function encodePassword() { if (!$this->validate(['password'])) { return false; } // create random string for password salting $this->password_salt = Yii::$app->getSecurity()->generateRandomString(); // store the password $this->password = Yii::$app->getSecurity()->generatePasswordHash($this->password.$this->password_salt); return true; }
php
public function encodePassword() { if (!$this->validate(['password'])) { return false; } // create random string for password salting $this->password_salt = Yii::$app->getSecurity()->generateRandomString(); // store the password $this->password = Yii::$app->getSecurity()->generatePasswordHash($this->password.$this->password_salt); return true; }
[ "public", "function", "encodePassword", "(", ")", "{", "if", "(", "!", "$", "this", "->", "validate", "(", "[", "'password'", "]", ")", ")", "{", "return", "false", ";", "}", "// create random string for password salting", "$", "this", "->", "password_salt", ...
Encodes the current active record password field. @return boolean
[ "Encodes", "the", "current", "active", "record", "password", "field", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/User.php#L325-L337
train
luyadev/luya-module-admin
src/models/User.php
User.getTitleNamed
public function getTitleNamed() { return !isset(self::getTitles()[$this->title]) ?: self::getTitles()[$this->title]; }
php
public function getTitleNamed() { return !isset(self::getTitles()[$this->title]) ?: self::getTitles()[$this->title]; }
[ "public", "function", "getTitleNamed", "(", ")", "{", "return", "!", "isset", "(", "self", "::", "getTitles", "(", ")", "[", "$", "this", "->", "title", "]", ")", "?", ":", "self", "::", "getTitles", "(", ")", "[", "$", "this", "->", "title", "]", ...
Get the title Mr, Mrs. as string for the current user. @return string
[ "Get", "the", "title", "Mr", "Mrs", ".", "as", "string", "for", "the", "current", "user", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/User.php#L344-L347
train
luyadev/luya-module-admin
src/models/User.php
User.validatePassword
public function validatePassword($password) { return Yii::$app->security->validatePassword($password.$this->password_salt, $this->password); }
php
public function validatePassword($password) { return Yii::$app->security->validatePassword($password.$this->password_salt, $this->password); }
[ "public", "function", "validatePassword", "(", "$", "password", ")", "{", "return", "Yii", "::", "$", "app", "->", "security", "->", "validatePassword", "(", "$", "password", ".", "$", "this", "->", "password_salt", ",", "$", "this", "->", "password", ")",...
Validates the password for the current given user. @param string $password The plain user input password. @return boolean
[ "Validates", "the", "password", "for", "the", "current", "given", "user", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/User.php#L413-L416
train
luyadev/luya-module-admin
src/models/User.php
User.getAndStoreEmailVerificationToken
public function getAndStoreEmailVerificationToken() { $token = $this->generateToken(6); $this->updateAttributes([ 'email_verification_token' => sha1($token), 'email_verification_token_timestamp' => time(), ]); return $token; }
php
public function getAndStoreEmailVerificationToken() { $token = $this->generateToken(6); $this->updateAttributes([ 'email_verification_token' => sha1($token), 'email_verification_token_timestamp' => time(), ]); return $token; }
[ "public", "function", "getAndStoreEmailVerificationToken", "(", ")", "{", "$", "token", "=", "$", "this", "->", "generateToken", "(", "6", ")", ";", "$", "this", "->", "updateAttributes", "(", "[", "'email_verification_token'", "=>", "sha1", "(", "$", "token",...
Generate and save a email verification token and return the token. @return mixed @since 1.2.0
[ "Generate", "and", "save", "a", "email", "verification", "token", "and", "return", "the", "token", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/User.php#L446-L456
train
luyadev/luya-module-admin
src/models/StorageFile.php
StorageFile.delete
public function delete() { if ($this->beforeDelete()) { if (!Yii::$app->storage->fileSystemDeleteFile($this->name_new_compound)) { Logger::error("Unable to remove file from filesystem: " . $this->name_new_compound); } $this->updateAttributes(['is_deleted' => true]); $this->afterDelete(); return true; } }
php
public function delete() { if ($this->beforeDelete()) { if (!Yii::$app->storage->fileSystemDeleteFile($this->name_new_compound)) { Logger::error("Unable to remove file from filesystem: " . $this->name_new_compound); } $this->updateAttributes(['is_deleted' => true]); $this->afterDelete(); return true; } }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "$", "this", "->", "beforeDelete", "(", ")", ")", "{", "if", "(", "!", "Yii", "::", "$", "app", "->", "storage", "->", "fileSystemDeleteFile", "(", "$", "this", "->", "name_new_compound", ")", ...
Delete a given file. Override default implementation. Mark as deleted and remove files from file system. Keep file in order to provide all file references. @return boolean
[ "Delete", "a", "given", "file", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFile.php#L114-L126
train
luyadev/luya-module-admin
src/models/StorageFile.php
StorageFile.getCreateThumbnail
public function getCreateThumbnail() { if (!$this->isImage) { return false; } $tinyCrop = Yii::$app->storage->getFilterId(TinyCrop::identifier()); foreach ($this->images as $image) { if ($image->filter_id == $tinyCrop) { return ['source' => $image->source]; } } // create the thumbnail on the fly if not existing $image = Yii::$app->storage->createImage($this->id, $tinyCrop); if ($image) { return ['source' => $image->source]; } }
php
public function getCreateThumbnail() { if (!$this->isImage) { return false; } $tinyCrop = Yii::$app->storage->getFilterId(TinyCrop::identifier()); foreach ($this->images as $image) { if ($image->filter_id == $tinyCrop) { return ['source' => $image->source]; } } // create the thumbnail on the fly if not existing $image = Yii::$app->storage->createImage($this->id, $tinyCrop); if ($image) { return ['source' => $image->source]; } }
[ "public", "function", "getCreateThumbnail", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isImage", ")", "{", "return", "false", ";", "}", "$", "tinyCrop", "=", "Yii", "::", "$", "app", "->", "storage", "->", "getFilterId", "(", "TinyCrop", "::", ...
Create the thumbnail for this given file if its an image. > This method is used internal when uploading a file which is an image, the file manager preview images are created here. @return array Returns an array with the key source which contains the source to the thumbnail. @since 1.2.2.1
[ "Create", "the", "thumbnail", "for", "this", "given", "file", "if", "its", "an", "image", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFile.php#L241-L259
train
luyadev/luya-module-admin
src/models/StorageFile.php
StorageFile.getCreateThumbnailMedium
public function getCreateThumbnailMedium() { if (!$this->isImage) { return false; } $mediumThumbnail = Yii::$app->storage->getFilterId(MediumThumbnail::identifier()); foreach ($this->images as $image) { if ($image->filter_id == $mediumThumbnail) { return ['source' => $image->source]; } } // create the thumbnail on the fly if not existing $image = Yii::$app->storage->createImage($this->id, $mediumThumbnail); if ($image) { return ['source' => $image->source]; } }
php
public function getCreateThumbnailMedium() { if (!$this->isImage) { return false; } $mediumThumbnail = Yii::$app->storage->getFilterId(MediumThumbnail::identifier()); foreach ($this->images as $image) { if ($image->filter_id == $mediumThumbnail) { return ['source' => $image->source]; } } // create the thumbnail on the fly if not existing $image = Yii::$app->storage->createImage($this->id, $mediumThumbnail); if ($image) { return ['source' => $image->source]; } }
[ "public", "function", "getCreateThumbnailMedium", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isImage", ")", "{", "return", "false", ";", "}", "$", "mediumThumbnail", "=", "Yii", "::", "$", "app", "->", "storage", "->", "getFilterId", "(", "Medium...
Create the thumbnail medium for this given file if its an image. > This method is used internal when uploading a file which is an image, the file manager preview images are created here. @return array Returns an array with the key source which contains the source to the thumbnail medium. @since 1.2.2.1
[ "Create", "the", "thumbnail", "medium", "for", "this", "given", "file", "if", "its", "an", "image", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFile.php#L269-L287
train
luyadev/luya-module-admin
src/base/Filter.php
Filter.findModel
public function findModel() { // find filter model based on the identifier $model = StorageFilter::find()->where(['identifier' => static::identifier()])->one(); // if no model exists, create new record if (!$model) { $model = new StorageFilter(); $model->setAttributes([ 'name' => $this->name(), 'identifier' => static::identifier(), ]); $model->insert(false); $this->addLog("Added new filter '".static::identifier()."' with id '{$model->id}'."); } return $model; }
php
public function findModel() { // find filter model based on the identifier $model = StorageFilter::find()->where(['identifier' => static::identifier()])->one(); // if no model exists, create new record if (!$model) { $model = new StorageFilter(); $model->setAttributes([ 'name' => $this->name(), 'identifier' => static::identifier(), ]); $model->insert(false); $this->addLog("Added new filter '".static::identifier()."' with id '{$model->id}'."); } return $model; }
[ "public", "function", "findModel", "(", ")", "{", "// find filter model based on the identifier", "$", "model", "=", "StorageFilter", "::", "find", "(", ")", "->", "where", "(", "[", "'identifier'", "=>", "static", "::", "identifier", "(", ")", "]", ")", "->",...
Find the model based on the identifier. If the identifier does not exists in the database, create new record in the database. @return object \luya\admin\models\StorageFilter
[ "Find", "the", "model", "based", "on", "the", "identifier", ".", "If", "the", "identifier", "does", "not", "exists", "in", "the", "database", "create", "new", "record", "in", "the", "database", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Filter.php#L85-L101
train
luyadev/luya-module-admin
src/base/Filter.php
Filter.findEffect
public function findEffect($effectIdentifier) { // find effect model based on the effectIdentifier $model = StorageEffect::find()->where(['identifier' => $effectIdentifier])->asArray()->one(); // if the effect model could not found, throw Exception. if (!$model) { throw new Exception("The requested effect '$effectIdentifier' does not exist."); } // array return $model; }
php
public function findEffect($effectIdentifier) { // find effect model based on the effectIdentifier $model = StorageEffect::find()->where(['identifier' => $effectIdentifier])->asArray()->one(); // if the effect model could not found, throw Exception. if (!$model) { throw new Exception("The requested effect '$effectIdentifier' does not exist."); } // array return $model; }
[ "public", "function", "findEffect", "(", "$", "effectIdentifier", ")", "{", "// find effect model based on the effectIdentifier", "$", "model", "=", "StorageEffect", "::", "find", "(", ")", "->", "where", "(", "[", "'identifier'", "=>", "$", "effectIdentifier", "]",...
Find the effect model based on the effect identifier. If the effect could not found an exception will be thrown. @param string $effectIdentifier The name of effect, used EFFECT prefixed constants like + EFFECT_RESIZE + EFFECT_THUMBNAIL + EFFECT_CROP @return array Contain an array with the effect properties. @throws \luya\Exception
[ "Find", "the", "effect", "model", "based", "on", "the", "effect", "identifier", ".", "If", "the", "effect", "could", "not", "found", "an", "exception", "will", "be", "thrown", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Filter.php#L114-L124
train
luyadev/luya-module-admin
src/base/Filter.php
Filter.getEffectParamsList
public function getEffectParamsList($effectParams) { if ($this->_effectParamsList === null) { // see if the the effect defintion contains a vars key if (!array_key_exists('vars', $effectParams)) { throw new Exception("Required 'vars' key not found in effect definition array."); } foreach ($effectParams['vars'] as $item) { $this->_effectParamsList[] = $item['var']; } } return $this->_effectParamsList; }
php
public function getEffectParamsList($effectParams) { if ($this->_effectParamsList === null) { // see if the the effect defintion contains a vars key if (!array_key_exists('vars', $effectParams)) { throw new Exception("Required 'vars' key not found in effect definition array."); } foreach ($effectParams['vars'] as $item) { $this->_effectParamsList[] = $item['var']; } } return $this->_effectParamsList; }
[ "public", "function", "getEffectParamsList", "(", "$", "effectParams", ")", "{", "if", "(", "$", "this", "->", "_effectParamsList", "===", "null", ")", "{", "// see if the the effect defintion contains a vars key", "if", "(", "!", "array_key_exists", "(", "'vars'", ...
Get an array with all the effect param options, based on the effect params defintion. @param array $effectParams @throws \luya\Exception When the vars key does not exists in the effect definition. @return array
[ "Get", "an", "array", "with", "all", "the", "effect", "param", "options", "based", "on", "the", "effect", "params", "defintion", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Filter.php#L133-L147
train
luyadev/luya-module-admin
src/base/Filter.php
Filter.getChain
public function getChain() { $data = []; // get the chain from the effect, must be an array foreach ($this->chain() as $chainRow) { // set variables from chain array $effectIdentifier = $chainRow[0]; $effectParams = $chainRow[1]; // find the effect data for the effect identifier $effect = $this->findEffect($effectIdentifier); // get all params from the effect chain and verify if they are valid foreach ($effectParams as $effectParamVar => $effectParamValue) { if (!in_array($effectParamVar, $this->getEffectParamsList(Json::decode($effect['imagine_json_params'])))) { throw new Exception("Effect argument '$effectParamVar' does not exist in the effect definition of '{$effect['name']}'."); } } // create array with parsed effect id $data[] = ['effect_id' => $effect['id'], 'effect_json_values' => Json::encode($effectParams)]; } return $data; }
php
public function getChain() { $data = []; // get the chain from the effect, must be an array foreach ($this->chain() as $chainRow) { // set variables from chain array $effectIdentifier = $chainRow[0]; $effectParams = $chainRow[1]; // find the effect data for the effect identifier $effect = $this->findEffect($effectIdentifier); // get all params from the effect chain and verify if they are valid foreach ($effectParams as $effectParamVar => $effectParamValue) { if (!in_array($effectParamVar, $this->getEffectParamsList(Json::decode($effect['imagine_json_params'])))) { throw new Exception("Effect argument '$effectParamVar' does not exist in the effect definition of '{$effect['name']}'."); } } // create array with parsed effect id $data[] = ['effect_id' => $effect['id'], 'effect_json_values' => Json::encode($effectParams)]; } return $data; }
[ "public", "function", "getChain", "(", ")", "{", "$", "data", "=", "[", "]", ";", "// get the chain from the effect, must be an array", "foreach", "(", "$", "this", "->", "chain", "(", ")", "as", "$", "chainRow", ")", "{", "// set variables from chain array", "$...
Returns a parsed effect chain for the current Filter. The method verifys if the provieded effect parameters are available in the effect defintions of luya. @return array Each row of the array must have "effect_id" and "effect_json_values" key. @throws \luya\Exception When effect option could be found in the effect defintions.
[ "Returns", "a", "parsed", "effect", "chain", "for", "the", "current", "Filter", ".", "The", "method", "verifys", "if", "the", "provieded", "effect", "parameters", "are", "available", "in", "the", "effect", "defintions", "of", "luya", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Filter.php#L156-L177
train
crate/crate-pdo
src/Crate/PDO/PDO.php
PDO.setServer
public function setServer(ServerInterface $server): void { $this->server = $server; $this->server->configure($this); }
php
public function setServer(ServerInterface $server): void { $this->server = $server; $this->server->configure($this); }
[ "public", "function", "setServer", "(", "ServerInterface", "$", "server", ")", ":", "void", "{", "$", "this", "->", "server", "=", "$", "server", ";", "$", "this", "->", "server", "->", "configure", "(", "$", "this", ")", ";", "}" ]
Change the server implementation @param ServerInterface $server
[ "Change", "the", "server", "implementation" ]
1cd5f77062de1ede18aabd50108324fa94db068f
https://github.com/crate/crate-pdo/blob/1cd5f77062de1ede18aabd50108324fa94db068f/src/Crate/PDO/PDO.php#L150-L154
train
crate/crate-pdo
src/Crate/PDO/PDO.php
PDO.parseDSN
private static function parseDSN($dsn) { $matches = []; if (!preg_match(static::DSN_REGEX, $dsn, $matches)) { throw new PDOException(sprintf('Invalid DSN %s', $dsn)); } return array_slice($matches, 1); }
php
private static function parseDSN($dsn) { $matches = []; if (!preg_match(static::DSN_REGEX, $dsn, $matches)) { throw new PDOException(sprintf('Invalid DSN %s', $dsn)); } return array_slice($matches, 1); }
[ "private", "static", "function", "parseDSN", "(", "$", "dsn", ")", "{", "$", "matches", "=", "[", "]", ";", "if", "(", "!", "preg_match", "(", "static", "::", "DSN_REGEX", ",", "$", "dsn", ",", "$", "matches", ")", ")", "{", "throw", "new", "PDOExc...
Extract servers and optional custom schema from DSN string @param string $dsn The DSN string @throws \Crate\PDO\Exception\PDOException on an invalid DSN string @return array An array of ['host:post,host:port,...', 'schema']
[ "Extract", "servers", "and", "optional", "custom", "schema", "from", "DSN", "string" ]
1cd5f77062de1ede18aabd50108324fa94db068f
https://github.com/crate/crate-pdo/blob/1cd5f77062de1ede18aabd50108324fa94db068f/src/Crate/PDO/PDO.php#L165-L174
train
crate/crate-pdo
src/Crate/Stdlib/ArrayUtils.php
ArrayUtils.toArray
public static function toArray($value) { if (is_array($value)) { return $value; } if ($value === null) { return []; } if (!$value instanceof Traversable) { throw new Exception\InvalidArgumentException( 'An invalid value was provided, should either be an null, array or Traversable' ); } return iterator_to_array($value); }
php
public static function toArray($value) { if (is_array($value)) { return $value; } if ($value === null) { return []; } if (!$value instanceof Traversable) { throw new Exception\InvalidArgumentException( 'An invalid value was provided, should either be an null, array or Traversable' ); } return iterator_to_array($value); }
[ "public", "static", "function", "toArray", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "$", "value", "===", "null", ")", "{", "return", "[", "]", ";", "}", "...
Convert a optional value that when used is expected to be an array @param mixed $value @throws Exception\InvalidArgumentException @return array
[ "Convert", "a", "optional", "value", "that", "when", "used", "is", "expected", "to", "be", "an", "array" ]
1cd5f77062de1ede18aabd50108324fa94db068f
https://github.com/crate/crate-pdo/blob/1cd5f77062de1ede18aabd50108324fa94db068f/src/Crate/Stdlib/ArrayUtils.php#L40-L57
train
crate/crate-pdo
src/Crate/PDO/Http/ServerPool.php
ServerPool.configure
public function configure(PDOInterface $pdo): void { $sslMode = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_MODE); $protocol = $sslMode === PDO::CRATE_ATTR_SSL_MODE_DISABLED ? 'http' : 'https'; $options = [ RequestOptions::TIMEOUT => $pdo->getAttribute(PDO::ATTR_TIMEOUT), RequestOptions::CONNECT_TIMEOUT => $pdo->getAttribute(PDO::ATTR_TIMEOUT), RequestOptions::AUTH => $pdo->getAttribute(PDO::CRATE_ATTR_HTTP_BASIC_AUTH) ?: null, RequestOptions::HEADERS => [ 'Default-Schema' => $pdo->getAttribute(PDO::CRATE_ATTR_DEFAULT_SCHEMA), ], ]; if ($sslMode === PDO::CRATE_ATTR_SSL_MODE_ENABLED_BUT_WITHOUT_HOST_VERIFICATION) { $options['verify'] = false; } $ca = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_CA_PATH); $caPassword = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_CA_PASSWORD); if ($ca) { if ($caPassword) { $options[RequestOptions::VERIFY] = [$ca, $caPassword]; } else { $options[RequestOptions::VERIFY] = $ca; } } $cert = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_CERT_PATH); $certPassword = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_CERT_PASSWORD); if ($cert) { if ($certPassword) { $options[RequestOptions::CERT] = [$cert, $certPassword]; } else { $options[RequestOptions::CERT] = $cert; } } $key = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_KEY_PATH); $keyPassword = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_KEY_PASSWORD); if ($key) { if ($keyPassword) { $options[RequestOptions::SSL_KEY] = [$key, $keyPassword]; } else { $options[RequestOptions::SSL_KEY] = $key; } } $this->protocol = $protocol; $this->httpOptions = $options; }
php
public function configure(PDOInterface $pdo): void { $sslMode = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_MODE); $protocol = $sslMode === PDO::CRATE_ATTR_SSL_MODE_DISABLED ? 'http' : 'https'; $options = [ RequestOptions::TIMEOUT => $pdo->getAttribute(PDO::ATTR_TIMEOUT), RequestOptions::CONNECT_TIMEOUT => $pdo->getAttribute(PDO::ATTR_TIMEOUT), RequestOptions::AUTH => $pdo->getAttribute(PDO::CRATE_ATTR_HTTP_BASIC_AUTH) ?: null, RequestOptions::HEADERS => [ 'Default-Schema' => $pdo->getAttribute(PDO::CRATE_ATTR_DEFAULT_SCHEMA), ], ]; if ($sslMode === PDO::CRATE_ATTR_SSL_MODE_ENABLED_BUT_WITHOUT_HOST_VERIFICATION) { $options['verify'] = false; } $ca = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_CA_PATH); $caPassword = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_CA_PASSWORD); if ($ca) { if ($caPassword) { $options[RequestOptions::VERIFY] = [$ca, $caPassword]; } else { $options[RequestOptions::VERIFY] = $ca; } } $cert = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_CERT_PATH); $certPassword = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_CERT_PASSWORD); if ($cert) { if ($certPassword) { $options[RequestOptions::CERT] = [$cert, $certPassword]; } else { $options[RequestOptions::CERT] = $cert; } } $key = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_KEY_PATH); $keyPassword = $pdo->getAttribute(PDO::CRATE_ATTR_SSL_KEY_PASSWORD); if ($key) { if ($keyPassword) { $options[RequestOptions::SSL_KEY] = [$key, $keyPassword]; } else { $options[RequestOptions::SSL_KEY] = $key; } } $this->protocol = $protocol; $this->httpOptions = $options; }
[ "public", "function", "configure", "(", "PDOInterface", "$", "pdo", ")", ":", "void", "{", "$", "sslMode", "=", "$", "pdo", "->", "getAttribute", "(", "PDO", "::", "CRATE_ATTR_SSL_MODE", ")", ";", "$", "protocol", "=", "$", "sslMode", "===", "PDO", "::",...
Reconfigure the the server pool based on the attributes in PDO @param PDOInterface $pdo
[ "Reconfigure", "the", "the", "server", "pool", "based", "on", "the", "attributes", "in", "PDO" ]
1cd5f77062de1ede18aabd50108324fa94db068f
https://github.com/crate/crate-pdo/blob/1cd5f77062de1ede18aabd50108324fa94db068f/src/Crate/PDO/Http/ServerPool.php#L176-L230
train
crate/crate-pdo
src/Crate/PDO/PDOStatement.php
PDOStatement.updateBoundColumns
private function updateBoundColumns(array $row) { foreach ($this->columnBinding as $column => &$metadata) { $index = $this->collection->getColumnIndex($column); if ($index === null) { // todo: I would like to throw an exception and tell someone they screwed up // but i think that would violate the PDO api continue; } // Update by reference $value = $this->typedValue($row[$index], $metadata['type']); $metadata['ref'] = $value; } }
php
private function updateBoundColumns(array $row) { foreach ($this->columnBinding as $column => &$metadata) { $index = $this->collection->getColumnIndex($column); if ($index === null) { // todo: I would like to throw an exception and tell someone they screwed up // but i think that would violate the PDO api continue; } // Update by reference $value = $this->typedValue($row[$index], $metadata['type']); $metadata['ref'] = $value; } }
[ "private", "function", "updateBoundColumns", "(", "array", "$", "row", ")", "{", "foreach", "(", "$", "this", "->", "columnBinding", "as", "$", "column", "=>", "&", "$", "metadata", ")", "{", "$", "index", "=", "$", "this", "->", "collection", "->", "g...
Update all the bound column references @internal @param array $row @return void
[ "Update", "all", "the", "bound", "column", "references" ]
1cd5f77062de1ede18aabd50108324fa94db068f
https://github.com/crate/crate-pdo/blob/1cd5f77062de1ede18aabd50108324fa94db068f/src/Crate/PDO/PDOStatement.php#L178-L192
train
crate/crate-pdo
src/Crate/PDO/PDOStatement.php
PDOStatement.getObjectResult
private function getObjectResult(array $columns, array $row) { $obj = new \stdClass(); foreach ($columns as $key => $column) { $obj->{$column} = $row[$key]; } return $obj; }
php
private function getObjectResult(array $columns, array $row) { $obj = new \stdClass(); foreach ($columns as $key => $column) { $obj->{$column} = $row[$key]; } return $obj; }
[ "private", "function", "getObjectResult", "(", "array", "$", "columns", ",", "array", "$", "row", ")", "{", "$", "obj", "=", "new", "\\", "stdClass", "(", ")", ";", "foreach", "(", "$", "columns", "as", "$", "key", "=>", "$", "column", ")", "{", "$...
Generate object from array @param array $columns @param array $row
[ "Generate", "object", "from", "array" ]
1cd5f77062de1ede18aabd50108324fa94db068f
https://github.com/crate/crate-pdo/blob/1cd5f77062de1ede18aabd50108324fa94db068f/src/Crate/PDO/PDOStatement.php#L661-L669
train
wp-cli/search-replace-command
src/Search_Replace_Command.php
Search_Replace_Command.esc_sql_value
private static function esc_sql_value( $values ) { $quote = function ( $v ) { // Don't quote integer values to avoid MySQL's implicit type conversion. if ( preg_match( '/^[+-]?[0-9]{1,20}$/', $v ) ) { // MySQL BIGINT UNSIGNED max 18446744073709551615 (20 digits). return esc_sql( $v ); } // Put any string values between single quotes. return "'" . esc_sql( $v ) . "'"; }; if ( is_array( $values ) ) { return array_map( $quote, $values ); } return $quote( $values ); }
php
private static function esc_sql_value( $values ) { $quote = function ( $v ) { // Don't quote integer values to avoid MySQL's implicit type conversion. if ( preg_match( '/^[+-]?[0-9]{1,20}$/', $v ) ) { // MySQL BIGINT UNSIGNED max 18446744073709551615 (20 digits). return esc_sql( $v ); } // Put any string values between single quotes. return "'" . esc_sql( $v ) . "'"; }; if ( is_array( $values ) ) { return array_map( $quote, $values ); } return $quote( $values ); }
[ "private", "static", "function", "esc_sql_value", "(", "$", "values", ")", "{", "$", "quote", "=", "function", "(", "$", "v", ")", "{", "// Don't quote integer values to avoid MySQL's implicit type conversion.", "if", "(", "preg_match", "(", "'/^[+-]?[0-9]{1,20}$/'", ...
Puts MySQL string values in single quotes, to avoid them being interpreted as column names. @param string|array $values A single value or an array of values. @return string|array A quoted string if given a string, or an array of quoted strings if given an array of strings.
[ "Puts", "MySQL", "string", "values", "in", "single", "quotes", "to", "avoid", "them", "being", "interpreted", "as", "column", "names", "." ]
7d02c54facf039577ff13c7b7bb100e4757d85fd
https://github.com/wp-cli/search-replace-command/blob/7d02c54facf039577ff13c7b7bb100e4757d85fd/src/Search_Replace_Command.php#L728-L744
train
wp-cli/search-replace-command
src/WP_CLI/SearchReplacer.php
SearchReplacer.preg_error_message
private function preg_error_message( $error ) { static $error_names = null; if ( null === $error_names ) { $definitions = get_defined_constants( true ); $pcre_constants = array_key_exists( 'pcre', $definitions ) ? $definitions['pcre'] : array(); $error_names = array_flip( $pcre_constants ); } return isset( $error_names[ $error ] ) ? $error_names[ $error ] : '<unknown error>'; }
php
private function preg_error_message( $error ) { static $error_names = null; if ( null === $error_names ) { $definitions = get_defined_constants( true ); $pcre_constants = array_key_exists( 'pcre', $definitions ) ? $definitions['pcre'] : array(); $error_names = array_flip( $pcre_constants ); } return isset( $error_names[ $error ] ) ? $error_names[ $error ] : '<unknown error>'; }
[ "private", "function", "preg_error_message", "(", "$", "error", ")", "{", "static", "$", "error_names", "=", "null", ";", "if", "(", "null", "===", "$", "error_names", ")", "{", "$", "definitions", "=", "get_defined_constants", "(", "true", ")", ";", "$", ...
Get the PCRE error constant name from an error value. @param integer $error Error code. @return string Error constant name.
[ "Get", "the", "PCRE", "error", "constant", "name", "from", "an", "error", "value", "." ]
7d02c54facf039577ff13c7b7bb100e4757d85fd
https://github.com/wp-cli/search-replace-command/blob/7d02c54facf039577ff13c7b7bb100e4757d85fd/src/WP_CLI/SearchReplacer.php#L167-L181
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.eventExpired
protected function eventExpired($event) { $cachedDiff = $this->getCachedEvent($event)->diffInSeconds(Carbon::now()); return $cachedDiff < $this->config('root.cache.event_timeout', 10); }
php
protected function eventExpired($event) { $cachedDiff = $this->getCachedEvent($event)->diffInSeconds(Carbon::now()); return $cachedDiff < $this->config('root.cache.event_timeout', 10); }
[ "protected", "function", "eventExpired", "(", "$", "event", ")", "{", "$", "cachedDiff", "=", "$", "this", "->", "getCachedEvent", "(", "$", "event", ")", "->", "diffInSeconds", "(", "Carbon", "::", "now", "(", ")", ")", ";", "return", "$", "cachedDiff",...
Check if the event has expired. @param $event @return bool
[ "Check", "if", "the", "event", "has", "expired", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L70-L75
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.getCachedEvent
protected function getCachedEvent($event) { $path = $event->getResource()->getPath(); return isset($this->eventCache[$path]) ? $this->eventCache[$path] : $this->eventCache[$path] = Carbon::now()->subDay(); }
php
protected function getCachedEvent($event) { $path = $event->getResource()->getPath(); return isset($this->eventCache[$path]) ? $this->eventCache[$path] : $this->eventCache[$path] = Carbon::now()->subDay(); }
[ "protected", "function", "getCachedEvent", "(", "$", "event", ")", "{", "$", "path", "=", "$", "event", "->", "getResource", "(", ")", "->", "getPath", "(", ")", ";", "return", "isset", "(", "$", "this", "->", "eventCache", "[", "$", "path", "]", ")"...
Get an event from cache. @param $event @return mixed|static
[ "Get", "an", "event", "from", "cache", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L84-L91
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.eventWasProcessed
protected function eventWasProcessed($event) { if ($this->eventExpired($event)) { return true; } $this->resetEventCache($event); return false; }
php
protected function eventWasProcessed($event) { if ($this->eventExpired($event)) { return true; } $this->resetEventCache($event); return false; }
[ "protected", "function", "eventWasProcessed", "(", "$", "event", ")", "{", "if", "(", "$", "this", "->", "eventExpired", "(", "$", "event", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "resetEventCache", "(", "$", "event", ")", ";", ...
Check if the event was processed recently. @param \JasonLewis\ResourceWatcher\Event $event @return bool
[ "Check", "if", "the", "event", "was", "processed", "recently", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L100-L109
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.firedOnlyOne
protected function firedOnlyOne($event, $path) { if ($test = $this->dataRepository->isTestFile($path)) { if ($test->sha1Changed() && !$this->dataRepository->isEnqueued($test)) { $this->dataRepository->addTestToQueue($test); $this->showProgress('QUEUE: test added to queue'); } return true; } return false; }
php
protected function firedOnlyOne($event, $path) { if ($test = $this->dataRepository->isTestFile($path)) { if ($test->sha1Changed() && !$this->dataRepository->isEnqueued($test)) { $this->dataRepository->addTestToQueue($test); $this->showProgress('QUEUE: test added to queue'); } return true; } return false; }
[ "protected", "function", "firedOnlyOne", "(", "$", "event", ",", "$", "path", ")", "{", "if", "(", "$", "test", "=", "$", "this", "->", "dataRepository", "->", "isTestFile", "(", "$", "path", ")", ")", "{", "if", "(", "$", "test", "->", "sha1Changed"...
Check if has changed and add test to queue. @param $event @param $path @return bool
[ "Check", "if", "has", "changed", "and", "add", "test", "to", "queue", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L119-L132
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.isConfig
protected function isConfig($path) { if ($this->config()->isConfigFile($path)) { $this->config()->invalidateConfig(); $this->loader->loadEverything(); return true; } return false; }
php
protected function isConfig($path) { if ($this->config()->isConfigFile($path)) { $this->config()->invalidateConfig(); $this->loader->loadEverything(); return true; } return false; }
[ "protected", "function", "isConfig", "(", "$", "path", ")", "{", "if", "(", "$", "this", "->", "config", "(", ")", "->", "isConfigFile", "(", "$", "path", ")", ")", "{", "$", "this", "->", "config", "(", ")", "->", "invalidateConfig", "(", ")", ";"...
Check if the changed file is the config file and reload. @param $path @return bool
[ "Check", "if", "the", "changed", "file", "is", "the", "config", "file", "and", "reload", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L141-L152
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.run
public function run(Command $command, $showTests = false) { $this->setCommand($command); $this->initialize($showTests); $this->watch(); return true; }
php
public function run(Command $command, $showTests = false) { $this->setCommand($command); $this->initialize($showTests); $this->watch(); return true; }
[ "public", "function", "run", "(", "Command", "$", "command", ",", "$", "showTests", "=", "false", ")", "{", "$", "this", "->", "setCommand", "(", "$", "command", ")", ";", "$", "this", "->", "initialize", "(", "$", "showTests", ")", ";", "$", "this",...
Watch for file changes. @param Command $command @param bool $showTests @return bool
[ "Watch", "for", "file", "changes", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L172-L181
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.initialize
protected function initialize($showTests) { $this->showComment($this->config('root.names.watcher'), 'info'); if (!$this->is_initialized) { $this->loader->loadEverything($showTests); $this->is_initialized = true; } }
php
protected function initialize($showTests) { $this->showComment($this->config('root.names.watcher'), 'info'); if (!$this->is_initialized) { $this->loader->loadEverything($showTests); $this->is_initialized = true; } }
[ "protected", "function", "initialize", "(", "$", "showTests", ")", "{", "$", "this", "->", "showComment", "(", "$", "this", "->", "config", "(", "'root.names.watcher'", ")", ",", "'info'", ")", ";", "if", "(", "!", "$", "this", "->", "is_initialized", ")...
Initialize the Watcher.
[ "Initialize", "the", "Watcher", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L186-L195
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.showEventMessage
protected function showEventMessage($event, $path) { $type = $this->config()->isConfigFile($path) ? 'CONFIGURATION' : 'FILE'; $change = strtoupper($this->getEventName($event->getCode())); $this->showProgress("{$type} {$change}: {$path}", 'error'); }
php
protected function showEventMessage($event, $path) { $type = $this->config()->isConfigFile($path) ? 'CONFIGURATION' : 'FILE'; $change = strtoupper($this->getEventName($event->getCode())); $this->showProgress("{$type} {$change}: {$path}", 'error'); }
[ "protected", "function", "showEventMessage", "(", "$", "event", ",", "$", "path", ")", "{", "$", "type", "=", "$", "this", "->", "config", "(", ")", "->", "isConfigFile", "(", "$", "path", ")", "?", "'CONFIGURATION'", ":", "'FILE'", ";", "$", "change",...
Display a message about the event on terminal. @param $event @param $path
[ "Display", "a", "message", "about", "the", "event", "on", "terminal", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L203-L212
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.watch
protected function watch() { $this->showProgress('BOOT: booting watchers...'); if (is_null($this->loader->watchFolders)) { $this->showProgress('No watch folders found.', 'error'); return; } foreach ($this->loader->watchFolders as $folder) { if (!file_exists($folder)) { $this->showProgress("ERROR: folder {$folder} does not exists", 'error'); continue; } $this->showProgress('WATCHING '.$folder); $this->listeners[$folder] = $this->watcher->watch($folder); $this->listeners[$folder]->anything(function ($event, $resource, $path) { if (!$this->isExcluded($path)) { $this->fireEvent($event, $resource, $path); } }); } $this->watchConfigFile(); $this->watcher->start(); }
php
protected function watch() { $this->showProgress('BOOT: booting watchers...'); if (is_null($this->loader->watchFolders)) { $this->showProgress('No watch folders found.', 'error'); return; } foreach ($this->loader->watchFolders as $folder) { if (!file_exists($folder)) { $this->showProgress("ERROR: folder {$folder} does not exists", 'error'); continue; } $this->showProgress('WATCHING '.$folder); $this->listeners[$folder] = $this->watcher->watch($folder); $this->listeners[$folder]->anything(function ($event, $resource, $path) { if (!$this->isExcluded($path)) { $this->fireEvent($event, $resource, $path); } }); } $this->watchConfigFile(); $this->watcher->start(); }
[ "protected", "function", "watch", "(", ")", "{", "$", "this", "->", "showProgress", "(", "'BOOT: booting watchers...'", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "loader", "->", "watchFolders", ")", ")", "{", "$", "this", "->", "showProgress"...
Watch folders for changes.
[ "Watch", "folders", "for", "changes", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L217-L248
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.fireEvent
public function fireEvent($event, $resource, $path) { if ($this->eventWasProcessed($event, $resource, $path)) { return; } $this->showEventMessage($event, $path); if ($this->isConfig($path)) { return; } if ($this->firedOnlyOne($event, $path)) { return; } $this->loader->loadEverything(); if ($this->queueTestSuites($path)) { return; } $this->dataRepository->queueAllTests(); }
php
public function fireEvent($event, $resource, $path) { if ($this->eventWasProcessed($event, $resource, $path)) { return; } $this->showEventMessage($event, $path); if ($this->isConfig($path)) { return; } if ($this->firedOnlyOne($event, $path)) { return; } $this->loader->loadEverything(); if ($this->queueTestSuites($path)) { return; } $this->dataRepository->queueAllTests(); }
[ "public", "function", "fireEvent", "(", "$", "event", ",", "$", "resource", ",", "$", "path", ")", "{", "if", "(", "$", "this", "->", "eventWasProcessed", "(", "$", "event", ",", "$", "resource", ",", "$", "path", ")", ")", "{", "return", ";", "}",...
Fire file modified event. @param $event @param $resource @param $path
[ "Fire", "file", "modified", "event", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L257-L280
train
antonioribeiro/tddd
src/package/Services/Watcher.php
Watcher.watchConfigFile
protected function watchConfigFile() { $this->showProgress('WATCHING CONFIG FILES'); $this->config()->getConfigFiles()->each(function ($file) { $this->watcher->watch($file); }); }
php
protected function watchConfigFile() { $this->showProgress('WATCHING CONFIG FILES'); $this->config()->getConfigFiles()->each(function ($file) { $this->watcher->watch($file); }); }
[ "protected", "function", "watchConfigFile", "(", ")", "{", "$", "this", "->", "showProgress", "(", "'WATCHING CONFIG FILES'", ")", ";", "$", "this", "->", "config", "(", ")", "->", "getConfigFiles", "(", ")", "->", "each", "(", "function", "(", "$", "file"...
Watch the config file for changes.
[ "Watch", "the", "config", "file", "for", "changes", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Watcher.php#L321-L328
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.createLinkToEditFile
protected function createLinkToEditFile($test, $fileName, $line, $occurrence) { if (!$this->fileExistsOnTest($fileName, $test)) { return $line[$occurrence]; } $fileName = base64_encode($fileName); $tag = sprintf( '<a href="javascript:jQuery.get(\'%s\');" class="file">%s</a>', route( 'tests-watcher.file.edit', [ 'filename' => $fileName, 'suite_id' => $test->suite->id, 'line' => $line[2], ] ), $line[$occurrence] ); return $tag; }
php
protected function createLinkToEditFile($test, $fileName, $line, $occurrence) { if (!$this->fileExistsOnTest($fileName, $test)) { return $line[$occurrence]; } $fileName = base64_encode($fileName); $tag = sprintf( '<a href="javascript:jQuery.get(\'%s\');" class="file">%s</a>', route( 'tests-watcher.file.edit', [ 'filename' => $fileName, 'suite_id' => $test->suite->id, 'line' => $line[2], ] ), $line[$occurrence] ); return $tag; }
[ "protected", "function", "createLinkToEditFile", "(", "$", "test", ",", "$", "fileName", ",", "$", "line", ",", "$", "occurrence", ")", "{", "if", "(", "!", "$", "this", "->", "fileExistsOnTest", "(", "$", "fileName", ",", "$", "test", ")", ")", "{", ...
Create link to call the editor for a file. @param $test @param $fileName @param $line @param $occurrence @return string
[ "Create", "link", "to", "call", "the", "editor", "for", "a", "file", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L45-L67
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.createLinks
protected function createLinks($lines, $matches, $test) { foreach ($matches as $line) { if (!empty($line) && is_array($line) && count($line) > 0 && is_array($line[0]) && count($line[0]) > 0) { $occurence = strpos($lines, $line[0]) === false ? 1 : 0; $lines = str_replace( $line[$occurence], $this->createLinkToEditFile($test, $line[1], $line, $occurence), $lines ); } } return $lines; }
php
protected function createLinks($lines, $matches, $test) { foreach ($matches as $line) { if (!empty($line) && is_array($line) && count($line) > 0 && is_array($line[0]) && count($line[0]) > 0) { $occurence = strpos($lines, $line[0]) === false ? 1 : 0; $lines = str_replace( $line[$occurence], $this->createLinkToEditFile($test, $line[1], $line, $occurence), $lines ); } } return $lines; }
[ "protected", "function", "createLinks", "(", "$", "lines", ",", "$", "matches", ",", "$", "test", ")", "{", "foreach", "(", "$", "matches", "as", "$", "line", ")", "{", "if", "(", "!", "empty", "(", "$", "line", ")", "&&", "is_array", "(", "$", "...
Create links. @param $lines @param $matches @return mixed
[ "Create", "links", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L77-L92
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.findSourceCodeReferences
protected function findSourceCodeReferences($lines, $test) { preg_match_all( config('tddd.root.regex_file_matcher'), strip_tags($this->brToCR($lines)), $matches, PREG_SET_ORDER ); return array_filter($matches); }
php
protected function findSourceCodeReferences($lines, $test) { preg_match_all( config('tddd.root.regex_file_matcher'), strip_tags($this->brToCR($lines)), $matches, PREG_SET_ORDER ); return array_filter($matches); }
[ "protected", "function", "findSourceCodeReferences", "(", "$", "lines", ",", "$", "test", ")", "{", "preg_match_all", "(", "config", "(", "'tddd.root.regex_file_matcher'", ")", ",", "strip_tags", "(", "$", "this", "->", "brToCR", "(", "$", "lines", ")", ")", ...
Find source code references. Must find at Object..test (resources/assets/js/tests/example.spec.js:4:23 (resources/assets/js/tests/example.spec.js:4 /resources/assets/js/tests/example.php:449 @param $lines @param $test @return mixed
[ "Find", "source", "code", "references", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L110-L120
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.getEditor
protected function getEditor($suite) { if (empty($suite) || is_null($editor = config("tddd.editors.{$suite->editor}"))) { return $this->getDefaultEditor(); } return $editor; }
php
protected function getEditor($suite) { if (empty($suite) || is_null($editor = config("tddd.editors.{$suite->editor}"))) { return $this->getDefaultEditor(); } return $editor; }
[ "protected", "function", "getEditor", "(", "$", "suite", ")", "{", "if", "(", "empty", "(", "$", "suite", ")", "||", "is_null", "(", "$", "editor", "=", "config", "(", "\"tddd.editors.{$suite->editor}\"", ")", ")", ")", "{", "return", "$", "this", "->", ...
Get the editor. @param $suite @return array
[ "Get", "the", "editor", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L163-L170
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.getJavascriptClientData
public function getJavascriptClientData() { $data = [ 'routes' => [ 'prefixes' => config('tddd.routes.prefixes'), ], 'project_id' => request()->get('project_id'), 'test_id' => request()->get('test_id'), 'root' => config('tddd.root'), ]; return json_encode($data); }
php
public function getJavascriptClientData() { $data = [ 'routes' => [ 'prefixes' => config('tddd.routes.prefixes'), ], 'project_id' => request()->get('project_id'), 'test_id' => request()->get('test_id'), 'root' => config('tddd.root'), ]; return json_encode($data); }
[ "public", "function", "getJavascriptClientData", "(", ")", "{", "$", "data", "=", "[", "'routes'", "=>", "[", "'prefixes'", "=>", "config", "(", "'tddd.routes.prefixes'", ")", ",", "]", ",", "'project_id'", "=>", "request", "(", ")", "->", "get", "(", "'pr...
Generates data for the javascript client.
[ "Generates", "data", "for", "the", "javascript", "client", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L175-L190
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.getScreenshots
protected function getScreenshots($test, $log) { $screenshots = $test->suite->tester->name !== 'dusk' ? $this->getOutput($test, $test->suite->tester->output_folder, $test->suite->tester->output_png_fail_extension) : $this->parseDuskScreenshots($log, $test->suite->tester->output_folder); if (is_null($screenshots)) { return; } $screenshots = collect($screenshots)->map(function ($path) use ($test) { return replace_suite_paths($test->suite, $path); }); return json_encode($screenshots->toArray()); }
php
protected function getScreenshots($test, $log) { $screenshots = $test->suite->tester->name !== 'dusk' ? $this->getOutput($test, $test->suite->tester->output_folder, $test->suite->tester->output_png_fail_extension) : $this->parseDuskScreenshots($log, $test->suite->tester->output_folder); if (is_null($screenshots)) { return; } $screenshots = collect($screenshots)->map(function ($path) use ($test) { return replace_suite_paths($test->suite, $path); }); return json_encode($screenshots->toArray()); }
[ "protected", "function", "getScreenshots", "(", "$", "test", ",", "$", "log", ")", "{", "$", "screenshots", "=", "$", "test", "->", "suite", "->", "tester", "->", "name", "!==", "'dusk'", "?", "$", "this", "->", "getOutput", "(", "$", "test", ",", "$...
Get a list of png files to store in database. @param $test @param $log @return null|string
[ "Get", "a", "list", "of", "png", "files", "to", "store", "in", "database", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L200-L215
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.linkFiles
protected function linkFiles($lines, $test) { $matches = $this->findSourceCodeReferences($lines, $test); if (count($matches) != 0) { $lines = $this->createLinks($lines, $matches, $test); } return $this->CRToBr($lines); }
php
protected function linkFiles($lines, $test) { $matches = $this->findSourceCodeReferences($lines, $test); if (count($matches) != 0) { $lines = $this->createLinks($lines, $matches, $test); } return $this->CRToBr($lines); }
[ "protected", "function", "linkFiles", "(", "$", "lines", ",", "$", "test", ")", "{", "$", "matches", "=", "$", "this", "->", "findSourceCodeReferences", "(", "$", "lines", ",", "$", "test", ")", ";", "if", "(", "count", "(", "$", "matches", ")", "!="...
Create links for files. @param $lines @return string
[ "Create", "links", "for", "files", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L253-L262
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.parseDuskScreenshots
protected function parseDuskScreenshots($log, $folder) { preg_match_all('/[0-9]\)+\s(.+::.*)/', $log, $matches, PREG_SET_ORDER); $result = []; foreach ($matches as $line) { $name = str_replace("\r", '', $line[1]); $name = str_replace('\\', '_', $name); $name = str_replace('::', '_', $name); $result[] = $folder.DIRECTORY_SEPARATOR."failure-{$name}-0.png"; } return count($result) == 0 ? null : $result; }
php
protected function parseDuskScreenshots($log, $folder) { preg_match_all('/[0-9]\)+\s(.+::.*)/', $log, $matches, PREG_SET_ORDER); $result = []; foreach ($matches as $line) { $name = str_replace("\r", '', $line[1]); $name = str_replace('\\', '_', $name); $name = str_replace('::', '_', $name); $result[] = $folder.DIRECTORY_SEPARATOR."failure-{$name}-0.png"; } return count($result) == 0 ? null : $result; }
[ "protected", "function", "parseDuskScreenshots", "(", "$", "log", ",", "$", "folder", ")", "{", "preg_match_all", "(", "'/[0-9]\\)+\\s(.+::.*)/'", ",", "$", "log", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "$", "result", "=", "[", "]", ";", "fo...
Generate a lista of screenshots. @param $log @param $folder @return array|null
[ "Generate", "a", "lista", "of", "screenshots", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L288-L303
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.isExcluded
public function isExcluded($exclusions, $path, $file = '') { if ($file) { if (!$file instanceof SplFileInfo) { $path = make_path([$path, $file]); } else { $path = $file->getPathname(); } } foreach ($exclusions ?: [] as $excluded) { if (starts_with($path, $excluded)) { return true; } } return false; }
php
public function isExcluded($exclusions, $path, $file = '') { if ($file) { if (!$file instanceof SplFileInfo) { $path = make_path([$path, $file]); } else { $path = $file->getPathname(); } } foreach ($exclusions ?: [] as $excluded) { if (starts_with($path, $excluded)) { return true; } } return false; }
[ "public", "function", "isExcluded", "(", "$", "exclusions", ",", "$", "path", ",", "$", "file", "=", "''", ")", "{", "if", "(", "$", "file", ")", "{", "if", "(", "!", "$", "file", "instanceof", "SplFileInfo", ")", "{", "$", "path", "=", "make_path"...
Check if a path is excluded. @param $exclusions @param $path @param string $file @return bool
[ "Check", "if", "a", "path", "is", "excluded", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L340-L357
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.formatLog
public function formatLog($log, $test) { return !empty($log) ? $this->linkFiles($this->ansi2Html($log), $test) : $log; }
php
public function formatLog($log, $test) { return !empty($log) ? $this->linkFiles($this->ansi2Html($log), $test) : $log; }
[ "public", "function", "formatLog", "(", "$", "log", ",", "$", "test", ")", "{", "return", "!", "empty", "(", "$", "log", ")", "?", "$", "this", "->", "linkFiles", "(", "$", "this", "->", "ansi2Html", "(", "$", "log", ")", ",", "$", "test", ")", ...
Format output log. @param $log @return mixed|string
[ "Format", "output", "log", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L366-L371
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.ansi2Html
protected function ansi2Html($log) { $string = html_entity_decode( $this->ansiConverter->convert($log) ); $string = str_replace("\r\n", '<br>', $string); $string = str_replace("\n", '<br>', $string); return $string; }
php
protected function ansi2Html($log) { $string = html_entity_decode( $this->ansiConverter->convert($log) ); $string = str_replace("\r\n", '<br>', $string); $string = str_replace("\n", '<br>', $string); return $string; }
[ "protected", "function", "ansi2Html", "(", "$", "log", ")", "{", "$", "string", "=", "html_entity_decode", "(", "$", "this", "->", "ansiConverter", "->", "convert", "(", "$", "log", ")", ")", ";", "$", "string", "=", "str_replace", "(", "\"\\r\\n\"", ","...
Convert output ansi chars to html. @param $log @return mixed|string
[ "Convert", "output", "ansi", "chars", "to", "html", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L380-L391
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.getOutput
protected function getOutput($test, $outputFolder, $extension) { if (empty($outputFolder)) { return; } $file = replace_suite_paths($test->suite, make_path([ make_path([$test->suite->project->path, $outputFolder]), str_replace(['.php', '::', '\\', '/'], ['', '.', '', ''], $test->name).$extension, ])); return file_exists($file) ? $this->renderHtml(file_get_contents($file)) : null; }
php
protected function getOutput($test, $outputFolder, $extension) { if (empty($outputFolder)) { return; } $file = replace_suite_paths($test->suite, make_path([ make_path([$test->suite->project->path, $outputFolder]), str_replace(['.php', '::', '\\', '/'], ['', '.', '', ''], $test->name).$extension, ])); return file_exists($file) ? $this->renderHtml(file_get_contents($file)) : null; }
[ "protected", "function", "getOutput", "(", "$", "test", ",", "$", "outputFolder", ",", "$", "extension", ")", "{", "if", "(", "empty", "(", "$", "outputFolder", ")", ")", "{", "return", ";", "}", "$", "file", "=", "replace_suite_paths", "(", "$", "test...
Get the test output. @param $test @param $outputFolder @param $extension @return null|string
[ "Get", "the", "test", "output", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L416-L428
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.encodeFile
protected function encodeFile($file) { $type = pathinfo($file, PATHINFO_EXTENSION); $data = file_get_contents($file); if ($type == 'html') { return $data; } return 'data:image/'.$type.';base64,'.base64_encode($data); }
php
protected function encodeFile($file) { $type = pathinfo($file, PATHINFO_EXTENSION); $data = file_get_contents($file); if ($type == 'html') { return $data; } return 'data:image/'.$type.';base64,'.base64_encode($data); }
[ "protected", "function", "encodeFile", "(", "$", "file", ")", "{", "$", "type", "=", "pathinfo", "(", "$", "file", ",", "PATHINFO_EXTENSION", ")", ";", "$", "data", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", "(", "$", "type", "==", "...
Encode a image or html for database storage. @param $file @return bool|mixed|string
[ "Encode", "a", "image", "or", "html", "for", "database", "storage", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L437-L448
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.makeEditFileCommand
public function makeEditFileCommand($file, $line, $suite_id) { $suite = $this->findSuiteById($suite_id); $file = $this->addProjectRootPath( base64_decode($file), $suite ); $command = trim(str_replace( ['{file}', '{line}'], [$file, $line], $this->getEditorBinary($suite) )); return ends_with($command, ':') ? substr($command, 0, -1) : $command; }
php
public function makeEditFileCommand($file, $line, $suite_id) { $suite = $this->findSuiteById($suite_id); $file = $this->addProjectRootPath( base64_decode($file), $suite ); $command = trim(str_replace( ['{file}', '{line}'], [$file, $line], $this->getEditorBinary($suite) )); return ends_with($command, ':') ? substr($command, 0, -1) : $command; }
[ "public", "function", "makeEditFileCommand", "(", "$", "file", ",", "$", "line", ",", "$", "suite_id", ")", "{", "$", "suite", "=", "$", "this", "->", "findSuiteById", "(", "$", "suite_id", ")", ";", "$", "file", "=", "$", "this", "->", "addProjectRoot...
Make open file command. @param $file @param $line @param int $suite_id @return string
[ "Make", "open", "file", "command", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L459-L477
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.addProjectRootPath
public function addProjectRootPath($fileName, $suite) { if (starts_with($fileName, DIRECTORY_SEPARATOR) || empty($suite)) { return $fileName; } return $suite->project->path.DIRECTORY_SEPARATOR.$fileName; }
php
public function addProjectRootPath($fileName, $suite) { if (starts_with($fileName, DIRECTORY_SEPARATOR) || empty($suite)) { return $fileName; } return $suite->project->path.DIRECTORY_SEPARATOR.$fileName; }
[ "public", "function", "addProjectRootPath", "(", "$", "fileName", ",", "$", "suite", ")", "{", "if", "(", "starts_with", "(", "$", "fileName", ",", "DIRECTORY_SEPARATOR", ")", "||", "empty", "(", "$", "suite", ")", ")", "{", "return", "$", "fileName", ";...
Add project root to path. @param $fileName @param $suite @return string
[ "Add", "project", "root", "to", "path", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L502-L509
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Helpers.php
Helpers.normalizePath
public function normalizePath($path) { $path = trim($path); $path = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path); if (ends_with($path, DIRECTORY_SEPARATOR)) { $path = substr($path, 0, -1); } return $path; }
php
public function normalizePath($path) { $path = trim($path); $path = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path); if (ends_with($path, DIRECTORY_SEPARATOR)) { $path = substr($path, 0, -1); } return $path; }
[ "public", "function", "normalizePath", "(", "$", "path", ")", "{", "$", "path", "=", "trim", "(", "$", "path", ")", ";", "$", "path", "=", "str_replace", "(", "DIRECTORY_SEPARATOR", ".", "DIRECTORY_SEPARATOR", ",", "DIRECTORY_SEPARATOR", ",", "$", "path", ...
Normalize a path removing inconsistences. @param $path @return bool|mixed|string
[ "Normalize", "a", "path", "removing", "inconsistences", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Helpers.php#L528-L539
train
antonioribeiro/tddd
src/package/Services/Cache.php
Cache.put
public function put($key, $value, $minutes = 525600) { $this->getCacheInstance()->put($key, $value, $minutes); return $value; }
php
public function put($key, $value, $minutes = 525600) { $this->getCacheInstance()->put($key, $value, $minutes); return $value; }
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", ",", "$", "minutes", "=", "525600", ")", "{", "$", "this", "->", "getCacheInstance", "(", ")", "->", "put", "(", "$", "key", ",", "$", "value", ",", "$", "minutes", ")", ";", "retur...
Put a value to the cache store. @throws \Exception @return mixed
[ "Put", "a", "value", "to", "the", "cache", "store", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Cache.php#L21-L26
train
antonioribeiro/tddd
src/package/Services/Cache.php
Cache.getCacheInstance
protected function getCacheInstance() { if (!$this->cache) { $this->cache = app($this->config('root.cache.instance')); } return $this->cache; }
php
protected function getCacheInstance() { if (!$this->cache) { $this->cache = app($this->config('root.cache.instance')); } return $this->cache; }
[ "protected", "function", "getCacheInstance", "(", ")", "{", "if", "(", "!", "$", "this", "->", "cache", ")", "{", "$", "this", "->", "cache", "=", "app", "(", "$", "this", "->", "config", "(", "'root.cache.instance'", ")", ")", ";", "}", "return", "$...
Get the cache instance. @throws \Exception @return array|\Illuminate\Foundation\Application|mixed
[ "Get", "the", "cache", "instance", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Cache.php#L49-L56
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Notifications.php
Notifications.notify
public function notify($project_id) { $this->notifier->notifyViaChannels( $this->getProjectTests($project_id)->reject(function ($item) { return $item['state'] != 'failed' && is_null($item['notified_at']); }) ); }
php
public function notify($project_id) { $this->notifier->notifyViaChannels( $this->getProjectTests($project_id)->reject(function ($item) { return $item['state'] != 'failed' && is_null($item['notified_at']); }) ); }
[ "public", "function", "notify", "(", "$", "project_id", ")", "{", "$", "this", "->", "notifier", "->", "notifyViaChannels", "(", "$", "this", "->", "getProjectTests", "(", "$", "project_id", ")", "->", "reject", "(", "function", "(", "$", "item", ")", "{...
Notify users. @param $project_id
[ "Notify", "users", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Notifications.php#L27-L34
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Projects.php
Projects.deleteMissingProjects
public function deleteMissingProjects($projects) { foreach (Project::all() as $project) { if (!in_array($project->name, $projects)) { $project->delete(); } } }
php
public function deleteMissingProjects($projects) { foreach (Project::all() as $project) { if (!in_array($project->name, $projects)) { $project->delete(); } } }
[ "public", "function", "deleteMissingProjects", "(", "$", "projects", ")", "{", "foreach", "(", "Project", "::", "all", "(", ")", "as", "$", "project", ")", "{", "if", "(", "!", "in_array", "(", "$", "project", "->", "name", ",", "$", "projects", ")", ...
Delete unavailable projects. @param $projects
[ "Delete", "unavailable", "projects", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Projects.php#L40-L47
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Projects.php
Projects.projectSha1HasChanged
public function projectSha1HasChanged() { $currentSha1 = sha1($projectsJson = $this->getProjects()->toJson()); $oldSha1 = app('tddd.cache')->get(Constants::CACHE_PROJECTS_KEY); if ($hasChanged = $currentSha1 != $oldSha1) { app('tddd.cache')->put(Constants::CACHE_PROJECTS_KEY, sha1($projectsJson)); } return $hasChanged; }
php
public function projectSha1HasChanged() { $currentSha1 = sha1($projectsJson = $this->getProjects()->toJson()); $oldSha1 = app('tddd.cache')->get(Constants::CACHE_PROJECTS_KEY); if ($hasChanged = $currentSha1 != $oldSha1) { app('tddd.cache')->put(Constants::CACHE_PROJECTS_KEY, sha1($projectsJson)); } return $hasChanged; }
[ "public", "function", "projectSha1HasChanged", "(", ")", "{", "$", "currentSha1", "=", "sha1", "(", "$", "projectsJson", "=", "$", "this", "->", "getProjects", "(", ")", "->", "toJson", "(", ")", ")", ";", "$", "oldSha1", "=", "app", "(", "'tddd.cache'",...
Get a SHA1 for all projects. @return bool
[ "Get", "a", "SHA1", "for", "all", "projects", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Projects.php#L116-L127
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Projects.php
Projects.getProjectState
public function getProjectState($tests) { if ($tests->contains('state', 'running')) { return 'running'; } if ($tests->contains('state', 'queued')) { return 'queued'; } if ($tests->contains('state', 'failed')) { return 'failed'; } if ($tests->every('state', 'ok')) { return 'ok'; } return 'idle'; }
php
public function getProjectState($tests) { if ($tests->contains('state', 'running')) { return 'running'; } if ($tests->contains('state', 'queued')) { return 'queued'; } if ($tests->contains('state', 'failed')) { return 'failed'; } if ($tests->every('state', 'ok')) { return 'ok'; } return 'idle'; }
[ "public", "function", "getProjectState", "(", "$", "tests", ")", "{", "if", "(", "$", "tests", "->", "contains", "(", "'state'", ",", "'running'", ")", ")", "{", "return", "'running'", ";", "}", "if", "(", "$", "tests", "->", "contains", "(", "'state'"...
The the project state. @param \Illuminate\Support\Collection $tests @return string
[ "The", "the", "project", "state", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Projects.php#L146-L165
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Projects.php
Projects.enableProject
protected function enableProject($enable, $project) { $project->timestamps = false; $project->enabled = $enable; $project->save(); }
php
protected function enableProject($enable, $project) { $project->timestamps = false; $project->enabled = $enable; $project->save(); }
[ "protected", "function", "enableProject", "(", "$", "enable", ",", "$", "project", ")", "{", "$", "project", "->", "timestamps", "=", "false", ";", "$", "project", "->", "enabled", "=", "$", "enable", ";", "$", "project", "->", "save", "(", ")", ";", ...
Enable a test. @param $enable @param \PragmaRX\Tddd\Package\Data\Models\Project $project
[ "Enable", "a", "test", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Projects.php#L196-L203
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Projects.php
Projects.reset
public function reset($project_id = null) { foreach ($this->queryTests($project_id)->get() as $test) { $this->resetTest($test); } }
php
public function reset($project_id = null) { foreach ($this->queryTests($project_id)->get() as $test) { $this->resetTest($test); } }
[ "public", "function", "reset", "(", "$", "project_id", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "queryTests", "(", "$", "project_id", ")", "->", "get", "(", ")", "as", "$", "test", ")", "{", "$", "this", "->", "resetTest", "(", "$"...
Run all tests or projects tests. @param null $project_id
[ "Run", "all", "tests", "or", "projects", "tests", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Projects.php#L227-L232
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Projects.php
Projects.toggleAll
public function toggleAll() { Project::all()->each(function ($project) { $this->enableProject(!$project->enabled, $project); }); }
php
public function toggleAll() { Project::all()->each(function ($project) { $this->enableProject(!$project->enabled, $project); }); }
[ "public", "function", "toggleAll", "(", ")", "{", "Project", "::", "all", "(", ")", "->", "each", "(", "function", "(", "$", "project", ")", "{", "$", "this", "->", "enableProject", "(", "!", "$", "project", "->", "enabled", ",", "$", "project", ")",...
Toggle the enabled state of all projects.
[ "Toggle", "the", "enabled", "state", "of", "all", "projects", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Projects.php#L237-L242
train
antonioribeiro/tddd
src/package/Services/Config.php
Config.loadConfig
public function loadConfig() { if ($this->configIsValid()) { return; } $this->yaml->loadToConfig($this->getConfigPath(), 'tddd', true)->toArray(); }
php
public function loadConfig() { if ($this->configIsValid()) { return; } $this->yaml->loadToConfig($this->getConfigPath(), 'tddd', true)->toArray(); }
[ "public", "function", "loadConfig", "(", ")", "{", "if", "(", "$", "this", "->", "configIsValid", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "yaml", "->", "loadToConfig", "(", "$", "this", "->", "getConfigPath", "(", ")", ",", "'tddd'...
Load the config.
[ "Load", "the", "config", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Config.php#L64-L71
train
antonioribeiro/tddd
src/package/Services/Config.php
Config.getConfigPath
public function getConfigPath() { if (is_null($this->configPath)) { $this->configPath = replace_laravel_paths(config('tddd-base.path')); } return $this->configPath; }
php
public function getConfigPath() { if (is_null($this->configPath)) { $this->configPath = replace_laravel_paths(config('tddd-base.path')); } return $this->configPath; }
[ "public", "function", "getConfigPath", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "configPath", ")", ")", "{", "$", "this", "->", "configPath", "=", "replace_laravel_paths", "(", "config", "(", "'tddd-base.path'", ")", ")", ";", "}", "r...
Get the config path. @return \Illuminate\Config\Repository|mixed
[ "Get", "the", "config", "path", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Config.php#L98-L105
train
antonioribeiro/tddd
src/package/Services/Config.php
Config.set
public function set($data) { $this->config = array_merge($data, $this->config); $this->mergeWithLaravelConfig(); }
php
public function set($data) { $this->config = array_merge($data, $this->config); $this->mergeWithLaravelConfig(); }
[ "public", "function", "set", "(", "$", "data", ")", "{", "$", "this", "->", "config", "=", "array_merge", "(", "$", "data", ",", "$", "this", "->", "config", ")", ";", "$", "this", "->", "mergeWithLaravelConfig", "(", ")", ";", "}" ]
Set the config item. @param $data
[ "Set", "the", "config", "item", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Config.php#L112-L117
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Queue.php
Queue.isEnqueued
public function isEnqueued($test) { return $test->state == Constants::STATE_QUEUED && QueueModel::where('test_id', $test->id)->first(); }
php
public function isEnqueued($test) { return $test->state == Constants::STATE_QUEUED && QueueModel::where('test_id', $test->id)->first(); }
[ "public", "function", "isEnqueued", "(", "$", "test", ")", "{", "return", "$", "test", "->", "state", "==", "Constants", "::", "STATE_QUEUED", "&&", "QueueModel", "::", "where", "(", "'test_id'", ",", "$", "test", "->", "id", ")", "->", "first", "(", "...
Is the test in the queue? @param $test @return bool
[ "Is", "the", "test", "in", "the", "queue?" ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Queue.php#L18-L24
train
antonioribeiro/tddd
src/package/ServiceProvider.php
ServiceProvider.boot
public function boot() { $this->publishConfiguration(); $this->loadConfig(); $this->loadMigrations(); $this->loadRoutes(); $this->loadViews(); }
php
public function boot() { $this->publishConfiguration(); $this->loadConfig(); $this->loadMigrations(); $this->loadRoutes(); $this->loadViews(); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "publishConfiguration", "(", ")", ";", "$", "this", "->", "loadConfig", "(", ")", ";", "$", "this", "->", "loadMigrations", "(", ")", ";", "$", "this", "->", "loadRoutes", "(", ")", ";",...
Boot Service Provider.
[ "Boot", "Service", "Provider", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/ServiceProvider.php#L37-L48
train
antonioribeiro/tddd
src/package/ServiceProvider.php
ServiceProvider.registerConfig
protected function registerConfig() { $config = $this->config = app('PragmaRX\Tddd\Package\Services\Config'); $this->app->singleton('tddd.config', function () use ($config) { return $config; }); }
php
protected function registerConfig() { $config = $this->config = app('PragmaRX\Tddd\Package\Services\Config'); $this->app->singleton('tddd.config', function () use ($config) { return $config; }); }
[ "protected", "function", "registerConfig", "(", ")", "{", "$", "config", "=", "$", "this", "->", "config", "=", "app", "(", "'PragmaRX\\Tddd\\Package\\Services\\Config'", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'tddd.config'", ",", "functi...
Register service tester.
[ "Register", "service", "tester", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/ServiceProvider.php#L213-L220
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Listener.php
Listener.on
public function on($event, Closure $callback) { if (!in_array($event, ['*', 'modify', 'delete', 'create'])) { throw new RuntimeException('Could not bind to unknown event '.$event); } $this->registerBinding($event, $callback); }
php
public function on($event, Closure $callback) { if (!in_array($event, ['*', 'modify', 'delete', 'create'])) { throw new RuntimeException('Could not bind to unknown event '.$event); } $this->registerBinding($event, $callback); }
[ "public", "function", "on", "(", "$", "event", ",", "Closure", "$", "callback", ")", "{", "if", "(", "!", "in_array", "(", "$", "event", ",", "[", "'*'", ",", "'modify'", ",", "'delete'", ",", "'create'", "]", ")", ")", "{", "throw", "new", "Runtim...
Bind to a given event. @param string $event @param \Closure $callback @throws \RuntimeException @return void
[ "Bind", "to", "a", "given", "event", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Listener.php#L27-L34
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Listener.php
Listener.getBindings
public function getBindings($binding = null) { if (is_null($binding)) { return $this->bindings; } return $this->bindings[$binding]; }
php
public function getBindings($binding = null) { if (is_null($binding)) { return $this->bindings; } return $this->bindings[$binding]; }
[ "public", "function", "getBindings", "(", "$", "binding", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "binding", ")", ")", "{", "return", "$", "this", "->", "bindings", ";", "}", "return", "$", "this", "->", "bindings", "[", "$", "binding"...
Get the bindings or a specific array of bindings. @param string $binding @return array
[ "Get", "the", "bindings", "or", "a", "specific", "array", "of", "bindings", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Listener.php#L164-L171
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Listener.php
Listener.determineEventBinding
public function determineEventBinding(Event $event) { switch ($event->getCode()) { case Event::RESOURCE_DELETED: return 'delete'; break; case Event::RESOURCE_CREATED: return 'create'; break; case Event::RESOURCE_MODIFIED: return 'modify'; break; } }
php
public function determineEventBinding(Event $event) { switch ($event->getCode()) { case Event::RESOURCE_DELETED: return 'delete'; break; case Event::RESOURCE_CREATED: return 'create'; break; case Event::RESOURCE_MODIFIED: return 'modify'; break; } }
[ "public", "function", "determineEventBinding", "(", "Event", "$", "event", ")", "{", "switch", "(", "$", "event", "->", "getCode", "(", ")", ")", "{", "case", "Event", "::", "RESOURCE_DELETED", ":", "return", "'delete'", ";", "break", ";", "case", "Event",...
Determine the binding for a given event. @param \JasonLewis\ResourceWatcher\Event $event @return string
[ "Determine", "the", "binding", "for", "a", "given", "event", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Listener.php#L180-L193
train
antonioribeiro/tddd
src/package/Support/Executor.php
Executor.exec
public function exec($command, $runDir = null, Closure $callback = null, $timeout = null) { $process = new Process($command, $runDir); $process->setTimeout($timeout); $this->startedAt = Carbon::now(); $process->run($callback); $this->endedAt = Carbon::now(); return $process; }
php
public function exec($command, $runDir = null, Closure $callback = null, $timeout = null) { $process = new Process($command, $runDir); $process->setTimeout($timeout); $this->startedAt = Carbon::now(); $process->run($callback); $this->endedAt = Carbon::now(); return $process; }
[ "public", "function", "exec", "(", "$", "command", ",", "$", "runDir", "=", "null", ",", "Closure", "$", "callback", "=", "null", ",", "$", "timeout", "=", "null", ")", "{", "$", "process", "=", "new", "Process", "(", "$", "command", ",", "$", "run...
Execute one command. @param $command @param null $runDir @param Closure|null $callback @param null $timeout @return Process
[ "Execute", "one", "command", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/Executor.php#L27-L40
train
antonioribeiro/tddd
src/package/Services/Loader.php
Loader.createSuite
private function createSuite($suite_name, $project, $suite_data) { $this->showProgress(" -- suite '{$suite_name}'"); if (!$this->dataRepository->createOrUpdateSuite($suite_name, $project->id, $suite_data)) { $this->displayMessages($this->dataRepository->getMessages()); die; } }
php
private function createSuite($suite_name, $project, $suite_data) { $this->showProgress(" -- suite '{$suite_name}'"); if (!$this->dataRepository->createOrUpdateSuite($suite_name, $project->id, $suite_data)) { $this->displayMessages($this->dataRepository->getMessages()); die; } }
[ "private", "function", "createSuite", "(", "$", "suite_name", ",", "$", "project", ",", "$", "suite_data", ")", "{", "$", "this", "->", "showProgress", "(", "\" -- suite '{$suite_name}'\"", ")", ";", "if", "(", "!", "$", "this", "->", "dataRepository", "->"...
Create or update the suite. @param $suite_name @param $project @param $suite_data
[ "Create", "or", "update", "the", "suite", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Loader.php#L48-L56
train
antonioribeiro/tddd
src/package/Services/Loader.php
Loader.loadEverything
public function loadEverything($showTests = false) { $this->showProgress('Config loaded from '.Config::getConfigPath()); $this->loadTesters(); $this->loadProjects(); $this->loadTests($showTests); }
php
public function loadEverything($showTests = false) { $this->showProgress('Config loaded from '.Config::getConfigPath()); $this->loadTesters(); $this->loadProjects(); $this->loadTests($showTests); }
[ "public", "function", "loadEverything", "(", "$", "showTests", "=", "false", ")", "{", "$", "this", "->", "showProgress", "(", "'Config loaded from '", ".", "Config", "::", "getConfigPath", "(", ")", ")", ";", "$", "this", "->", "loadTesters", "(", ")", ";...
Read configuration and load testers, projects, suites...
[ "Read", "configuration", "and", "load", "testers", "projects", "suites", "..." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Loader.php#L61-L70
train
antonioribeiro/tddd
src/package/Services/Loader.php
Loader.loadProjects
public function loadProjects() { $this->showProgress('Loading projects and suites...', 'info'); if (!is_arrayable($projects = $this->config('projects')) or count($projects) == 0) { $this->showProgress('No projects found.', 'error'); return; } foreach ($projects as $data) { $this->showProgress("Project '{$data['name']}'", 'comment'); $project = $this->dataRepository->createOrUpdateProject($data['name'], $data['path'], $data['tests_path']); $this->refreshProjectSuites($data, $project); $this->addToWatchFolders($data['path'], $data['watch_folders']); $this->addToExclusions($data['path'], $data['exclude']); } $this->dataRepository->deleteMissingProjects(collect($this->config('projects'))->pluck('name')->toArray()); }
php
public function loadProjects() { $this->showProgress('Loading projects and suites...', 'info'); if (!is_arrayable($projects = $this->config('projects')) or count($projects) == 0) { $this->showProgress('No projects found.', 'error'); return; } foreach ($projects as $data) { $this->showProgress("Project '{$data['name']}'", 'comment'); $project = $this->dataRepository->createOrUpdateProject($data['name'], $data['path'], $data['tests_path']); $this->refreshProjectSuites($data, $project); $this->addToWatchFolders($data['path'], $data['watch_folders']); $this->addToExclusions($data['path'], $data['exclude']); } $this->dataRepository->deleteMissingProjects(collect($this->config('projects'))->pluck('name')->toArray()); }
[ "public", "function", "loadProjects", "(", ")", "{", "$", "this", "->", "showProgress", "(", "'Loading projects and suites...'", ",", "'info'", ")", ";", "if", "(", "!", "is_arrayable", "(", "$", "projects", "=", "$", "this", "->", "config", "(", "'projects'...
Load all projects to database.
[ "Load", "all", "projects", "to", "database", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Loader.php#L97-L120
train
antonioribeiro/tddd
src/package/Services/Loader.php
Loader.addToWatchFolders
public function addToWatchFolders($path, $watch_folders) { collect($watch_folders)->each(function ($folder) use ($path) { $this->watchFolders[] = !file_exists($new = make_path([$path, $folder])) && file_exists($folder) ? $folder : $new; }); }
php
public function addToWatchFolders($path, $watch_folders) { collect($watch_folders)->each(function ($folder) use ($path) { $this->watchFolders[] = !file_exists($new = make_path([$path, $folder])) && file_exists($folder) ? $folder : $new; }); }
[ "public", "function", "addToWatchFolders", "(", "$", "path", ",", "$", "watch_folders", ")", "{", "collect", "(", "$", "watch_folders", ")", "->", "each", "(", "function", "(", "$", "folder", ")", "use", "(", "$", "path", ")", "{", "$", "this", "->", ...
Add folders to the watch list. @param $path @param $watch_folders
[ "Add", "folders", "to", "the", "watch", "list", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Loader.php#L140-L147
train
antonioribeiro/tddd
src/package/Services/Loader.php
Loader.addToExclusions
public function addToExclusions($path, $exclude) { collect($exclude)->each(function ($folder) use ($path) { $this->exclusions[] = $excluded = make_path([$path, $folder]); $this->showProgress("EXCLUDED: {$excluded}"); }); }
php
public function addToExclusions($path, $exclude) { collect($exclude)->each(function ($folder) use ($path) { $this->exclusions[] = $excluded = make_path([$path, $folder]); $this->showProgress("EXCLUDED: {$excluded}"); }); }
[ "public", "function", "addToExclusions", "(", "$", "path", ",", "$", "exclude", ")", "{", "collect", "(", "$", "exclude", ")", "->", "each", "(", "function", "(", "$", "folder", ")", "use", "(", "$", "path", ")", "{", "$", "this", "->", "exclusions",...
Add path to exclusions list. @param $path @param $exclude
[ "Add", "path", "to", "exclusions", "list", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Loader.php#L155-L162
train
antonioribeiro/tddd
src/package/Services/Loader.php
Loader.refreshProjectSuites
private function refreshProjectSuites($data, $project) { $this->dataRepository->removeMissingSuites($suites = $data['suites'], $project); collect($suites)->map(function ($data, $name) use ($project) { $this->createSuite($name, $project, $data); }); }
php
private function refreshProjectSuites($data, $project) { $this->dataRepository->removeMissingSuites($suites = $data['suites'], $project); collect($suites)->map(function ($data, $name) use ($project) { $this->createSuite($name, $project, $data); }); }
[ "private", "function", "refreshProjectSuites", "(", "$", "data", ",", "$", "project", ")", "{", "$", "this", "->", "dataRepository", "->", "removeMissingSuites", "(", "$", "suites", "=", "$", "data", "[", "'suites'", "]", ",", "$", "project", ")", ";", "...
Refresh all suites for a project. @param $data @param $project
[ "Refresh", "all", "suites", "for", "a", "project", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Loader.php#L170-L177
train
antonioribeiro/tddd
src/package/Services/Base.php
Base.config
protected function config($key = null, $default = null) { if (is_null($key)) { return app('tddd.config'); } return ConfigFacade::get($key, $default); }
php
protected function config($key = null, $default = null) { if (is_null($key)) { return app('tddd.config'); } return ConfigFacade::get($key, $default); }
[ "protected", "function", "config", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "app", "(", "'tddd.config'", ")", ";", "}", "return", "ConfigFacade", "::", ...
Get a configuration key. @param $key @throws \Exception @return mixed
[ "Get", "a", "configuration", "key", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Base.php#L31-L38
train
antonioribeiro/tddd
src/package/Services/Base.php
Base.displayMessages
protected function displayMessages($messages) { $fatal = $messages->reduce(function ($carry, $message) { $prefix = $message['type'] == 'error' ? 'FATAL ERROR: ' : ''; $this->command->{$message['type']}($prefix.$message['body']); if ($message['type'] == 'error') { return true; } return $carry; }); if ($fatal == true) { die; } }
php
protected function displayMessages($messages) { $fatal = $messages->reduce(function ($carry, $message) { $prefix = $message['type'] == 'error' ? 'FATAL ERROR: ' : ''; $this->command->{$message['type']}($prefix.$message['body']); if ($message['type'] == 'error') { return true; } return $carry; }); if ($fatal == true) { die; } }
[ "protected", "function", "displayMessages", "(", "$", "messages", ")", "{", "$", "fatal", "=", "$", "messages", "->", "reduce", "(", "function", "(", "$", "carry", ",", "$", "message", ")", "{", "$", "prefix", "=", "$", "message", "[", "'type'", "]", ...
Display messages in terminal. @param $messages
[ "Display", "messages", "in", "terminal", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Base.php#L91-L108
train
antonioribeiro/tddd
src/package/Services/Base.php
Base.setCommand
protected function setCommand($command) { $this->command = $command; if (!is_null($this->loader)) { $this->loader->setCommand($this->command); } }
php
protected function setCommand($command) { $this->command = $command; if (!is_null($this->loader)) { $this->loader->setCommand($this->command); } }
[ "protected", "function", "setCommand", "(", "$", "command", ")", "{", "$", "this", "->", "command", "=", "$", "command", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "loader", ")", ")", "{", "$", "this", "->", "loader", "->", "setCommand",...
Set the command. @param $command
[ "Set", "the", "command", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Services/Base.php#L115-L122
train
antonioribeiro/tddd
src/package/Console/Commands/BaseCommand.php
BaseCommand.drawLine
public function drawLine($len = 80) { if (is_string($len)) { $len = strlen($len); } $this->line(str_repeat('-', max($len, 80))); }
php
public function drawLine($len = 80) { if (is_string($len)) { $len = strlen($len); } $this->line(str_repeat('-', max($len, 80))); }
[ "public", "function", "drawLine", "(", "$", "len", "=", "80", ")", "{", "if", "(", "is_string", "(", "$", "len", ")", ")", "{", "$", "len", "=", "strlen", "(", "$", "len", ")", ";", "}", "$", "this", "->", "line", "(", "str_repeat", "(", "'-'",...
Draw a line in console. @param int $len
[ "Draw", "a", "line", "in", "console", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Console/Commands/BaseCommand.php#L14-L21
train
antonioribeiro/tddd
src/package/Http/Controllers/Files.php
Files.editFile
public function editFile($fileName, $suite_id, $line = null) { $this->executor->exec( $command = $this->dataRepository->makeEditFileCommand($fileName, $line, $suite_id) ); return $this->success(); }
php
public function editFile($fileName, $suite_id, $line = null) { $this->executor->exec( $command = $this->dataRepository->makeEditFileCommand($fileName, $line, $suite_id) ); return $this->success(); }
[ "public", "function", "editFile", "(", "$", "fileName", ",", "$", "suite_id", ",", "$", "line", "=", "null", ")", "{", "$", "this", "->", "executor", "->", "exec", "(", "$", "command", "=", "$", "this", "->", "dataRepository", "->", "makeEditFileCommand"...
Open a file in the editor. @param $fileName @param null $suite_id @param null $line @return mixed
[ "Open", "a", "file", "in", "the", "editor", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Http/Controllers/Files.php#L16-L23
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Tracker.php
Tracker.register
public function register(ResourceInterface $resource, Listener $listener) { $this->tracked[$resource->getKey()] = [$resource, $listener]; }
php
public function register(ResourceInterface $resource, Listener $listener) { $this->tracked[$resource->getKey()] = [$resource, $listener]; }
[ "public", "function", "register", "(", "ResourceInterface", "$", "resource", ",", "Listener", "$", "listener", ")", "{", "$", "this", "->", "tracked", "[", "$", "resource", "->", "getKey", "(", ")", "]", "=", "[", "$", "resource", ",", "$", "listener", ...
Register a resource with the tracker. @param \JasonLewis\ResourceWatcher\Resource\ResourceInterface $resource @param \JasonLewis\ResourceWatcher\Listener $listener @return void
[ "Register", "a", "resource", "with", "the", "tracker", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Tracker.php#L24-L27
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Tracker.php
Tracker.checkTrackings
public function checkTrackings() { foreach ($this->tracked as $name => $tracked) { list($resource, $listener) = $tracked; if (!$events = $resource->detectChanges()) { continue; } foreach ($events as $event) { if ($event instanceof Event) { $this->callListenerBindings($listener, $event); } } } }
php
public function checkTrackings() { foreach ($this->tracked as $name => $tracked) { list($resource, $listener) = $tracked; if (!$events = $resource->detectChanges()) { continue; } foreach ($events as $event) { if ($event instanceof Event) { $this->callListenerBindings($listener, $event); } } } }
[ "public", "function", "checkTrackings", "(", ")", "{", "foreach", "(", "$", "this", "->", "tracked", "as", "$", "name", "=>", "$", "tracked", ")", "{", "list", "(", "$", "resource", ",", "$", "listener", ")", "=", "$", "tracked", ";", "if", "(", "!...
Detect any changes on the tracked resources. @return void
[ "Detect", "any", "changes", "on", "the", "tracked", "resources", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Tracker.php#L54-L69
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Tracker.php
Tracker.callListenerBindings
protected function callListenerBindings(Listener $listener, Event $event) { $binding = $listener->determineEventBinding($event); if ($listener->hasBinding($binding)) { foreach ($listener->getBindings($binding) as $callback) { $resource = $event->getResource(); call_user_func($callback, $resource, $resource->getPath()); } } // If a listener has a binding for anything we'll also spin through // them and call each of them. if ($listener->hasBinding('*')) { foreach ($listener->getBindings('*') as $callback) { $resource = $event->getResource(); call_user_func($callback, $event, $resource, $resource->getPath()); } } }
php
protected function callListenerBindings(Listener $listener, Event $event) { $binding = $listener->determineEventBinding($event); if ($listener->hasBinding($binding)) { foreach ($listener->getBindings($binding) as $callback) { $resource = $event->getResource(); call_user_func($callback, $resource, $resource->getPath()); } } // If a listener has a binding for anything we'll also spin through // them and call each of them. if ($listener->hasBinding('*')) { foreach ($listener->getBindings('*') as $callback) { $resource = $event->getResource(); call_user_func($callback, $event, $resource, $resource->getPath()); } } }
[ "protected", "function", "callListenerBindings", "(", "Listener", "$", "listener", ",", "Event", "$", "event", ")", "{", "$", "binding", "=", "$", "listener", "->", "determineEventBinding", "(", "$", "event", ")", ";", "if", "(", "$", "listener", "->", "ha...
Call the bindings on the listener for a given event. @param \JasonLewis\ResourceWatcher\Listener $listener @param \JasonLewis\ResourceWatcher\Event $event @return void
[ "Call", "the", "bindings", "on", "the", "listener", "for", "a", "given", "event", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Tracker.php#L79-L100
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Watcher.php
Watcher.watch
public function watch($resource) { if (!$this->files->exists($resource)) { throw new RuntimeException('Resource must exist before you can watch it.'); } elseif ($this->files->isDirectory($resource)) { $resource = new DirectoryResource(new SplFileInfo($resource), $this->files); $resource->setupDirectory(); } else { $resource = new FileResource(new SplFileInfo($resource), $this->files); } // The listener gives users the ability to bind listeners on the events // created when watching a file or directory. We'll give the listener // to the tracker so the tracker can fire any bound listeners. $listener = new Listener(); $this->tracker->register($resource, $listener); return $listener; }
php
public function watch($resource) { if (!$this->files->exists($resource)) { throw new RuntimeException('Resource must exist before you can watch it.'); } elseif ($this->files->isDirectory($resource)) { $resource = new DirectoryResource(new SplFileInfo($resource), $this->files); $resource->setupDirectory(); } else { $resource = new FileResource(new SplFileInfo($resource), $this->files); } // The listener gives users the ability to bind listeners on the events // created when watching a file or directory. We'll give the listener // to the tracker so the tracker can fire any bound listeners. $listener = new Listener(); $this->tracker->register($resource, $listener); return $listener; }
[ "public", "function", "watch", "(", "$", "resource", ")", "{", "if", "(", "!", "$", "this", "->", "files", "->", "exists", "(", "$", "resource", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Resource must exist before you can watch it.'", ")", ";...
Register a resource to be watched. @param string $resource @return \JasonLewis\ResourceWatcher\Listener
[ "Register", "a", "resource", "to", "be", "watched", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Watcher.php#L56-L76
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Watcher.php
Watcher.startWatch
public function startWatch($interval = 1000000, $timeout = null, Closure $callback = null) { $this->watching = true; $timeWatching = 0; while ($this->watching) { if (is_callable($callback)) { call_user_func($callback, $this); } usleep($interval); $this->tracker->checkTrackings(); $timeWatching += $interval; if (!is_null($timeout) and $timeWatching >= $timeout) { $this->stopWatch(); } } }
php
public function startWatch($interval = 1000000, $timeout = null, Closure $callback = null) { $this->watching = true; $timeWatching = 0; while ($this->watching) { if (is_callable($callback)) { call_user_func($callback, $this); } usleep($interval); $this->tracker->checkTrackings(); $timeWatching += $interval; if (!is_null($timeout) and $timeWatching >= $timeout) { $this->stopWatch(); } } }
[ "public", "function", "startWatch", "(", "$", "interval", "=", "1000000", ",", "$", "timeout", "=", "null", ",", "Closure", "$", "callback", "=", "null", ")", "{", "$", "this", "->", "watching", "=", "true", ";", "$", "timeWatching", "=", "0", ";", "...
Start watching for a given interval. The interval and timeout and measured in microseconds, so 1,000,000 microseconds is equal to 1 second. @param int $interval @param int $timeout @param \Closure $callback @return void
[ "Start", "watching", "for", "a", "given", "interval", ".", "The", "interval", "and", "timeout", "and", "measured", "in", "microseconds", "so", "1", "000", "000", "microseconds", "is", "equal", "to", "1", "second", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Watcher.php#L88-L109
train
antonioribeiro/tddd
src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Watcher.php
Watcher.start
public function start($interval = 1000000, $timeout = null, Closure $callback = null) { $this->startWatch($interval, $timeout, $callback); }
php
public function start($interval = 1000000, $timeout = null, Closure $callback = null) { $this->startWatch($interval, $timeout, $callback); }
[ "public", "function", "start", "(", "$", "interval", "=", "1000000", ",", "$", "timeout", "=", "null", ",", "Closure", "$", "callback", "=", "null", ")", "{", "$", "this", "->", "startWatch", "(", "$", "interval", ",", "$", "timeout", ",", "$", "call...
Alias of startWatch. @param int $interval @param int $timeout @param \Closure $callback @return void
[ "Alias", "of", "startWatch", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Watcher.php#L120-L123
train
antonioribeiro/tddd
src/package/Http/Controllers/Projects.php
Projects.run
public function run(Request $request) { $this->dataRepository->runProjectTests($request->get('projects')); return $this->success(); }
php
public function run(Request $request) { $this->dataRepository->runProjectTests($request->get('projects')); return $this->success(); }
[ "public", "function", "run", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "dataRepository", "->", "runProjectTests", "(", "$", "request", "->", "get", "(", "'projects'", ")", ")", ";", "return", "$", "this", "->", "success", "(", ")", "...
Run project tests. @return mixed
[ "Run", "project", "tests", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Http/Controllers/Projects.php#L43-L48
train
antonioribeiro/tddd
src/package/Http/Controllers/Projects.php
Projects.reset
public function reset(Request $request) { $this->dataRepository->reset($request->get('projects')); return $this->success(); }
php
public function reset(Request $request) { $this->dataRepository->reset($request->get('projects')); return $this->success(); }
[ "public", "function", "reset", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "dataRepository", "->", "reset", "(", "$", "request", "->", "get", "(", "'projects'", ")", ")", ";", "return", "$", "this", "->", "success", "(", ")", ";", "}...
Reset projects tests states. @param Request $request @return mixed
[ "Reset", "projects", "tests", "states", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Http/Controllers/Projects.php#L57-L62
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Suites.php
Suites.createOrUpdateSuite
public function createOrUpdateSuite($name, $project_id, $suite_data) { $project_id = $project_id instanceof Project ? $project_id->id : $project_id; if (is_null($tester = Tester::where('name', $suite_data['tester'])->first())) { $this->addMessage("Tester {$suite_data['tester']} not found.", 'error'); return false; } return Suite::updateOrCreate( [ 'name' => $name, 'project_id' => $project_id, ], [ 'tester_id' => $tester->id, 'tests_path' => array_get($suite_data, 'tests_path'), 'command_options' => array_get($suite_data, 'command_options'), 'file_mask' => array_get($suite_data, 'file_mask'), 'retries' => array_get($suite_data, 'retries'), 'editor' => array_get($suite_data, 'editor'), 'coverage_enabled' => array_get($suite_data, 'coverage.enabled', false), 'coverage_index' => array_get($suite_data, 'coverage.index'), ] ); }
php
public function createOrUpdateSuite($name, $project_id, $suite_data) { $project_id = $project_id instanceof Project ? $project_id->id : $project_id; if (is_null($tester = Tester::where('name', $suite_data['tester'])->first())) { $this->addMessage("Tester {$suite_data['tester']} not found.", 'error'); return false; } return Suite::updateOrCreate( [ 'name' => $name, 'project_id' => $project_id, ], [ 'tester_id' => $tester->id, 'tests_path' => array_get($suite_data, 'tests_path'), 'command_options' => array_get($suite_data, 'command_options'), 'file_mask' => array_get($suite_data, 'file_mask'), 'retries' => array_get($suite_data, 'retries'), 'editor' => array_get($suite_data, 'editor'), 'coverage_enabled' => array_get($suite_data, 'coverage.enabled', false), 'coverage_index' => array_get($suite_data, 'coverage.index'), ] ); }
[ "public", "function", "createOrUpdateSuite", "(", "$", "name", ",", "$", "project_id", ",", "$", "suite_data", ")", "{", "$", "project_id", "=", "$", "project_id", "instanceof", "Project", "?", "$", "project_id", "->", "id", ":", "$", "project_id", ";", "i...
Create or update a suite. @param $name @param $project_id @param $suite_data @return Suite|null|bool
[ "Create", "or", "update", "a", "suite", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Suites.php#L21-L47
train
antonioribeiro/tddd
src/package/Data/Repositories/Support/Suites.php
Suites.removeMissingSuites
public function removeMissingSuites($suites, $project) { Suite::where('project_id', $project->id)->whereNotIn('name', collect($suites)->keys())->each(function ($suite) { $suite->delete(); }); }
php
public function removeMissingSuites($suites, $project) { Suite::where('project_id', $project->id)->whereNotIn('name', collect($suites)->keys())->each(function ($suite) { $suite->delete(); }); }
[ "public", "function", "removeMissingSuites", "(", "$", "suites", ",", "$", "project", ")", "{", "Suite", "::", "where", "(", "'project_id'", ",", "$", "project", "->", "id", ")", "->", "whereNotIn", "(", "'name'", ",", "collect", "(", "$", "suites", ")",...
Remove suites that are not in present in config. @param $suites @param $project
[ "Remove", "suites", "that", "are", "not", "in", "present", "in", "config", "." ]
f6c69e165bbba870d4a3259c9e6baed2cb5e51fb
https://github.com/antonioribeiro/tddd/blob/f6c69e165bbba870d4a3259c9e6baed2cb5e51fb/src/package/Data/Repositories/Support/Suites.php#L90-L95
train