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
BlueTeaNL/JIRA-Rest-API-PHP
src/Crowd/Endpoint/AuthenticationEndpoint.php
AuthenticationEndpoint.authentication
public function authentication($username, $password) { $endpoint = sprintf('authentication?username=%s', urlencode($username)); $parameters['value'] = $password; return $this->apiClient->callEndpoint( $endpoint, $parameters, null, HttpMethod::REQUEST_POST ); }
php
public function authentication($username, $password) { $endpoint = sprintf('authentication?username=%s', urlencode($username)); $parameters['value'] = $password; return $this->apiClient->callEndpoint( $endpoint, $parameters, null, HttpMethod::REQUEST_POST ); }
[ "public", "function", "authentication", "(", "$", "username", ",", "$", "password", ")", "{", "$", "endpoint", "=", "sprintf", "(", "'authentication?username=%s'", ",", "urlencode", "(", "$", "username", ")", ")", ";", "$", "parameters", "[", "'value'", "]",...
Authenticate user with Crowd @param $username @param $password @return mixed
[ "Authenticate", "user", "with", "Crowd" ]
56309ee711f86d5bc085f391bba3e50155e14106
https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Crowd/Endpoint/AuthenticationEndpoint.php#L18-L28
train
IDCI-Consulting/ExtraFormBundle
Model/ConfiguredType.php
ConfiguredType.getExtraFormConstraints
public function getExtraFormConstraints() { if (null === $this->extraFormType) { return null; } $configurationArray = json_decode($this->configuration, true); return $configurationArray['extra_form_constraints']; }
php
public function getExtraFormConstraints() { if (null === $this->extraFormType) { return null; } $configurationArray = json_decode($this->configuration, true); return $configurationArray['extra_form_constraints']; }
[ "public", "function", "getExtraFormConstraints", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "extraFormType", ")", "{", "return", "null", ";", "}", "$", "configurationArray", "=", "json_decode", "(", "$", "this", "->", "configuration", ",", ...
Get extra form constraints. @return array
[ "Get", "extra", "form", "constraints", "." ]
3481c69fd078754f3d0c5947dd59a5536ed13da0
https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Model/ConfiguredType.php#L286-L295
train
adrianorsouza/reCAPTCHA-lib
lib/ReCaptcha/CaptchaTheme.php
CaptchaTheme._theme
protected function _theme($theme_name = NULL, $options = array()) { if ( count($options) > 0 ) { // Avoid invalid options passed via array foreach ($options as $opt => $value) { if ( !array_key_exists($opt, $this->_recaptchaOptions) ) { unset($options[$opt]); } } } // Avoid empty values foreach ($this->_recaptchaOptions as $key => $value) { if ( NULL === $value || $value === 0 ) { unset($this->_recaptchaOptions[$key]); } } $this->_recaptchaOptions = array_merge($this->_recaptchaOptions, $options); if ( NULL !== $theme_name ) { $this->_recaptchaOptions['theme'] = $theme_name; } // Skip to default reCAPTCHA theme if there is no options if ( count($this->_recaptchaOptions) == 0 ) { return; } // Whether lang option value is not built-in try to set it from a translation file if ( isset($this->_recaptchaOptions['lang']) && !in_array($this->_recaptchaOptions['lang'], $this->_builtInlang) && !isset($this->_recaptchaOptions['custom_translations']) ) { $this->setTranslation($this->_recaptchaOptions['lang']); } // Whether theme empty set default theme to default for FALLBACK if ( !isset($this->_recaptchaOptions['theme']) && count($this->_recaptchaOptions) > 0 ) { $this->_recaptchaOptions['theme'] = 'red'; } // Skip to default reCAPTCHA theme if it's set to 'red' and there is no options at all if ( $this->_recaptchaOptions['theme'] === 'red' && count($this->_recaptchaOptions) == 1 ) { return; } // Whether the theme name is Standard_Themes or not if ( in_array($this->_recaptchaOptions['theme'], $this->_standardThemes) ) { unset($this->_recaptchaOptions['custom_theme_widget']); $js_options = json_encode($this->_recaptchaOptions); return sprintf($this->_optionsWrapper, $js_options); } elseif ( $this->_recaptchaOptions['theme'] === 'custom' ) { // Custom theme MUST have an option [custom_theme_widget: ID_some_widget_name] set for recaptcha // If this option is not set, we make it. if ( !isset($this->_recaptchaOptions['custom_theme_widget']) ) { $this->_recaptchaOptions['custom_theme_widget'] = 'recaptcha_widget'; } $custom_template = $this->custom_theme($this->_recaptchaOptions['custom_theme_widget']); $js_options = json_encode($this->_recaptchaOptions); return sprintf($this->_optionsWrapper, $js_options) . $custom_template; } // FALLBACK to red one default theme return; }
php
protected function _theme($theme_name = NULL, $options = array()) { if ( count($options) > 0 ) { // Avoid invalid options passed via array foreach ($options as $opt => $value) { if ( !array_key_exists($opt, $this->_recaptchaOptions) ) { unset($options[$opt]); } } } // Avoid empty values foreach ($this->_recaptchaOptions as $key => $value) { if ( NULL === $value || $value === 0 ) { unset($this->_recaptchaOptions[$key]); } } $this->_recaptchaOptions = array_merge($this->_recaptchaOptions, $options); if ( NULL !== $theme_name ) { $this->_recaptchaOptions['theme'] = $theme_name; } // Skip to default reCAPTCHA theme if there is no options if ( count($this->_recaptchaOptions) == 0 ) { return; } // Whether lang option value is not built-in try to set it from a translation file if ( isset($this->_recaptchaOptions['lang']) && !in_array($this->_recaptchaOptions['lang'], $this->_builtInlang) && !isset($this->_recaptchaOptions['custom_translations']) ) { $this->setTranslation($this->_recaptchaOptions['lang']); } // Whether theme empty set default theme to default for FALLBACK if ( !isset($this->_recaptchaOptions['theme']) && count($this->_recaptchaOptions) > 0 ) { $this->_recaptchaOptions['theme'] = 'red'; } // Skip to default reCAPTCHA theme if it's set to 'red' and there is no options at all if ( $this->_recaptchaOptions['theme'] === 'red' && count($this->_recaptchaOptions) == 1 ) { return; } // Whether the theme name is Standard_Themes or not if ( in_array($this->_recaptchaOptions['theme'], $this->_standardThemes) ) { unset($this->_recaptchaOptions['custom_theme_widget']); $js_options = json_encode($this->_recaptchaOptions); return sprintf($this->_optionsWrapper, $js_options); } elseif ( $this->_recaptchaOptions['theme'] === 'custom' ) { // Custom theme MUST have an option [custom_theme_widget: ID_some_widget_name] set for recaptcha // If this option is not set, we make it. if ( !isset($this->_recaptchaOptions['custom_theme_widget']) ) { $this->_recaptchaOptions['custom_theme_widget'] = 'recaptcha_widget'; } $custom_template = $this->custom_theme($this->_recaptchaOptions['custom_theme_widget']); $js_options = json_encode($this->_recaptchaOptions); return sprintf($this->_optionsWrapper, $js_options) . $custom_template; } // FALLBACK to red one default theme return; }
[ "protected", "function", "_theme", "(", "$", "theme_name", "=", "NULL", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "count", "(", "$", "options", ")", ">", "0", ")", "{", "// Avoid invalid options passed via array", "foreach", "(", ...
Standard Theme Display's Theme customization for reCAPTCHA widget by writting a snippet for Standard_Themes and Custom_Theming @param string $theme_name Optional theme name. NOTE: overwrite theme if it's set in an external config @param array $options reCAPTCHA Associative array of available options. NOTE: overwrite options set in an external config @return string Standard_Theme | Custom_Theme | Fallback default reCAPTCHA theme
[ "Standard", "Theme", "Display", "s", "Theme", "customization", "for", "reCAPTCHA", "widget", "by", "writting", "a", "snippet", "for", "Standard_Themes", "and", "Custom_Theming" ]
0875e6deab68b9949033417d10db4d2aefeccdcb
https://github.com/adrianorsouza/reCAPTCHA-lib/blob/0875e6deab68b9949033417d10db4d2aefeccdcb/lib/ReCaptcha/CaptchaTheme.php#L94-L162
train
adrianorsouza/reCAPTCHA-lib
lib/ReCaptcha/CaptchaTheme.php
CaptchaTheme.i18n
protected function i18n($key = NULL, $path = NULL) { static $RECAPTCHA_LANG; if ( $RECAPTCHA_LANG ) { return isset($key) ? $RECAPTCHA_LANG[$key] : $RECAPTCHA_LANG; } if ( !isset($this->_recaptchaOptions['lang']) ) { $language = $this->clientLang(); } else { $language = $this->_recaptchaOptions['lang']; } $RECAPTCHA_LANG = array( 'instructions_visual' => 'Enter the words above:', 'instructions_audio' => 'Type what you hear:', 'play_again' => 'Play sound again', 'cant_hear_this' => 'Download sound as MP3', 'visual_challenge' => 'Get an image CAPTCHA', 'audio_challenge' => 'Get an audio CAPTCHA', 'refresh_btn' => 'Get another CAPTCHA', 'help_btn' => 'Help', 'incorrect_try_again' => 'Incorrect, please try again.' ); // default: path/to/vendor/lib/ReCaptcha/I18n/recaptcha.lang.[langcode].php $path = ( NULL === $path ) ? __DIR__ . DIRECTORY_SEPARATOR . 'I18n' : $path; $language_file = rtrim($path, '/') . DIRECTORY_SEPARATOR . 'recaptcha.lang.' . $language . '.php'; if ( file_exists( $language_file ) ) { include_once $language_file; } return isset($key) ? $RECAPTCHA_LANG[$key] : $RECAPTCHA_LANG; }
php
protected function i18n($key = NULL, $path = NULL) { static $RECAPTCHA_LANG; if ( $RECAPTCHA_LANG ) { return isset($key) ? $RECAPTCHA_LANG[$key] : $RECAPTCHA_LANG; } if ( !isset($this->_recaptchaOptions['lang']) ) { $language = $this->clientLang(); } else { $language = $this->_recaptchaOptions['lang']; } $RECAPTCHA_LANG = array( 'instructions_visual' => 'Enter the words above:', 'instructions_audio' => 'Type what you hear:', 'play_again' => 'Play sound again', 'cant_hear_this' => 'Download sound as MP3', 'visual_challenge' => 'Get an image CAPTCHA', 'audio_challenge' => 'Get an audio CAPTCHA', 'refresh_btn' => 'Get another CAPTCHA', 'help_btn' => 'Help', 'incorrect_try_again' => 'Incorrect, please try again.' ); // default: path/to/vendor/lib/ReCaptcha/I18n/recaptcha.lang.[langcode].php $path = ( NULL === $path ) ? __DIR__ . DIRECTORY_SEPARATOR . 'I18n' : $path; $language_file = rtrim($path, '/') . DIRECTORY_SEPARATOR . 'recaptcha.lang.' . $language . '.php'; if ( file_exists( $language_file ) ) { include_once $language_file; } return isset($key) ? $RECAPTCHA_LANG[$key] : $RECAPTCHA_LANG; }
[ "protected", "function", "i18n", "(", "$", "key", "=", "NULL", ",", "$", "path", "=", "NULL", ")", "{", "static", "$", "RECAPTCHA_LANG", ";", "if", "(", "$", "RECAPTCHA_LANG", ")", "{", "return", "isset", "(", "$", "key", ")", "?", "$", "RECAPTCHA_LA...
Fetch I18n language line @param string $key The string translated @param string $path Optional path to your own language file @return array|string
[ "Fetch", "I18n", "language", "line" ]
0875e6deab68b9949033417d10db4d2aefeccdcb
https://github.com/adrianorsouza/reCAPTCHA-lib/blob/0875e6deab68b9949033417d10db4d2aefeccdcb/lib/ReCaptcha/CaptchaTheme.php#L235-L274
train
adrianorsouza/reCAPTCHA-lib
lib/ReCaptcha/CaptchaTheme.php
CaptchaTheme.clientLang
public function clientLang() { if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) { $language = explode(',', preg_replace('/(;\s?q=[0-9\.]+)|\s/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])))); return strtolower($language[0]); } return; }
php
public function clientLang() { if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) { $language = explode(',', preg_replace('/(;\s?q=[0-9\.]+)|\s/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])))); return strtolower($language[0]); } return; }
[ "public", "function", "clientLang", "(", ")", "{", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT_LANGUAGE'", "]", ")", ")", "{", "$", "language", "=", "explode", "(", "','", ",", "preg_replace", "(", "'/(;\\s?q=[0-9\\.]+)|\\s/i'", ",", "''", ...
Get user's browser language preference @return string @deprecated will be remove in major release v1.0.0
[ "Get", "user", "s", "browser", "language", "preference" ]
0875e6deab68b9949033417d10db4d2aefeccdcb
https://github.com/adrianorsouza/reCAPTCHA-lib/blob/0875e6deab68b9949033417d10db4d2aefeccdcb/lib/ReCaptcha/CaptchaTheme.php#L283-L292
train
IDCI-Consulting/ExtraFormBundle
Form/Type/ReCaptchaType.php
ReCaptchaType.isEnabled
private function isEnabled() { if (!$this->enabled) { return false; } if ($this->authorizationChecker) { foreach ($this->trustedRoles as $trustedRole) { if ($this->authorizationChecker->isGranted($trustedRole)) { return false; } } } return true; }
php
private function isEnabled() { if (!$this->enabled) { return false; } if ($this->authorizationChecker) { foreach ($this->trustedRoles as $trustedRole) { if ($this->authorizationChecker->isGranted($trustedRole)) { return false; } } } return true; }
[ "private", "function", "isEnabled", "(", ")", "{", "if", "(", "!", "$", "this", "->", "enabled", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "authorizationChecker", ")", "{", "foreach", "(", "$", "this", "->", "trustedRoles", ...
Is the recaptcha form field enabled ? @return bool
[ "Is", "the", "recaptcha", "form", "field", "enabled", "?" ]
3481c69fd078754f3d0c5947dd59a5536ed13da0
https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Form/Type/ReCaptchaType.php#L175-L190
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.init
public static function init() { $className = get_called_class(); if (empty(static::$_fieldsDefined[$className])) { static::_defineFields(); static::_initFields(); static::$_fieldsDefined[$className] = true; } if (empty(static::$_relationshipsDefined[$className]) && static::isRelational()) { static::_defineRelationships(); static::_initRelationships(); static::$_relationshipsDefined[$className] = true; } if (empty(static::$_eventsDefined[$className])) { static::_defineEvents(); static::$_eventsDefined[$className] = true; } }
php
public static function init() { $className = get_called_class(); if (empty(static::$_fieldsDefined[$className])) { static::_defineFields(); static::_initFields(); static::$_fieldsDefined[$className] = true; } if (empty(static::$_relationshipsDefined[$className]) && static::isRelational()) { static::_defineRelationships(); static::_initRelationships(); static::$_relationshipsDefined[$className] = true; } if (empty(static::$_eventsDefined[$className])) { static::_defineEvents(); static::$_eventsDefined[$className] = true; } }
[ "public", "static", "function", "init", "(", ")", "{", "$", "className", "=", "get_called_class", "(", ")", ";", "if", "(", "empty", "(", "static", "::", "$", "_fieldsDefined", "[", "$", "className", "]", ")", ")", "{", "static", "::", "_defineFields", ...
init Initializes the model by checking the ancestor tree for the existence of various config fields and merges them. @uses static::$_fieldsDefined Sets static::$_fieldsDefined[get_called_class()] to true after running. @uses static::$_relationshipsDefined Sets static::$_relationshipsDefined[get_called_class()] to true after running. @uses static::$_eventsDefined Sets static::$_eventsDefined[get_called_class()] to true after running. @used-by static::__construct() @used-by static::fieldExists() @used-by static::getClassFields() @used-by static::getColumnName() @return void
[ "init", "Initializes", "the", "model", "by", "checking", "the", "ancestor", "tree", "for", "the", "existence", "of", "various", "config", "fields", "and", "merges", "them", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L385-L406
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.setValue
public function setValue($name, $value) { // handle field if (static::fieldExists($name)) { $this->_setFieldValue($name, $value); } // undefined else { return false; } }
php
public function setValue($name, $value) { // handle field if (static::fieldExists($name)) { $this->_setFieldValue($name, $value); } // undefined else { return false; } }
[ "public", "function", "setValue", "(", "$", "name", ",", "$", "value", ")", "{", "// handle field", "if", "(", "static", "::", "fieldExists", "(", "$", "name", ")", ")", "{", "$", "this", "->", "_setFieldValue", "(", "$", "name", ",", "$", "value", "...
Sets a value on this model. @param string $name @param mixed $value @return void|false False if the field does not exist. Void otherwise.
[ "Sets", "a", "value", "on", "this", "model", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L474-L484
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.create
public static function create($values = [], $save = false) { $className = get_called_class(); // create class $ActiveRecord = new $className(); $ActiveRecord->setFields($values); if ($save) { $ActiveRecord->save(); } return $ActiveRecord; }
php
public static function create($values = [], $save = false) { $className = get_called_class(); // create class $ActiveRecord = new $className(); $ActiveRecord->setFields($values); if ($save) { $ActiveRecord->save(); } return $ActiveRecord; }
[ "public", "static", "function", "create", "(", "$", "values", "=", "[", "]", ",", "$", "save", "=", "false", ")", "{", "$", "className", "=", "get_called_class", "(", ")", ";", "// create class", "$", "ActiveRecord", "=", "new", "$", "className", "(", ...
Create a new object from this model. @param array $values Array of keys as fields and values. @param boolean $save If the object should be immediately saved to database before being returned. @return static An object of this model.
[ "Create", "a", "new", "object", "from", "this", "model", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L513-L526
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.changeClass
public function changeClass($className = false, $fieldValues = false) { if (!$className) { return $this; } $this->_record[static::_cn('Class')] = $className; $ActiveRecord = new $className($this->_record, true, $this->isPhantom); if ($fieldValues) { $ActiveRecord->setFields($fieldValues); } if (!$this->isPhantom) { $ActiveRecord->save(); } return $ActiveRecord; }
php
public function changeClass($className = false, $fieldValues = false) { if (!$className) { return $this; } $this->_record[static::_cn('Class')] = $className; $ActiveRecord = new $className($this->_record, true, $this->isPhantom); if ($fieldValues) { $ActiveRecord->setFields($fieldValues); } if (!$this->isPhantom) { $ActiveRecord->save(); } return $ActiveRecord; }
[ "public", "function", "changeClass", "(", "$", "className", "=", "false", ",", "$", "fieldValues", "=", "false", ")", "{", "if", "(", "!", "$", "className", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "_record", "[", "static", "::",...
Used to instantiate a new model of a different class with this model's field's. Useful when you have similar classes or subclasses with the same parent. @param string $className If you leave this blank the return will be $this @param array $fieldValues Optional. Any field values you want to override. @return static A new model of a different class with this model's field's. Useful when you have similar classes or subclasses with the same parent.
[ "Used", "to", "instantiate", "a", "new", "model", "of", "a", "different", "class", "with", "this", "model", "s", "field", "s", ".", "Useful", "when", "you", "have", "similar", "classes", "or", "subclasses", "with", "the", "same", "parent", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L545-L563
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.setFields
public function setFields($values) { foreach ($values as $field => $value) { $this->_setFieldValue($field, $value); } }
php
public function setFields($values) { foreach ($values as $field => $value) { $this->_setFieldValue($field, $value); } }
[ "public", "function", "setFields", "(", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "this", "->", "_setFieldValue", "(", "$", "field", ",", "$", "value", ")", ";", "}", "}" ]
Change multiple fields in the model with an array. @param array $values Field/values array to change multiple fields in this model. @return void
[ "Change", "multiple", "fields", "in", "the", "model", "with", "an", "array", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L571-L576
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getData
public function getData() { $data = []; foreach (static::$_classFields[get_called_class()] as $field => $options) { $data[$field] = $this->_getFieldValue($field); } if ($this->validationErrors) { $data['validationErrors'] = $this->validationErrors; } return $data; }
php
public function getData() { $data = []; foreach (static::$_classFields[get_called_class()] as $field => $options) { $data[$field] = $this->_getFieldValue($field); } if ($this->validationErrors) { $data['validationErrors'] = $this->validationErrors; } return $data; }
[ "public", "function", "getData", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "static", "::", "$", "_classFields", "[", "get_called_class", "(", ")", "]", "as", "$", "field", "=>", "$", "options", ")", "{", "$", "data", "[", "$",...
Gets normalized object data. @return array The model's data as a normal array with any validation errors included.
[ "Gets", "normalized", "object", "data", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L605-L618
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.save
public function save($deep = true) { // run before save $this->beforeSave(); if (static::isVersioned()) { $this->beforeVersionedSave(); } // set created if (static::fieldExists('Created') && (!$this->Created || ($this->Created == 'CURRENT_TIMESTAMP'))) { $this->Created = time(); } // validate if (!$this->validate($deep)) { throw new Exception('Cannot save invalid record'); } $this->clearCaches(); if ($this->isDirty) { // prepare record values $recordValues = $this->_prepareRecordValues(); // transform record to set array $set = static::_mapValuesToSet($recordValues); // create new or update existing if ($this->_isPhantom) { DB::nonQuery( 'INSERT INTO `%s` SET %s', [ static::$tableName, join(',', $set), ], [static::class,'handleError'] ); $this->_record[static::$primaryKey ? static::$primaryKey : 'ID'] = DB::insertID(); $this->_isPhantom = false; $this->_isNew = true; } elseif (count($set)) { DB::nonQuery( 'UPDATE `%s` SET %s WHERE `%s` = %u', [ static::$tableName, join(',', $set), static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $this->getPrimaryKeyValue(), ], [static::class,'handleError'] ); $this->_isUpdated = true; } // update state $this->_isDirty = false; if (static::isVersioned()) { $this->afterVersionedSave(); } } $this->afterSave(); }
php
public function save($deep = true) { // run before save $this->beforeSave(); if (static::isVersioned()) { $this->beforeVersionedSave(); } // set created if (static::fieldExists('Created') && (!$this->Created || ($this->Created == 'CURRENT_TIMESTAMP'))) { $this->Created = time(); } // validate if (!$this->validate($deep)) { throw new Exception('Cannot save invalid record'); } $this->clearCaches(); if ($this->isDirty) { // prepare record values $recordValues = $this->_prepareRecordValues(); // transform record to set array $set = static::_mapValuesToSet($recordValues); // create new or update existing if ($this->_isPhantom) { DB::nonQuery( 'INSERT INTO `%s` SET %s', [ static::$tableName, join(',', $set), ], [static::class,'handleError'] ); $this->_record[static::$primaryKey ? static::$primaryKey : 'ID'] = DB::insertID(); $this->_isPhantom = false; $this->_isNew = true; } elseif (count($set)) { DB::nonQuery( 'UPDATE `%s` SET %s WHERE `%s` = %u', [ static::$tableName, join(',', $set), static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $this->getPrimaryKeyValue(), ], [static::class,'handleError'] ); $this->_isUpdated = true; } // update state $this->_isDirty = false; if (static::isVersioned()) { $this->afterVersionedSave(); } } $this->afterSave(); }
[ "public", "function", "save", "(", "$", "deep", "=", "true", ")", "{", "// run before save", "$", "this", "->", "beforeSave", "(", ")", ";", "if", "(", "static", "::", "isVersioned", "(", ")", ")", "{", "$", "this", "->", "beforeVersionedSave", "(", ")...
Saves this object to the database currently in use. @param bool $deep Default is true. When true will try to save any dirty models in any defined and initialized relationships. @uses $this->_isPhantom @uses $this->_isDirty
[ "Saves", "this", "object", "to", "the", "database", "currently", "in", "use", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L689-L754
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.destroy
public function destroy() { if (static::isVersioned()) { if (static::$createRevisionOnDestroy) { // save a copy to history table if ($this->fieldExists('Created')) { $this->Created = time(); } $recordValues = $this->_prepareRecordValues(); $set = static::_mapValuesToSet($recordValues); DB::nonQuery( 'INSERT INTO `%s` SET %s', [ static::getHistoryTable(), join(',', $set), ] ); } } return static::delete($this->getPrimaryKeyValue()); }
php
public function destroy() { if (static::isVersioned()) { if (static::$createRevisionOnDestroy) { // save a copy to history table if ($this->fieldExists('Created')) { $this->Created = time(); } $recordValues = $this->_prepareRecordValues(); $set = static::_mapValuesToSet($recordValues); DB::nonQuery( 'INSERT INTO `%s` SET %s', [ static::getHistoryTable(), join(',', $set), ] ); } } return static::delete($this->getPrimaryKeyValue()); }
[ "public", "function", "destroy", "(", ")", "{", "if", "(", "static", "::", "isVersioned", "(", ")", ")", "{", "if", "(", "static", "::", "$", "createRevisionOnDestroy", ")", "{", "// save a copy to history table", "if", "(", "$", "this", "->", "fieldExists",...
Deletes this object. @return bool True if database returns number of affected rows above 0. False otherwise.
[ "Deletes", "this", "object", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L762-L786
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.delete
public static function delete($id) { DB::nonQuery('DELETE FROM `%s` WHERE `%s` = %u', [ static::$tableName, static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id, ], [static::class,'handleError']); return DB::affectedRows() > 0; }
php
public static function delete($id) { DB::nonQuery('DELETE FROM `%s` WHERE `%s` = %u', [ static::$tableName, static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id, ], [static::class,'handleError']); return DB::affectedRows() > 0; }
[ "public", "static", "function", "delete", "(", "$", "id", ")", "{", "DB", "::", "nonQuery", "(", "'DELETE FROM `%s` WHERE `%s` = %u'", ",", "[", "static", "::", "$", "tableName", ",", "static", "::", "_cn", "(", "static", "::", "$", "primaryKey", "?", "sta...
Delete by ID @param int $id @return bool True if database returns number of affected rows above 0. False otherwise.
[ "Delete", "by", "ID" ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L794-L803
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getByID
public static function getByID($id) { $record = static::getRecordByField(static::$primaryKey ? static::$primaryKey : 'ID', $id, true); return static::instantiateRecord($record); }
php
public static function getByID($id) { $record = static::getRecordByField(static::$primaryKey ? static::$primaryKey : 'ID', $id, true); return static::instantiateRecord($record); }
[ "public", "static", "function", "getByID", "(", "$", "id", ")", "{", "$", "record", "=", "static", "::", "getRecordByField", "(", "static", "::", "$", "primaryKey", "?", "static", "::", "$", "primaryKey", ":", "'ID'", ",", "$", "id", ",", "true", ")", ...
Get model object by primary key. @param int $id @return static|null
[ "Get", "model", "object", "by", "primary", "key", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L847-L852
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getByField
public static function getByField($field, $value, $cacheIndex = false) { $record = static::getRecordByField($field, $value, $cacheIndex); return static::instantiateRecord($record); }
php
public static function getByField($field, $value, $cacheIndex = false) { $record = static::getRecordByField($field, $value, $cacheIndex); return static::instantiateRecord($record); }
[ "public", "static", "function", "getByField", "(", "$", "field", ",", "$", "value", ",", "$", "cacheIndex", "=", "false", ")", "{", "$", "record", "=", "static", "::", "getRecordByField", "(", "$", "field", ",", "$", "value", ",", "$", "cacheIndex", ")...
Get model object by field. @param string $field Field name @param string $value Field value @param boolean $cacheIndex Optional. If we should cache the result or not. Default is false. @return static|null
[ "Get", "model", "object", "by", "field", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L862-L867
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getRecordByField
public static function getRecordByField($field, $value, $cacheIndex = false) { $query = 'SELECT * FROM `%s` WHERE `%s` = "%s" LIMIT 1'; $params = [ static::$tableName, static::_cn($field), DB::escape($value), ]; if ($cacheIndex) { $key = sprintf('%s/%s:%s', static::$tableName, $field, $value); return DB::oneRecordCached($key, $query, $params, [static::class,'handleError']); } else { return DB::oneRecord($query, $params, [static::class,'handleError']); } }
php
public static function getRecordByField($field, $value, $cacheIndex = false) { $query = 'SELECT * FROM `%s` WHERE `%s` = "%s" LIMIT 1'; $params = [ static::$tableName, static::_cn($field), DB::escape($value), ]; if ($cacheIndex) { $key = sprintf('%s/%s:%s', static::$tableName, $field, $value); return DB::oneRecordCached($key, $query, $params, [static::class,'handleError']); } else { return DB::oneRecord($query, $params, [static::class,'handleError']); } }
[ "public", "static", "function", "getRecordByField", "(", "$", "field", ",", "$", "value", ",", "$", "cacheIndex", "=", "false", ")", "{", "$", "query", "=", "'SELECT * FROM `%s` WHERE `%s` = \"%s\" LIMIT 1'", ";", "$", "params", "=", "[", "static", "::", "$", ...
Get record by field. @param string $field Field name @param string $value Field value @param boolean $cacheIndex Optional. If we should cache the result or not. Default is false. @return array|null First database result.
[ "Get", "record", "by", "field", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L877-L892
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getRecordByWhere
public static function getRecordByWhere($conditions, $options = []) { if (!is_array($conditions)) { $conditions = [$conditions]; } $options = Util::prepareOptions($options, [ 'order' => false, ]); // initialize conditions and order $conditions = static::_mapConditions($conditions); $order = $options['order'] ? static::_mapFieldOrder($options['order']) : []; return DB::oneRecord( 'SELECT * FROM `%s` WHERE (%s) %s LIMIT 1', [ static::$tableName, join(') AND (', $conditions), $order ? 'ORDER BY '.join(',', $order) : '', ], [static::class,'handleError'] ); }
php
public static function getRecordByWhere($conditions, $options = []) { if (!is_array($conditions)) { $conditions = [$conditions]; } $options = Util::prepareOptions($options, [ 'order' => false, ]); // initialize conditions and order $conditions = static::_mapConditions($conditions); $order = $options['order'] ? static::_mapFieldOrder($options['order']) : []; return DB::oneRecord( 'SELECT * FROM `%s` WHERE (%s) %s LIMIT 1', [ static::$tableName, join(') AND (', $conditions), $order ? 'ORDER BY '.join(',', $order) : '', ], [static::class,'handleError'] ); }
[ "public", "static", "function", "getRecordByWhere", "(", "$", "conditions", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "is_array", "(", "$", "conditions", ")", ")", "{", "$", "conditions", "=", "[", "$", "conditions", "]", ";", "}"...
Get the first result as an array from a simple select query with a where clause you can provide. @param array|string $conditions If passed as a string a database Where clause. If an array of field/value pairs will convert to a series of `field`='value' conditions joined with an AND operator. @param array|string $options Only takes 'order' option. A raw database string that will be inserted into the OR clause of the query or an array of field/direction pairs. @return array|null First database result.
[ "Get", "the", "first", "result", "as", "an", "array", "from", "a", "simple", "select", "query", "with", "a", "where", "clause", "you", "can", "provide", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L915-L940
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getAllByContextObject
public static function getAllByContextObject(ActiveRecord $Record, $options = []) { return static::getAllByContext($Record::$rootClass, $Record->getPrimaryKeyValue(), $options); }
php
public static function getAllByContextObject(ActiveRecord $Record, $options = []) { return static::getAllByContext($Record::$rootClass, $Record->getPrimaryKeyValue(), $options); }
[ "public", "static", "function", "getAllByContextObject", "(", "ActiveRecord", "$", "Record", ",", "$", "options", "=", "[", "]", ")", "{", "return", "static", "::", "getAllByContext", "(", "$", "Record", "::", "$", "rootClass", ",", "$", "Record", "->", "g...
Get all models in the database by passing in an ActiveRecord model which has a 'ContextClass' field by the passed in records primary key. @param ActiveRecord $Record @param array $options @return static[]|null Array of instantiated ActiveRecord models returned from the database result.
[ "Get", "all", "models", "in", "the", "database", "by", "passing", "in", "an", "ActiveRecord", "model", "which", "has", "a", "ContextClass", "field", "by", "the", "passed", "in", "records", "primary", "key", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L973-L976
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.buildExtraColumns
public static function buildExtraColumns($columns) { if (!empty($columns)) { if (is_array($columns)) { foreach ($columns as $key => $value) { return ', '.$value.' AS '.$key; } } else { return ', ' . $columns; } } }
php
public static function buildExtraColumns($columns) { if (!empty($columns)) { if (is_array($columns)) { foreach ($columns as $key => $value) { return ', '.$value.' AS '.$key; } } else { return ', ' . $columns; } } }
[ "public", "static", "function", "buildExtraColumns", "(", "$", "columns", ")", "{", "if", "(", "!", "empty", "(", "$", "columns", ")", ")", "{", "if", "(", "is_array", "(", "$", "columns", ")", ")", "{", "foreach", "(", "$", "columns", "as", "$", "...
Builds the extra columns you might want to add to a database select query after the initial list of model fields. @param array|string $columns An array of keys and values or a string which will be added to a list of fields after the query's SELECT clause. @return string|null Extra columns to add after a SELECT clause in a query. Always starts with a comma.
[ "Builds", "the", "extra", "columns", "you", "might", "want", "to", "add", "to", "a", "database", "select", "query", "after", "the", "initial", "list", "of", "model", "fields", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1026-L1037
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.buildHaving
public static function buildHaving($having) { if (!empty($having)) { return ' HAVING (' . (is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having) . ')'; } }
php
public static function buildHaving($having) { if (!empty($having)) { return ' HAVING (' . (is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having) . ')'; } }
[ "public", "static", "function", "buildHaving", "(", "$", "having", ")", "{", "if", "(", "!", "empty", "(", "$", "having", ")", ")", "{", "return", "' HAVING ('", ".", "(", "is_array", "(", "$", "having", ")", "?", "join", "(", "') AND ('", ",", "stat...
Builds the HAVING clause of a MySQL database query. @param array|string $having Same as conditions. Can provide a string to use or an array of field/value pairs which will be joined by the AND operator. @return string|null
[ "Builds", "the", "HAVING", "clause", "of", "a", "MySQL", "database", "query", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1045-L1050
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getAllRecordsByWhere
public static function getAllRecordsByWhere($conditions = [], $options = []) { $className = get_called_class(); $options = Util::prepareOptions($options, [ 'indexField' => false, 'order' => false, 'limit' => false, 'offset' => 0, 'calcFoundRows' => !empty($options['limit']), 'extraColumns' => false, 'having' => false, ]); // initialize conditions if ($conditions) { if (is_string($conditions)) { $conditions = [$conditions]; } $conditions = static::_mapConditions($conditions); } // build query $query = 'SELECT %1$s `%3$s`.*'; $query .= static::buildExtraColumns($options['extraColumns']); $query .= ' FROM `%2$s` AS `%3$s`'; $query .= ' WHERE (%4$s)'; $query .= static::buildHaving($options['having']); $params = [ $options['calcFoundRows'] ? 'SQL_CALC_FOUND_ROWS' : '', static::$tableName, $className::$rootClass, $conditions ? join(') AND (', $conditions) : '1', ]; if ($options['order']) { $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); } if ($options['limit']) { $query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']); } if ($options['indexField']) { return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class,'handleError']); } else { return DB::allRecords($query, $params, [static::class,'handleError']); } }
php
public static function getAllRecordsByWhere($conditions = [], $options = []) { $className = get_called_class(); $options = Util::prepareOptions($options, [ 'indexField' => false, 'order' => false, 'limit' => false, 'offset' => 0, 'calcFoundRows' => !empty($options['limit']), 'extraColumns' => false, 'having' => false, ]); // initialize conditions if ($conditions) { if (is_string($conditions)) { $conditions = [$conditions]; } $conditions = static::_mapConditions($conditions); } // build query $query = 'SELECT %1$s `%3$s`.*'; $query .= static::buildExtraColumns($options['extraColumns']); $query .= ' FROM `%2$s` AS `%3$s`'; $query .= ' WHERE (%4$s)'; $query .= static::buildHaving($options['having']); $params = [ $options['calcFoundRows'] ? 'SQL_CALC_FOUND_ROWS' : '', static::$tableName, $className::$rootClass, $conditions ? join(') AND (', $conditions) : '1', ]; if ($options['order']) { $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); } if ($options['limit']) { $query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']); } if ($options['indexField']) { return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class,'handleError']); } else { return DB::allRecords($query, $params, [static::class,'handleError']); } }
[ "public", "static", "function", "getAllRecordsByWhere", "(", "$", "conditions", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "className", "=", "get_called_class", "(", ")", ";", "$", "options", "=", "Util", "::", "prepareOptions", "(...
Gets database results as array from a simple select query with a where clause you can provide. @param array|string $conditions If passed as a string a database Where clause. If an array of field/value pairs will convert to a series of `field`='value' conditions joined with an AND operator. @param array|string $options @return array[]|null Array of records from the database result.
[ "Gets", "database", "results", "as", "array", "from", "a", "simple", "select", "query", "with", "a", "where", "clause", "you", "can", "provide", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1059-L1110
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getAllRecords
public static function getAllRecords($options = []) { $options = Util::prepareOptions($options, [ 'indexField' => false, 'order' => false, 'limit' => false, 'calcFoundRows' => false, 'offset' => 0, ]); $query = 'SELECT '.($options['calcFoundRows'] ? 'SQL_CALC_FOUND_ROWS' : '').'* FROM `%s`'; $params = [ static::$tableName, ]; if ($options['order']) { $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); } if ($options['limit']) { $query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']); } if ($options['indexField']) { return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class,'handleError']); } else { return DB::allRecords($query, $params, [static::class,'handleError']); } }
php
public static function getAllRecords($options = []) { $options = Util::prepareOptions($options, [ 'indexField' => false, 'order' => false, 'limit' => false, 'calcFoundRows' => false, 'offset' => 0, ]); $query = 'SELECT '.($options['calcFoundRows'] ? 'SQL_CALC_FOUND_ROWS' : '').'* FROM `%s`'; $params = [ static::$tableName, ]; if ($options['order']) { $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); } if ($options['limit']) { $query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']); } if ($options['indexField']) { return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class,'handleError']); } else { return DB::allRecords($query, $params, [static::class,'handleError']); } }
[ "public", "static", "function", "getAllRecords", "(", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "Util", "::", "prepareOptions", "(", "$", "options", ",", "[", "'indexField'", "=>", "false", ",", "'order'", "=>", "false", ",", "'limit'...
Attempts to get all database records for this class and returns them as is from the database. @param array $options @return array[]|null
[ "Attempts", "to", "get", "all", "database", "records", "for", "this", "class", "and", "returns", "them", "as", "is", "from", "the", "database", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1129-L1157
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.instantiateRecords
public static function instantiateRecords($records) { foreach ($records as &$record) { $className = static::_getRecordClass($record); $record = new $className($record); } return $records; }
php
public static function instantiateRecords($records) { foreach ($records as &$record) { $className = static::_getRecordClass($record); $record = new $className($record); } return $records; }
[ "public", "static", "function", "instantiateRecords", "(", "$", "records", ")", "{", "foreach", "(", "$", "records", "as", "&", "$", "record", ")", "{", "$", "className", "=", "static", "::", "_getRecordClass", "(", "$", "record", ")", ";", "$", "record"...
Converts an array of database records to a model corresponding to each record. Will attempt to use the record's Class field value to as the class to instantiate as or the name of this class if none is provided. @param array $record An array of database rows. @return static|null An array of instantiated ActiveRecord models from the provided data.
[ "Converts", "an", "array", "of", "database", "records", "to", "a", "model", "corresponding", "to", "each", "record", ".", "Will", "attempt", "to", "use", "the", "record", "s", "Class", "field", "value", "to", "as", "the", "class", "to", "instantiate", "as"...
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1195-L1203
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getFieldOptions
public static function getFieldOptions($field, $optionKey = false) { if ($optionKey) { return static::$_classFields[get_called_class()][$field][$optionKey]; } else { return static::$_classFields[get_called_class()][$field]; } }
php
public static function getFieldOptions($field, $optionKey = false) { if ($optionKey) { return static::$_classFields[get_called_class()][$field][$optionKey]; } else { return static::$_classFields[get_called_class()][$field]; } }
[ "public", "static", "function", "getFieldOptions", "(", "$", "field", ",", "$", "optionKey", "=", "false", ")", "{", "if", "(", "$", "optionKey", ")", "{", "return", "static", "::", "$", "_classFields", "[", "get_called_class", "(", ")", "]", "[", "$", ...
Returns either a field option or an array of all the field options. @param string $field Name of the field. @param boolean $optionKey @return void
[ "Returns", "either", "a", "field", "option", "or", "an", "array", "of", "all", "the", "field", "options", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1288-L1295
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getColumnName
public static function getColumnName($field) { static::init(); if (!static::fieldExists($field)) { throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); } return static::$_classFields[get_called_class()][$field]['columnName']; }
php
public static function getColumnName($field) { static::init(); if (!static::fieldExists($field)) { throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); } return static::$_classFields[get_called_class()][$field]['columnName']; }
[ "public", "static", "function", "getColumnName", "(", "$", "field", ")", "{", "static", "::", "init", "(", ")", ";", "if", "(", "!", "static", "::", "fieldExists", "(", "$", "field", ")", ")", "{", "throw", "new", "Exception", "(", "'getColumnName called...
Returns columnName for given field @param string $field name of field @return string column name
[ "Returns", "columnName", "for", "given", "field" ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1302-L1310
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord.getValidationError
public function getValidationError($field) { // break apart path $crumbs = explode('.', $field); // resolve path recursively $cur = &$this->_validationErrors; while ($crumb = array_shift($crumbs)) { if (array_key_exists($crumb, $cur)) { $cur = &$cur[$crumb]; } else { return null; } } // return current value return $cur; }
php
public function getValidationError($field) { // break apart path $crumbs = explode('.', $field); // resolve path recursively $cur = &$this->_validationErrors; while ($crumb = array_shift($crumbs)) { if (array_key_exists($crumb, $cur)) { $cur = &$cur[$crumb]; } else { return null; } } // return current value return $cur; }
[ "public", "function", "getValidationError", "(", "$", "field", ")", "{", "// break apart path", "$", "crumbs", "=", "explode", "(", "'.'", ",", "$", "field", ")", ";", "// resolve path recursively", "$", "cur", "=", "&", "$", "this", "->", "_validationErrors",...
Get a validation error for a given field. @param string $field Name of the field. @return string|null A validation error for the field. Null is no validation error found.
[ "Get", "a", "validation", "error", "for", "a", "given", "field", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1364-L1381
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord._getRecordClass
protected static function _getRecordClass($record) { $static = get_called_class(); if (!static::fieldExists('Class')) { return $static; } $columnName = static::_cn('Class'); if (!empty($record[$columnName]) && is_subclass_of($record[$columnName], $static)) { return $record[$columnName]; } else { return $static; } }
php
protected static function _getRecordClass($record) { $static = get_called_class(); if (!static::fieldExists('Class')) { return $static; } $columnName = static::_cn('Class'); if (!empty($record[$columnName]) && is_subclass_of($record[$columnName], $static)) { return $record[$columnName]; } else { return $static; } }
[ "protected", "static", "function", "_getRecordClass", "(", "$", "record", ")", "{", "$", "static", "=", "get_called_class", "(", ")", ";", "if", "(", "!", "static", "::", "fieldExists", "(", "'Class'", ")", ")", "{", "return", "$", "static", ";", "}", ...
Returns class name for instantiating given record @param array $record record @return string class name
[ "Returns", "class", "name", "for", "instantiating", "given", "record" ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1660-L1675
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord._getFieldValue
protected function _getFieldValue($field, $useDefault = true) { $fieldOptions = static::$_classFields[get_called_class()][$field]; if (isset($this->_record[$fieldOptions['columnName']])) { $value = $this->_record[$fieldOptions['columnName']]; // apply type-dependent transformations switch ($fieldOptions['type']) { case 'password': { return $value; } case 'timestamp': { if (!isset($this->_convertedValues[$field])) { if ($value && $value != '0000-00-00 00:00:00') { $this->_convertedValues[$field] = strtotime($value); } else { $this->_convertedValues[$field] = null; } } return $this->_convertedValues[$field]; } case 'serialized': { if (!isset($this->_convertedValues[$field])) { $this->_convertedValues[$field] = is_string($value) ? unserialize($value) : $value; } return $this->_convertedValues[$field]; } case 'set': case 'list': { if (!isset($this->_convertedValues[$field])) { $delim = empty($fieldOptions['delimiter']) ? ',' : $fieldOptions['delimiter']; $this->_convertedValues[$field] = array_filter(preg_split('/\s*'.$delim.'\s*/', $value)); } return $this->_convertedValues[$field]; } case 'boolean': { if (!isset($this->_convertedValues[$field])) { $this->_convertedValues[$field] = (boolean)$value; } return $this->_convertedValues[$field]; } default: { return $value; } } } elseif ($useDefault && isset($fieldOptions['default'])) { // return default return $fieldOptions['default']; } else { switch ($fieldOptions['type']) { case 'set': case 'list': { return []; } default: { return null; } } } }
php
protected function _getFieldValue($field, $useDefault = true) { $fieldOptions = static::$_classFields[get_called_class()][$field]; if (isset($this->_record[$fieldOptions['columnName']])) { $value = $this->_record[$fieldOptions['columnName']]; // apply type-dependent transformations switch ($fieldOptions['type']) { case 'password': { return $value; } case 'timestamp': { if (!isset($this->_convertedValues[$field])) { if ($value && $value != '0000-00-00 00:00:00') { $this->_convertedValues[$field] = strtotime($value); } else { $this->_convertedValues[$field] = null; } } return $this->_convertedValues[$field]; } case 'serialized': { if (!isset($this->_convertedValues[$field])) { $this->_convertedValues[$field] = is_string($value) ? unserialize($value) : $value; } return $this->_convertedValues[$field]; } case 'set': case 'list': { if (!isset($this->_convertedValues[$field])) { $delim = empty($fieldOptions['delimiter']) ? ',' : $fieldOptions['delimiter']; $this->_convertedValues[$field] = array_filter(preg_split('/\s*'.$delim.'\s*/', $value)); } return $this->_convertedValues[$field]; } case 'boolean': { if (!isset($this->_convertedValues[$field])) { $this->_convertedValues[$field] = (boolean)$value; } return $this->_convertedValues[$field]; } default: { return $value; } } } elseif ($useDefault && isset($fieldOptions['default'])) { // return default return $fieldOptions['default']; } else { switch ($fieldOptions['type']) { case 'set': case 'list': { return []; } default: { return null; } } } }
[ "protected", "function", "_getFieldValue", "(", "$", "field", ",", "$", "useDefault", "=", "true", ")", "{", "$", "fieldOptions", "=", "static", "::", "$", "_classFields", "[", "get_called_class", "(", ")", "]", "[", "$", "field", "]", ";", "if", "(", ...
Retrieves given field's value @param string $field Name of field @return mixed value
[ "Retrieves", "given", "field", "s", "value" ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1693-L1768
train
Divergence/framework
src/Models/ActiveRecord.php
ActiveRecord._setFieldValue
protected function _setFieldValue($field, $value) { // ignore setting versioning fields if (static::isVersioned()) { if (array_key_exists($field, static::$versioningFields)) { return false; } } if (!static::fieldExists($field)) { return false; } $fieldOptions = static::$_classFields[get_called_class()][$field]; // no overriding autoincrements if ($fieldOptions['autoincrement']) { return false; } // pre-process value $forceDirty = false; switch ($fieldOptions['type']) { case 'clob': case 'string': { $value = $this->_setStringValue($fieldOptions, $value); break; } case 'boolean': { $value = $this->_setBooleanValue($value); break; } case 'decimal': { $value = $this->_setDecimalValue($value); break; } case 'int': case 'uint': case 'integer': { $value = $this->_setIntegerValue($fieldOptions, $value); break; } case 'timestamp': { $value = $this->_setTimestampValue($value); break; } case 'date': { $value = $this->_setDateValue($value); break; } // these types are converted to strings from another PHP type on save case 'serialized': { $this->_convertedValues[$field] = $value; $value = $this->_setSerializedValue($value); break; } case 'enum': { $value = $this->_setEnumValue($fieldOptions, $value); break; } case 'set': case 'list': { $value = $this->_setListValue($fieldOptions, $value); $this->_convertedValues[$field] = $value; $forceDirty = true; break; } } if ($forceDirty || (empty($this->_record[$field]) && isset($value)) || ($this->_record[$field] !== $value)) { $columnName = static::_cn($field); if (isset($this->_record[$columnName])) { $this->_originalValues[$field] = $this->_record[$columnName]; } $this->_record[$columnName] = $value; $this->_isDirty = true; // unset invalidated relationships if (!empty($fieldOptions['relationships']) && static::isRelational()) { foreach ($fieldOptions['relationships'] as $relationship => $isCached) { if ($isCached) { unset($this->_relatedObjects[$relationship]); } } } return true; } else { return false; } }
php
protected function _setFieldValue($field, $value) { // ignore setting versioning fields if (static::isVersioned()) { if (array_key_exists($field, static::$versioningFields)) { return false; } } if (!static::fieldExists($field)) { return false; } $fieldOptions = static::$_classFields[get_called_class()][$field]; // no overriding autoincrements if ($fieldOptions['autoincrement']) { return false; } // pre-process value $forceDirty = false; switch ($fieldOptions['type']) { case 'clob': case 'string': { $value = $this->_setStringValue($fieldOptions, $value); break; } case 'boolean': { $value = $this->_setBooleanValue($value); break; } case 'decimal': { $value = $this->_setDecimalValue($value); break; } case 'int': case 'uint': case 'integer': { $value = $this->_setIntegerValue($fieldOptions, $value); break; } case 'timestamp': { $value = $this->_setTimestampValue($value); break; } case 'date': { $value = $this->_setDateValue($value); break; } // these types are converted to strings from another PHP type on save case 'serialized': { $this->_convertedValues[$field] = $value; $value = $this->_setSerializedValue($value); break; } case 'enum': { $value = $this->_setEnumValue($fieldOptions, $value); break; } case 'set': case 'list': { $value = $this->_setListValue($fieldOptions, $value); $this->_convertedValues[$field] = $value; $forceDirty = true; break; } } if ($forceDirty || (empty($this->_record[$field]) && isset($value)) || ($this->_record[$field] !== $value)) { $columnName = static::_cn($field); if (isset($this->_record[$columnName])) { $this->_originalValues[$field] = $this->_record[$columnName]; } $this->_record[$columnName] = $value; $this->_isDirty = true; // unset invalidated relationships if (!empty($fieldOptions['relationships']) && static::isRelational()) { foreach ($fieldOptions['relationships'] as $relationship => $isCached) { if ($isCached) { unset($this->_relatedObjects[$relationship]); } } } return true; } else { return false; } }
[ "protected", "function", "_setFieldValue", "(", "$", "field", ",", "$", "value", ")", "{", "// ignore setting versioning fields", "if", "(", "static", "::", "isVersioned", "(", ")", ")", "{", "if", "(", "array_key_exists", "(", "$", "field", ",", "static", "...
Sets given field's value @param string $field Name of field @param mixed $value New value @return mixed value
[ "Sets", "given", "field", "s", "value" ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/ActiveRecord.php#L1837-L1940
train
agoat/contao-customcontentelements-bundle
src/Resources/contao/models/ElementsModel.php
ElementsModel.findPublishedByAlias
public function findPublishedByAlias($strAlias, array $arrOptions=array()) { $t = static::$strTable; $arrColumns = array("$t.alias=? AND $t.invisible=''"); return static::findOneBy($arrColumns, $strAlias, $arrOptions); }
php
public function findPublishedByAlias($strAlias, array $arrOptions=array()) { $t = static::$strTable; $arrColumns = array("$t.alias=? AND $t.invisible=''"); return static::findOneBy($arrColumns, $strAlias, $arrOptions); }
[ "public", "function", "findPublishedByAlias", "(", "$", "strAlias", ",", "array", "$", "arrOptions", "=", "array", "(", ")", ")", "{", "$", "t", "=", "static", "::", "$", "strTable", ";", "$", "arrColumns", "=", "array", "(", "\"$t.alias=? AND $t.invisible='...
Find published content elements by their alias @param string $strAlias The alias of the content element @param array $arrOptions An optional options array @return \Model|\ElementsModel|null A model or null if there is no content element
[ "Find", "published", "content", "elements", "by", "their", "alias" ]
a74d880d74352d2ed887e13f29115bbc48ad84cc
https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/models/ElementsModel.php#L61-L68
train
IDCI-Consulting/ExtraFormBundle
Form/Event/CollectionEventSubscriber.php
CollectionEventSubscriber.preSubmitData
public function preSubmitData(FormEvent $event) { $form = $event->getForm(); $data = $event->getData(); if (null === $data || '' === $data) { $data = array(); } foreach ($form as $name => $child) { if (!isset($data[$name])) { $form->remove($name); } } }
php
public function preSubmitData(FormEvent $event) { $form = $event->getForm(); $data = $event->getData(); if (null === $data || '' === $data) { $data = array(); } foreach ($form as $name => $child) { if (!isset($data[$name])) { $form->remove($name); } } }
[ "public", "function", "preSubmitData", "(", "FormEvent", "$", "event", ")", "{", "$", "form", "=", "$", "event", "->", "getForm", "(", ")", ";", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";", "if", "(", "null", "===", "$", "data", ...
Pre submit data. @param FormEvent $event
[ "Pre", "submit", "data", "." ]
3481c69fd078754f3d0c5947dd59a5536ed13da0
https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Form/Event/CollectionEventSubscriber.php#L88-L102
train
IDCI-Consulting/ExtraFormBundle
Form/Event/CollectionEventSubscriber.php
CollectionEventSubscriber.buildCollection
public function buildCollection(FormEvent $event, $eventName) { $form = $event->getForm(); for ($i = 0; $i < $this->options['max_items']; ++$i) { $required = $i < $this->options['min_items'] ? true : false; $displayed = $i < $this->options['min_items'] || $this->isDisplayable($event, $i, $eventName); $options = $this->options['options']; $options['required'] = isset($options['required']) ? $options['required'] && $required : $required ; $options['attr'] = array_replace( isset($options['attr']) ? $options['attr'] : array(), array( 'data-collection-id' => $this->options['collection_id'], 'data-display' => $displayed ? 'show' : 'hide', 'data-position' => $i, ) ); if (!$displayed) { self::disableConstraints($options); } $form->add($i, $this->options['type'], $options); $form->get($i)->add('__to_remove', CheckboxType::class, array( 'mapped' => false, 'required' => false, 'data' => !$displayed, 'attr' => array( 'class' => 'idci_collection_item_remove', ), )); } }
php
public function buildCollection(FormEvent $event, $eventName) { $form = $event->getForm(); for ($i = 0; $i < $this->options['max_items']; ++$i) { $required = $i < $this->options['min_items'] ? true : false; $displayed = $i < $this->options['min_items'] || $this->isDisplayable($event, $i, $eventName); $options = $this->options['options']; $options['required'] = isset($options['required']) ? $options['required'] && $required : $required ; $options['attr'] = array_replace( isset($options['attr']) ? $options['attr'] : array(), array( 'data-collection-id' => $this->options['collection_id'], 'data-display' => $displayed ? 'show' : 'hide', 'data-position' => $i, ) ); if (!$displayed) { self::disableConstraints($options); } $form->add($i, $this->options['type'], $options); $form->get($i)->add('__to_remove', CheckboxType::class, array( 'mapped' => false, 'required' => false, 'data' => !$displayed, 'attr' => array( 'class' => 'idci_collection_item_remove', ), )); } }
[ "public", "function", "buildCollection", "(", "FormEvent", "$", "event", ",", "$", "eventName", ")", "{", "$", "form", "=", "$", "event", "->", "getForm", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "opti...
Build collection. @param FormEvent $event @param string $eventName
[ "Build", "collection", "." ]
3481c69fd078754f3d0c5947dd59a5536ed13da0
https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Form/Event/CollectionEventSubscriber.php#L110-L147
train
IDCI-Consulting/ExtraFormBundle
Form/Event/CollectionEventSubscriber.php
CollectionEventSubscriber.changeData
public function changeData(FormEvent $event) { $data = $event->getData(); if (null === $data) { $data = array(); } if ($data instanceof \Doctrine\Common\Collections\Collection) { $event->setData($data->getValues()); } else { $event->setData(array_values($data)); } }
php
public function changeData(FormEvent $event) { $data = $event->getData(); if (null === $data) { $data = array(); } if ($data instanceof \Doctrine\Common\Collections\Collection) { $event->setData($data->getValues()); } else { $event->setData(array_values($data)); } }
[ "public", "function", "changeData", "(", "FormEvent", "$", "event", ")", "{", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";", "if", "(", "null", "===", "$", "data", ")", "{", "$", "data", "=", "array", "(", ")", ";", "}", "if", ...
Change data. @param FormEvent $event
[ "Change", "data", "." ]
3481c69fd078754f3d0c5947dd59a5536ed13da0
https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Form/Event/CollectionEventSubscriber.php#L154-L167
train
IDCI-Consulting/ExtraFormBundle
Form/Event/CollectionEventSubscriber.php
CollectionEventSubscriber.onSubmit
public function onSubmit(FormEvent $event) { $form = $event->getForm(); $data = $event->getData(); if (null === $data) { $data = array(); } if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) { throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)'); } // The data mapper only adds, but does not remove items, so do this here $toDelete = array(); foreach ($data as $name => $child) { if (null === $child || ( $form->get($name)->has('__to_remove') && true === $form->get($name)->get('__to_remove')->getData() )) { $toDelete[] = $name; } } foreach ($toDelete as $name) { unset($data[$name]); } if ($data instanceof \Doctrine\Common\Collections\Collection) { $event->setData($data->getValues()); } else { $event->setData($data); } }
php
public function onSubmit(FormEvent $event) { $form = $event->getForm(); $data = $event->getData(); if (null === $data) { $data = array(); } if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) { throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)'); } // The data mapper only adds, but does not remove items, so do this here $toDelete = array(); foreach ($data as $name => $child) { if (null === $child || ( $form->get($name)->has('__to_remove') && true === $form->get($name)->get('__to_remove')->getData() )) { $toDelete[] = $name; } } foreach ($toDelete as $name) { unset($data[$name]); } if ($data instanceof \Doctrine\Common\Collections\Collection) { $event->setData($data->getValues()); } else { $event->setData($data); } }
[ "public", "function", "onSubmit", "(", "FormEvent", "$", "event", ")", "{", "$", "form", "=", "$", "event", "->", "getForm", "(", ")", ";", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";", "if", "(", "null", "===", "$", "data", ")"...
On submit. @param FormEvent $event
[ "On", "submit", "." ]
3481c69fd078754f3d0c5947dd59a5536ed13da0
https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Form/Event/CollectionEventSubscriber.php#L174-L208
train
IDCI-Consulting/ExtraFormBundle
Form/Event/CollectionEventSubscriber.php
CollectionEventSubscriber.isDisplayable
protected function isDisplayable(FormEvent $event, $i, $eventName) { $form = $event->getForm(); $data = $event->getData(); if (!isset($data[$i])) { return false; } $item = is_object($data[$i]) ? (array) $data[$i] : $data[$i]; if (!is_array($item)) { return true; } if (FormEvents::PRE_SUBMIT === $eventName) { if (isset($item['__to_remove'])) { return !(bool) $item['__to_remove']; } } foreach ($item as $k => $v) { if (FormEvents::PRE_SUBMIT === $eventName && HiddenType::class === get_class($form->get($i)->get($k)->getConfig()->getType()->getInnerType()) ) { continue; } // Value not null if (null !== $v && '' !== $v) { return true; } } return false; }
php
protected function isDisplayable(FormEvent $event, $i, $eventName) { $form = $event->getForm(); $data = $event->getData(); if (!isset($data[$i])) { return false; } $item = is_object($data[$i]) ? (array) $data[$i] : $data[$i]; if (!is_array($item)) { return true; } if (FormEvents::PRE_SUBMIT === $eventName) { if (isset($item['__to_remove'])) { return !(bool) $item['__to_remove']; } } foreach ($item as $k => $v) { if (FormEvents::PRE_SUBMIT === $eventName && HiddenType::class === get_class($form->get($i)->get($k)->getConfig()->getType()->getInnerType()) ) { continue; } // Value not null if (null !== $v && '' !== $v) { return true; } } return false; }
[ "protected", "function", "isDisplayable", "(", "FormEvent", "$", "event", ",", "$", "i", ",", "$", "eventName", ")", "{", "$", "form", "=", "$", "event", "->", "getForm", "(", ")", ";", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";"...
Is displayable. @param FormEvent $event @param int $i @param string $eventName @return bool
[ "Is", "displayable", "." ]
3481c69fd078754f3d0c5947dd59a5536ed13da0
https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Form/Event/CollectionEventSubscriber.php#L219-L254
train
Divergence/framework
src/IO/Database/SQL.php
SQL.getCreateTable
public static function getCreateTable($recordClass, $historyVariant = false) { $indexes = $historyVariant ? [] : $recordClass::$indexes; $fulltextColumns = []; $queryString = []; // history table revisionID field if ($historyVariant) { $queryString[] = '`RevisionID` int(10) unsigned NOT NULL auto_increment'; $queryString[] = 'PRIMARY KEY (`RevisionID`)'; } $queryString = array_merge($queryString, static::compileFields($recordClass, $historyVariant)); if (!$historyVariant) { // If ContextClass && ContextID are members of this model let's index them if ($recordClass::fieldExists('ContextClass') && $recordClass::fieldExists('ContextID')) { $queryString[] = static::getContextIndex($recordClass); } $fulltextColumns = static::getFullTextColumns($recordClass); } // compile indexes foreach ($indexes as $indexName => $index) { // translate field names foreach ($index['fields'] as &$indexField) { $indexField = $recordClass::getColumnName($indexField); } if (!empty($index['fulltext'])) { $fulltextColumns = array_unique(array_merge($fulltextColumns, $index['fields'])); continue; } $queryString[] = sprintf( '%s KEY `%s` (`%s`)', !empty($index['unique']) ? 'UNIQUE' : '', $indexName, join('`,`', $index['fields']) ); } if (!empty($fulltextColumns)) { $queryString[] = 'FULLTEXT KEY `FULLTEXT` (`'.join('`,`', $fulltextColumns).'`)'; } $createSQL = sprintf( "CREATE TABLE IF NOT EXISTS `%s` (\n\t%s\n) ENGINE=MyISAM DEFAULT CHARSET=utf8;", $historyVariant ? $recordClass::getHistoryTable() : $recordClass::$tableName, join("\n\t,", $queryString) ); // append history table SQL if (!$historyVariant && is_subclass_of($recordClass, 'VersionedRecord')) { $createSQL .= PHP_EOL.PHP_EOL.PHP_EOL.static::getCreateTable($recordClass, true); } return $createSQL; }
php
public static function getCreateTable($recordClass, $historyVariant = false) { $indexes = $historyVariant ? [] : $recordClass::$indexes; $fulltextColumns = []; $queryString = []; // history table revisionID field if ($historyVariant) { $queryString[] = '`RevisionID` int(10) unsigned NOT NULL auto_increment'; $queryString[] = 'PRIMARY KEY (`RevisionID`)'; } $queryString = array_merge($queryString, static::compileFields($recordClass, $historyVariant)); if (!$historyVariant) { // If ContextClass && ContextID are members of this model let's index them if ($recordClass::fieldExists('ContextClass') && $recordClass::fieldExists('ContextID')) { $queryString[] = static::getContextIndex($recordClass); } $fulltextColumns = static::getFullTextColumns($recordClass); } // compile indexes foreach ($indexes as $indexName => $index) { // translate field names foreach ($index['fields'] as &$indexField) { $indexField = $recordClass::getColumnName($indexField); } if (!empty($index['fulltext'])) { $fulltextColumns = array_unique(array_merge($fulltextColumns, $index['fields'])); continue; } $queryString[] = sprintf( '%s KEY `%s` (`%s`)', !empty($index['unique']) ? 'UNIQUE' : '', $indexName, join('`,`', $index['fields']) ); } if (!empty($fulltextColumns)) { $queryString[] = 'FULLTEXT KEY `FULLTEXT` (`'.join('`,`', $fulltextColumns).'`)'; } $createSQL = sprintf( "CREATE TABLE IF NOT EXISTS `%s` (\n\t%s\n) ENGINE=MyISAM DEFAULT CHARSET=utf8;", $historyVariant ? $recordClass::getHistoryTable() : $recordClass::$tableName, join("\n\t,", $queryString) ); // append history table SQL if (!$historyVariant && is_subclass_of($recordClass, 'VersionedRecord')) { $createSQL .= PHP_EOL.PHP_EOL.PHP_EOL.static::getCreateTable($recordClass, true); } return $createSQL; }
[ "public", "static", "function", "getCreateTable", "(", "$", "recordClass", ",", "$", "historyVariant", "=", "false", ")", "{", "$", "indexes", "=", "$", "historyVariant", "?", "[", "]", ":", "$", "recordClass", "::", "$", "indexes", ";", "$", "fulltextColu...
Generates a MySQL create table query from a Divergence\Models\ActiveRecord class. @param string $recordClass Class name @param boolean $historyVariant @return void
[ "Generates", "a", "MySQL", "create", "table", "query", "from", "a", "Divergence", "\\", "Models", "\\", "ActiveRecord", "class", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/SQL.php#L103-L164
train
amphp/cluster
src/Watcher.php
Watcher.stop
public function stop() { if (!$this->running) { return; } $this->running = false; $promise = call(function () { $promises = []; foreach (clone $this->workers as $worker) { \assert($worker instanceof Internal\IpcParent); $promises[] = call(function () use ($worker) { list($process, $promise) = $this->workers[$worker]; \assert($process instanceof Process); try { yield $worker->shutdown(); yield Promise\timeout($promise, self::WORKER_TIMEOUT); } catch (ContextException $exception) { // Ignore if the worker has already died unexpectedly. } finally { if ($process->isRunning()) { $process->kill(); } } }); } list($exceptions) = yield Promise\any($promises); $this->workers = new \SplObjectStorage; if (!empty($exceptions)) { $exception = new MultiReasonException($exceptions); $message = \implode('; ', \array_map(function (\Throwable $exception): string { return $exception->getMessage(); }, $exceptions)); throw new ClusterException("Stopping the cluster failed: " . $message, 0, $exception); } }); $this->deferred->resolve($promise); }
php
public function stop() { if (!$this->running) { return; } $this->running = false; $promise = call(function () { $promises = []; foreach (clone $this->workers as $worker) { \assert($worker instanceof Internal\IpcParent); $promises[] = call(function () use ($worker) { list($process, $promise) = $this->workers[$worker]; \assert($process instanceof Process); try { yield $worker->shutdown(); yield Promise\timeout($promise, self::WORKER_TIMEOUT); } catch (ContextException $exception) { // Ignore if the worker has already died unexpectedly. } finally { if ($process->isRunning()) { $process->kill(); } } }); } list($exceptions) = yield Promise\any($promises); $this->workers = new \SplObjectStorage; if (!empty($exceptions)) { $exception = new MultiReasonException($exceptions); $message = \implode('; ', \array_map(function (\Throwable $exception): string { return $exception->getMessage(); }, $exceptions)); throw new ClusterException("Stopping the cluster failed: " . $message, 0, $exception); } }); $this->deferred->resolve($promise); }
[ "public", "function", "stop", "(", ")", "{", "if", "(", "!", "$", "this", "->", "running", ")", "{", "return", ";", "}", "$", "this", "->", "running", "=", "false", ";", "$", "promise", "=", "call", "(", "function", "(", ")", "{", "$", "promises"...
Stops the cluster.
[ "Stops", "the", "cluster", "." ]
33e7b71902ce85c221d4d3d35d4bd879af052686
https://github.com/amphp/cluster/blob/33e7b71902ce85c221d4d3d35d4bd879af052686/src/Watcher.php#L276-L319
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.escape
public static function escape($data) { if (is_string($data)) { $data = static::getConnection()->quote($data); $data = substr($data, 1, strlen($data)-2); return $data; } elseif (is_array($data)) { foreach ($data as $key=>$string) { if (is_string($string)) { $data[$key] = static::escape($string); } } return $data; } return $data; }
php
public static function escape($data) { if (is_string($data)) { $data = static::getConnection()->quote($data); $data = substr($data, 1, strlen($data)-2); return $data; } elseif (is_array($data)) { foreach ($data as $key=>$string) { if (is_string($string)) { $data[$key] = static::escape($string); } } return $data; } return $data; }
[ "public", "static", "function", "escape", "(", "$", "data", ")", "{", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "$", "data", "=", "static", "::", "getConnection", "(", ")", "->", "quote", "(", "$", "data", ")", ";", "$", "data", "=...
Recursive escape for strings or arrays of strings. @param mixed $data If string will do a simple escape. If array will iterate over array members recursively and escape any found strings. @return mixed Same as $data input but with all found strings escaped in place.
[ "Recursive", "escape", "for", "strings", "or", "arrays", "of", "strings", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L181-L196
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.allRecords
public static function allRecords($query, $parameters = [], $errorHandler = null) { // execute query $result = static::query($query, $parameters, $errorHandler); $records = []; while ($record = $result->fetch(PDO::FETCH_ASSOC)) { $records[] = $record; } return $records; }
php
public static function allRecords($query, $parameters = [], $errorHandler = null) { // execute query $result = static::query($query, $parameters, $errorHandler); $records = []; while ($record = $result->fetch(PDO::FETCH_ASSOC)) { $records[] = $record; } return $records; }
[ "public", "static", "function", "allRecords", "(", "$", "query", ",", "$", "parameters", "=", "[", "]", ",", "$", "errorHandler", "=", "null", ")", "{", "// execute query", "$", "result", "=", "static", "::", "query", "(", "$", "query", ",", "$", "para...
Runs a query and returns all results as an associative array. @param string $query A MySQL query @param array|string $parameters Optional parameters for vsprintf (array) or sprintf (string) to use for formatting the query. @param callable $errorHandler A callback that will run in the event of an error instead of static::handleError @return array Result from query or an empty array if nothing found.
[ "Runs", "a", "query", "and", "returns", "all", "results", "as", "an", "associative", "array", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L365-L376
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.allValues
public static function allValues($valueKey, $query, $parameters = [], $errorHandler = null) { // execute query $result = static::query($query, $parameters, $errorHandler); $records = []; while ($record = $result->fetch(PDO::FETCH_ASSOC)) { $records[] = $record[$valueKey]; } return $records; }
php
public static function allValues($valueKey, $query, $parameters = [], $errorHandler = null) { // execute query $result = static::query($query, $parameters, $errorHandler); $records = []; while ($record = $result->fetch(PDO::FETCH_ASSOC)) { $records[] = $record[$valueKey]; } return $records; }
[ "public", "static", "function", "allValues", "(", "$", "valueKey", ",", "$", "query", ",", "$", "parameters", "=", "[", "]", ",", "$", "errorHandler", "=", "null", ")", "{", "// execute query", "$", "result", "=", "static", "::", "query", "(", "$", "qu...
Gets you some column from every record. @param string $valueKey The name of the column you want. @param string $query A MySQL query @param array|string $parameters Optional parameters for vsprintf (array) or sprintf (string) to use for formatting the query. @param callable $errorHandler A callback that will run in the event of an error instead of static::handleError @return array The column provided in $valueKey from each found record combined as an array. Will be an empty array if no records are found.
[ "Gets", "you", "some", "column", "from", "every", "record", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L388-L399
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.oneRecordCached
public static function oneRecordCached($cacheKey, $query, $parameters = [], $errorHandler = null) { // check for cached record if (array_key_exists($cacheKey, static::$_record_cache)) { // return cache hit return static::$_record_cache[$cacheKey]; } // preprocess and execute query $result = static::query($query, $parameters, $errorHandler); // get record $record = $result->fetch(PDO::FETCH_ASSOC); // save record to cache if ($cacheKey) { static::$_record_cache[$cacheKey] = $record; } // return record return $record; }
php
public static function oneRecordCached($cacheKey, $query, $parameters = [], $errorHandler = null) { // check for cached record if (array_key_exists($cacheKey, static::$_record_cache)) { // return cache hit return static::$_record_cache[$cacheKey]; } // preprocess and execute query $result = static::query($query, $parameters, $errorHandler); // get record $record = $result->fetch(PDO::FETCH_ASSOC); // save record to cache if ($cacheKey) { static::$_record_cache[$cacheKey] = $record; } // return record return $record; }
[ "public", "static", "function", "oneRecordCached", "(", "$", "cacheKey", ",", "$", "query", ",", "$", "parameters", "=", "[", "]", ",", "$", "errorHandler", "=", "null", ")", "{", "// check for cached record", "if", "(", "array_key_exists", "(", "$", "cacheK...
Returns the first database record from a query with caching It is recommended that you LIMIT 1 any records you want out of this to avoid having the database doing any work. @param string $cacheKey A key for the cache to use for this query. If the key is found in the existing cache will return that instead of running the query. @param string $query A MySQL query @param array|string $parameters Optional parameters for vsprintf (array) or sprintf (string) to use for formatting the query. @param callable $errorHandler A callback that will run in the event of an error instead of static::handleError @return array Result from query or an empty array if nothing found. @uses static::$_record_cache
[ "Returns", "the", "first", "database", "record", "from", "a", "query", "with", "caching" ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L427-L449
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.oneRecord
public static function oneRecord($query, $parameters = [], $errorHandler = null) { // preprocess and execute query $result = static::query($query, $parameters, $errorHandler); // get record $record = $result->fetch(PDO::FETCH_ASSOC); // return record return $record; }
php
public static function oneRecord($query, $parameters = [], $errorHandler = null) { // preprocess and execute query $result = static::query($query, $parameters, $errorHandler); // get record $record = $result->fetch(PDO::FETCH_ASSOC); // return record return $record; }
[ "public", "static", "function", "oneRecord", "(", "$", "query", ",", "$", "parameters", "=", "[", "]", ",", "$", "errorHandler", "=", "null", ")", "{", "// preprocess and execute query", "$", "result", "=", "static", "::", "query", "(", "$", "query", ",", ...
Returns the first database record from a query. It is recommended that you LIMIT 1 any records you want out of this to avoid having the database doing any work. @param string $query A MySQL query @param array|string $parameters Optional parameters for vsprintf (array) or sprintf (string) to use for formatting the query. @param callable $errorHandler A callback that will run in the event of an error instead of static::handleError @return array Result from query or an empty array if nothing found.
[ "Returns", "the", "first", "database", "record", "from", "a", "query", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L462-L472
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.oneValue
public static function oneValue($query, $parameters = [], $errorHandler = null) { // get the first record $record = static::oneRecord($query, $parameters, $errorHandler); if ($record) { // return first value of the record return array_shift($record); } else { return false; } }
php
public static function oneValue($query, $parameters = [], $errorHandler = null) { // get the first record $record = static::oneRecord($query, $parameters, $errorHandler); if ($record) { // return first value of the record return array_shift($record); } else { return false; } }
[ "public", "static", "function", "oneValue", "(", "$", "query", ",", "$", "parameters", "=", "[", "]", ",", "$", "errorHandler", "=", "null", ")", "{", "// get the first record", "$", "record", "=", "static", "::", "oneRecord", "(", "$", "query", ",", "$"...
Returns the first value of the first database record from a query. @param string $query A MySQL query @param array|string $parameters Optional parameters for vsprintf (array) or sprintf (string) to use for formatting the query. @param callable $errorHandler A callback that will run in the event of an error instead of static::handleError @return string|false First field from the first record from a query or false if nothing found.
[ "Returns", "the", "first", "value", "of", "the", "first", "database", "record", "from", "a", "query", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L482-L493
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.handleError
public static function handleError($query = '', $queryLog = false, $errorHandler = null) { if (is_callable($errorHandler, false, $callable)) { return call_user_func($errorHandler, $query, $queryLog); } // save queryLog if ($queryLog) { $error = static::getConnection()->errorInfo(); $queryLog['error'] = $error[2]; static::finishQueryLog($queryLog); } // get error message $error = static::getConnection()->errorInfo(); $message = $error[2]; if (App::$Config['environment']=='dev') { $Handler = \Divergence\App::$whoops->popHandler(); $Handler->addDataTable("Query Information", [ 'Query' => $query, 'Error' => $message, 'ErrorCode' => static::getConnection()->errorCode(), ]); \Divergence\App::$whoops->pushHandler($Handler); throw new \RuntimeException("Database error!"); } else { throw new \RuntimeException("Database error!"); } }
php
public static function handleError($query = '', $queryLog = false, $errorHandler = null) { if (is_callable($errorHandler, false, $callable)) { return call_user_func($errorHandler, $query, $queryLog); } // save queryLog if ($queryLog) { $error = static::getConnection()->errorInfo(); $queryLog['error'] = $error[2]; static::finishQueryLog($queryLog); } // get error message $error = static::getConnection()->errorInfo(); $message = $error[2]; if (App::$Config['environment']=='dev') { $Handler = \Divergence\App::$whoops->popHandler(); $Handler->addDataTable("Query Information", [ 'Query' => $query, 'Error' => $message, 'ErrorCode' => static::getConnection()->errorCode(), ]); \Divergence\App::$whoops->pushHandler($Handler); throw new \RuntimeException("Database error!"); } else { throw new \RuntimeException("Database error!"); } }
[ "public", "static", "function", "handleError", "(", "$", "query", "=", "''", ",", "$", "queryLog", "=", "false", ",", "$", "errorHandler", "=", "null", ")", "{", "if", "(", "is_callable", "(", "$", "errorHandler", ",", "false", ",", "$", "callable", ")...
Handles any errors that are thrown by PDO If App::$Config['environment'] is 'dev' this method will attempt to hook into whoops and provide it with information about this query. @throws \RuntimeException Database error! @param string $query The query which caused the error. @param boolean|array $queryLog An array created by startQueryLog containing logging information about this query. @param callable $errorHandler An array handler to use instead of this one. If you pass this in it will run first and return directly. @return void|mixed If $errorHandler is set to a callable it will try to run it and return anything that it returns. Otherwise void
[ "Handles", "any", "errors", "that", "are", "thrown", "by", "PDO" ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L507-L539
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.preprocessQuery
protected static function preprocessQuery($query, $parameters = []) { if (is_array($parameters) && count($parameters)) { return vsprintf($query, $parameters); } else { if (isset($parameters)) { return sprintf($query, $parameters); } else { return $query; } } }
php
protected static function preprocessQuery($query, $parameters = []) { if (is_array($parameters) && count($parameters)) { return vsprintf($query, $parameters); } else { if (isset($parameters)) { return sprintf($query, $parameters); } else { return $query; } } }
[ "protected", "static", "function", "preprocessQuery", "(", "$", "query", ",", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "parameters", ")", "&&", "count", "(", "$", "parameters", ")", ")", "{", "return", "vsprintf", "(...
Formats a query with vsprintf if you pass an array and sprintf if you pass a string. @param string $query A database query. @param array|string $parameters Parameter(s) for vsprintf (array) or sprintf (string) @return string A formatted query.
[ "Formats", "a", "query", "with", "vsprintf", "if", "you", "pass", "an", "array", "and", "sprintf", "if", "you", "pass", "a", "string", "." ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L548-L559
train
Divergence/framework
src/IO/Database/MySQL.php
MySQL.finishQueryLog
protected static function finishQueryLog(&$queryLog, $result = false) { if ($queryLog == false) { return false; } // save finish time and number of affected rows $queryLog['time_finish'] = sprintf('%f', microtime(true)); $queryLog['time_duration_ms'] = ($queryLog['time_finish'] - $queryLog['time_start']) * 1000; // save result information if ($result) { $queryLog['result_fields'] = $result->field_count; $queryLog['result_rows'] = $result->num_rows; } // build backtrace string // TODO: figure out a nice toString option that isn't too bulky //$queryLog['backtrace'] = debug_backtrace(); // monolog here }
php
protected static function finishQueryLog(&$queryLog, $result = false) { if ($queryLog == false) { return false; } // save finish time and number of affected rows $queryLog['time_finish'] = sprintf('%f', microtime(true)); $queryLog['time_duration_ms'] = ($queryLog['time_finish'] - $queryLog['time_start']) * 1000; // save result information if ($result) { $queryLog['result_fields'] = $result->field_count; $queryLog['result_rows'] = $result->num_rows; } // build backtrace string // TODO: figure out a nice toString option that isn't too bulky //$queryLog['backtrace'] = debug_backtrace(); // monolog here }
[ "protected", "static", "function", "finishQueryLog", "(", "&", "$", "queryLog", ",", "$", "result", "=", "false", ")", "{", "if", "(", "$", "queryLog", "==", "false", ")", "{", "return", "false", ";", "}", "// save finish time and number of affected rows", "$"...
Uses the log array created by startQueryLog and sets 'time_finish' on it as well as 'time_duration_ms' If a PDO result is passed it will also set 'result_fields' and 'result_rows' on the passed in array. Probably gonna remove this entirely. Query logging should be done via services like New Relic. @param array|false $queryLog Passed by reference. The query log array created by startQueryLog @param object|false $result The result from @return void|false
[ "Uses", "the", "log", "array", "created", "by", "startQueryLog", "and", "sets", "time_finish", "on", "it", "as", "well", "as", "time_duration_ms" ]
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/IO/Database/MySQL.php#L590-L611
train
1ma/Psr7Hmac
src/Internal/RequestSerializer.php
RequestSerializer.serialize
public static function serialize(RequestInterface $request): string { return self::requestLine($request).self::headers($request).$request->getBody(); }
php
public static function serialize(RequestInterface $request): string { return self::requestLine($request).self::headers($request).$request->getBody(); }
[ "public", "static", "function", "serialize", "(", "RequestInterface", "$", "request", ")", ":", "string", "{", "return", "self", "::", "requestLine", "(", "$", "request", ")", ".", "self", "::", "headers", "(", "$", "request", ")", ".", "$", "request", "...
Returns the string representation of an HTTP request. @param RequestInterface $request Request to convert to a string. @return string
[ "Returns", "the", "string", "representation", "of", "an", "HTTP", "request", "." ]
0d0681e02d1a684f4a54a55684a44aa75ce9d807
https://github.com/1ma/Psr7Hmac/blob/0d0681e02d1a684f4a54a55684a44aa75ce9d807/src/Internal/RequestSerializer.php#L20-L23
train
AXN-Informatique/laravel-models-generator
src/Relations/BelongsTo.php
BelongsTo.getContent
public function getContent() { return strtr($this->getRelationStubContent(), [ '{{name}}' => $this->name, '{{relatedTable}}' => $this->relatedModel->getTable(), '{{relatedModel}}' => $this->relatedModel->getClass(), '{{foreignKey}}' => $this->foreignKey, ]); }
php
public function getContent() { return strtr($this->getRelationStubContent(), [ '{{name}}' => $this->name, '{{relatedTable}}' => $this->relatedModel->getTable(), '{{relatedModel}}' => $this->relatedModel->getClass(), '{{foreignKey}}' => $this->foreignKey, ]); }
[ "public", "function", "getContent", "(", ")", "{", "return", "strtr", "(", "$", "this", "->", "getRelationStubContent", "(", ")", ",", "[", "'{{name}}'", "=>", "$", "this", "->", "name", ",", "'{{relatedTable}}'", "=>", "$", "this", "->", "relatedModel", "...
Retourne le contenu de la relation. @return string
[ "Retourne", "le", "contenu", "de", "la", "relation", "." ]
f3f185b1274afff91885033e630b133e089bcc56
https://github.com/AXN-Informatique/laravel-models-generator/blob/f3f185b1274afff91885033e630b133e089bcc56/src/Relations/BelongsTo.php#L48-L56
train
AltThree/Throttle
src/ThrottlingMiddleware.php
ThrottlingMiddleware.safeHandle
protected function safeHandle(Request $request, Closure $next, int $limit, $decay, bool $global, bool $headers) { if ($this->shouldPassThrough($request)) { return $next($request); } $key = $global ? sha1($request->ip()) : $request->fingerprint(); if ($this->limiter->tooManyAttempts($key, $limit, $decay)) { throw $this->buildException($key, $limit, $headers); } $this->limiter->hit($key, $decay); $response = $next($request); $response->headers->add($this->getHeaders($key, $limit, $headers)); return $response; }
php
protected function safeHandle(Request $request, Closure $next, int $limit, $decay, bool $global, bool $headers) { if ($this->shouldPassThrough($request)) { return $next($request); } $key = $global ? sha1($request->ip()) : $request->fingerprint(); if ($this->limiter->tooManyAttempts($key, $limit, $decay)) { throw $this->buildException($key, $limit, $headers); } $this->limiter->hit($key, $decay); $response = $next($request); $response->headers->add($this->getHeaders($key, $limit, $headers)); return $response; }
[ "protected", "function", "safeHandle", "(", "Request", "$", "request", ",", "Closure", "$", "next", ",", "int", "$", "limit", ",", "$", "decay", ",", "bool", "$", "global", ",", "bool", "$", "headers", ")", "{", "if", "(", "$", "this", "->", "shouldP...
Handle an incoming request, with correct types. @param \Illuminate\Http\Request $request @param \Closure $next @param int $limit @param int|float $decay @param bool $global @param bool $headers @throws \AltThree\Throttle\ThrottlingException @return mixed
[ "Handle", "an", "incoming", "request", "with", "correct", "types", "." ]
a735f88b8129bad4e9433d7dc7574ef495b17712
https://github.com/AltThree/Throttle/blob/a735f88b8129bad4e9433d7dc7574ef495b17712/src/ThrottlingMiddleware.php#L93-L112
train
Divergence/framework
src/Controllers/RecordsRequestHandler.php
RecordsRequestHandler.handleRequest
public static function handleRequest() { // save static class static::$calledClass = get_called_class(); // handle JSON requests if (static::peekPath() == 'json') { // check access for API response modes static::$responseMode = static::shiftPath(); if (in_array(static::$responseMode, ['json','jsonp'])) { if (!static::checkAPIAccess()) { return static::throwAPIUnAuthorizedError(); } } } return static::handleRecordsRequest(); }
php
public static function handleRequest() { // save static class static::$calledClass = get_called_class(); // handle JSON requests if (static::peekPath() == 'json') { // check access for API response modes static::$responseMode = static::shiftPath(); if (in_array(static::$responseMode, ['json','jsonp'])) { if (!static::checkAPIAccess()) { return static::throwAPIUnAuthorizedError(); } } } return static::handleRecordsRequest(); }
[ "public", "static", "function", "handleRequest", "(", ")", "{", "// save static class", "static", "::", "$", "calledClass", "=", "get_called_class", "(", ")", ";", "// handle JSON requests", "if", "(", "static", "::", "peekPath", "(", ")", "==", "'json'", ")", ...
Start of routing for this controller. Methods in this execution path will always respond either as an error or a normal response. Responsible for detecting JSON or JSONP response modes. @return void
[ "Start", "of", "routing", "for", "this", "controller", ".", "Methods", "in", "this", "execution", "path", "will", "always", "respond", "either", "as", "an", "error", "or", "a", "normal", "response", ".", "Responsible", "for", "detecting", "JSON", "or", "JSON...
daaf78aa4b10ad59bf52b9e31480c748ad82e8c3
https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Controllers/RecordsRequestHandler.php#L55-L72
train
agoat/contao-customcontentelements-bundle
src/Resources/contao/classes/Controller.php
Controller.addContentElementsCSS
public function addContentElementsCSS ($strBuffer='', $objTemplate=null) { foreach (array('CSS', 'SCSS' , 'LESS') as $strType) { if ($GLOBALS['TL_CTB_' . $strType] == '') { continue; } $strKey = substr(md5($strType . $GLOBALS['TL_CTB_CSS'] . $GLOBALS['TL_CTB_SCSS'] . $GLOBALS['TL_CTB_LESS']), 0, 12); $strPath = 'assets/css/' . $strKey . '.' . strtolower($strType); // Write to a temporary file in the assets folder if (!file_exists($strPath)) { $objFile = new File($strPath, true); $objFile->write($GLOBALS['TL_CTB_' . $strType]); $objFile->close(); } $strPath .= '|static'; // add file path to TL_USER_CSS $GLOBALS['TL_USER_CSS'][] = $strPath; } return $strBuffer; }
php
public function addContentElementsCSS ($strBuffer='', $objTemplate=null) { foreach (array('CSS', 'SCSS' , 'LESS') as $strType) { if ($GLOBALS['TL_CTB_' . $strType] == '') { continue; } $strKey = substr(md5($strType . $GLOBALS['TL_CTB_CSS'] . $GLOBALS['TL_CTB_SCSS'] . $GLOBALS['TL_CTB_LESS']), 0, 12); $strPath = 'assets/css/' . $strKey . '.' . strtolower($strType); // Write to a temporary file in the assets folder if (!file_exists($strPath)) { $objFile = new File($strPath, true); $objFile->write($GLOBALS['TL_CTB_' . $strType]); $objFile->close(); } $strPath .= '|static'; // add file path to TL_USER_CSS $GLOBALS['TL_USER_CSS'][] = $strPath; } return $strBuffer; }
[ "public", "function", "addContentElementsCSS", "(", "$", "strBuffer", "=", "''", ",", "$", "objTemplate", "=", "null", ")", "{", "foreach", "(", "array", "(", "'CSS'", ",", "'SCSS'", ",", "'LESS'", ")", "as", "$", "strType", ")", "{", "if", "(", "$", ...
Adds CSS created in content elements templates to the TL_USER_CSS global @param string $strBuffer @param Template $objTemplate @return string
[ "Adds", "CSS", "created", "in", "content", "elements", "templates", "to", "the", "TL_USER_CSS", "global" ]
a74d880d74352d2ed887e13f29115bbc48ad84cc
https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Controller.php#L158-L185
train
agoat/contao-customcontentelements-bundle
src/Resources/contao/classes/Controller.php
Controller.addContentElementsJS
public function addContentElementsJS ($strBuffer='', $objTemplate=null) { if ($GLOBALS['TL_CTB_JS'] == '') { return $strBuffer; } $strKey = substr(md5('js' . $GLOBALS['TL_CTB_JS']), 0, 12); $strPath = 'assets/js/' . $strKey . '.js'; // Write to a temporary file in the assets folder if (!file_exists($strPath)) { $objFile = new File($strPath, true); $objFile->write($GLOBALS['TL_CTB_JS']); $objFile->close(); } $strPath .= '|static'; // add file path to TL_JAVASCRIPT $GLOBALS['TL_JAVASCRIPT'][] = $strPath; return $strBuffer; }
php
public function addContentElementsJS ($strBuffer='', $objTemplate=null) { if ($GLOBALS['TL_CTB_JS'] == '') { return $strBuffer; } $strKey = substr(md5('js' . $GLOBALS['TL_CTB_JS']), 0, 12); $strPath = 'assets/js/' . $strKey . '.js'; // Write to a temporary file in the assets folder if (!file_exists($strPath)) { $objFile = new File($strPath, true); $objFile->write($GLOBALS['TL_CTB_JS']); $objFile->close(); } $strPath .= '|static'; // add file path to TL_JAVASCRIPT $GLOBALS['TL_JAVASCRIPT'][] = $strPath; return $strBuffer; }
[ "public", "function", "addContentElementsJS", "(", "$", "strBuffer", "=", "''", ",", "$", "objTemplate", "=", "null", ")", "{", "if", "(", "$", "GLOBALS", "[", "'TL_CTB_JS'", "]", "==", "''", ")", "{", "return", "$", "strBuffer", ";", "}", "$", "strKey...
Adds Javascript created in content elements templates to the TL_JAVASCRIPT global @param string $strBuffer @param Template $objTemplate @return string
[ "Adds", "Javascript", "created", "in", "content", "elements", "templates", "to", "the", "TL_JAVASCRIPT", "global" ]
a74d880d74352d2ed887e13f29115bbc48ad84cc
https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Controller.php#L196-L220
train
agoat/contao-customcontentelements-bundle
src/Resources/contao/classes/Controller.php
Controller.registerBlockElements
public function registerBlockElements () { // Don´t register twice if (isset($GLOBALS['TL_CTE']['CTE'])) { return; } $db = \Database::getInstance(); if ($db->tableExists("tl_elements")) { $arrElements = $db->prepare("SELECT * FROM tl_elements ORDER BY sorting ASC") ->execute() ->fetchAllAssoc(); } if ($arrElements === null) { return; } // Add content blocks as content elements foreach ($arrElements as $arrElement) { $GLOBALS['TL_CTE']['CTE'][$arrElement['alias']] = 'Agoat\CustomContentElementsBundle\Contao\ContentElement'; $GLOBALS['TL_LANG']['CTE'][$arrElement['alias']] = array($arrElement['title'],$arrElement['description']); } }
php
public function registerBlockElements () { // Don´t register twice if (isset($GLOBALS['TL_CTE']['CTE'])) { return; } $db = \Database::getInstance(); if ($db->tableExists("tl_elements")) { $arrElements = $db->prepare("SELECT * FROM tl_elements ORDER BY sorting ASC") ->execute() ->fetchAllAssoc(); } if ($arrElements === null) { return; } // Add content blocks as content elements foreach ($arrElements as $arrElement) { $GLOBALS['TL_CTE']['CTE'][$arrElement['alias']] = 'Agoat\CustomContentElementsBundle\Contao\ContentElement'; $GLOBALS['TL_LANG']['CTE'][$arrElement['alias']] = array($arrElement['title'],$arrElement['description']); } }
[ "public", "function", "registerBlockElements", "(", ")", "{", "// Don´t register twice", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'TL_CTE'", "]", "[", "'CTE'", "]", ")", ")", "{", "return", ";", "}", "$", "db", "=", "\\", "Database", "::", "getInst...
Adds the content elements from the database to the config array
[ "Adds", "the", "content", "elements", "from", "the", "database", "to", "the", "config", "array" ]
a74d880d74352d2ed887e13f29115bbc48ad84cc
https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Controller.php#L226-L254
train
agoat/contao-customcontentelements-bundle
src/Resources/contao/classes/Controller.php
Controller.getRootPageId
public static function getRootPageId ($strTable, $intId) { if ($strTable == 'tl_article') { $objArticle = \ArticleModel::findById($intId); if ($objArticle === null) { return null; } $objPage = \PageModel::findWithDetails($objArticle->pid); if ($objPage === null) { return null; } return $objPage->rootId; } elseif($strTable == 'tl_news') { $objNews = \NewsModel::findById($intId); if ($objNews === null) { return null; } $objPage = \PageModel::findWithDetails($objNews->getRelated('pid')->jumpTo); if ($objPage === null) { return null; } return $objPage->rootId; } else { // HOOK: custom method to discover the layout id if (isset($GLOBALS['TL_HOOKS']['getRootPageId']) && is_array($GLOBALS['TL_HOOKS']['getRootPageId'])) { foreach ($GLOBALS['TL_HOOKS']['getRootPageId'] as $callback) { //$this->import($callback[0]); $rootId = static::importStatic($callback[0])->{$callback[1]}($strTable, $intId); if (rootId) { return $rootId; } } } } return null; }
php
public static function getRootPageId ($strTable, $intId) { if ($strTable == 'tl_article') { $objArticle = \ArticleModel::findById($intId); if ($objArticle === null) { return null; } $objPage = \PageModel::findWithDetails($objArticle->pid); if ($objPage === null) { return null; } return $objPage->rootId; } elseif($strTable == 'tl_news') { $objNews = \NewsModel::findById($intId); if ($objNews === null) { return null; } $objPage = \PageModel::findWithDetails($objNews->getRelated('pid')->jumpTo); if ($objPage === null) { return null; } return $objPage->rootId; } else { // HOOK: custom method to discover the layout id if (isset($GLOBALS['TL_HOOKS']['getRootPageId']) && is_array($GLOBALS['TL_HOOKS']['getRootPageId'])) { foreach ($GLOBALS['TL_HOOKS']['getRootPageId'] as $callback) { //$this->import($callback[0]); $rootId = static::importStatic($callback[0])->{$callback[1]}($strTable, $intId); if (rootId) { return $rootId; } } } } return null; }
[ "public", "static", "function", "getRootPageId", "(", "$", "strTable", ",", "$", "intId", ")", "{", "if", "(", "$", "strTable", "==", "'tl_article'", ")", "{", "$", "objArticle", "=", "\\", "ArticleModel", "::", "findById", "(", "$", "intId", ")", ";", ...
Resolve the rootpage ID from table and id @param string $strTable The name of the table (article or news) @param integer $intId An article or a news article ID @return integer The theme ID
[ "Resolve", "the", "rootpage", "ID", "from", "table", "and", "id" ]
a74d880d74352d2ed887e13f29115bbc48ad84cc
https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Controller.php#L265-L324
train
agoat/contao-customcontentelements-bundle
src/Resources/contao/classes/Controller.php
Controller.addBackendCSS
private static function addBackendCSS($objLayout) { $arrCSS = \StringUtil::deserialize($objLayout->backendCSS); if (!empty($arrCSS) && is_array($arrCSS)) { // Consider the sorting order (see #5038) if ($objLayout->orderBackendCSS != '') { $tmp = \StringUtil::deserialize($objLayout->orderBackendCSS); if (!empty($tmp) && is_array($tmp)) { // Remove all values $arrOrder = array_map(function(){}, array_flip($tmp)); // Move the matching elements to their position in $arrOrder foreach ($arrCSS as $k=>$v) { if (array_key_exists($v, $arrOrder)) { $arrOrder[$v] = $v; unset($arrCSS[$k]); } } // Append the left-over style sheets at the end if (!empty($arrCSS)) { $arrOrder = array_merge($arrOrder, array_values($arrCSS)); } // Remove empty (unreplaced) entries $arrCSS = array_values(array_filter($arrOrder)); unset($arrOrder); } } // Get the file entries from the database $objFiles = \FilesModel::findMultipleByUuids($arrCSS); if ($objFiles !== null) { while ($objFiles->next()) { if (file_exists(TL_ROOT . '/' . $objFiles->path)) { $GLOBALS['TL_USER_CSS'][] = $objFiles->path . '|static'; } } } unset($objFiles); } }
php
private static function addBackendCSS($objLayout) { $arrCSS = \StringUtil::deserialize($objLayout->backendCSS); if (!empty($arrCSS) && is_array($arrCSS)) { // Consider the sorting order (see #5038) if ($objLayout->orderBackendCSS != '') { $tmp = \StringUtil::deserialize($objLayout->orderBackendCSS); if (!empty($tmp) && is_array($tmp)) { // Remove all values $arrOrder = array_map(function(){}, array_flip($tmp)); // Move the matching elements to their position in $arrOrder foreach ($arrCSS as $k=>$v) { if (array_key_exists($v, $arrOrder)) { $arrOrder[$v] = $v; unset($arrCSS[$k]); } } // Append the left-over style sheets at the end if (!empty($arrCSS)) { $arrOrder = array_merge($arrOrder, array_values($arrCSS)); } // Remove empty (unreplaced) entries $arrCSS = array_values(array_filter($arrOrder)); unset($arrOrder); } } // Get the file entries from the database $objFiles = \FilesModel::findMultipleByUuids($arrCSS); if ($objFiles !== null) { while ($objFiles->next()) { if (file_exists(TL_ROOT . '/' . $objFiles->path)) { $GLOBALS['TL_USER_CSS'][] = $objFiles->path . '|static'; } } } unset($objFiles); } }
[ "private", "static", "function", "addBackendCSS", "(", "$", "objLayout", ")", "{", "$", "arrCSS", "=", "\\", "StringUtil", "::", "deserialize", "(", "$", "objLayout", "->", "backendCSS", ")", ";", "if", "(", "!", "empty", "(", "$", "arrCSS", ")", "&&", ...
Adds the backend CSS of the layout to the backend template @param LayoutModel $objLayout The layout object
[ "Adds", "the", "backend", "CSS", "of", "the", "layout", "to", "the", "backend", "template" ]
a74d880d74352d2ed887e13f29115bbc48ad84cc
https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Controller.php#L402-L456
train
agoat/contao-customcontentelements-bundle
src/Resources/contao/classes/Controller.php
Controller.addBackendJS
private static function addBackendJS($objLayout) { $arrJS = \StringUtil::deserialize($objLayout->backendJS); if (!empty($arrJS) && is_array($arrJS)) { // Consider the sorting order (see #5038) if ($objLayout->orderBackendJS != '') { $tmp = \StringUtil::deserialize($objLayout->orderBackendJS); if (!empty($tmp) && is_array($tmp)) { // Remove all values $arrOrder = array_map(function(){}, array_flip($tmp)); // Move the matching elements to their position in $arrOrder foreach ($arrJS as $k=>$v) { if (array_key_exists($v, $arrOrder)) { $arrOrder[$v] = $v; unset($arrJS[$k]); } } // Append the left-over style sheets at the end if (!empty($arrJS)) { $arrOrder = array_merge($arrOrder, array_values($arrJS)); } // Remove empty (unreplaced) entries $arrJS = array_values(array_filter($arrOrder)); unset($arrOrder); } } // Get the file entries from the database $objFiles = \FilesModel::findMultipleByUuids($arrJS); if ($objFiles !== null) { while ($objFiles->next()) { if (file_exists(TL_ROOT . '/' . $objFiles->path)) { $GLOBALS['TL_JAVASCRIPT'][] = $objFiles->path . '|static'; } } } unset($objFiles); } }
php
private static function addBackendJS($objLayout) { $arrJS = \StringUtil::deserialize($objLayout->backendJS); if (!empty($arrJS) && is_array($arrJS)) { // Consider the sorting order (see #5038) if ($objLayout->orderBackendJS != '') { $tmp = \StringUtil::deserialize($objLayout->orderBackendJS); if (!empty($tmp) && is_array($tmp)) { // Remove all values $arrOrder = array_map(function(){}, array_flip($tmp)); // Move the matching elements to their position in $arrOrder foreach ($arrJS as $k=>$v) { if (array_key_exists($v, $arrOrder)) { $arrOrder[$v] = $v; unset($arrJS[$k]); } } // Append the left-over style sheets at the end if (!empty($arrJS)) { $arrOrder = array_merge($arrOrder, array_values($arrJS)); } // Remove empty (unreplaced) entries $arrJS = array_values(array_filter($arrOrder)); unset($arrOrder); } } // Get the file entries from the database $objFiles = \FilesModel::findMultipleByUuids($arrJS); if ($objFiles !== null) { while ($objFiles->next()) { if (file_exists(TL_ROOT . '/' . $objFiles->path)) { $GLOBALS['TL_JAVASCRIPT'][] = $objFiles->path . '|static'; } } } unset($objFiles); } }
[ "private", "static", "function", "addBackendJS", "(", "$", "objLayout", ")", "{", "$", "arrJS", "=", "\\", "StringUtil", "::", "deserialize", "(", "$", "objLayout", "->", "backendJS", ")", ";", "if", "(", "!", "empty", "(", "$", "arrJS", ")", "&&", "is...
Adds the backend Javascript of the layout to the backend template @param LayoutModel $objLayout The layout object
[ "Adds", "the", "backend", "Javascript", "of", "the", "layout", "to", "the", "backend", "template" ]
a74d880d74352d2ed887e13f29115bbc48ad84cc
https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Controller.php#L464-L518
train
Vanare/behat-cucumber-formatter
src/Formatter/Formatter.php
Formatter.onAfterExercise
public function onAfterExercise(TestworkEvent\AfterExerciseCompleted $event) { $this->timer->stop(); $this->renderer->render(); $this->printer->write($this->renderer->getResult()); }
php
public function onAfterExercise(TestworkEvent\AfterExerciseCompleted $event) { $this->timer->stop(); $this->renderer->render(); $this->printer->write($this->renderer->getResult()); }
[ "public", "function", "onAfterExercise", "(", "TestworkEvent", "\\", "AfterExerciseCompleted", "$", "event", ")", "{", "$", "this", "->", "timer", "->", "stop", "(", ")", ";", "$", "this", "->", "renderer", "->", "render", "(", ")", ";", "$", "this", "->...
Triggers after running tests. @param TestworkEvent\AfterExerciseCompleted $event
[ "Triggers", "after", "running", "tests", "." ]
b28ae403404be4c74c740a3948d9338fc51443a3
https://github.com/Vanare/behat-cucumber-formatter/blob/b28ae403404be4c74c740a3948d9338fc51443a3/src/Formatter/Formatter.php#L326-L332
train
BlueTeaNL/JIRA-Rest-API-PHP
src/Jira/Endpoint/JqlEndpoint.php
JqlEndpoint.search
public function search($jql, $startAt = null, $maxResults = null, $validateQuery = null, $fields = null, $expand = null) { $parameters = array( 'jql' => $jql, 'startAt' => $startAt, 'maxResults' => $maxResults, 'validateQuery' => $validateQuery, 'fields' => $fields, 'expand' => $expand ); return $this->apiClient->callEndpoint('search', $parameters); }
php
public function search($jql, $startAt = null, $maxResults = null, $validateQuery = null, $fields = null, $expand = null) { $parameters = array( 'jql' => $jql, 'startAt' => $startAt, 'maxResults' => $maxResults, 'validateQuery' => $validateQuery, 'fields' => $fields, 'expand' => $expand ); return $this->apiClient->callEndpoint('search', $parameters); }
[ "public", "function", "search", "(", "$", "jql", ",", "$", "startAt", "=", "null", ",", "$", "maxResults", "=", "null", ",", "$", "validateQuery", "=", "null", ",", "$", "fields", "=", "null", ",", "$", "expand", "=", "null", ")", "{", "$", "parame...
Searches for issues using JQL @param $jql @param null $startAt @param null $maxResults @param null $validateQuery @param null $fields @param null $expand @return mixed
[ "Searches", "for", "issues", "using", "JQL" ]
56309ee711f86d5bc085f391bba3e50155e14106
https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/JqlEndpoint.php#L22-L33
train
Vanare/behat-cucumber-formatter
src/Node/Step.php
Step.getProcessedResult
public function getProcessedResult() { $status = StepResult::SKIPPED; if (!empty(static::$resultLabels[$this->getResultCode()])) { $status = static::$resultLabels[$this->getResultCode()]; } return [ 'status' => $status, 'error_message' => $this->getException(), 'duration' => $this->getDuration() * 1000 * 1000000, ]; }
php
public function getProcessedResult() { $status = StepResult::SKIPPED; if (!empty(static::$resultLabels[$this->getResultCode()])) { $status = static::$resultLabels[$this->getResultCode()]; } return [ 'status' => $status, 'error_message' => $this->getException(), 'duration' => $this->getDuration() * 1000 * 1000000, ]; }
[ "public", "function", "getProcessedResult", "(", ")", "{", "$", "status", "=", "StepResult", "::", "SKIPPED", ";", "if", "(", "!", "empty", "(", "static", "::", "$", "resultLabels", "[", "$", "this", "->", "getResultCode", "(", ")", "]", ")", ")", "{",...
Process result. @return array
[ "Process", "result", "." ]
b28ae403404be4c74c740a3948d9338fc51443a3
https://github.com/Vanare/behat-cucumber-formatter/blob/b28ae403404be4c74c740a3948d9338fc51443a3/src/Node/Step.php#L139-L152
train
IDCI-Consulting/ExtraFormBundle
Configuration/Fetcher/ConfigurationFetcherRegistry.php
ConfigurationFetcherRegistry.getFetcher
public function getFetcher($alias) { if (!is_string($alias)) { throw new UnexpectedTypeException($alias, 'string'); } if (!isset($this->fetchers[$alias])) { throw new \InvalidArgumentException(sprintf('Could not load configuration fetcher "%s"', $alias)); } return $this->fetchers[$alias]; }
php
public function getFetcher($alias) { if (!is_string($alias)) { throw new UnexpectedTypeException($alias, 'string'); } if (!isset($this->fetchers[$alias])) { throw new \InvalidArgumentException(sprintf('Could not load configuration fetcher "%s"', $alias)); } return $this->fetchers[$alias]; }
[ "public", "function", "getFetcher", "(", "$", "alias", ")", "{", "if", "(", "!", "is_string", "(", "$", "alias", ")", ")", "{", "throw", "new", "UnexpectedTypeException", "(", "$", "alias", ",", "'string'", ")", ";", "}", "if", "(", "!", "isset", "("...
Returns fetcher. @param string $alias the alias @return ConfigurationFetcherInterface
[ "Returns", "fetcher", "." ]
3481c69fd078754f3d0c5947dd59a5536ed13da0
https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Configuration/Fetcher/ConfigurationFetcherRegistry.php#L44-L55
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsInDays
public function seeDateIsInDays($date, $days) { \PHPUnit_Framework_Assert::assertEquals($days, $this->_GetNow()->diffInDays($this->_ParseDate($date), false)); }
php
public function seeDateIsInDays($date, $days) { \PHPUnit_Framework_Assert::assertEquals($days, $this->_GetNow()->diffInDays($this->_ParseDate($date), false)); }
[ "public", "function", "seeDateIsInDays", "(", "$", "date", ",", "$", "days", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "days", ",", "$", "this", "->", "_GetNow", "(", ")", "->", "diffInDays", "(", "$", "this", "->", "_Pa...
See date is in a given number of days. @param string $date @param int $days
[ "See", "date", "is", "in", "a", "given", "number", "of", "days", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L70-L72
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsInDays
public function dontSeeDateIsInDays($date, $days) { \PHPUnit_Framework_Assert::assertNotEquals($days, $this->_GetNow()->diffInDays($this->_ParseDate($date), false)); }
php
public function dontSeeDateIsInDays($date, $days) { \PHPUnit_Framework_Assert::assertNotEquals($days, $this->_GetNow()->diffInDays($this->_ParseDate($date), false)); }
[ "public", "function", "dontSeeDateIsInDays", "(", "$", "date", ",", "$", "days", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "days", ",", "$", "this", "->", "_GetNow", "(", ")", "->", "diffInDays", "(", "$", "this", "->",...
See date is not in a given number of days. @param string $date @param int $days
[ "See", "date", "is", "not", "in", "a", "given", "number", "of", "days", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L80-L82
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsInMonths
public function seeDateIsInMonths($date, $months) { \PHPUnit_Framework_Assert::assertEquals($months, $this->_GetNow()->diffInMonths($this->_ParseDate($date), false)); }
php
public function seeDateIsInMonths($date, $months) { \PHPUnit_Framework_Assert::assertEquals($months, $this->_GetNow()->diffInMonths($this->_ParseDate($date), false)); }
[ "public", "function", "seeDateIsInMonths", "(", "$", "date", ",", "$", "months", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "months", ",", "$", "this", "->", "_GetNow", "(", ")", "->", "diffInMonths", "(", "$", "this", "->"...
See date is in a given number of months. @param string $date @param int $months
[ "See", "date", "is", "in", "a", "given", "number", "of", "months", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L208-L210
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsInMonths
public function dontSeeDateIsInMonths($date, $months) { \PHPUnit_Framework_Assert::assertNotEquals($months, $this->_GetNow()->diffInMonths($this->_ParseDate($date), false)); }
php
public function dontSeeDateIsInMonths($date, $months) { \PHPUnit_Framework_Assert::assertNotEquals($months, $this->_GetNow()->diffInMonths($this->_ParseDate($date), false)); }
[ "public", "function", "dontSeeDateIsInMonths", "(", "$", "date", ",", "$", "months", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "months", ",", "$", "this", "->", "_GetNow", "(", ")", "->", "diffInMonths", "(", "$", "this",...
See date is not in a given number of months. @param string $date @param int $months
[ "See", "date", "is", "not", "in", "a", "given", "number", "of", "months", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L218-L220
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsInYears
public function seeDateIsInYears($date, $years) { \PHPUnit_Framework_Assert::assertEquals($years, $this->_GetNow()->diffInYears($this->_ParseDate($date), false)); }
php
public function seeDateIsInYears($date, $years) { \PHPUnit_Framework_Assert::assertEquals($years, $this->_GetNow()->diffInYears($this->_ParseDate($date), false)); }
[ "public", "function", "seeDateIsInYears", "(", "$", "date", ",", "$", "years", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "years", ",", "$", "this", "->", "_GetNow", "(", ")", "->", "diffInYears", "(", "$", "this", "->", ...
See date is in a given number of years. @param string $date @param int $years
[ "See", "date", "is", "in", "a", "given", "number", "of", "years", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L286-L288
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsInYears
public function dontSeeDateIsInYears($date, $years) { \PHPUnit_Framework_Assert::assertNotEquals($years, $this->_GetNow()->diffInYears($this->_ParseDate($date), false)); }
php
public function dontSeeDateIsInYears($date, $years) { \PHPUnit_Framework_Assert::assertNotEquals($years, $this->_GetNow()->diffInYears($this->_ParseDate($date), false)); }
[ "public", "function", "dontSeeDateIsInYears", "(", "$", "date", ",", "$", "years", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "years", ",", "$", "this", "->", "_GetNow", "(", ")", "->", "diffInYears", "(", "$", "this", "...
See date is in not a given number of years. @param string $date @param int $years
[ "See", "date", "is", "in", "not", "a", "given", "number", "of", "years", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L296-L298
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsMonday
public function seeDateIsMonday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::MONDAY); }
php
public function seeDateIsMonday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::MONDAY); }
[ "public", "function", "seeDateIsMonday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "MONDAY", ")", ";", "}" ]
See date is a Monday. @param string $date
[ "See", "date", "is", "a", "Monday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L345-L347
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsMonday
public function dontSeeDateIsMonday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::MONDAY); }
php
public function dontSeeDateIsMonday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::MONDAY); }
[ "public", "function", "dontSeeDateIsMonday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertFalse", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "MONDAY", ")", ";", "}" ]
See date is not a Monday. @param string $date
[ "See", "date", "is", "not", "a", "Monday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L354-L356
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsTuesday
public function seeDateIsTuesday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::TUESDAY); }
php
public function seeDateIsTuesday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::TUESDAY); }
[ "public", "function", "seeDateIsTuesday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "TUESDAY", ")", ";", "}" ]
See date is a Tuesday. @param string $date
[ "See", "date", "is", "a", "Tuesday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L363-L365
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsTuesday
public function dontSeeDateIsTuesday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::TUESDAY); }
php
public function dontSeeDateIsTuesday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::TUESDAY); }
[ "public", "function", "dontSeeDateIsTuesday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertFalse", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "TUESDAY", ")", ";", "}" ]
See date is not a Tuesday. @param string $date
[ "See", "date", "is", "not", "a", "Tuesday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L372-L374
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsWednesday
public function seeDateIsWednesday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::WEDNESDAY); }
php
public function seeDateIsWednesday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::WEDNESDAY); }
[ "public", "function", "seeDateIsWednesday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "WEDNESDAY", ")", ";", "}" ]
See date is a Wednesday. @param string $date
[ "See", "date", "is", "a", "Wednesday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L381-L383
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsWednesday
public function dontSeeDateIsWednesday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::WEDNESDAY); }
php
public function dontSeeDateIsWednesday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::WEDNESDAY); }
[ "public", "function", "dontSeeDateIsWednesday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertFalse", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "WEDNESDAY", ")", ";", "}...
See date is not a Wednesday. @param string $date
[ "See", "date", "is", "not", "a", "Wednesday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L390-L392
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsThursday
public function seeDateIsThursday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::THURSDAY); }
php
public function seeDateIsThursday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::THURSDAY); }
[ "public", "function", "seeDateIsThursday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "THURSDAY", ")", ";", "}" ]
See date is a Thursday. @param string $date
[ "See", "date", "is", "a", "Thursday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L399-L401
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsThursday
public function dontSeeDateIsThursday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::THURSDAY); }
php
public function dontSeeDateIsThursday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::THURSDAY); }
[ "public", "function", "dontSeeDateIsThursday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertFalse", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "THURSDAY", ")", ";", "}" ...
See date is not a Thursday. @param string $date
[ "See", "date", "is", "not", "a", "Thursday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L408-L410
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsFriday
public function seeDateIsFriday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::FRIDAY); }
php
public function seeDateIsFriday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::FRIDAY); }
[ "public", "function", "seeDateIsFriday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "FRIDAY", ")", ";", "}" ]
See date is a Friday @param string $date
[ "See", "date", "is", "a", "Friday" ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L417-L419
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsFriday
public function dontSeeDateIsFriday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::FRIDAY); }
php
public function dontSeeDateIsFriday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::FRIDAY); }
[ "public", "function", "dontSeeDateIsFriday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertFalse", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "FRIDAY", ")", ";", "}" ]
See date is not a Friday. @param string $date
[ "See", "date", "is", "not", "a", "Friday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L426-L428
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsSaturday
public function seeDateIsSaturday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::SATURDAY); }
php
public function seeDateIsSaturday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::SATURDAY); }
[ "public", "function", "seeDateIsSaturday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "SATURDAY", ")", ";", "}" ]
See date is a Saturday. @param string $date
[ "See", "date", "is", "a", "Saturday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L435-L437
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsSaturday
public function dontSeeDateIsSaturday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::SATURDAY); }
php
public function dontSeeDateIsSaturday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::SATURDAY); }
[ "public", "function", "dontSeeDateIsSaturday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertFalse", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "SATURDAY", ")", ";", "}" ...
See date is not a Saturday. @param string $date
[ "See", "date", "is", "not", "a", "Saturday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L444-L446
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateIsSunday
public function seeDateIsSunday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::SUNDAY); }
php
public function seeDateIsSunday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::SUNDAY); }
[ "public", "function", "seeDateIsSunday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "SUNDAY", ")", ";", "}" ]
See date is a Sunday. @param string $date
[ "See", "date", "is", "a", "Sunday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L453-L455
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateIsSunday
public function dontSeeDateIsSunday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::SUNDAY); }
php
public function dontSeeDateIsSunday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::SUNDAY); }
[ "public", "function", "dontSeeDateIsSunday", "(", "$", "date", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertFalse", "(", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", "==", "Carbon", "::", "SUNDAY", ")", ";", "}" ]
See date is not a Sunday. @param string $date
[ "See", "date", "is", "not", "a", "Sunday", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L462-L464
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateMatches
public function seeDateMatches($d1, $d2) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($d1)->eq($this->_ParseDate($d2))); }
php
public function seeDateMatches($d1, $d2) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($d1)->eq($this->_ParseDate($d2))); }
[ "public", "function", "seeDateMatches", "(", "$", "d1", ",", "$", "d2", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "d1", ")", "->", "eq", "(", "$", "this", "->", "_ParseDate", "(", "$...
See that two dates match. @param string $d1 @param string $d2
[ "See", "that", "two", "dates", "match", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L512-L514
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateMatches
public function dontSeeDateMatches($d1, $d2) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($d1)->ne($this->_ParseDate($d2))); }
php
public function dontSeeDateMatches($d1, $d2) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($d1)->ne($this->_ParseDate($d2))); }
[ "public", "function", "dontSeeDateMatches", "(", "$", "d1", ",", "$", "d2", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "this", "->", "_ParseDate", "(", "$", "d1", ")", "->", "ne", "(", "$", "this", "->", "_ParseDate", "(", ...
See that two dates don't match. @param string $d1 @param string $d2
[ "See", "that", "two", "dates", "don", "t", "match", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L522-L524
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDateInQuarter
public function seeDateInQuarter($date, $quarter) { \PHPUnit_Framework_Assert::assertEquals($quarter, $this->_ParseDate($date)->quarter); }
php
public function seeDateInQuarter($date, $quarter) { \PHPUnit_Framework_Assert::assertEquals($quarter, $this->_ParseDate($date)->quarter); }
[ "public", "function", "seeDateInQuarter", "(", "$", "date", ",", "$", "quarter", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "quarter", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "quarter", ")", ";", ...
See the date is within a particular quarter of the year. @param string $date @param int $quarter
[ "See", "the", "date", "is", "within", "a", "particular", "quarter", "of", "the", "year", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L644-L646
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDateInQuarter
public function dontSeeDateInQuarter($date, $quarter) { \PHPUnit_Framework_Assert::assertNotEquals($quarter, $this->_ParseDate($date)->quarter); }
php
public function dontSeeDateInQuarter($date, $quarter) { \PHPUnit_Framework_Assert::assertNotEquals($quarter, $this->_ParseDate($date)->quarter); }
[ "public", "function", "dontSeeDateInQuarter", "(", "$", "date", ",", "$", "quarter", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "quarter", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "quarter", ")", ...
See the date is not within a particular quarter of the year. @param string $date @param int $quarter
[ "See", "the", "date", "is", "not", "within", "a", "particular", "quarter", "of", "the", "year", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L654-L656
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDayInWeek
public function seeDayInWeek($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->dayOfWeek); }
php
public function seeDayInWeek($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->dayOfWeek); }
[ "public", "function", "seeDayInWeek", "(", "$", "date", ",", "$", "day", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "day", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", ")", ";", "}" ]
See the date is a given day in the week. @param string $date @param int $day
[ "See", "the", "date", "is", "a", "given", "day", "in", "the", "week", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L686-L688
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDayInWeek
public function dontSeeDayInWeek($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->dayOfWeek); }
php
public function dontSeeDayInWeek($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->dayOfWeek); }
[ "public", "function", "dontSeeDayInWeek", "(", "$", "date", ",", "$", "day", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "day", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfWeek", ")", ";", "...
See the date is not a given day in the week. @param string $date @param int $day
[ "See", "the", "date", "is", "not", "a", "given", "day", "in", "the", "week", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L696-L698
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDayInMonth
public function seeDayInMonth($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->day); }
php
public function seeDayInMonth($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->day); }
[ "public", "function", "seeDayInMonth", "(", "$", "date", ",", "$", "day", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "day", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "day", ")", ";", "}" ]
See the date is a given day in the month. @param string $date @param int $day
[ "See", "the", "date", "is", "a", "given", "day", "in", "the", "month", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L706-L708
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDayInMonth
public function dontSeeDayInMonth($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->day); }
php
public function dontSeeDayInMonth($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->day); }
[ "public", "function", "dontSeeDayInMonth", "(", "$", "date", ",", "$", "day", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "day", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "day", ")", ";", "}" ]
See the date is not a given day in the month. @param string $date @param int $day
[ "See", "the", "date", "is", "not", "a", "given", "day", "in", "the", "month", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L716-L718
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeDayInYear
public function seeDayInYear($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->dayOfYear); }
php
public function seeDayInYear($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->dayOfYear); }
[ "public", "function", "seeDayInYear", "(", "$", "date", ",", "$", "day", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "day", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfYear", ")", ";", "}" ]
See the date is a given day in the year. @param string $date @param int $day
[ "See", "the", "date", "is", "a", "given", "day", "in", "the", "year", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L726-L728
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeDayInYear
public function dontSeeDayInYear($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->dayOfYear); }
php
public function dontSeeDayInYear($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->dayOfYear); }
[ "public", "function", "dontSeeDayInYear", "(", "$", "date", ",", "$", "day", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "day", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "dayOfYear", ")", ";", "...
See the date is not a given day in the year. @param string $date @param int $day
[ "See", "the", "date", "is", "not", "a", "given", "day", "in", "the", "year", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L736-L738
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeWeekInYear
public function seeWeekInYear($date, $week) { \PHPUnit_Framework_Assert::assertEquals($week, $this->_ParseDate($date)->weekOfYear); }
php
public function seeWeekInYear($date, $week) { \PHPUnit_Framework_Assert::assertEquals($week, $this->_ParseDate($date)->weekOfYear); }
[ "public", "function", "seeWeekInYear", "(", "$", "date", ",", "$", "week", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "week", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "weekOfYear", ")", ";", "}" ...
See the date is a given week in the year. @param string $date @param int $week
[ "See", "the", "date", "is", "a", "given", "week", "in", "the", "year", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L768-L770
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeWeekInYear
public function dontSeeWeekInYear($date, $week) { \PHPUnit_Framework_Assert::assertNotEquals($week, $this->_ParseDate($date)->weekOfYear); }
php
public function dontSeeWeekInYear($date, $week) { \PHPUnit_Framework_Assert::assertNotEquals($week, $this->_ParseDate($date)->weekOfYear); }
[ "public", "function", "dontSeeWeekInYear", "(", "$", "date", ",", "$", "week", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "week", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "weekOfYear", ")", ";",...
See the date is not a given week in the year. @param string $date @param int $week
[ "See", "the", "date", "is", "not", "a", "given", "week", "in", "the", "year", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L778-L780
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.seeMonthInYear
public function seeMonthInYear($date, $month) { \PHPUnit_Framework_Assert::assertEquals($month, $this->_ParseDate($date)->month); }
php
public function seeMonthInYear($date, $month) { \PHPUnit_Framework_Assert::assertEquals($month, $this->_ParseDate($date)->month); }
[ "public", "function", "seeMonthInYear", "(", "$", "date", ",", "$", "month", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "month", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "month", ")", ";", "}" ]
See the month in the year is a given value. @param string $date @param int $month
[ "See", "the", "month", "in", "the", "year", "is", "a", "given", "value", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L790-L792
train
nathanmac/datetime-codeception-module
src/Module/Date.php
Date.dontSeeMonthInYear
public function dontSeeMonthInYear($date, $month) { \PHPUnit_Framework_Assert::assertNotEquals($month, $this->_ParseDate($date)->month); }
php
public function dontSeeMonthInYear($date, $month) { \PHPUnit_Framework_Assert::assertNotEquals($month, $this->_ParseDate($date)->month); }
[ "public", "function", "dontSeeMonthInYear", "(", "$", "date", ",", "$", "month", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotEquals", "(", "$", "month", ",", "$", "this", "->", "_ParseDate", "(", "$", "date", ")", "->", "month", ")", ";", ...
See the month in the year is not a given value. @param string $date @param int $month
[ "See", "the", "month", "in", "the", "year", "is", "not", "a", "given", "value", "." ]
0dfda12968af4baa8d755656d5416db9f3c37db2
https://github.com/nathanmac/datetime-codeception-module/blob/0dfda12968af4baa8d755656d5416db9f3c37db2/src/Module/Date.php#L800-L803
train
asinfotrack/yii2-comments
models/Comment.php
Comment.getSubject
public function getSubject() { if (!$this->isNewRecord && $this->subject === null) { $this->subject = call_user_func([$this->model_class, 'findOne'], $this->foreign_pk); if ($this->subject === null) { $msg = Yii::t('app', 'Could not find model for attachment `{attachment}`', [ 'attachment'=>$this->id ]); throw new ErrorException($msg); } } return $this->subject; }
php
public function getSubject() { if (!$this->isNewRecord && $this->subject === null) { $this->subject = call_user_func([$this->model_class, 'findOne'], $this->foreign_pk); if ($this->subject === null) { $msg = Yii::t('app', 'Could not find model for attachment `{attachment}`', [ 'attachment'=>$this->id ]); throw new ErrorException($msg); } } return $this->subject; }
[ "public", "function", "getSubject", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isNewRecord", "&&", "$", "this", "->", "subject", "===", "null", ")", "{", "$", "this", "->", "subject", "=", "call_user_func", "(", "[", "$", "this", "->", "model...
Getter for the subject model @return \yii\db\ActiveRecord the subject of this comment @throws \yii\base\ErrorException
[ "Getter", "for", "the", "subject", "model" ]
8f3b1ea239a4e940bc32472d16fb09c2b71135f7
https://github.com/asinfotrack/yii2-comments/blob/8f3b1ea239a4e940bc32472d16fb09c2b71135f7/models/Comment.php#L150-L162
train
asinfotrack/yii2-comments
models/Comment.php
Comment.setSubject
public function setSubject($subject) { self::validateSubject($subject, true); $this->model_class = $subject->className(); $this->foreign_pk = $subject->getPrimaryKey(true); $this->subject = $subject; }
php
public function setSubject($subject) { self::validateSubject($subject, true); $this->model_class = $subject->className(); $this->foreign_pk = $subject->getPrimaryKey(true); $this->subject = $subject; }
[ "public", "function", "setSubject", "(", "$", "subject", ")", "{", "self", "::", "validateSubject", "(", "$", "subject", ",", "true", ")", ";", "$", "this", "->", "model_class", "=", "$", "subject", "->", "className", "(", ")", ";", "$", "this", "->", ...
Sets the subject-model for this comment @param \yii\db\ActiveRecord $subject the subject model
[ "Sets", "the", "subject", "-", "model", "for", "this", "comment" ]
8f3b1ea239a4e940bc32472d16fb09c2b71135f7
https://github.com/asinfotrack/yii2-comments/blob/8f3b1ea239a4e940bc32472d16fb09c2b71135f7/models/Comment.php#L169-L176
train
asinfotrack/yii2-comments
models/Comment.php
Comment.validateSubject
public static function validateSubject($subject, $throwException = true) { if (!ComponentConfig::isActiveRecord($subject, $throwException)) return false; if (!ComponentConfig::hasBehavior($subject, CommentsBehavior::className(), $throwException)) return false; if (empty($subject->primaryKey) || (is_array($subject->primaryKey) && count($subject->primaryKey) === 0)) { if (!$throwException) return false; $msg = Yii::t('app', 'The model needs a valid primary key'); throw new InvalidParamException($msg); } if ($subject->isNewRecord) { if (!$throwException) return false; $msg = Yii::t('app', 'Commenting is not possible on unsaved models'); throw new InvalidParamException($msg); } return true; }
php
public static function validateSubject($subject, $throwException = true) { if (!ComponentConfig::isActiveRecord($subject, $throwException)) return false; if (!ComponentConfig::hasBehavior($subject, CommentsBehavior::className(), $throwException)) return false; if (empty($subject->primaryKey) || (is_array($subject->primaryKey) && count($subject->primaryKey) === 0)) { if (!$throwException) return false; $msg = Yii::t('app', 'The model needs a valid primary key'); throw new InvalidParamException($msg); } if ($subject->isNewRecord) { if (!$throwException) return false; $msg = Yii::t('app', 'Commenting is not possible on unsaved models'); throw new InvalidParamException($msg); } return true; }
[ "public", "static", "function", "validateSubject", "(", "$", "subject", ",", "$", "throwException", "=", "true", ")", "{", "if", "(", "!", "ComponentConfig", "::", "isActiveRecord", "(", "$", "subject", ",", "$", "throwException", ")", ")", "return", "false"...
Validates if the model is an active record, has the comments behavior, has a primary key and is not a new record. @param \yii\db\ActiveRecord $subject the subject model @param bool $throwException @return bool false means this subject is invalid @throws \yii\base\InvalidConfigException|\yii\base\InvalidParamException
[ "Validates", "if", "the", "model", "is", "an", "active", "record", "has", "the", "comments", "behavior", "has", "a", "primary", "key", "and", "is", "not", "a", "new", "record", "." ]
8f3b1ea239a4e940bc32472d16fb09c2b71135f7
https://github.com/asinfotrack/yii2-comments/blob/8f3b1ea239a4e940bc32472d16fb09c2b71135f7/models/Comment.php#L186-L204
train
LostKobrakai/Migrations
classes/TemplateMigration.php
TemplateMigration.update
public function update() { $t = new Template; $t->name = $this->getTemplateName(); $fg = new Fieldgroup; $fg->name = $this->getTemplateName(); foreach($this->fields as $field) { // add global fields if(!($field->flags & Field::flagGlobal)) continue; $fg->add($field); } $fg->save(); $t->fieldgroup = $fg; $t->fieldgroup->save(); $t->save(); $this->templateSetup($t); $t->fieldgroup->save(); $t->save(); return $t; }
php
public function update() { $t = new Template; $t->name = $this->getTemplateName(); $fg = new Fieldgroup; $fg->name = $this->getTemplateName(); foreach($this->fields as $field) { // add global fields if(!($field->flags & Field::flagGlobal)) continue; $fg->add($field); } $fg->save(); $t->fieldgroup = $fg; $t->fieldgroup->save(); $t->save(); $this->templateSetup($t); $t->fieldgroup->save(); $t->save(); return $t; }
[ "public", "function", "update", "(", ")", "{", "$", "t", "=", "new", "Template", ";", "$", "t", "->", "name", "=", "$", "this", "->", "getTemplateName", "(", ")", ";", "$", "fg", "=", "new", "Fieldgroup", ";", "$", "fg", "->", "name", "=", "$", ...
Create a template Add a fieldgroup with the 'title' field @todo add all global fields instead
[ "Create", "a", "template", "Add", "a", "fieldgroup", "with", "the", "title", "field" ]
54972f8c0c45e9dc8710845f61f32cb70af3e72d
https://github.com/LostKobrakai/Migrations/blob/54972f8c0c45e9dc8710845f61f32cb70af3e72d/classes/TemplateMigration.php#L15-L37
train