id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
9,200 | faithmade/churchthemes | ctfw-widgets.php | ChurchThemeFrameworkWidgets.init | public static function init() {
// bail if the CTFW_Widget class is loaded elsewhere
if( class_exists( 'CTFW_Widget' ) ){
return;
}
$pluginDir = untrailingslashit( plugin_dir_path( __FILE__ ) );
$pluginURL = untrailingslashit( plugin_dir_url( __FILE__ ) );
define( 'CTFW_WIDGETS_INC_DIR', $pluginDir . '/includes' );
define( 'CTFW_WIDGETS_CLASS_DIR', CTFW_WIDGETS_INC_DIR . '/classes' );
define( 'CTFW_WIDGETS_ADMIN_DIR', CTFW_WIDGETS_INC_DIR . '/admin' );
define( 'CTFW_WIDGETS_WIDGET_TEMPLATE_DIR', CTFW_WIDGETS_INC_DIR . '/widget-templates' );
define( 'CTFW_WIDGETS_JS_DIR', CTFW_WIDGETS_INC_DIR . '/js' );
define( 'CTFW_WIDGETS_CSS_DIR', CTFW_WIDGETS_INC_DIR . '/css' );
define( 'CTFW_WIDGETS_DIR_URL', $pluginURL );
define( 'CTFW_WIDGETS_JS_DIR_URL', $pluginURL . '/js' );
define( 'CTFW_WIDGETS_CSS_DIR_URL', $pluginURL . '/css' );
define( 'CTFW_WIDGETS_VERSION', 1.0 );
add_action( 'plugins_loaded', array( __CLASS__, 'setup') );
} | php | public static function init() {
// bail if the CTFW_Widget class is loaded elsewhere
if( class_exists( 'CTFW_Widget' ) ){
return;
}
$pluginDir = untrailingslashit( plugin_dir_path( __FILE__ ) );
$pluginURL = untrailingslashit( plugin_dir_url( __FILE__ ) );
define( 'CTFW_WIDGETS_INC_DIR', $pluginDir . '/includes' );
define( 'CTFW_WIDGETS_CLASS_DIR', CTFW_WIDGETS_INC_DIR . '/classes' );
define( 'CTFW_WIDGETS_ADMIN_DIR', CTFW_WIDGETS_INC_DIR . '/admin' );
define( 'CTFW_WIDGETS_WIDGET_TEMPLATE_DIR', CTFW_WIDGETS_INC_DIR . '/widget-templates' );
define( 'CTFW_WIDGETS_JS_DIR', CTFW_WIDGETS_INC_DIR . '/js' );
define( 'CTFW_WIDGETS_CSS_DIR', CTFW_WIDGETS_INC_DIR . '/css' );
define( 'CTFW_WIDGETS_DIR_URL', $pluginURL );
define( 'CTFW_WIDGETS_JS_DIR_URL', $pluginURL . '/js' );
define( 'CTFW_WIDGETS_CSS_DIR_URL', $pluginURL . '/css' );
define( 'CTFW_WIDGETS_VERSION', 1.0 );
add_action( 'plugins_loaded', array( __CLASS__, 'setup') );
} | [
"public",
"static",
"function",
"init",
"(",
")",
"{",
"// bail if the CTFW_Widget class is loaded elsewhere",
"if",
"(",
"class_exists",
"(",
"'CTFW_Widget'",
")",
")",
"{",
"return",
";",
"}",
"$",
"pluginDir",
"=",
"untrailingslashit",
"(",
"plugin_dir_path",
"(",
"__FILE__",
")",
")",
";",
"$",
"pluginURL",
"=",
"untrailingslashit",
"(",
"plugin_dir_url",
"(",
"__FILE__",
")",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_INC_DIR'",
",",
"$",
"pluginDir",
".",
"'/includes'",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_CLASS_DIR'",
",",
"CTFW_WIDGETS_INC_DIR",
".",
"'/classes'",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_ADMIN_DIR'",
",",
"CTFW_WIDGETS_INC_DIR",
".",
"'/admin'",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_WIDGET_TEMPLATE_DIR'",
",",
"CTFW_WIDGETS_INC_DIR",
".",
"'/widget-templates'",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_JS_DIR'",
",",
"CTFW_WIDGETS_INC_DIR",
".",
"'/js'",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_CSS_DIR'",
",",
"CTFW_WIDGETS_INC_DIR",
".",
"'/css'",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_DIR_URL'",
",",
"$",
"pluginURL",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_JS_DIR_URL'",
",",
"$",
"pluginURL",
".",
"'/js'",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_CSS_DIR_URL'",
",",
"$",
"pluginURL",
".",
"'/css'",
")",
";",
"define",
"(",
"'CTFW_WIDGETS_VERSION'",
",",
"1.0",
")",
";",
"add_action",
"(",
"'plugins_loaded'",
",",
"array",
"(",
"__CLASS__",
",",
"'setup'",
")",
")",
";",
"}"
] | define plugin directory | [
"define",
"plugin",
"directory"
] | b121e840edaec8fdb3189fc9324cc88d7a0db81c | https://github.com/faithmade/churchthemes/blob/b121e840edaec8fdb3189fc9324cc88d7a0db81c/ctfw-widgets.php#L16-L39 |
9,201 | joffreydemetz/database | src/DatabaseHelper.php | DatabaseHelper.splitSql | public static function splitSql($sql)
{
$start = 0;
$open = false;
$char = '';
$end = strlen($sql);
$queries = [];
for($i=0; $i<$end; $i++){
$current = substr($sql, $i, 1);
if ( $current == '"' || $current == '\'' ){
$n = 2;
while(substr($sql, $i - $n + 1, 1) == '\\' && $n < $i){
$n++;
}
if ( $n % 2 == 0 ){
if ( $open ){
if ( $current == $char ){
$open = false;
$char = '';
}
}
else {
$open = true;
$char = $current;
}
}
}
if ( ($current == ';' && !$open) || $i == $end - 1 ){
$queries[] = substr($sql, $start, ($i - $start + 1));
$start = $i + 1;
}
}
return $queries;
} | php | public static function splitSql($sql)
{
$start = 0;
$open = false;
$char = '';
$end = strlen($sql);
$queries = [];
for($i=0; $i<$end; $i++){
$current = substr($sql, $i, 1);
if ( $current == '"' || $current == '\'' ){
$n = 2;
while(substr($sql, $i - $n + 1, 1) == '\\' && $n < $i){
$n++;
}
if ( $n % 2 == 0 ){
if ( $open ){
if ( $current == $char ){
$open = false;
$char = '';
}
}
else {
$open = true;
$char = $current;
}
}
}
if ( ($current == ';' && !$open) || $i == $end - 1 ){
$queries[] = substr($sql, $start, ($i - $start + 1));
$start = $i + 1;
}
}
return $queries;
} | [
"public",
"static",
"function",
"splitSql",
"(",
"$",
"sql",
")",
"{",
"$",
"start",
"=",
"0",
";",
"$",
"open",
"=",
"false",
";",
"$",
"char",
"=",
"''",
";",
"$",
"end",
"=",
"strlen",
"(",
"$",
"sql",
")",
";",
"$",
"queries",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"end",
";",
"$",
"i",
"++",
")",
"{",
"$",
"current",
"=",
"substr",
"(",
"$",
"sql",
",",
"$",
"i",
",",
"1",
")",
";",
"if",
"(",
"$",
"current",
"==",
"'\"'",
"||",
"$",
"current",
"==",
"'\\''",
")",
"{",
"$",
"n",
"=",
"2",
";",
"while",
"(",
"substr",
"(",
"$",
"sql",
",",
"$",
"i",
"-",
"$",
"n",
"+",
"1",
",",
"1",
")",
"==",
"'\\\\'",
"&&",
"$",
"n",
"<",
"$",
"i",
")",
"{",
"$",
"n",
"++",
";",
"}",
"if",
"(",
"$",
"n",
"%",
"2",
"==",
"0",
")",
"{",
"if",
"(",
"$",
"open",
")",
"{",
"if",
"(",
"$",
"current",
"==",
"$",
"char",
")",
"{",
"$",
"open",
"=",
"false",
";",
"$",
"char",
"=",
"''",
";",
"}",
"}",
"else",
"{",
"$",
"open",
"=",
"true",
";",
"$",
"char",
"=",
"$",
"current",
";",
"}",
"}",
"}",
"if",
"(",
"(",
"$",
"current",
"==",
"';'",
"&&",
"!",
"$",
"open",
")",
"||",
"$",
"i",
"==",
"$",
"end",
"-",
"1",
")",
"{",
"$",
"queries",
"[",
"]",
"=",
"substr",
"(",
"$",
"sql",
",",
"$",
"start",
",",
"(",
"$",
"i",
"-",
"$",
"start",
"+",
"1",
")",
")",
";",
"$",
"start",
"=",
"$",
"i",
"+",
"1",
";",
"}",
"}",
"return",
"$",
"queries",
";",
"}"
] | Splits a string of multiple queries into an array of individual queries.
@param string $sql Input SQL string with which to split into individual queries.
@return array The queries from the input string separated into an array. | [
"Splits",
"a",
"string",
"of",
"multiple",
"queries",
"into",
"an",
"array",
"of",
"individual",
"queries",
"."
] | 627ef404914c06427159322da50700c1f2610a13 | https://github.com/joffreydemetz/database/blob/627ef404914c06427159322da50700c1f2610a13/src/DatabaseHelper.php#L68-L106 |
9,202 | gibboncms/gibbon | src/Support/DataSeparation.php | DataSeparation.splitData | protected function splitData($data, $sectionNames)
{
$sections = explode(
$this->getDataSeparator(),
str_replace("\n\r", "\n", $data),
count($sectionNames)
);
try {
$parts = array_combine($sectionNames, $sections);
} catch (\Exception $e) {
throw new EntityParseException;
}
return $parts;
} | php | protected function splitData($data, $sectionNames)
{
$sections = explode(
$this->getDataSeparator(),
str_replace("\n\r", "\n", $data),
count($sectionNames)
);
try {
$parts = array_combine($sectionNames, $sections);
} catch (\Exception $e) {
throw new EntityParseException;
}
return $parts;
} | [
"protected",
"function",
"splitData",
"(",
"$",
"data",
",",
"$",
"sectionNames",
")",
"{",
"$",
"sections",
"=",
"explode",
"(",
"$",
"this",
"->",
"getDataSeparator",
"(",
")",
",",
"str_replace",
"(",
"\"\\n\\r\"",
",",
"\"\\n\"",
",",
"$",
"data",
")",
",",
"count",
"(",
"$",
"sectionNames",
")",
")",
";",
"try",
"{",
"$",
"parts",
"=",
"array_combine",
"(",
"$",
"sectionNames",
",",
"$",
"sections",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"EntityParseException",
";",
"}",
"return",
"$",
"parts",
";",
"}"
] | Split data by the separator
@param string $data
@param array $sectionNames
@return array | [
"Split",
"data",
"by",
"the",
"separator"
] | 2905e90b2902149b3358b385264e98b97cf4fc00 | https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Support/DataSeparation.php#L16-L31 |
9,203 | gourmet/common | Model/Behavior/DuplicatableBehavior.php | DuplicatableBehavior.duplicate | public function duplicate(Model $Model, $data, $config = array()) {
$config = array_merge($this->settings[$Model->alias], $config);
if (empty($Model->id) && empty($data[$Model->alias][$Model->primaryKey])) {
throw new Exception(__d('common', "Missing primary key for duplicatable '%s' data", $Model->name));
}
$id = $Model->id ? $Model->id : $data[$Model->alias][$Model->primaryKey];
$conditions = array($Model->primaryKey => $id) + (array) $this->settings[$Model->alias]['scope'];
if (
!empty($this->settings[$Model->alias]['scope'])
&& !$Model->find('count', compact('conditions'))
) {
return false;
}
$duplicateData = array(
$config['duplicatedKey'] => $id,
$config['duplicatedModel'] => (!empty($Model->plugin) ? $Model->plugin . '.' : '') . $Model->name
);
$DuplicateModel = ClassRegistry::init($config['model']);
$DuplicateModel->create();
$duplicateRecord = $DuplicateModel->find('first', array('conditions' => $duplicateData, 'recursive' => -1));
if (!empty($duplicateRecord)) {
$DuplicateModel->id = $duplicateRecord[$DuplicateModel->alias][$DuplicateModel->primaryKey];
}
foreach ((array) $config['mapFields'] as $field => $path) {
$value = Hash::extract($data, $path);
$duplicateData[$field] = array_pop($value);
if (
!empty($duplicateRecord[$DuplicateModel->alias][$field])
&& $duplicateRecord[$DuplicateModel->alias][$field] === $duplicateData[$field]
) {
unset($duplicateData[$field]);
}
}
if (
(empty($duplicateRecord) || 1 < count($duplicateData))
&& (!empty($DuplicateModel->id) || $DuplicateModel->create($duplicateData))
&& !$DuplicateModel->save()
) {
return false;
}
return true;
} | php | public function duplicate(Model $Model, $data, $config = array()) {
$config = array_merge($this->settings[$Model->alias], $config);
if (empty($Model->id) && empty($data[$Model->alias][$Model->primaryKey])) {
throw new Exception(__d('common', "Missing primary key for duplicatable '%s' data", $Model->name));
}
$id = $Model->id ? $Model->id : $data[$Model->alias][$Model->primaryKey];
$conditions = array($Model->primaryKey => $id) + (array) $this->settings[$Model->alias]['scope'];
if (
!empty($this->settings[$Model->alias]['scope'])
&& !$Model->find('count', compact('conditions'))
) {
return false;
}
$duplicateData = array(
$config['duplicatedKey'] => $id,
$config['duplicatedModel'] => (!empty($Model->plugin) ? $Model->plugin . '.' : '') . $Model->name
);
$DuplicateModel = ClassRegistry::init($config['model']);
$DuplicateModel->create();
$duplicateRecord = $DuplicateModel->find('first', array('conditions' => $duplicateData, 'recursive' => -1));
if (!empty($duplicateRecord)) {
$DuplicateModel->id = $duplicateRecord[$DuplicateModel->alias][$DuplicateModel->primaryKey];
}
foreach ((array) $config['mapFields'] as $field => $path) {
$value = Hash::extract($data, $path);
$duplicateData[$field] = array_pop($value);
if (
!empty($duplicateRecord[$DuplicateModel->alias][$field])
&& $duplicateRecord[$DuplicateModel->alias][$field] === $duplicateData[$field]
) {
unset($duplicateData[$field]);
}
}
if (
(empty($duplicateRecord) || 1 < count($duplicateData))
&& (!empty($DuplicateModel->id) || $DuplicateModel->create($duplicateData))
&& !$DuplicateModel->save()
) {
return false;
}
return true;
} | [
"public",
"function",
"duplicate",
"(",
"Model",
"$",
"Model",
",",
"$",
"data",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
",",
"$",
"config",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"Model",
"->",
"id",
")",
"&&",
"empty",
"(",
"$",
"data",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"$",
"Model",
"->",
"primaryKey",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__d",
"(",
"'common'",
",",
"\"Missing primary key for duplicatable '%s' data\"",
",",
"$",
"Model",
"->",
"name",
")",
")",
";",
"}",
"$",
"id",
"=",
"$",
"Model",
"->",
"id",
"?",
"$",
"Model",
"->",
"id",
":",
"$",
"data",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"$",
"Model",
"->",
"primaryKey",
"]",
";",
"$",
"conditions",
"=",
"array",
"(",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"id",
")",
"+",
"(",
"array",
")",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"'scope'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"'scope'",
"]",
")",
"&&",
"!",
"$",
"Model",
"->",
"find",
"(",
"'count'",
",",
"compact",
"(",
"'conditions'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"duplicateData",
"=",
"array",
"(",
"$",
"config",
"[",
"'duplicatedKey'",
"]",
"=>",
"$",
"id",
",",
"$",
"config",
"[",
"'duplicatedModel'",
"]",
"=>",
"(",
"!",
"empty",
"(",
"$",
"Model",
"->",
"plugin",
")",
"?",
"$",
"Model",
"->",
"plugin",
".",
"'.'",
":",
"''",
")",
".",
"$",
"Model",
"->",
"name",
")",
";",
"$",
"DuplicateModel",
"=",
"ClassRegistry",
"::",
"init",
"(",
"$",
"config",
"[",
"'model'",
"]",
")",
";",
"$",
"DuplicateModel",
"->",
"create",
"(",
")",
";",
"$",
"duplicateRecord",
"=",
"$",
"DuplicateModel",
"->",
"find",
"(",
"'first'",
",",
"array",
"(",
"'conditions'",
"=>",
"$",
"duplicateData",
",",
"'recursive'",
"=>",
"-",
"1",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"duplicateRecord",
")",
")",
"{",
"$",
"DuplicateModel",
"->",
"id",
"=",
"$",
"duplicateRecord",
"[",
"$",
"DuplicateModel",
"->",
"alias",
"]",
"[",
"$",
"DuplicateModel",
"->",
"primaryKey",
"]",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"config",
"[",
"'mapFields'",
"]",
"as",
"$",
"field",
"=>",
"$",
"path",
")",
"{",
"$",
"value",
"=",
"Hash",
"::",
"extract",
"(",
"$",
"data",
",",
"$",
"path",
")",
";",
"$",
"duplicateData",
"[",
"$",
"field",
"]",
"=",
"array_pop",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"duplicateRecord",
"[",
"$",
"DuplicateModel",
"->",
"alias",
"]",
"[",
"$",
"field",
"]",
")",
"&&",
"$",
"duplicateRecord",
"[",
"$",
"DuplicateModel",
"->",
"alias",
"]",
"[",
"$",
"field",
"]",
"===",
"$",
"duplicateData",
"[",
"$",
"field",
"]",
")",
"{",
"unset",
"(",
"$",
"duplicateData",
"[",
"$",
"field",
"]",
")",
";",
"}",
"}",
"if",
"(",
"(",
"empty",
"(",
"$",
"duplicateRecord",
")",
"||",
"1",
"<",
"count",
"(",
"$",
"duplicateData",
")",
")",
"&&",
"(",
"!",
"empty",
"(",
"$",
"DuplicateModel",
"->",
"id",
")",
"||",
"$",
"DuplicateModel",
"->",
"create",
"(",
"$",
"duplicateData",
")",
")",
"&&",
"!",
"$",
"DuplicateModel",
"->",
"save",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Clone model's data.
@param Model $Model
@param array $options
@return [type] | [
"Clone",
"model",
"s",
"data",
"."
] | 53ad4e919c51606dc81f2c716267d01ee768ade5 | https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/Behavior/DuplicatableBehavior.php#L71-L121 |
9,204 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/mongo/db.php | Mongo_Db.instance | public static function instance($name = 'default')
{
if (\array_key_exists($name, static::$instances))
{
return static::$instances[$name];
}
if (empty(static::$instances))
{
\Config::load('db', true);
}
if ( ! ($config = \Config::get('db.mongo.'.$name)))
{
throw new \Mongo_DbException('Invalid instance name given.');
}
static::$instances[$name] = new static($config);
return static::$instances[$name];
} | php | public static function instance($name = 'default')
{
if (\array_key_exists($name, static::$instances))
{
return static::$instances[$name];
}
if (empty(static::$instances))
{
\Config::load('db', true);
}
if ( ! ($config = \Config::get('db.mongo.'.$name)))
{
throw new \Mongo_DbException('Invalid instance name given.');
}
static::$instances[$name] = new static($config);
return static::$instances[$name];
} | [
"public",
"static",
"function",
"instance",
"(",
"$",
"name",
"=",
"'default'",
")",
"{",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"name",
",",
"static",
"::",
"$",
"instances",
")",
")",
"{",
"return",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"instances",
")",
")",
"{",
"\\",
"Config",
"::",
"load",
"(",
"'db'",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"config",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'db.mongo.'",
".",
"$",
"name",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Mongo_DbException",
"(",
"'Invalid instance name given.'",
")",
";",
"}",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
"=",
"new",
"static",
"(",
"$",
"config",
")",
";",
"return",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
";",
"}"
] | Acts as a Multiton. Will return the requested instance, or will create
a new one if it does not exist.
@param string $name The instance name
@return Mongo_Db | [
"Acts",
"as",
"a",
"Multiton",
".",
"Will",
"return",
"the",
"requested",
"instance",
"or",
"will",
"create",
"a",
"new",
"one",
"if",
"it",
"does",
"not",
"exist",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/mongo/db.php#L111-L131 |
9,205 | antwebes/ChateaClientBundle | Controller/ApiProxyController.php | ApiProxyController.apiAction | public function apiAction(Request $request)
{
if ($request->isXmlHttpRequest() or $request->headers->get('Content-Type') =='application/json') {
$pathInfo = $request->getPathInfo();
if(!$this->getApiRequestAllow()->isAllow($pathInfo)){
throw new NotFoundHttpException('No route allow for " '.$request->getMethod().' '.$pathInfo.'"');
}
$query_string = null;
if ($request->server->get('QUERY_STRING')){
$query_string = '?' .$request->server->get('QUERY_STRING');
}
$url_api = $pathInfo . $query_string;
/*
* Only is configurable the first folder
* internalapi/users/username-available
* is changed to api/users/username-available
*/
$array = explode("/", $url_api);
unset($array[1]);
$text = implode("/", $array);
$url_api = "/api".$text;
$apiUri = trim($url_api,'/');
try{
return $this->container->get('antwebes_chateaclient_bundle.http.api_client')->sendRequest('GET',$apiUri);
}catch (ClientErrorResponseException $e){
$headersGuzzle = $e->getResponse()->getHeaders()->toArray();
$headersSymfony = array();
foreach($headersGuzzle as $key=>$value){
//this header is not suporter in symfony
if($key != 'Transfer-Encoding' && $value !== 'chunked'){
$headersSymfony[$key] = $value[0];
}
}
return new Response($e->getResponse()->getBody(true),
$e->getResponse()->getStatusCode(),
$headersSymfony
);
}
}else{
throw new NotFoundHttpException();
}
} | php | public function apiAction(Request $request)
{
if ($request->isXmlHttpRequest() or $request->headers->get('Content-Type') =='application/json') {
$pathInfo = $request->getPathInfo();
if(!$this->getApiRequestAllow()->isAllow($pathInfo)){
throw new NotFoundHttpException('No route allow for " '.$request->getMethod().' '.$pathInfo.'"');
}
$query_string = null;
if ($request->server->get('QUERY_STRING')){
$query_string = '?' .$request->server->get('QUERY_STRING');
}
$url_api = $pathInfo . $query_string;
/*
* Only is configurable the first folder
* internalapi/users/username-available
* is changed to api/users/username-available
*/
$array = explode("/", $url_api);
unset($array[1]);
$text = implode("/", $array);
$url_api = "/api".$text;
$apiUri = trim($url_api,'/');
try{
return $this->container->get('antwebes_chateaclient_bundle.http.api_client')->sendRequest('GET',$apiUri);
}catch (ClientErrorResponseException $e){
$headersGuzzle = $e->getResponse()->getHeaders()->toArray();
$headersSymfony = array();
foreach($headersGuzzle as $key=>$value){
//this header is not suporter in symfony
if($key != 'Transfer-Encoding' && $value !== 'chunked'){
$headersSymfony[$key] = $value[0];
}
}
return new Response($e->getResponse()->getBody(true),
$e->getResponse()->getStatusCode(),
$headersSymfony
);
}
}else{
throw new NotFoundHttpException();
}
} | [
"public",
"function",
"apiAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"isXmlHttpRequest",
"(",
")",
"or",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'Content-Type'",
")",
"==",
"'application/json'",
")",
"{",
"$",
"pathInfo",
"=",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getApiRequestAllow",
"(",
")",
"->",
"isAllow",
"(",
"$",
"pathInfo",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'No route allow for \" '",
".",
"$",
"request",
"->",
"getMethod",
"(",
")",
".",
"' '",
".",
"$",
"pathInfo",
".",
"'\"'",
")",
";",
"}",
"$",
"query_string",
"=",
"null",
";",
"if",
"(",
"$",
"request",
"->",
"server",
"->",
"get",
"(",
"'QUERY_STRING'",
")",
")",
"{",
"$",
"query_string",
"=",
"'?'",
".",
"$",
"request",
"->",
"server",
"->",
"get",
"(",
"'QUERY_STRING'",
")",
";",
"}",
"$",
"url_api",
"=",
"$",
"pathInfo",
".",
"$",
"query_string",
";",
"/*\n * Only is configurable the first folder\n * internalapi/users/username-available\n * is changed to api/users/username-available\n */",
"$",
"array",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"url_api",
")",
";",
"unset",
"(",
"$",
"array",
"[",
"1",
"]",
")",
";",
"$",
"text",
"=",
"implode",
"(",
"\"/\"",
",",
"$",
"array",
")",
";",
"$",
"url_api",
"=",
"\"/api\"",
".",
"$",
"text",
";",
"$",
"apiUri",
"=",
"trim",
"(",
"$",
"url_api",
",",
"'/'",
")",
";",
"try",
"{",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'antwebes_chateaclient_bundle.http.api_client'",
")",
"->",
"sendRequest",
"(",
"'GET'",
",",
"$",
"apiUri",
")",
";",
"}",
"catch",
"(",
"ClientErrorResponseException",
"$",
"e",
")",
"{",
"$",
"headersGuzzle",
"=",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getHeaders",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"headersSymfony",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"headersGuzzle",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"//this header is not suporter in symfony",
"if",
"(",
"$",
"key",
"!=",
"'Transfer-Encoding'",
"&&",
"$",
"value",
"!==",
"'chunked'",
")",
"{",
"$",
"headersSymfony",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"}",
"}",
"return",
"new",
"Response",
"(",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getBody",
"(",
"true",
")",
",",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getStatusCode",
"(",
")",
",",
"$",
"headersSymfony",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"}"
] | Resolve api calls
@param Request $request
@return Response | [
"Resolve",
"api",
"calls"
] | a4deb5f966b6ddcf817068e859787e32d399acf6 | https://github.com/antwebes/ChateaClientBundle/blob/a4deb5f966b6ddcf817068e859787e32d399acf6/Controller/ApiProxyController.php#L28-L73 |
9,206 | bishopb/vanilla | applications/dashboard/controllers/class.logcontroller.php | LogController.Confirm | public function Confirm($Action, $LogIDs = '') {
$this->Permission('Garden.Moderation.Manage');
$this->Form->InputPrefix = '';
$this->Form->IDPrefix = 'Confirm_';
if (trim($LogIDs))
$LogIDArray = explode(',', $LogIDs);
else
$LogIDArray = array();
// We also want to collect the users from the log.
$Logs = $this->LogModel->GetIDs($LogIDArray);
$Users = array();
foreach ($Logs as $Log) {
$UserID = $Log['RecordUserID'];
if (!$UserID)
continue;
$Users[$UserID] = array('UserID' => $UserID);
}
Gdn::UserModel()->JoinUsers($Users, array('UserID'));
$this->SetData('Users', $Users);
$this->SetData('Action', $Action);
$this->SetData('ActionUrl', Url("/log/$Action?logids=".urlencode($LogIDs)));
$this->SetData('ItemCount', count($LogIDArray));
$this->Render();
} | php | public function Confirm($Action, $LogIDs = '') {
$this->Permission('Garden.Moderation.Manage');
$this->Form->InputPrefix = '';
$this->Form->IDPrefix = 'Confirm_';
if (trim($LogIDs))
$LogIDArray = explode(',', $LogIDs);
else
$LogIDArray = array();
// We also want to collect the users from the log.
$Logs = $this->LogModel->GetIDs($LogIDArray);
$Users = array();
foreach ($Logs as $Log) {
$UserID = $Log['RecordUserID'];
if (!$UserID)
continue;
$Users[$UserID] = array('UserID' => $UserID);
}
Gdn::UserModel()->JoinUsers($Users, array('UserID'));
$this->SetData('Users', $Users);
$this->SetData('Action', $Action);
$this->SetData('ActionUrl', Url("/log/$Action?logids=".urlencode($LogIDs)));
$this->SetData('ItemCount', count($LogIDArray));
$this->Render();
} | [
"public",
"function",
"Confirm",
"(",
"$",
"Action",
",",
"$",
"LogIDs",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Moderation.Manage'",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"InputPrefix",
"=",
"''",
";",
"$",
"this",
"->",
"Form",
"->",
"IDPrefix",
"=",
"'Confirm_'",
";",
"if",
"(",
"trim",
"(",
"$",
"LogIDs",
")",
")",
"$",
"LogIDArray",
"=",
"explode",
"(",
"','",
",",
"$",
"LogIDs",
")",
";",
"else",
"$",
"LogIDArray",
"=",
"array",
"(",
")",
";",
"// We also want to collect the users from the log.",
"$",
"Logs",
"=",
"$",
"this",
"->",
"LogModel",
"->",
"GetIDs",
"(",
"$",
"LogIDArray",
")",
";",
"$",
"Users",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"Logs",
"as",
"$",
"Log",
")",
"{",
"$",
"UserID",
"=",
"$",
"Log",
"[",
"'RecordUserID'",
"]",
";",
"if",
"(",
"!",
"$",
"UserID",
")",
"continue",
";",
"$",
"Users",
"[",
"$",
"UserID",
"]",
"=",
"array",
"(",
"'UserID'",
"=>",
"$",
"UserID",
")",
";",
"}",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"JoinUsers",
"(",
"$",
"Users",
",",
"array",
"(",
"'UserID'",
")",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Users'",
",",
"$",
"Users",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Action'",
",",
"$",
"Action",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'ActionUrl'",
",",
"Url",
"(",
"\"/log/$Action?logids=\"",
".",
"urlencode",
"(",
"$",
"LogIDs",
")",
")",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'ItemCount'",
",",
"count",
"(",
"$",
"LogIDArray",
")",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Confirmation page.
@since 2.0.?
@access public
@param string $Action Type of action.
@param array $LogIDs Numeric IDs of items to confirm. | [
"Confirmation",
"page",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.logcontroller.php#L39-L67 |
9,207 | bishopb/vanilla | applications/dashboard/controllers/class.logcontroller.php | LogController.Count | public function Count($Operation) {
$this->Permission('Garden.Moderation.Manage');
if ($Operation == 'edits')
$Operation = array('edit', 'delete');
else
$Operation = explode(',', $Operation);
array_map('ucfirst', $Operation);
$Count = $this->LogModel->GetCountWhere(array('Operation' => $Operation));
if ($Count > 0)
echo '<span class="Alert">', $Count, '</span>';
} | php | public function Count($Operation) {
$this->Permission('Garden.Moderation.Manage');
if ($Operation == 'edits')
$Operation = array('edit', 'delete');
else
$Operation = explode(',', $Operation);
array_map('ucfirst', $Operation);
$Count = $this->LogModel->GetCountWhere(array('Operation' => $Operation));
if ($Count > 0)
echo '<span class="Alert">', $Count, '</span>';
} | [
"public",
"function",
"Count",
"(",
"$",
"Operation",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Moderation.Manage'",
")",
";",
"if",
"(",
"$",
"Operation",
"==",
"'edits'",
")",
"$",
"Operation",
"=",
"array",
"(",
"'edit'",
",",
"'delete'",
")",
";",
"else",
"$",
"Operation",
"=",
"explode",
"(",
"','",
",",
"$",
"Operation",
")",
";",
"array_map",
"(",
"'ucfirst'",
",",
"$",
"Operation",
")",
";",
"$",
"Count",
"=",
"$",
"this",
"->",
"LogModel",
"->",
"GetCountWhere",
"(",
"array",
"(",
"'Operation'",
"=>",
"$",
"Operation",
")",
")",
";",
"if",
"(",
"$",
"Count",
">",
"0",
")",
"echo",
"'<span class=\"Alert\">'",
",",
"$",
"Count",
",",
"'</span>'",
";",
"}"
] | Count log items.
@since 2.0.?
@access public
@param string $Operation Comma-separated ist of action types to find. | [
"Count",
"log",
"items",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.logcontroller.php#L77-L90 |
9,208 | bishopb/vanilla | applications/dashboard/controllers/class.logcontroller.php | LogController.Delete | public function Delete($LogIDs) {
$this->Permission('Garden.Moderation.Manage');
// Grab the logs.
$this->LogModel->Delete($LogIDs);
$this->Render('Blank', 'Utility');
} | php | public function Delete($LogIDs) {
$this->Permission('Garden.Moderation.Manage');
// Grab the logs.
$this->LogModel->Delete($LogIDs);
$this->Render('Blank', 'Utility');
} | [
"public",
"function",
"Delete",
"(",
"$",
"LogIDs",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Moderation.Manage'",
")",
";",
"// Grab the logs.",
"$",
"this",
"->",
"LogModel",
"->",
"Delete",
"(",
"$",
"LogIDs",
")",
";",
"$",
"this",
"->",
"Render",
"(",
"'Blank'",
",",
"'Utility'",
")",
";",
"}"
] | Delete logs.
@since 2.0.?
@access public
@param array $LogIDs Numeric IDs of logs to delete. | [
"Delete",
"logs",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.logcontroller.php#L100-L105 |
9,209 | bishopb/vanilla | applications/dashboard/controllers/class.logcontroller.php | LogController.DeleteSpam | public function DeleteSpam($LogIDs) {
$this->Permission('Garden.Moderation.Manage');
if (!$this->Request->IsPostBack())
throw PermissionException('Javascript');
$LogIDs = explode(',', $LogIDs);
// Ban the appropriate users.
$UserIDs = $this->Form->GetFormValue('UserID', array());
if (!is_array($UserIDs))
$UserIDs = array();
if (!empty($UserIDs)) {
// Grab the rest of the log entries.
$OtherLogIDs = $this->LogModel->GetWhere(array('Operation' => 'Spam', 'RecordUserID' => $UserIDs));
$OtherLogIDs = ConsolidateArrayValuesByKey($OtherLogIDs, 'LogID');
$LogIDs = array_merge($LogIDs, $OtherLogIDs);
foreach ($UserIDs as $UserID) {
Gdn::UserModel()->Ban($UserID, array('Reason' => 'Spam', 'DeleteContent' => TRUE, 'Log' => TRUE));
}
}
// Grab the logs.
$this->LogModel->Delete($LogIDs);
$this->Render('Blank', 'Utility');
} | php | public function DeleteSpam($LogIDs) {
$this->Permission('Garden.Moderation.Manage');
if (!$this->Request->IsPostBack())
throw PermissionException('Javascript');
$LogIDs = explode(',', $LogIDs);
// Ban the appropriate users.
$UserIDs = $this->Form->GetFormValue('UserID', array());
if (!is_array($UserIDs))
$UserIDs = array();
if (!empty($UserIDs)) {
// Grab the rest of the log entries.
$OtherLogIDs = $this->LogModel->GetWhere(array('Operation' => 'Spam', 'RecordUserID' => $UserIDs));
$OtherLogIDs = ConsolidateArrayValuesByKey($OtherLogIDs, 'LogID');
$LogIDs = array_merge($LogIDs, $OtherLogIDs);
foreach ($UserIDs as $UserID) {
Gdn::UserModel()->Ban($UserID, array('Reason' => 'Spam', 'DeleteContent' => TRUE, 'Log' => TRUE));
}
}
// Grab the logs.
$this->LogModel->Delete($LogIDs);
$this->Render('Blank', 'Utility');
} | [
"public",
"function",
"DeleteSpam",
"(",
"$",
"LogIDs",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Moderation.Manage'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"Request",
"->",
"IsPostBack",
"(",
")",
")",
"throw",
"PermissionException",
"(",
"'Javascript'",
")",
";",
"$",
"LogIDs",
"=",
"explode",
"(",
"','",
",",
"$",
"LogIDs",
")",
";",
"// Ban the appropriate users.",
"$",
"UserIDs",
"=",
"$",
"this",
"->",
"Form",
"->",
"GetFormValue",
"(",
"'UserID'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"UserIDs",
")",
")",
"$",
"UserIDs",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"UserIDs",
")",
")",
"{",
"// Grab the rest of the log entries.",
"$",
"OtherLogIDs",
"=",
"$",
"this",
"->",
"LogModel",
"->",
"GetWhere",
"(",
"array",
"(",
"'Operation'",
"=>",
"'Spam'",
",",
"'RecordUserID'",
"=>",
"$",
"UserIDs",
")",
")",
";",
"$",
"OtherLogIDs",
"=",
"ConsolidateArrayValuesByKey",
"(",
"$",
"OtherLogIDs",
",",
"'LogID'",
")",
";",
"$",
"LogIDs",
"=",
"array_merge",
"(",
"$",
"LogIDs",
",",
"$",
"OtherLogIDs",
")",
";",
"foreach",
"(",
"$",
"UserIDs",
"as",
"$",
"UserID",
")",
"{",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"Ban",
"(",
"$",
"UserID",
",",
"array",
"(",
"'Reason'",
"=>",
"'Spam'",
",",
"'DeleteContent'",
"=>",
"TRUE",
",",
"'Log'",
"=>",
"TRUE",
")",
")",
";",
"}",
"}",
"// Grab the logs.",
"$",
"this",
"->",
"LogModel",
"->",
"Delete",
"(",
"$",
"LogIDs",
")",
";",
"$",
"this",
"->",
"Render",
"(",
"'Blank'",
",",
"'Utility'",
")",
";",
"}"
] | Delete spam and optionally delete the users.
@param type $LogIDs | [
"Delete",
"spam",
"and",
"optionally",
"delete",
"the",
"users",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.logcontroller.php#L111-L138 |
9,210 | bishopb/vanilla | applications/dashboard/controllers/class.logcontroller.php | LogController.Initialize | public function Initialize() {
parent::Initialize();
Gdn_Theme::Section('Dashboard');
$this->AddJsFile('log.js');
$this->AddJsFile('jquery.expander.js');
$this->AddJsFile('jquery-ui.js');
$this->Form->InputPrefix = '';
} | php | public function Initialize() {
parent::Initialize();
Gdn_Theme::Section('Dashboard');
$this->AddJsFile('log.js');
$this->AddJsFile('jquery.expander.js');
$this->AddJsFile('jquery-ui.js');
$this->Form->InputPrefix = '';
} | [
"public",
"function",
"Initialize",
"(",
")",
"{",
"parent",
"::",
"Initialize",
"(",
")",
";",
"Gdn_Theme",
"::",
"Section",
"(",
"'Dashboard'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'log.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.expander.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery-ui.js'",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"InputPrefix",
"=",
"''",
";",
"}"
] | Always triggered first. Add Javascript files.
@since 2.0.?
@access public | [
"Always",
"triggered",
"first",
".",
"Add",
"Javascript",
"files",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.logcontroller.php#L241-L248 |
9,211 | bishopb/vanilla | applications/dashboard/controllers/class.logcontroller.php | LogController.Moderation | public function Moderation($Page = '') {
$this->Permission('Garden.Moderation.Manage');
$Where = array('Operation' => array('Moderate', 'Pending'));
// Filter by category menu
if ($CategoryID = Gdn::Request()->GetValue('CategoryID')) {
$this->SetData('ModerationCategoryID', $CategoryID);
$Where['CategoryID'] = $CategoryID;
}
list($Offset, $Limit) = OffsetLimit($Page, 10);
$this->SetData('Title', T('Moderation Queue'));
$RecordCount = $this->LogModel->GetCountWhere($Where);
$this->SetData('RecordCount', $RecordCount);
if ($Offset >= $RecordCount)
$Offset = $RecordCount - $Limit;
$Log = $this->LogModel->GetWhere($Where, 'LogID', 'Desc', $Offset, $Limit);
$this->SetData('Log', $Log);
if ($this->DeliveryType() == DELIVERY_TYPE_VIEW)
$this->View = 'Table';
$this->AddSideMenu('dashboard/log/moderation');
$this->Render();
} | php | public function Moderation($Page = '') {
$this->Permission('Garden.Moderation.Manage');
$Where = array('Operation' => array('Moderate', 'Pending'));
// Filter by category menu
if ($CategoryID = Gdn::Request()->GetValue('CategoryID')) {
$this->SetData('ModerationCategoryID', $CategoryID);
$Where['CategoryID'] = $CategoryID;
}
list($Offset, $Limit) = OffsetLimit($Page, 10);
$this->SetData('Title', T('Moderation Queue'));
$RecordCount = $this->LogModel->GetCountWhere($Where);
$this->SetData('RecordCount', $RecordCount);
if ($Offset >= $RecordCount)
$Offset = $RecordCount - $Limit;
$Log = $this->LogModel->GetWhere($Where, 'LogID', 'Desc', $Offset, $Limit);
$this->SetData('Log', $Log);
if ($this->DeliveryType() == DELIVERY_TYPE_VIEW)
$this->View = 'Table';
$this->AddSideMenu('dashboard/log/moderation');
$this->Render();
} | [
"public",
"function",
"Moderation",
"(",
"$",
"Page",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Moderation.Manage'",
")",
";",
"$",
"Where",
"=",
"array",
"(",
"'Operation'",
"=>",
"array",
"(",
"'Moderate'",
",",
"'Pending'",
")",
")",
";",
"// Filter by category menu",
"if",
"(",
"$",
"CategoryID",
"=",
"Gdn",
"::",
"Request",
"(",
")",
"->",
"GetValue",
"(",
"'CategoryID'",
")",
")",
"{",
"$",
"this",
"->",
"SetData",
"(",
"'ModerationCategoryID'",
",",
"$",
"CategoryID",
")",
";",
"$",
"Where",
"[",
"'CategoryID'",
"]",
"=",
"$",
"CategoryID",
";",
"}",
"list",
"(",
"$",
"Offset",
",",
"$",
"Limit",
")",
"=",
"OffsetLimit",
"(",
"$",
"Page",
",",
"10",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Title'",
",",
"T",
"(",
"'Moderation Queue'",
")",
")",
";",
"$",
"RecordCount",
"=",
"$",
"this",
"->",
"LogModel",
"->",
"GetCountWhere",
"(",
"$",
"Where",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'RecordCount'",
",",
"$",
"RecordCount",
")",
";",
"if",
"(",
"$",
"Offset",
">=",
"$",
"RecordCount",
")",
"$",
"Offset",
"=",
"$",
"RecordCount",
"-",
"$",
"Limit",
";",
"$",
"Log",
"=",
"$",
"this",
"->",
"LogModel",
"->",
"GetWhere",
"(",
"$",
"Where",
",",
"'LogID'",
",",
"'Desc'",
",",
"$",
"Offset",
",",
"$",
"Limit",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Log'",
",",
"$",
"Log",
")",
";",
"if",
"(",
"$",
"this",
"->",
"DeliveryType",
"(",
")",
"==",
"DELIVERY_TYPE_VIEW",
")",
"$",
"this",
"->",
"View",
"=",
"'Table'",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'dashboard/log/moderation'",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | View moderation logs.
@since 2.0.?
@access public
@param mixed $CategoryUrl Slug.
@param int $Page Page number. | [
"View",
"moderation",
"logs",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.logcontroller.php#L259-L286 |
9,212 | bishopb/vanilla | applications/dashboard/controllers/class.logcontroller.php | LogController.Restore | public function Restore($LogIDs) {
$this->Permission('Garden.Moderation.Manage');
// Grab the logs.
$Logs = $this->LogModel->GetIDs($LogIDs);
try {
foreach ($Logs as $Log) {
$this->LogModel->Restore($Log);
}
} catch (Exception $Ex) {
$this->Form->AddError($Ex->getMessage());
}
$this->LogModel->Recalculate();
$this->Render('Blank', 'Utility');
} | php | public function Restore($LogIDs) {
$this->Permission('Garden.Moderation.Manage');
// Grab the logs.
$Logs = $this->LogModel->GetIDs($LogIDs);
try {
foreach ($Logs as $Log) {
$this->LogModel->Restore($Log);
}
} catch (Exception $Ex) {
$this->Form->AddError($Ex->getMessage());
}
$this->LogModel->Recalculate();
$this->Render('Blank', 'Utility');
} | [
"public",
"function",
"Restore",
"(",
"$",
"LogIDs",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Moderation.Manage'",
")",
";",
"// Grab the logs.",
"$",
"Logs",
"=",
"$",
"this",
"->",
"LogModel",
"->",
"GetIDs",
"(",
"$",
"LogIDs",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"Logs",
"as",
"$",
"Log",
")",
"{",
"$",
"this",
"->",
"LogModel",
"->",
"Restore",
"(",
"$",
"Log",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"Ex",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"$",
"Ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"LogModel",
"->",
"Recalculate",
"(",
")",
";",
"$",
"this",
"->",
"Render",
"(",
"'Blank'",
",",
"'Utility'",
")",
";",
"}"
] | Restore logs.
@since 2.0.?
@access public
@param array $LogIDs List of log IDs. | [
"Restore",
"logs",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.logcontroller.php#L296-L310 |
9,213 | bishopb/vanilla | applications/dashboard/controllers/class.logcontroller.php | LogController.Spam | public function Spam($Page = '') {
$this->Permission('Garden.Moderation.Manage');
list($Offset, $Limit) = OffsetLimit($Page, 10);
$this->SetData('Title', T('Spam Queue'));
$Where = array('Operation' => array('Spam'));
$RecordCount = $this->LogModel->GetCountWhere($Where);
$this->SetData('RecordCount', $RecordCount);
if ($Offset >= $RecordCount)
$Offset = $RecordCount - $Limit;
$Log = $this->LogModel->GetWhere($Where, 'LogID', 'Desc', $Offset, $Limit);
$this->SetData('Log', $Log);
if ($this->DeliveryType() == DELIVERY_TYPE_VIEW)
$this->View = 'Table';
$this->AddSideMenu('dashboard/log/spam');
$this->Render();
} | php | public function Spam($Page = '') {
$this->Permission('Garden.Moderation.Manage');
list($Offset, $Limit) = OffsetLimit($Page, 10);
$this->SetData('Title', T('Spam Queue'));
$Where = array('Operation' => array('Spam'));
$RecordCount = $this->LogModel->GetCountWhere($Where);
$this->SetData('RecordCount', $RecordCount);
if ($Offset >= $RecordCount)
$Offset = $RecordCount - $Limit;
$Log = $this->LogModel->GetWhere($Where, 'LogID', 'Desc', $Offset, $Limit);
$this->SetData('Log', $Log);
if ($this->DeliveryType() == DELIVERY_TYPE_VIEW)
$this->View = 'Table';
$this->AddSideMenu('dashboard/log/spam');
$this->Render();
} | [
"public",
"function",
"Spam",
"(",
"$",
"Page",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Moderation.Manage'",
")",
";",
"list",
"(",
"$",
"Offset",
",",
"$",
"Limit",
")",
"=",
"OffsetLimit",
"(",
"$",
"Page",
",",
"10",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Title'",
",",
"T",
"(",
"'Spam Queue'",
")",
")",
";",
"$",
"Where",
"=",
"array",
"(",
"'Operation'",
"=>",
"array",
"(",
"'Spam'",
")",
")",
";",
"$",
"RecordCount",
"=",
"$",
"this",
"->",
"LogModel",
"->",
"GetCountWhere",
"(",
"$",
"Where",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'RecordCount'",
",",
"$",
"RecordCount",
")",
";",
"if",
"(",
"$",
"Offset",
">=",
"$",
"RecordCount",
")",
"$",
"Offset",
"=",
"$",
"RecordCount",
"-",
"$",
"Limit",
";",
"$",
"Log",
"=",
"$",
"this",
"->",
"LogModel",
"->",
"GetWhere",
"(",
"$",
"Where",
",",
"'LogID'",
",",
"'Desc'",
",",
"$",
"Offset",
",",
"$",
"Limit",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'Log'",
",",
"$",
"Log",
")",
";",
"if",
"(",
"$",
"this",
"->",
"DeliveryType",
"(",
")",
"==",
"DELIVERY_TYPE_VIEW",
")",
"$",
"this",
"->",
"View",
"=",
"'Table'",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'dashboard/log/spam'",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | View spam logs.
@since 2.0.?
@access public
@param int $Page Page number. | [
"View",
"spam",
"logs",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.logcontroller.php#L355-L375 |
9,214 | jmpantoja/planb-utils | src/DS/Exception/InvalidArgumentException.php | InvalidArgumentException.make | public static function make($data, string $reason, ?\Throwable $previous = null): self
{
$message = self::buildMessage($data, $reason);
return new static($message, $previous);
} | php | public static function make($data, string $reason, ?\Throwable $previous = null): self
{
$message = self::buildMessage($data, $reason);
return new static($message, $previous);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"data",
",",
"string",
"$",
"reason",
",",
"?",
"\\",
"Throwable",
"$",
"previous",
"=",
"null",
")",
":",
"self",
"{",
"$",
"message",
"=",
"self",
"::",
"buildMessage",
"(",
"$",
"data",
",",
"$",
"reason",
")",
";",
"return",
"new",
"static",
"(",
"$",
"message",
",",
"$",
"previous",
")",
";",
"}"
] | InvalidItemException named constructor.
@param mixed $data
@param string $reason
@param null|\Throwable $previous
@return \PlanB\DS\Exception\InvalidArgumentException | [
"InvalidItemException",
"named",
"constructor",
"."
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/DS/Exception/InvalidArgumentException.php#L41-L47 |
9,215 | kore/CTXParser | src/php/CTXParser/Tokenizer.php | Tokenizer.getTokenName | public function getTokenName($type)
{
if (!isset($this->tokenNames[$type])) {
throw new \RuntimeException(
"Unknown token $type."
);
}
return $this->tokenNames[$type];
} | php | public function getTokenName($type)
{
if (!isset($this->tokenNames[$type])) {
throw new \RuntimeException(
"Unknown token $type."
);
}
return $this->tokenNames[$type];
} | [
"public",
"function",
"getTokenName",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tokenNames",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Unknown token $type.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"tokenNames",
"[",
"$",
"type",
"]",
";",
"}"
] | Get token name
@param int $type
@return string | [
"Get",
"token",
"name"
] | 9b11c2311a9de61baee7edafe46d1671dd5833c4 | https://github.com/kore/CTXParser/blob/9b11c2311a9de61baee7edafe46d1671dd5833c4/src/php/CTXParser/Tokenizer.php#L79-L88 |
9,216 | Archi-Strasbourg/archi-wiki | modules/archi/includes/archiAdministration.class.php | ArchiAdministration.ajouterParcours | public function ajouterParcours($params = array())
{
if (isset($this->variablesPost['libelleParcours']) && $this->variablesPost['libelleParcours']!='' && isset($this->variablesPost['dateAjoutParcours']) && $this->variablesPost['dateAjoutParcours']!='') {
$d = new dateObject();
$parcoursActif = '0';
if (isset($this->variablesPost['isActif']) && $this->variablesPost['isActif']=='1') {
$parcoursActif = '1';
}
$reqInsert = "INSERT INTO parcoursArt (libelleParcours, isActif, dateAjoutParcours,commentaireParcours, idSource ) VALUES (";
$reqInsert .= "\"".mysql_real_escape_string($this->variablesPost['libelleParcours'])."\",";
$reqInsert .= "'".$parcoursActif."',";
$reqInsert .= "'".$d->toBdd($this->variablesPost['dateAjoutParcours'])."',";
$reqInsert .= "\"".mysql_real_escape_string($this->variablesPost['commentaireParcours'])."\",";
$reqInsert .= "'".$this->variablesPost['idSource']."'";
$reqInsert .= ")";
$resInsert = $this->connexionBdd->requete($reqInsert);
}
} | php | public function ajouterParcours($params = array())
{
if (isset($this->variablesPost['libelleParcours']) && $this->variablesPost['libelleParcours']!='' && isset($this->variablesPost['dateAjoutParcours']) && $this->variablesPost['dateAjoutParcours']!='') {
$d = new dateObject();
$parcoursActif = '0';
if (isset($this->variablesPost['isActif']) && $this->variablesPost['isActif']=='1') {
$parcoursActif = '1';
}
$reqInsert = "INSERT INTO parcoursArt (libelleParcours, isActif, dateAjoutParcours,commentaireParcours, idSource ) VALUES (";
$reqInsert .= "\"".mysql_real_escape_string($this->variablesPost['libelleParcours'])."\",";
$reqInsert .= "'".$parcoursActif."',";
$reqInsert .= "'".$d->toBdd($this->variablesPost['dateAjoutParcours'])."',";
$reqInsert .= "\"".mysql_real_escape_string($this->variablesPost['commentaireParcours'])."\",";
$reqInsert .= "'".$this->variablesPost['idSource']."'";
$reqInsert .= ")";
$resInsert = $this->connexionBdd->requete($reqInsert);
}
} | [
"public",
"function",
"ajouterParcours",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'libelleParcours'",
"]",
")",
"&&",
"$",
"this",
"->",
"variablesPost",
"[",
"'libelleParcours'",
"]",
"!=",
"''",
"&&",
"isset",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'dateAjoutParcours'",
"]",
")",
"&&",
"$",
"this",
"->",
"variablesPost",
"[",
"'dateAjoutParcours'",
"]",
"!=",
"''",
")",
"{",
"$",
"d",
"=",
"new",
"dateObject",
"(",
")",
";",
"$",
"parcoursActif",
"=",
"'0'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'isActif'",
"]",
")",
"&&",
"$",
"this",
"->",
"variablesPost",
"[",
"'isActif'",
"]",
"==",
"'1'",
")",
"{",
"$",
"parcoursActif",
"=",
"'1'",
";",
"}",
"$",
"reqInsert",
"=",
"\"INSERT INTO parcoursArt (libelleParcours, isActif, dateAjoutParcours,commentaireParcours, idSource ) VALUES (\"",
";",
"$",
"reqInsert",
".=",
"\"\\\"\"",
".",
"mysql_real_escape_string",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'libelleParcours'",
"]",
")",
".",
"\"\\\",\"",
";",
"$",
"reqInsert",
".=",
"\"'\"",
".",
"$",
"parcoursActif",
".",
"\"',\"",
";",
"$",
"reqInsert",
".=",
"\"'\"",
".",
"$",
"d",
"->",
"toBdd",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'dateAjoutParcours'",
"]",
")",
".",
"\"',\"",
";",
"$",
"reqInsert",
".=",
"\"\\\"\"",
".",
"mysql_real_escape_string",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'commentaireParcours'",
"]",
")",
".",
"\"\\\",\"",
";",
"$",
"reqInsert",
".=",
"\"'\"",
".",
"$",
"this",
"->",
"variablesPost",
"[",
"'idSource'",
"]",
".",
"\"'\"",
";",
"$",
"reqInsert",
".=",
"\")\"",
";",
"$",
"resInsert",
"=",
"$",
"this",
"->",
"connexionBdd",
"->",
"requete",
"(",
"$",
"reqInsert",
")",
";",
"}",
"}"
] | Ajouter un parcours
@param array $params Paramètres
@return void | [
"Ajouter",
"un",
"parcours"
] | b9fb39f43a78409890a7de96426c1f6c49d5c323 | https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdministration.class.php#L745-L762 |
9,217 | Archi-Strasbourg/archi-wiki | modules/archi/includes/archiAdministration.class.php | ArchiAdministration.modifierParcours | public function modifierParcours($params = array())
{
if (isset($this->variablesPost['idParcours']) && $this->variablesPost['idParcours']!='' && $this->variablesPost['idParcours']!='0' && isset($this->variablesPost['libelleParcours']) && $this->variablesPost['libelleParcours']!='' && isset($this->variablesPost['dateAjoutParcours']) && $this->variablesPost['dateAjoutParcours']!='') {
$d = new dateObject();
$parcoursActif = '0';
if (isset($this->variablesPost['isActif']) && $this->variablesPost['isActif']=='1') {
$parcoursActif = '1';
}
$reqUpdate = "UPDATE parcoursArt set dateAjoutParcours='".$d->toBdd($this->variablesPost['dateAjoutParcours'])."',isActif='".$parcoursActif."',libelleParcours=\"".mysql_real_escape_string($this->variablesPost['libelleParcours'])."\",commentaireParcours=\"".mysql_real_escape_string($this->variablesPost['commentaireParcours'])."\",idSource='".$this->variablesPost['idSource']."', trace='".mysql_escape_string($this->variablesPost['trace'])."', levels='".mysql_escape_string($this->variablesPost['newLevels'])."'
WHERE idParcours='".$this->variablesPost['idParcours']."'";
$resUpdate = $this->connexionBdd->requete($reqUpdate);
}
} | php | public function modifierParcours($params = array())
{
if (isset($this->variablesPost['idParcours']) && $this->variablesPost['idParcours']!='' && $this->variablesPost['idParcours']!='0' && isset($this->variablesPost['libelleParcours']) && $this->variablesPost['libelleParcours']!='' && isset($this->variablesPost['dateAjoutParcours']) && $this->variablesPost['dateAjoutParcours']!='') {
$d = new dateObject();
$parcoursActif = '0';
if (isset($this->variablesPost['isActif']) && $this->variablesPost['isActif']=='1') {
$parcoursActif = '1';
}
$reqUpdate = "UPDATE parcoursArt set dateAjoutParcours='".$d->toBdd($this->variablesPost['dateAjoutParcours'])."',isActif='".$parcoursActif."',libelleParcours=\"".mysql_real_escape_string($this->variablesPost['libelleParcours'])."\",commentaireParcours=\"".mysql_real_escape_string($this->variablesPost['commentaireParcours'])."\",idSource='".$this->variablesPost['idSource']."', trace='".mysql_escape_string($this->variablesPost['trace'])."', levels='".mysql_escape_string($this->variablesPost['newLevels'])."'
WHERE idParcours='".$this->variablesPost['idParcours']."'";
$resUpdate = $this->connexionBdd->requete($reqUpdate);
}
} | [
"public",
"function",
"modifierParcours",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'idParcours'",
"]",
")",
"&&",
"$",
"this",
"->",
"variablesPost",
"[",
"'idParcours'",
"]",
"!=",
"''",
"&&",
"$",
"this",
"->",
"variablesPost",
"[",
"'idParcours'",
"]",
"!=",
"'0'",
"&&",
"isset",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'libelleParcours'",
"]",
")",
"&&",
"$",
"this",
"->",
"variablesPost",
"[",
"'libelleParcours'",
"]",
"!=",
"''",
"&&",
"isset",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'dateAjoutParcours'",
"]",
")",
"&&",
"$",
"this",
"->",
"variablesPost",
"[",
"'dateAjoutParcours'",
"]",
"!=",
"''",
")",
"{",
"$",
"d",
"=",
"new",
"dateObject",
"(",
")",
";",
"$",
"parcoursActif",
"=",
"'0'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'isActif'",
"]",
")",
"&&",
"$",
"this",
"->",
"variablesPost",
"[",
"'isActif'",
"]",
"==",
"'1'",
")",
"{",
"$",
"parcoursActif",
"=",
"'1'",
";",
"}",
"$",
"reqUpdate",
"=",
"\"UPDATE parcoursArt set dateAjoutParcours='\"",
".",
"$",
"d",
"->",
"toBdd",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'dateAjoutParcours'",
"]",
")",
".",
"\"',isActif='\"",
".",
"$",
"parcoursActif",
".",
"\"',libelleParcours=\\\"\"",
".",
"mysql_real_escape_string",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'libelleParcours'",
"]",
")",
".",
"\"\\\",commentaireParcours=\\\"\"",
".",
"mysql_real_escape_string",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'commentaireParcours'",
"]",
")",
".",
"\"\\\",idSource='\"",
".",
"$",
"this",
"->",
"variablesPost",
"[",
"'idSource'",
"]",
".",
"\"', trace='\"",
".",
"mysql_escape_string",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'trace'",
"]",
")",
".",
"\"', levels='\"",
".",
"mysql_escape_string",
"(",
"$",
"this",
"->",
"variablesPost",
"[",
"'newLevels'",
"]",
")",
".",
"\"'\n WHERE idParcours='\"",
".",
"$",
"this",
"->",
"variablesPost",
"[",
"'idParcours'",
"]",
".",
"\"'\"",
";",
"$",
"resUpdate",
"=",
"$",
"this",
"->",
"connexionBdd",
"->",
"requete",
"(",
"$",
"reqUpdate",
")",
";",
"}",
"}"
] | Modifier un parcours
@param array $params Paramètres
@return void | [
"Modifier",
"un",
"parcours"
] | b9fb39f43a78409890a7de96426c1f6c49d5c323 | https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdministration.class.php#L771-L783 |
9,218 | zebba/Utility | ParameterConverter.php | ParameterConverter.toArray | static public function toArray($args, $type_of = null)
{
if (is_array($args)) {
$failed = array_filter($args, function ($e) use ($type_of) {
return (! is_object($e) || ! $e instanceof $type_of);
});
if (0 < count($failed)) {
throw new \DomainException(sprintf('You must provide only objects of class %s.', $type_of));
}
} else {
if (! is_object($args) || ! $args instanceof $type_of) {
throw new \DomainException(sprintf('You must provide only objects of class %s.', $type_of));
}
$args = array($args);
}
return $args;
} | php | static public function toArray($args, $type_of = null)
{
if (is_array($args)) {
$failed = array_filter($args, function ($e) use ($type_of) {
return (! is_object($e) || ! $e instanceof $type_of);
});
if (0 < count($failed)) {
throw new \DomainException(sprintf('You must provide only objects of class %s.', $type_of));
}
} else {
if (! is_object($args) || ! $args instanceof $type_of) {
throw new \DomainException(sprintf('You must provide only objects of class %s.', $type_of));
}
$args = array($args);
}
return $args;
} | [
"static",
"public",
"function",
"toArray",
"(",
"$",
"args",
",",
"$",
"type_of",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"$",
"failed",
"=",
"array_filter",
"(",
"$",
"args",
",",
"function",
"(",
"$",
"e",
")",
"use",
"(",
"$",
"type_of",
")",
"{",
"return",
"(",
"!",
"is_object",
"(",
"$",
"e",
")",
"||",
"!",
"$",
"e",
"instanceof",
"$",
"type_of",
")",
";",
"}",
")",
";",
"if",
"(",
"0",
"<",
"count",
"(",
"$",
"failed",
")",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"sprintf",
"(",
"'You must provide only objects of class %s.'",
",",
"$",
"type_of",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"args",
")",
"||",
"!",
"$",
"args",
"instanceof",
"$",
"type_of",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"sprintf",
"(",
"'You must provide only objects of class %s.'",
",",
"$",
"type_of",
")",
")",
";",
"}",
"$",
"args",
"=",
"array",
"(",
"$",
"args",
")",
";",
"}",
"return",
"$",
"args",
";",
"}"
] | Returns an array of objects of the same type
<code>
<?php
namespace Foo;
$now = new \DateTime('now');
$datetimes = \Zebba\Component\Utility\ParameterConverter::toArray($now, '\DateTime'); // array($now)
$datetimes = \Zebba\Component\Utility\ParameterConverter::toArray(array($now, $now), '\DateTime'); // array($now, $now)
?>
</code>
@param mixed:object|object[] $args
@param string $type_of
@throws \DomainException if the provided input does not match the specified type $type_of
@return object[] | [
"Returns",
"an",
"array",
"of",
"objects",
"of",
"the",
"same",
"type"
] | 7c6be69b12927f2286ad7c88be176b01f9d75827 | https://github.com/zebba/Utility/blob/7c6be69b12927f2286ad7c88be176b01f9d75827/ParameterConverter.php#L29-L48 |
9,219 | Stratadox/HydrationMapper | src/Instruction/Relation/HasMany.php | HasMany.manyNestedInThe | private function manyNestedInThe(string $property): MapsProperty
{
if (null !== $this->container && !class_exists($this->container)) {
throw NoSuchClass::couldNotLoadCollection($this->container);
}
return $this->addConstraintTo(HasManyNested::inPropertyWithDifferentKey(
$property,
$this->keyOr($property),
$this->container(),
$this->hydrator()
));
} | php | private function manyNestedInThe(string $property): MapsProperty
{
if (null !== $this->container && !class_exists($this->container)) {
throw NoSuchClass::couldNotLoadCollection($this->container);
}
return $this->addConstraintTo(HasManyNested::inPropertyWithDifferentKey(
$property,
$this->keyOr($property),
$this->container(),
$this->hydrator()
));
} | [
"private",
"function",
"manyNestedInThe",
"(",
"string",
"$",
"property",
")",
":",
"MapsProperty",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"container",
"&&",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"container",
")",
")",
"{",
"throw",
"NoSuchClass",
"::",
"couldNotLoadCollection",
"(",
"$",
"this",
"->",
"container",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addConstraintTo",
"(",
"HasManyNested",
"::",
"inPropertyWithDifferentKey",
"(",
"$",
"property",
",",
"$",
"this",
"->",
"keyOr",
"(",
"$",
"property",
")",
",",
"$",
"this",
"->",
"container",
"(",
")",
",",
"$",
"this",
"->",
"hydrator",
"(",
")",
")",
")",
";",
"}"
] | Maps an eagerly loaded collection from a nested data set.
@param string $property The property that gets a nested eager relationship.
@return MapsProperty The resulting property mapping.
@throws InvalidMapperConfiguration | [
"Maps",
"an",
"eagerly",
"loaded",
"collection",
"from",
"a",
"nested",
"data",
"set",
"."
] | d9bf1f10b7626312e0a2466a2ef255ec972acb41 | https://github.com/Stratadox/HydrationMapper/blob/d9bf1f10b7626312e0a2466a2ef255ec972acb41/src/Instruction/Relation/HasMany.php#L57-L68 |
9,220 | Stratadox/HydrationMapper | src/Instruction/Relation/HasMany.php | HasMany.manyProxiesInThe | private function manyProxiesInThe(string $property): MapsProperty
{
if (null === $this->loader) {
throw NoLoaderAvailable::whilstRequiredFor($this->class);
}
return $this->addConstraintTo(HasManyProxies::inPropertyWithDifferentKey(
$property,
$this->keyOr($property),
$this->container(),
ProxyFactory::fromThis(
SimpleHydrator::forThe($this->class),
$this->loader,
$this->updaterFactory()
)
));
} | php | private function manyProxiesInThe(string $property): MapsProperty
{
if (null === $this->loader) {
throw NoLoaderAvailable::whilstRequiredFor($this->class);
}
return $this->addConstraintTo(HasManyProxies::inPropertyWithDifferentKey(
$property,
$this->keyOr($property),
$this->container(),
ProxyFactory::fromThis(
SimpleHydrator::forThe($this->class),
$this->loader,
$this->updaterFactory()
)
));
} | [
"private",
"function",
"manyProxiesInThe",
"(",
"string",
"$",
"property",
")",
":",
"MapsProperty",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"loader",
")",
"{",
"throw",
"NoLoaderAvailable",
"::",
"whilstRequiredFor",
"(",
"$",
"this",
"->",
"class",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addConstraintTo",
"(",
"HasManyProxies",
"::",
"inPropertyWithDifferentKey",
"(",
"$",
"property",
",",
"$",
"this",
"->",
"keyOr",
"(",
"$",
"property",
")",
",",
"$",
"this",
"->",
"container",
"(",
")",
",",
"ProxyFactory",
"::",
"fromThis",
"(",
"SimpleHydrator",
"::",
"forThe",
"(",
"$",
"this",
"->",
"class",
")",
",",
"$",
"this",
"->",
"loader",
",",
"$",
"this",
"->",
"updaterFactory",
"(",
")",
")",
")",
")",
";",
"}"
] | Maps an extra lazily loaded collection as list of proxies.
@param string $property The property that gets an extra lazy relationship.
@return MapsProperty The resulting property mapping.
@throws InvalidMapperConfiguration | [
"Maps",
"an",
"extra",
"lazily",
"loaded",
"collection",
"as",
"list",
"of",
"proxies",
"."
] | d9bf1f10b7626312e0a2466a2ef255ec972acb41 | https://github.com/Stratadox/HydrationMapper/blob/d9bf1f10b7626312e0a2466a2ef255ec972acb41/src/Instruction/Relation/HasMany.php#L77-L92 |
9,221 | Stratadox/HydrationMapper | src/Instruction/Relation/HasMany.php | HasMany.oneProxyInThe | private function oneProxyInThe(string $property): MapsProperty
{
if (null === $this->loader) {
throw NoLoaderAvailable::whilstRequiredFor($this->class);
}
if (null === $this->container) {
throw NoContainerAvailable::whilstRequiredFor($this->class);
}
try {
return HasOneProxy::inProperty($property,
ProxyFactory::fromThis(
SimpleHydrator::forThe($this->container),
$this->loader,
new PropertyUpdaterFactory
)
);
} catch (CannotInstantiateThis $problem) {
throw NoSuchClass::couldNotLoadCollection($this->container);
}
} | php | private function oneProxyInThe(string $property): MapsProperty
{
if (null === $this->loader) {
throw NoLoaderAvailable::whilstRequiredFor($this->class);
}
if (null === $this->container) {
throw NoContainerAvailable::whilstRequiredFor($this->class);
}
try {
return HasOneProxy::inProperty($property,
ProxyFactory::fromThis(
SimpleHydrator::forThe($this->container),
$this->loader,
new PropertyUpdaterFactory
)
);
} catch (CannotInstantiateThis $problem) {
throw NoSuchClass::couldNotLoadCollection($this->container);
}
} | [
"private",
"function",
"oneProxyInThe",
"(",
"string",
"$",
"property",
")",
":",
"MapsProperty",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"loader",
")",
"{",
"throw",
"NoLoaderAvailable",
"::",
"whilstRequiredFor",
"(",
"$",
"this",
"->",
"class",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"container",
")",
"{",
"throw",
"NoContainerAvailable",
"::",
"whilstRequiredFor",
"(",
"$",
"this",
"->",
"class",
")",
";",
"}",
"try",
"{",
"return",
"HasOneProxy",
"::",
"inProperty",
"(",
"$",
"property",
",",
"ProxyFactory",
"::",
"fromThis",
"(",
"SimpleHydrator",
"::",
"forThe",
"(",
"$",
"this",
"->",
"container",
")",
",",
"$",
"this",
"->",
"loader",
",",
"new",
"PropertyUpdaterFactory",
")",
")",
";",
"}",
"catch",
"(",
"CannotInstantiateThis",
"$",
"problem",
")",
"{",
"throw",
"NoSuchClass",
"::",
"couldNotLoadCollection",
"(",
"$",
"this",
"->",
"container",
")",
";",
"}",
"}"
] | Maps a lazily loaded collection as a single proxy.
@param string $property The property that gets a lazy relationship.
@return MapsProperty The resulting property mapping.
@throws InvalidMapperConfiguration | [
"Maps",
"a",
"lazily",
"loaded",
"collection",
"as",
"a",
"single",
"proxy",
"."
] | d9bf1f10b7626312e0a2466a2ef255ec972acb41 | https://github.com/Stratadox/HydrationMapper/blob/d9bf1f10b7626312e0a2466a2ef255ec972acb41/src/Instruction/Relation/HasMany.php#L101-L120 |
9,222 | marando/color | src/Marando/Color/Color.php | Color.rgb | public static function rgb($r = 255, $g = 255, $b = 255)
{
// Check if values are in range.
static::validateComp('R', $r, 0, 255);
static::validateComp('G', $g, 0, 255);
static::validateComp('B', $b, 0, 255);
return new static($r, $g, $b);
} | php | public static function rgb($r = 255, $g = 255, $b = 255)
{
// Check if values are in range.
static::validateComp('R', $r, 0, 255);
static::validateComp('G', $g, 0, 255);
static::validateComp('B', $b, 0, 255);
return new static($r, $g, $b);
} | [
"public",
"static",
"function",
"rgb",
"(",
"$",
"r",
"=",
"255",
",",
"$",
"g",
"=",
"255",
",",
"$",
"b",
"=",
"255",
")",
"{",
"// Check if values are in range.",
"static",
"::",
"validateComp",
"(",
"'R'",
",",
"$",
"r",
",",
"0",
",",
"255",
")",
";",
"static",
"::",
"validateComp",
"(",
"'G'",
",",
"$",
"g",
",",
"0",
",",
"255",
")",
";",
"static",
"::",
"validateComp",
"(",
"'B'",
",",
"$",
"b",
",",
"0",
",",
"255",
")",
";",
"return",
"new",
"static",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"}"
] | Creates a new Color instance from RGB components ranging from 0 to 255.
@param int $r Red, 0-255
@param int $g Green, 0-255
@param int $b Blue, 0-255
@return static | [
"Creates",
"a",
"new",
"Color",
"instance",
"from",
"RGB",
"components",
"ranging",
"from",
"0",
"to",
"255",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L84-L92 |
9,223 | marando/color | src/Marando/Color/Color.php | Color.hex | public static function hex($hex)
{
// RGB Hex -> RGB
static::hex2rgb($hex, $r, $g, $b);
return static::rgb($r, $g, $b);
} | php | public static function hex($hex)
{
// RGB Hex -> RGB
static::hex2rgb($hex, $r, $g, $b);
return static::rgb($r, $g, $b);
} | [
"public",
"static",
"function",
"hex",
"(",
"$",
"hex",
")",
"{",
"// RGB Hex -> RGB",
"static",
"::",
"hex2rgb",
"(",
"$",
"hex",
",",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"return",
"static",
"::",
"rgb",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"}"
] | Creates a new Color instance from an RGB hex color code. Both six digit
and 3 digit hex codes are supported.
@param $hex Hex color in format #7d52eb or #7d5.
@return Color | [
"Creates",
"a",
"new",
"Color",
"instance",
"from",
"an",
"RGB",
"hex",
"color",
"code",
".",
"Both",
"six",
"digit",
"and",
"3",
"digit",
"hex",
"codes",
"are",
"supported",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L125-L131 |
9,224 | marando/color | src/Marando/Color/Color.php | Color.rand | public static function rand($h = [0, 360], $s = [0, 1], $l = [0, 1])
{
// Validate input criteria
static::validateComp('H low', $h[0], 0, 360);
static::validateComp('S low', $s[0], 0, 1);
static::validateComp('L low', $l[0], 0, 1);
static::validateComp('H high', $h[1], 0, 360);
static::validateComp('S high', $s[1], 0, 1);
static::validateComp('L high', $l[1], 0, 1);
// Loop until calculated random HSL -> RGB -> HSL value matches params.
$i = 0;
while (true) {
// Random HSL color
$color = static::hsl(
static::randFloat($h[0], $h[1], 1),
static::randFloat($s[0], $s[1], 0.001),
static::randFloat($l[0], $l[1], 0.001)
);
// Check if the HSL matches the input criteria
$hMatch = $color->h >= $h[0] && $color->h <= $h[1];
$sMatch = $color->s >= $s[0] && $color->s <= $s[1];
$lMatch = $color->l >= $l[0] && $color->l <= $l[1];
if ($hMatch && $sMatch && $lMatch) {
// Match found...
break;
} elseif ($i > 50) {
// Stop if not found by now.
throw new Exception();
break;
} else {
$i++;
}
}
return $color;
} | php | public static function rand($h = [0, 360], $s = [0, 1], $l = [0, 1])
{
// Validate input criteria
static::validateComp('H low', $h[0], 0, 360);
static::validateComp('S low', $s[0], 0, 1);
static::validateComp('L low', $l[0], 0, 1);
static::validateComp('H high', $h[1], 0, 360);
static::validateComp('S high', $s[1], 0, 1);
static::validateComp('L high', $l[1], 0, 1);
// Loop until calculated random HSL -> RGB -> HSL value matches params.
$i = 0;
while (true) {
// Random HSL color
$color = static::hsl(
static::randFloat($h[0], $h[1], 1),
static::randFloat($s[0], $s[1], 0.001),
static::randFloat($l[0], $l[1], 0.001)
);
// Check if the HSL matches the input criteria
$hMatch = $color->h >= $h[0] && $color->h <= $h[1];
$sMatch = $color->s >= $s[0] && $color->s <= $s[1];
$lMatch = $color->l >= $l[0] && $color->l <= $l[1];
if ($hMatch && $sMatch && $lMatch) {
// Match found...
break;
} elseif ($i > 50) {
// Stop if not found by now.
throw new Exception();
break;
} else {
$i++;
}
}
return $color;
} | [
"public",
"static",
"function",
"rand",
"(",
"$",
"h",
"=",
"[",
"0",
",",
"360",
"]",
",",
"$",
"s",
"=",
"[",
"0",
",",
"1",
"]",
",",
"$",
"l",
"=",
"[",
"0",
",",
"1",
"]",
")",
"{",
"// Validate input criteria",
"static",
"::",
"validateComp",
"(",
"'H low'",
",",
"$",
"h",
"[",
"0",
"]",
",",
"0",
",",
"360",
")",
";",
"static",
"::",
"validateComp",
"(",
"'S low'",
",",
"$",
"s",
"[",
"0",
"]",
",",
"0",
",",
"1",
")",
";",
"static",
"::",
"validateComp",
"(",
"'L low'",
",",
"$",
"l",
"[",
"0",
"]",
",",
"0",
",",
"1",
")",
";",
"static",
"::",
"validateComp",
"(",
"'H high'",
",",
"$",
"h",
"[",
"1",
"]",
",",
"0",
",",
"360",
")",
";",
"static",
"::",
"validateComp",
"(",
"'S high'",
",",
"$",
"s",
"[",
"1",
"]",
",",
"0",
",",
"1",
")",
";",
"static",
"::",
"validateComp",
"(",
"'L high'",
",",
"$",
"l",
"[",
"1",
"]",
",",
"0",
",",
"1",
")",
";",
"// Loop until calculated random HSL -> RGB -> HSL value matches params.",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"// Random HSL color",
"$",
"color",
"=",
"static",
"::",
"hsl",
"(",
"static",
"::",
"randFloat",
"(",
"$",
"h",
"[",
"0",
"]",
",",
"$",
"h",
"[",
"1",
"]",
",",
"1",
")",
",",
"static",
"::",
"randFloat",
"(",
"$",
"s",
"[",
"0",
"]",
",",
"$",
"s",
"[",
"1",
"]",
",",
"0.001",
")",
",",
"static",
"::",
"randFloat",
"(",
"$",
"l",
"[",
"0",
"]",
",",
"$",
"l",
"[",
"1",
"]",
",",
"0.001",
")",
")",
";",
"// Check if the HSL matches the input criteria",
"$",
"hMatch",
"=",
"$",
"color",
"->",
"h",
">=",
"$",
"h",
"[",
"0",
"]",
"&&",
"$",
"color",
"->",
"h",
"<=",
"$",
"h",
"[",
"1",
"]",
";",
"$",
"sMatch",
"=",
"$",
"color",
"->",
"s",
">=",
"$",
"s",
"[",
"0",
"]",
"&&",
"$",
"color",
"->",
"s",
"<=",
"$",
"s",
"[",
"1",
"]",
";",
"$",
"lMatch",
"=",
"$",
"color",
"->",
"l",
">=",
"$",
"l",
"[",
"0",
"]",
"&&",
"$",
"color",
"->",
"l",
"<=",
"$",
"l",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"hMatch",
"&&",
"$",
"sMatch",
"&&",
"$",
"lMatch",
")",
"{",
"// Match found...",
"break",
";",
"}",
"elseif",
"(",
"$",
"i",
">",
"50",
")",
"{",
"// Stop if not found by now.",
"throw",
"new",
"Exception",
"(",
")",
";",
"break",
";",
"}",
"else",
"{",
"$",
"i",
"++",
";",
"}",
"}",
"return",
"$",
"color",
";",
"}"
] | Generates a random color. Minimum and maximum values are specified for
all of the HSL components.
@param array $h Random hue min/max, 0-360
@param array $s Random saturation min/max, 0-1
@param array $l Random lightness min/max, 0-1
@return Color
@throws Exception | [
"Generates",
"a",
"random",
"color",
".",
"Minimum",
"and",
"maximum",
"values",
"are",
"specified",
"for",
"all",
"of",
"the",
"HSL",
"components",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L144-L182 |
9,225 | marando/color | src/Marando/Color/Color.php | Color.parse | public static function parse($color)
{
$hsl = '/hsl\(([0-9]{1,3}),\s*([0-9]{1,3})%,\s*([0-9]{1,3})%\)/';
$rgb = '/rgb\(([0-9]{1,3}),\s*([0-9]{1,3}),\s*([0-9]{1,3})\)/';
// HSL
if (preg_match($hsl, $color, $m)) {
return static::hsl((int)$m[1], (int)$m[2] / 100, (int)$m[3] / 100);
} // RGB
elseif (preg_match($rgb, $color, $m)) {
return static::rgb((int)$m[1], (int)$m[2], (int)$m[3]);
} // Hex
else {
return static::hex($color);
};
} | php | public static function parse($color)
{
$hsl = '/hsl\(([0-9]{1,3}),\s*([0-9]{1,3})%,\s*([0-9]{1,3})%\)/';
$rgb = '/rgb\(([0-9]{1,3}),\s*([0-9]{1,3}),\s*([0-9]{1,3})\)/';
// HSL
if (preg_match($hsl, $color, $m)) {
return static::hsl((int)$m[1], (int)$m[2] / 100, (int)$m[3] / 100);
} // RGB
elseif (preg_match($rgb, $color, $m)) {
return static::rgb((int)$m[1], (int)$m[2], (int)$m[3]);
} // Hex
else {
return static::hex($color);
};
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"color",
")",
"{",
"$",
"hsl",
"=",
"'/hsl\\(([0-9]{1,3}),\\s*([0-9]{1,3})%,\\s*([0-9]{1,3})%\\)/'",
";",
"$",
"rgb",
"=",
"'/rgb\\(([0-9]{1,3}),\\s*([0-9]{1,3}),\\s*([0-9]{1,3})\\)/'",
";",
"// HSL",
"if",
"(",
"preg_match",
"(",
"$",
"hsl",
",",
"$",
"color",
",",
"$",
"m",
")",
")",
"{",
"return",
"static",
"::",
"hsl",
"(",
"(",
"int",
")",
"$",
"m",
"[",
"1",
"]",
",",
"(",
"int",
")",
"$",
"m",
"[",
"2",
"]",
"/",
"100",
",",
"(",
"int",
")",
"$",
"m",
"[",
"3",
"]",
"/",
"100",
")",
";",
"}",
"// RGB",
"elseif",
"(",
"preg_match",
"(",
"$",
"rgb",
",",
"$",
"color",
",",
"$",
"m",
")",
")",
"{",
"return",
"static",
"::",
"rgb",
"(",
"(",
"int",
")",
"$",
"m",
"[",
"1",
"]",
",",
"(",
"int",
")",
"$",
"m",
"[",
"2",
"]",
",",
"(",
"int",
")",
"$",
"m",
"[",
"3",
"]",
")",
";",
"}",
"// Hex",
"else",
"{",
"return",
"static",
"::",
"hex",
"(",
"$",
"color",
")",
";",
"}",
";",
"}"
] | Parses an HTML color in either hex, hsl, or rgb.
@param $color
@return Color | [
"Parses",
"an",
"HTML",
"color",
"in",
"either",
"hex",
"hsl",
"or",
"rgb",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L191-L207 |
9,226 | marando/color | src/Marando/Color/Color.php | Color.dist | public function dist(Color $c)
{
return sqrt(
($c->r - $this->r) ** 2 +
($c->g - $this->g) ** 2 +
($c->b - $this->b) ** 2
);
} | php | public function dist(Color $c)
{
return sqrt(
($c->r - $this->r) ** 2 +
($c->g - $this->g) ** 2 +
($c->b - $this->b) ** 2
);
} | [
"public",
"function",
"dist",
"(",
"Color",
"$",
"c",
")",
"{",
"return",
"sqrt",
"(",
"(",
"$",
"c",
"->",
"r",
"-",
"$",
"this",
"->",
"r",
")",
"**",
"2",
"+",
"(",
"$",
"c",
"->",
"g",
"-",
"$",
"this",
"->",
"g",
")",
"**",
"2",
"+",
"(",
"$",
"c",
"->",
"b",
"-",
"$",
"this",
"->",
"b",
")",
"**",
"2",
")",
";",
"}"
] | Calculates the distance between this color and another.
@param Color $c
@return float | [
"Calculates",
"the",
"distance",
"between",
"this",
"color",
"and",
"another",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L274-L281 |
9,227 | marando/color | src/Marando/Color/Color.php | Color.calcHSL | private function calcHSL()
{
// RGB -> HSL
self::rgb2hsl($this->r, $this->g, $this->b, $h, $s, $l);
return [$h, $s, $l];
} | php | private function calcHSL()
{
// RGB -> HSL
self::rgb2hsl($this->r, $this->g, $this->b, $h, $s, $l);
return [$h, $s, $l];
} | [
"private",
"function",
"calcHSL",
"(",
")",
"{",
"// RGB -> HSL",
"self",
"::",
"rgb2hsl",
"(",
"$",
"this",
"->",
"r",
",",
"$",
"this",
"->",
"g",
",",
"$",
"this",
"->",
"b",
",",
"$",
"h",
",",
"$",
"s",
",",
"$",
"l",
")",
";",
"return",
"[",
"$",
"h",
",",
"$",
"s",
",",
"$",
"l",
"]",
";",
"}"
] | Calculates this color's HSL components.
@return array | [
"Calculates",
"this",
"color",
"s",
"HSL",
"components",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L290-L296 |
9,228 | marando/color | src/Marando/Color/Color.php | Color.validateComp | private static function validateComp($component, $value, $min, $max)
{
if ($value < $min || $value > $max) {
throw new Exception(
"{$component} component {$value} must be {$min}-{$max}");
}
} | php | private static function validateComp($component, $value, $min, $max)
{
if ($value < $min || $value > $max) {
throw new Exception(
"{$component} component {$value} must be {$min}-{$max}");
}
} | [
"private",
"static",
"function",
"validateComp",
"(",
"$",
"component",
",",
"$",
"value",
",",
"$",
"min",
",",
"$",
"max",
")",
"{",
"if",
"(",
"$",
"value",
"<",
"$",
"min",
"||",
"$",
"value",
">",
"$",
"max",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"{$component} component {$value} must be {$min}-{$max}\"",
")",
";",
"}",
"}"
] | Validates a color component to see if fits within a range.
@param $component Name of the component.
@param $value Value of the component.
@param $min Min value allowed.
@param $max Max value allowed.
@throws Exception | [
"Validates",
"a",
"color",
"component",
"to",
"see",
"if",
"fits",
"within",
"a",
"range",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L323-L329 |
9,229 | marando/color | src/Marando/Color/Color.php | Color.rgb2hsl | private static function rgb2hsl($r, $g, $b, &$h, &$s, &$l)
{
$r /= 255;
$g /= 255;
$b /= 255;
$min = min([$r, $g, $b]);
$max = max([$r, $g, $b]);
$l = ($min + $max) / 2;
$l = round($l, 2);
if ($min == $max) {
$s = 0;
$h = 0;
return;
}
if ($l < 0.5) {
$s = ($max - $min) / ($max + $min);
} else {
$s = ($max - $min) / (2.0 - $max - $min);
}
if ($r == $max) {
$h = ($g - $b) / ($max - $min);
} elseif ($g == $max) {
$h = 2.0 + ($b - $r) / ($max - $min);
} else {
$h = 4.0 + ($r - $g) / ($max - $min);
}
$h *= 60;
$h = $h < 0 ? $h + 360 : $h;
$h = (int)round($h);
$s = round($s, 2);
} | php | private static function rgb2hsl($r, $g, $b, &$h, &$s, &$l)
{
$r /= 255;
$g /= 255;
$b /= 255;
$min = min([$r, $g, $b]);
$max = max([$r, $g, $b]);
$l = ($min + $max) / 2;
$l = round($l, 2);
if ($min == $max) {
$s = 0;
$h = 0;
return;
}
if ($l < 0.5) {
$s = ($max - $min) / ($max + $min);
} else {
$s = ($max - $min) / (2.0 - $max - $min);
}
if ($r == $max) {
$h = ($g - $b) / ($max - $min);
} elseif ($g == $max) {
$h = 2.0 + ($b - $r) / ($max - $min);
} else {
$h = 4.0 + ($r - $g) / ($max - $min);
}
$h *= 60;
$h = $h < 0 ? $h + 360 : $h;
$h = (int)round($h);
$s = round($s, 2);
} | [
"private",
"static",
"function",
"rgb2hsl",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
",",
"&",
"$",
"h",
",",
"&",
"$",
"s",
",",
"&",
"$",
"l",
")",
"{",
"$",
"r",
"/=",
"255",
";",
"$",
"g",
"/=",
"255",
";",
"$",
"b",
"/=",
"255",
";",
"$",
"min",
"=",
"min",
"(",
"[",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
"]",
")",
";",
"$",
"max",
"=",
"max",
"(",
"[",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
"]",
")",
";",
"$",
"l",
"=",
"(",
"$",
"min",
"+",
"$",
"max",
")",
"/",
"2",
";",
"$",
"l",
"=",
"round",
"(",
"$",
"l",
",",
"2",
")",
";",
"if",
"(",
"$",
"min",
"==",
"$",
"max",
")",
"{",
"$",
"s",
"=",
"0",
";",
"$",
"h",
"=",
"0",
";",
"return",
";",
"}",
"if",
"(",
"$",
"l",
"<",
"0.5",
")",
"{",
"$",
"s",
"=",
"(",
"$",
"max",
"-",
"$",
"min",
")",
"/",
"(",
"$",
"max",
"+",
"$",
"min",
")",
";",
"}",
"else",
"{",
"$",
"s",
"=",
"(",
"$",
"max",
"-",
"$",
"min",
")",
"/",
"(",
"2.0",
"-",
"$",
"max",
"-",
"$",
"min",
")",
";",
"}",
"if",
"(",
"$",
"r",
"==",
"$",
"max",
")",
"{",
"$",
"h",
"=",
"(",
"$",
"g",
"-",
"$",
"b",
")",
"/",
"(",
"$",
"max",
"-",
"$",
"min",
")",
";",
"}",
"elseif",
"(",
"$",
"g",
"==",
"$",
"max",
")",
"{",
"$",
"h",
"=",
"2.0",
"+",
"(",
"$",
"b",
"-",
"$",
"r",
")",
"/",
"(",
"$",
"max",
"-",
"$",
"min",
")",
";",
"}",
"else",
"{",
"$",
"h",
"=",
"4.0",
"+",
"(",
"$",
"r",
"-",
"$",
"g",
")",
"/",
"(",
"$",
"max",
"-",
"$",
"min",
")",
";",
"}",
"$",
"h",
"*=",
"60",
";",
"$",
"h",
"=",
"$",
"h",
"<",
"0",
"?",
"$",
"h",
"+",
"360",
":",
"$",
"h",
";",
"$",
"h",
"=",
"(",
"int",
")",
"round",
"(",
"$",
"h",
")",
";",
"$",
"s",
"=",
"round",
"(",
"$",
"s",
",",
"2",
")",
";",
"}"
] | Converts RGB to HSL.
@param $r Red, 0-255
@param $g Green, 0-255
@param $b Blue, 0-255
@param $h Hue, 0-360°
@param $s Saturation, 0-1
@param $l Lightness, 0-1 | [
"Converts",
"RGB",
"to",
"HSL",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L429-L467 |
9,230 | marando/color | src/Marando/Color/Color.php | Color.hex2rgb | private static function hex2rgb($hex, &$r, &$g, &$b)
{
// Remove hash if present
$hex = preg_replace('/[^a-fA-F0-9]/', '', $hex);
if (strlen($hex) == 6) {
// 6-digit hex
$r = substr($hex, 0, 2);
$g = substr($hex, 2, 2);
$b = substr($hex, 4, 2);
} else {
// 3-digit hex, pad to 6 total...
$r = $hex[0] . $hex[0];
$g = $hex[1] . $hex[1];
$b = $hex[2] . $hex[2];
}
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
} | php | private static function hex2rgb($hex, &$r, &$g, &$b)
{
// Remove hash if present
$hex = preg_replace('/[^a-fA-F0-9]/', '', $hex);
if (strlen($hex) == 6) {
// 6-digit hex
$r = substr($hex, 0, 2);
$g = substr($hex, 2, 2);
$b = substr($hex, 4, 2);
} else {
// 3-digit hex, pad to 6 total...
$r = $hex[0] . $hex[0];
$g = $hex[1] . $hex[1];
$b = $hex[2] . $hex[2];
}
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
} | [
"private",
"static",
"function",
"hex2rgb",
"(",
"$",
"hex",
",",
"&",
"$",
"r",
",",
"&",
"$",
"g",
",",
"&",
"$",
"b",
")",
"{",
"// Remove hash if present",
"$",
"hex",
"=",
"preg_replace",
"(",
"'/[^a-fA-F0-9]/'",
",",
"''",
",",
"$",
"hex",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"hex",
")",
"==",
"6",
")",
"{",
"// 6-digit hex",
"$",
"r",
"=",
"substr",
"(",
"$",
"hex",
",",
"0",
",",
"2",
")",
";",
"$",
"g",
"=",
"substr",
"(",
"$",
"hex",
",",
"2",
",",
"2",
")",
";",
"$",
"b",
"=",
"substr",
"(",
"$",
"hex",
",",
"4",
",",
"2",
")",
";",
"}",
"else",
"{",
"// 3-digit hex, pad to 6 total...",
"$",
"r",
"=",
"$",
"hex",
"[",
"0",
"]",
".",
"$",
"hex",
"[",
"0",
"]",
";",
"$",
"g",
"=",
"$",
"hex",
"[",
"1",
"]",
".",
"$",
"hex",
"[",
"1",
"]",
";",
"$",
"b",
"=",
"$",
"hex",
"[",
"2",
"]",
".",
"$",
"hex",
"[",
"2",
"]",
";",
"}",
"$",
"r",
"=",
"hexdec",
"(",
"$",
"r",
")",
";",
"$",
"g",
"=",
"hexdec",
"(",
"$",
"g",
")",
";",
"$",
"b",
"=",
"hexdec",
"(",
"$",
"b",
")",
";",
"}"
] | Converts an RGB Hex code to RGB.
@param $hex RGB Hex code, in format #7d52eb or #7d5
@param $r Red, 0-255
@param $g Green, 0-255
@param $b Blue,0-255 | [
"Converts",
"an",
"RGB",
"Hex",
"code",
"to",
"RGB",
"."
] | 04583283a56aa7239e26d0ae99ccbee2e4849347 | https://github.com/marando/color/blob/04583283a56aa7239e26d0ae99ccbee2e4849347/src/Marando/Color/Color.php#L491-L511 |
9,231 | Sowapps/orpheus-sqladapter | src/SQLRequest/SQLRequest.php | SQLRequest.getClone | public function getClone($withParameters=true) {
$clone = new static($this->sqlAdapter, $this->idField, $this->class);
if( $withParameters ) {
$clone->parameters = $this->parameters;
}
return $clone;
} | php | public function getClone($withParameters=true) {
$clone = new static($this->sqlAdapter, $this->idField, $this->class);
if( $withParameters ) {
$clone->parameters = $this->parameters;
}
return $clone;
} | [
"public",
"function",
"getClone",
"(",
"$",
"withParameters",
"=",
"true",
")",
"{",
"$",
"clone",
"=",
"new",
"static",
"(",
"$",
"this",
"->",
"sqlAdapter",
",",
"$",
"this",
"->",
"idField",
",",
"$",
"this",
"->",
"class",
")",
";",
"if",
"(",
"$",
"withParameters",
")",
"{",
"$",
"clone",
"->",
"parameters",
"=",
"$",
"this",
"->",
"parameters",
";",
"}",
"return",
"$",
"clone",
";",
"}"
] | Get a clone of current request
@param string $withParameters True to also copy parameters, default to true
@return SQLRequest | [
"Get",
"a",
"clone",
"of",
"current",
"request"
] | d7730e70f84d7d877a688ff4408cefea34117a1c | https://github.com/Sowapps/orpheus-sqladapter/blob/d7730e70f84d7d877a688ff4408cefea34117a1c/src/SQLRequest/SQLRequest.php#L73-L79 |
9,232 | Sowapps/orpheus-sqladapter | src/SQLRequest/SQLRequest.php | SQLRequest.get | protected function get($parameter, $default=null) {
return isset($this->parameters[$parameter]) ? $this->parameters[$parameter] : $default;
} | php | protected function get($parameter, $default=null) {
return isset($this->parameters[$parameter]) ? $this->parameters[$parameter] : $default;
} | [
"protected",
"function",
"get",
"(",
"$",
"parameter",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",
"$",
"parameter",
"]",
")",
"?",
"$",
"this",
"->",
"parameters",
"[",
"$",
"parameter",
"]",
":",
"$",
"default",
";",
"}"
] | Get a parameter for this query
@param string $parameter
@param mixed $default
@return mixed | [
"Get",
"a",
"parameter",
"for",
"this",
"query"
] | d7730e70f84d7d877a688ff4408cefea34117a1c | https://github.com/Sowapps/orpheus-sqladapter/blob/d7730e70f84d7d877a688ff4408cefea34117a1c/src/SQLRequest/SQLRequest.php#L127-L129 |
9,233 | Sowapps/orpheus-sqladapter | src/SQLRequest/SQLRequest.php | SQLRequest.getQuery | public function getQuery() {
$output = $this->get('output');
try {
$this->set('output', SQLAdapter::SQLQUERY);
$result = $this->run();
} catch( \Exception $e ) {
}
$this->set('output', $output);
if( isset($e) ) {
throw $e;
}
return $result;
} | php | public function getQuery() {
$output = $this->get('output');
try {
$this->set('output', SQLAdapter::SQLQUERY);
$result = $this->run();
} catch( \Exception $e ) {
}
$this->set('output', $output);
if( isset($e) ) {
throw $e;
}
return $result;
} | [
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"get",
"(",
"'output'",
")",
";",
"try",
"{",
"$",
"this",
"->",
"set",
"(",
"'output'",
",",
"SQLAdapter",
"::",
"SQLQUERY",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"$",
"this",
"->",
"set",
"(",
"'output'",
",",
"$",
"output",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"e",
")",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get the query as string
@throws Exception
@return string | [
"Get",
"the",
"query",
"as",
"string"
] | d7730e70f84d7d877a688ff4408cefea34117a1c | https://github.com/Sowapps/orpheus-sqladapter/blob/d7730e70f84d7d877a688ff4408cefea34117a1c/src/SQLRequest/SQLRequest.php#L171-L188 |
9,234 | open-orchestra/open-orchestra-front-bundle | FrontBundle/Manager/NodeResponseManager.php | NodeResponseManager.formatCacheInfo | protected function formatCacheInfo($MaxAge, $isPublic)
{
if (is_null($MaxAge)) {
$MaxAge = 0;
}
return array(self::MAX_AGE => $MaxAge, self::IS_PUBLIC => $isPublic);
} | php | protected function formatCacheInfo($MaxAge, $isPublic)
{
if (is_null($MaxAge)) {
$MaxAge = 0;
}
return array(self::MAX_AGE => $MaxAge, self::IS_PUBLIC => $isPublic);
} | [
"protected",
"function",
"formatCacheInfo",
"(",
"$",
"MaxAge",
",",
"$",
"isPublic",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"MaxAge",
")",
")",
"{",
"$",
"MaxAge",
"=",
"0",
";",
"}",
"return",
"array",
"(",
"self",
"::",
"MAX_AGE",
"=>",
"$",
"MaxAge",
",",
"self",
"::",
"IS_PUBLIC",
"=>",
"$",
"isPublic",
")",
";",
"}"
] | Generate a CacheInfo
@param int|null $MaxAge
@param bool $isPublic
@return array | [
"Generate",
"a",
"CacheInfo"
] | 3c2cf3998af03e7a69fb6475b71d9c7d65b058bb | https://github.com/open-orchestra/open-orchestra-front-bundle/blob/3c2cf3998af03e7a69fb6475b71d9c7d65b058bb/FrontBundle/Manager/NodeResponseManager.php#L103-L110 |
9,235 | open-orchestra/open-orchestra-front-bundle | FrontBundle/Manager/NodeResponseManager.php | NodeResponseManager.mergeCacheInfo | protected function mergeCacheInfo(array $cacheInfo1, array $cacheInfo2)
{
$maxAge = $cacheInfo1[self::MAX_AGE];
if ($maxAge < 0 || (($cacheInfo2[self::MAX_AGE] < $maxAge)) && (-1 < $cacheInfo2[self::MAX_AGE])) {
$maxAge = $cacheInfo2[self::MAX_AGE];
}
$isPublic = $cacheInfo1[self::IS_PUBLIC] && $cacheInfo2[self::IS_PUBLIC];
return $this->formatCacheInfo($maxAge, $isPublic);
} | php | protected function mergeCacheInfo(array $cacheInfo1, array $cacheInfo2)
{
$maxAge = $cacheInfo1[self::MAX_AGE];
if ($maxAge < 0 || (($cacheInfo2[self::MAX_AGE] < $maxAge)) && (-1 < $cacheInfo2[self::MAX_AGE])) {
$maxAge = $cacheInfo2[self::MAX_AGE];
}
$isPublic = $cacheInfo1[self::IS_PUBLIC] && $cacheInfo2[self::IS_PUBLIC];
return $this->formatCacheInfo($maxAge, $isPublic);
} | [
"protected",
"function",
"mergeCacheInfo",
"(",
"array",
"$",
"cacheInfo1",
",",
"array",
"$",
"cacheInfo2",
")",
"{",
"$",
"maxAge",
"=",
"$",
"cacheInfo1",
"[",
"self",
"::",
"MAX_AGE",
"]",
";",
"if",
"(",
"$",
"maxAge",
"<",
"0",
"||",
"(",
"(",
"$",
"cacheInfo2",
"[",
"self",
"::",
"MAX_AGE",
"]",
"<",
"$",
"maxAge",
")",
")",
"&&",
"(",
"-",
"1",
"<",
"$",
"cacheInfo2",
"[",
"self",
"::",
"MAX_AGE",
"]",
")",
")",
"{",
"$",
"maxAge",
"=",
"$",
"cacheInfo2",
"[",
"self",
"::",
"MAX_AGE",
"]",
";",
"}",
"$",
"isPublic",
"=",
"$",
"cacheInfo1",
"[",
"self",
"::",
"IS_PUBLIC",
"]",
"&&",
"$",
"cacheInfo2",
"[",
"self",
"::",
"IS_PUBLIC",
"]",
";",
"return",
"$",
"this",
"->",
"formatCacheInfo",
"(",
"$",
"maxAge",
",",
"$",
"isPublic",
")",
";",
"}"
] | Merge two CacheInfo
@param array $cacheInfo1
@param array $cacheInfo2
@return array | [
"Merge",
"two",
"CacheInfo"
] | 3c2cf3998af03e7a69fb6475b71d9c7d65b058bb | https://github.com/open-orchestra/open-orchestra-front-bundle/blob/3c2cf3998af03e7a69fb6475b71d9c7d65b058bb/FrontBundle/Manager/NodeResponseManager.php#L120-L131 |
9,236 | nick-jones/simple-config | lib/SimpleConfig/Container.php | Container.offsetGet | public function offsetGet($field) {
if (isset($this->values[$field]) || $this->load($field)) {
return $this->values[$field];
}
return NULL;
} | php | public function offsetGet($field) {
if (isset($this->values[$field]) || $this->load($field)) {
return $this->values[$field];
}
return NULL;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"field",
"]",
")",
"||",
"$",
"this",
"->",
"load",
"(",
"$",
"field",
")",
")",
"{",
"return",
"$",
"this",
"->",
"values",
"[",
"$",
"field",
"]",
";",
"}",
"return",
"NULL",
";",
"}"
] | Retrieves a config value. If there is none, it will attempt to run a factory, if available.
@param mixed $field
@return mixed | [
"Retrieves",
"a",
"config",
"value",
".",
"If",
"there",
"is",
"none",
"it",
"will",
"attempt",
"to",
"run",
"a",
"factory",
"if",
"available",
"."
] | d828e18a87e52bb2b22448bcfb471aac17cb90d7 | https://github.com/nick-jones/simple-config/blob/d828e18a87e52bb2b22448bcfb471aac17cb90d7/lib/SimpleConfig/Container.php#L56-L62 |
9,237 | nick-jones/simple-config | lib/SimpleConfig/Container.php | Container.load | protected function load($field) {
if ($this->factoryExists($field)) {
$this->values[$field] = $this->runFactory($field);
return TRUE;
}
return FALSE;
} | php | protected function load($field) {
if ($this->factoryExists($field)) {
$this->values[$field] = $this->runFactory($field);
return TRUE;
}
return FALSE;
} | [
"protected",
"function",
"load",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"factoryExists",
"(",
"$",
"field",
")",
")",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"field",
"]",
"=",
"$",
"this",
"->",
"runFactory",
"(",
"$",
"field",
")",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Populates a config field with the result of a factory being run, if one exists.
@param string $field The name of the field to be loaded
@return bool TRUE if a factory has been successfully run, FALSE otherwise | [
"Populates",
"a",
"config",
"field",
"with",
"the",
"result",
"of",
"a",
"factory",
"being",
"run",
"if",
"one",
"exists",
"."
] | d828e18a87e52bb2b22448bcfb471aac17cb90d7 | https://github.com/nick-jones/simple-config/blob/d828e18a87e52bb2b22448bcfb471aac17cb90d7/lib/SimpleConfig/Container.php#L113-L120 |
9,238 | arnulfojr/apihistogram | ApiHistogram/ApiHistogramBundle/Repository/Dynamic/DynamicRepository.php | DynamicRepository.createTable | protected function createTable(SiteCapsuleInterface $capsule, array $parameters)
{
if ($this->tableExists($capsule))
{
return;
}
$connection = $this->getConnection();
/** @var AbstractSchemaManager $schemaManager */
$schemaManager = $connection->getSchemaManager();
$table = $this->buildTable($capsule, $parameters);
$schemaManager->createTable($table);
} | php | protected function createTable(SiteCapsuleInterface $capsule, array $parameters)
{
if ($this->tableExists($capsule))
{
return;
}
$connection = $this->getConnection();
/** @var AbstractSchemaManager $schemaManager */
$schemaManager = $connection->getSchemaManager();
$table = $this->buildTable($capsule, $parameters);
$schemaManager->createTable($table);
} | [
"protected",
"function",
"createTable",
"(",
"SiteCapsuleInterface",
"$",
"capsule",
",",
"array",
"$",
"parameters",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tableExists",
"(",
"$",
"capsule",
")",
")",
"{",
"return",
";",
"}",
"$",
"connection",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"/** @var AbstractSchemaManager $schemaManager */",
"$",
"schemaManager",
"=",
"$",
"connection",
"->",
"getSchemaManager",
"(",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"buildTable",
"(",
"$",
"capsule",
",",
"$",
"parameters",
")",
";",
"$",
"schemaManager",
"->",
"createTable",
"(",
"$",
"table",
")",
";",
"}"
] | Creates Table needed to persist the wished response
@param SiteCapsuleInterface $capsule
@param array $parameters
@throws PersistException | [
"Creates",
"Table",
"needed",
"to",
"persist",
"the",
"wished",
"response"
] | 842b126211996c81c121cb3128199e17f105e1f4 | https://github.com/arnulfojr/apihistogram/blob/842b126211996c81c121cb3128199e17f105e1f4/ApiHistogram/ApiHistogramBundle/Repository/Dynamic/DynamicRepository.php#L88-L102 |
9,239 | novuso/novusopress | core/NavbarWalker.php | NavbarWalker.end_lvl | public function end_lvl(&$output, $depth = 0, $args = [])
{
$indent = str_repeat(' ', $this->indent + $depth + 1);
$output .= sprintf('%s</ul>%s', $indent, PHP_EOL);
} | php | public function end_lvl(&$output, $depth = 0, $args = [])
{
$indent = str_repeat(' ', $this->indent + $depth + 1);
$output .= sprintf('%s</ul>%s', $indent, PHP_EOL);
} | [
"public",
"function",
"end_lvl",
"(",
"&",
"$",
"output",
",",
"$",
"depth",
"=",
"0",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"indent",
"=",
"str_repeat",
"(",
"' '",
",",
"$",
"this",
"->",
"indent",
"+",
"$",
"depth",
"+",
"1",
")",
";",
"$",
"output",
".=",
"sprintf",
"(",
"'%s</ul>%s'",
",",
"$",
"indent",
",",
"PHP_EOL",
")",
";",
"}"
] | Ends the list of after the elements are added
@param string $output Passed by reference. Used to append additional content.
@param integer $depth Depth of menu item. Used for padding.
@param array $args An array of arguments.
@see \Walker::end_lvl() | [
"Ends",
"the",
"list",
"of",
"after",
"the",
"elements",
"are",
"added"
] | e31a46b0afa4126788f5754f928552ce13f8531f | https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/NavbarWalker.php#L58-L62 |
9,240 | novuso/novusopress | core/NavbarWalker.php | NavbarWalker.end_el | public function end_el(&$output, $item, $depth = 0, $args = [])
{
if ($depth === 0 && in_array('menu-item-has-children', $item->classes)) {
$indent = str_repeat(' ', $this->indent + $depth);
$output .= sprintf('%s</li>%s', $indent, PHP_EOL);
} else {
$output .= sprintf('</li>%s', PHP_EOL);
}
} | php | public function end_el(&$output, $item, $depth = 0, $args = [])
{
if ($depth === 0 && in_array('menu-item-has-children', $item->classes)) {
$indent = str_repeat(' ', $this->indent + $depth);
$output .= sprintf('%s</li>%s', $indent, PHP_EOL);
} else {
$output .= sprintf('</li>%s', PHP_EOL);
}
} | [
"public",
"function",
"end_el",
"(",
"&",
"$",
"output",
",",
"$",
"item",
",",
"$",
"depth",
"=",
"0",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"depth",
"===",
"0",
"&&",
"in_array",
"(",
"'menu-item-has-children'",
",",
"$",
"item",
"->",
"classes",
")",
")",
"{",
"$",
"indent",
"=",
"str_repeat",
"(",
"' '",
",",
"$",
"this",
"->",
"indent",
"+",
"$",
"depth",
")",
";",
"$",
"output",
".=",
"sprintf",
"(",
"'%s</li>%s'",
",",
"$",
"indent",
",",
"PHP_EOL",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"sprintf",
"(",
"'</li>%s'",
",",
"PHP_EOL",
")",
";",
"}",
"}"
] | Ends the element output, if needed
@param string $output Passed by reference. Used to append additional content.
@param object $item Page data object. Not used.
@param integer $depth Depth of page. Not Used.
@param array $args An array of arguments.
@see \Walker::end_el() | [
"Ends",
"the",
"element",
"output",
"if",
"needed"
] | e31a46b0afa4126788f5754f928552ce13f8531f | https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/NavbarWalker.php#L145-L153 |
9,241 | novuso/novusopress | core/NavbarWalker.php | NavbarWalker.display_element | public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output)
{
if (!$element) {
return;
}
$id_field = $this->db_fields['id'];
if (is_object($args[0])) {
$args[0]->has_children = !empty($children_elements[$element->$id_field]);
}
return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
} | php | public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output)
{
if (!$element) {
return;
}
$id_field = $this->db_fields['id'];
if (is_object($args[0])) {
$args[0]->has_children = !empty($children_elements[$element->$id_field]);
}
return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
} | [
"public",
"function",
"display_element",
"(",
"$",
"element",
",",
"&",
"$",
"children_elements",
",",
"$",
"max_depth",
",",
"$",
"depth",
",",
"$",
"args",
",",
"&",
"$",
"output",
")",
"{",
"if",
"(",
"!",
"$",
"element",
")",
"{",
"return",
";",
"}",
"$",
"id_field",
"=",
"$",
"this",
"->",
"db_fields",
"[",
"'id'",
"]",
";",
"if",
"(",
"is_object",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"args",
"[",
"0",
"]",
"->",
"has_children",
"=",
"!",
"empty",
"(",
"$",
"children_elements",
"[",
"$",
"element",
"->",
"$",
"id_field",
"]",
")",
";",
"}",
"return",
"parent",
"::",
"display_element",
"(",
"$",
"element",
",",
"$",
"children_elements",
",",
"$",
"max_depth",
",",
"$",
"depth",
",",
"$",
"args",
",",
"$",
"output",
")",
";",
"}"
] | Traverse elements to create list from elements
Display one element if the element doesn't have any children otherwise,
display the element and its children. Will only traverse up to the max
depth and no ignore elements under that depth.
This method shouldn't be called directly, use the walk() method instead.
@param object $element Data object.
@param array $children_elements List of elements to continue traversing.
@param integer $max_depth Max depth to traverse.
@param integer $depth Depth of current element.
@param array $args An array of arguments.
@param string $output Passed by reference. Used to append additional content.
@return null | [
"Traverse",
"elements",
"to",
"create",
"list",
"from",
"elements"
] | e31a46b0afa4126788f5754f928552ce13f8531f | https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/NavbarWalker.php#L173-L186 |
9,242 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-filter/src/AbstractUnicode.php | AbstractUnicode.setEncoding | public function setEncoding($encoding = null)
{
if ($encoding !== null) {
if (!function_exists('mb_strtolower')) {
throw new Exception\ExtensionNotLoadedException(sprintf(
'%s requires mbstring extension to be loaded',
get_class($this)
));
}
$encoding = strtolower($encoding);
$mbEncodings = array_map('strtolower', mb_list_encodings());
if (!in_array($encoding, $mbEncodings)) {
throw new Exception\InvalidArgumentException(sprintf(
"Encoding '%s' is not supported by mbstring extension",
$encoding
));
}
}
$this->options['encoding'] = $encoding;
return $this;
} | php | public function setEncoding($encoding = null)
{
if ($encoding !== null) {
if (!function_exists('mb_strtolower')) {
throw new Exception\ExtensionNotLoadedException(sprintf(
'%s requires mbstring extension to be loaded',
get_class($this)
));
}
$encoding = strtolower($encoding);
$mbEncodings = array_map('strtolower', mb_list_encodings());
if (!in_array($encoding, $mbEncodings)) {
throw new Exception\InvalidArgumentException(sprintf(
"Encoding '%s' is not supported by mbstring extension",
$encoding
));
}
}
$this->options['encoding'] = $encoding;
return $this;
} | [
"public",
"function",
"setEncoding",
"(",
"$",
"encoding",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"encoding",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'mb_strtolower'",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ExtensionNotLoadedException",
"(",
"sprintf",
"(",
"'%s requires mbstring extension to be loaded'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"$",
"encoding",
"=",
"strtolower",
"(",
"$",
"encoding",
")",
";",
"$",
"mbEncodings",
"=",
"array_map",
"(",
"'strtolower'",
",",
"mb_list_encodings",
"(",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"encoding",
",",
"$",
"mbEncodings",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"Encoding '%s' is not supported by mbstring extension\"",
",",
"$",
"encoding",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"options",
"[",
"'encoding'",
"]",
"=",
"$",
"encoding",
";",
"return",
"$",
"this",
";",
"}"
] | Set the input encoding for the given string
@param string|null $encoding
@return self
@throws Exception\InvalidArgumentException
@throws Exception\ExtensionNotLoadedException | [
"Set",
"the",
"input",
"encoding",
"for",
"the",
"given",
"string"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/AbstractUnicode.php#L22-L44 |
9,243 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-filter/src/AbstractUnicode.php | AbstractUnicode.getEncoding | public function getEncoding()
{
if ($this->options['encoding'] === null && function_exists('mb_internal_encoding')) {
$this->options['encoding'] = mb_internal_encoding();
}
return $this->options['encoding'];
} | php | public function getEncoding()
{
if ($this->options['encoding'] === null && function_exists('mb_internal_encoding')) {
$this->options['encoding'] = mb_internal_encoding();
}
return $this->options['encoding'];
} | [
"public",
"function",
"getEncoding",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'encoding'",
"]",
"===",
"null",
"&&",
"function_exists",
"(",
"'mb_internal_encoding'",
")",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'encoding'",
"]",
"=",
"mb_internal_encoding",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"options",
"[",
"'encoding'",
"]",
";",
"}"
] | Returns the set encoding
@return string | [
"Returns",
"the",
"set",
"encoding"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/AbstractUnicode.php#L51-L58 |
9,244 | Ya-hui/php-curl | src/Response.php | Response.json | public function json()
{
$this->response->data = json_decode($this->response->body);
return $this->response;
} | php | public function json()
{
$this->response->data = json_decode($this->response->body);
return $this->response;
} | [
"public",
"function",
"json",
"(",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"data",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"response",
"->",
"body",
")",
";",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] | Convert to JSON string
@return object Response content | [
"Convert",
"to",
"JSON",
"string"
] | 45b49802db3bb2a20d328d4a5275caea5510ef38 | https://github.com/Ya-hui/php-curl/blob/45b49802db3bb2a20d328d4a5275caea5510ef38/src/Response.php#L60-L65 |
9,245 | studyportals/Utils | src/HTTP.php | HTTP.detectBaseURL | public static function detectBaseURL(){
if(PHP_SAPI == 'cli') return 'http://php-cli.invalid/';
$protocol = 'http://';
if(isset($_SERVER['HTTPS']) &&
filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)){
$protocol = 'https://';
}
/*
* We use Apache's user-dir feature for our local development
* environments (e.g. "http://localhost/~Academic/"). In order for
* base URL detection to properly pick up on these URL's we use the
* CONTEXT_PREFIX environment variable provided by recent (2.3.13+)
* versions of Apache.
*/
if(isset($_SERVER['CONTEXT_PREFIX'])){
$path = trim($_SERVER['CONTEXT_PREFIX'], '/\\') . '/';
}
else{
$path = './';
}
return self::normaliseURL("{$protocol}{$_SERVER['HTTP_HOST']}/{$path}");
} | php | public static function detectBaseURL(){
if(PHP_SAPI == 'cli') return 'http://php-cli.invalid/';
$protocol = 'http://';
if(isset($_SERVER['HTTPS']) &&
filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)){
$protocol = 'https://';
}
/*
* We use Apache's user-dir feature for our local development
* environments (e.g. "http://localhost/~Academic/"). In order for
* base URL detection to properly pick up on these URL's we use the
* CONTEXT_PREFIX environment variable provided by recent (2.3.13+)
* versions of Apache.
*/
if(isset($_SERVER['CONTEXT_PREFIX'])){
$path = trim($_SERVER['CONTEXT_PREFIX'], '/\\') . '/';
}
else{
$path = './';
}
return self::normaliseURL("{$protocol}{$_SERVER['HTTP_HOST']}/{$path}");
} | [
"public",
"static",
"function",
"detectBaseURL",
"(",
")",
"{",
"if",
"(",
"PHP_SAPI",
"==",
"'cli'",
")",
"return",
"'http://php-cli.invalid/'",
";",
"$",
"protocol",
"=",
"'http://'",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"&&",
"filter_var",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
")",
"{",
"$",
"protocol",
"=",
"'https://'",
";",
"}",
"/*\n\t\t * We use Apache's user-dir feature for our local development\n\t\t * environments (e.g. \"http://localhost/~Academic/\"). In order for\n\t\t * base URL detection to properly pick up on these URL's we use the\n\t\t * CONTEXT_PREFIX environment variable provided by recent (2.3.13+)\n\t\t * versions of Apache.\n\t\t */",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'CONTEXT_PREFIX'",
"]",
")",
")",
"{",
"$",
"path",
"=",
"trim",
"(",
"$",
"_SERVER",
"[",
"'CONTEXT_PREFIX'",
"]",
",",
"'/\\\\'",
")",
".",
"'/'",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"'./'",
";",
"}",
"return",
"self",
"::",
"normaliseURL",
"(",
"\"{$protocol}{$_SERVER['HTTP_HOST']}/{$path}\"",
")",
";",
"}"
] | Detect the base URL for the current request.
<p>URL detection is based upon the server environment. It is assumed the
URL always points to a directory on the server, <strong>not</strong> a
file. A trailing slash is thus always appended to the URL returned.</p>
<p>When When the request is run in CLI-mode, the URL
<strong>http://php-cli.invalid/</strong> is returned.</p>
@return string | [
"Detect",
"the",
"base",
"URL",
"for",
"the",
"current",
"request",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/HTTP.php#L91-L121 |
9,246 | studyportals/Utils | src/HTTP.php | HTTP.status | public static function status($status, $suppress = false){
$message = self::getStatusMessage($status);
if($suppress){
@header("HTTP/1.1 $status $message");
}
else{
header("HTTP/1.1 $status $message");
}
return $message;
} | php | public static function status($status, $suppress = false){
$message = self::getStatusMessage($status);
if($suppress){
@header("HTTP/1.1 $status $message");
}
else{
header("HTTP/1.1 $status $message");
}
return $message;
} | [
"public",
"static",
"function",
"status",
"(",
"$",
"status",
",",
"$",
"suppress",
"=",
"false",
")",
"{",
"$",
"message",
"=",
"self",
"::",
"getStatusMessage",
"(",
"$",
"status",
")",
";",
"if",
"(",
"$",
"suppress",
")",
"{",
"@",
"header",
"(",
"\"HTTP/1.1 $status $message\"",
")",
";",
"}",
"else",
"{",
"header",
"(",
"\"HTTP/1.1 $status $message\"",
")",
";",
"}",
"return",
"$",
"message",
";",
"}"
] | Set HTTP status-code.
<p>Sets a HTTP/1.1 compliant header for the requested {@link $status}
and returns a short message (e.g. "Not Found") that goes along with the
status-code.</p>
@param integer $status
@param bool $suppress
@return string
@see _messages::$_codes
@see HTTP::message() | [
"Set",
"HTTP",
"status",
"-",
"code",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/HTTP.php#L138-L152 |
9,247 | studyportals/Utils | src/HTTP.php | HTTP.message | public static function message($status, $message){
$title = self::status($status);
?>
<html>
<head>
<title><?= $title; ?></title>
</head>
<body>
<h1><?= $title; ?></h1>
<p>
<?= htmlentities($message, ENT_COMPAT |
ENT_HTML401, 'ISO-8859-1'); ?>.
</p>
</body>
</html>
<?php
} | php | public static function message($status, $message){
$title = self::status($status);
?>
<html>
<head>
<title><?= $title; ?></title>
</head>
<body>
<h1><?= $title; ?></h1>
<p>
<?= htmlentities($message, ENT_COMPAT |
ENT_HTML401, 'ISO-8859-1'); ?>.
</p>
</body>
</html>
<?php
} | [
"public",
"static",
"function",
"message",
"(",
"$",
"status",
",",
"$",
"message",
")",
"{",
"$",
"title",
"=",
"self",
"::",
"status",
"(",
"$",
"status",
")",
";",
"?>\n\n\t\t\t<html>\n\t\t\t\t<head>\n\t\t\t\t\t<title><?=",
"$",
"title",
";",
"?></title>\n\t\t\t\t</head>\n\t\t\t\t<body>\n\t\t\t\t\t<h1><?=",
"$",
"title",
";",
"?></h1>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<?=",
"htmlentities",
"(",
"$",
"message",
",",
"ENT_COMPAT",
"|",
"ENT_HTML401",
",",
"'ISO-8859-1'",
")",
";",
"?>.\n\t\t\t\t\t</p>\n\t\t\t\t</body>\n\t\t\t</html>\n\n\t\t<?php",
"}"
] | Set HTTP status-code and display a message.
<p>Calls {@link HTTP::status()} with {@link $status} and shows the
provided {@link $message} in a simple HTML document. This method is
primarily intended to transfer basic error messages to the client.</p>
@param integer $status
@param string $message
@return void
@see HTTP::status() | [
"Set",
"HTTP",
"status",
"-",
"code",
"and",
"display",
"a",
"message",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/HTTP.php#L186-L206 |
9,248 | studyportals/Utils | src/HTTP.php | HTTP.redirect | public static function redirect($url, $status = 307){
if(!in_array($status, [300, 301, 302, 303, 307])){
$status = 307;
}
$url = trim($url);
// Append base URL to a relative path
if(strtolower(substr($url, 0, 4)) != 'http'){
$base_url = self::detectBaseURL();
// Unable to detect the base URL
if(empty($base_url)){
self::message(500, 'Unable to detect base URL');
return;
}
$url = $base_url . ltrim($url, '/');
}
// Check target URL
$url = self::normaliseURL($url);
if($url == ''){
self::message(500, 'Invalid URL provided for redirect operation');
return;
}
// Automatic redirect
if($status != HTTP::MULTIPLE_CHOICES){
self::status($status);
header("Location: $url");
}
// Manual redirect
else{
self::status(HTTP::MULTIPLE_CHOICES);
// Prevent the notification page from being cached
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 CEST');
}
?>
<html>
<head>
<title>This Page has Moved</title>
</head>
<body>
<h1>This Page has Moved</h1>
<p>
The page you have requested has moved to another
location.
</p>
<p>
If you are not automatically redirected to
<a href="<?= $url ?>">the page's new location</a>,
please click <a href="<?= $url ?>">here</a> to do so
manually.<br>
If you keep seeing this message, or are otherwise unable
to reach the new location, please return to
<a href="/">our homepage</a> and attempt to
reach the page from there.
</p>
</body>
</html>
<?php
} | php | public static function redirect($url, $status = 307){
if(!in_array($status, [300, 301, 302, 303, 307])){
$status = 307;
}
$url = trim($url);
// Append base URL to a relative path
if(strtolower(substr($url, 0, 4)) != 'http'){
$base_url = self::detectBaseURL();
// Unable to detect the base URL
if(empty($base_url)){
self::message(500, 'Unable to detect base URL');
return;
}
$url = $base_url . ltrim($url, '/');
}
// Check target URL
$url = self::normaliseURL($url);
if($url == ''){
self::message(500, 'Invalid URL provided for redirect operation');
return;
}
// Automatic redirect
if($status != HTTP::MULTIPLE_CHOICES){
self::status($status);
header("Location: $url");
}
// Manual redirect
else{
self::status(HTTP::MULTIPLE_CHOICES);
// Prevent the notification page from being cached
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 CEST');
}
?>
<html>
<head>
<title>This Page has Moved</title>
</head>
<body>
<h1>This Page has Moved</h1>
<p>
The page you have requested has moved to another
location.
</p>
<p>
If you are not automatically redirected to
<a href="<?= $url ?>">the page's new location</a>,
please click <a href="<?= $url ?>">here</a> to do so
manually.<br>
If you keep seeing this message, or are otherwise unable
to reach the new location, please return to
<a href="/">our homepage</a> and attempt to
reach the page from there.
</p>
</body>
</html>
<?php
} | [
"public",
"static",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"status",
"=",
"307",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"status",
",",
"[",
"300",
",",
"301",
",",
"302",
",",
"303",
",",
"307",
"]",
")",
")",
"{",
"$",
"status",
"=",
"307",
";",
"}",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"// Append base URL to a relative path",
"if",
"(",
"strtolower",
"(",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"4",
")",
")",
"!=",
"'http'",
")",
"{",
"$",
"base_url",
"=",
"self",
"::",
"detectBaseURL",
"(",
")",
";",
"// Unable to detect the base URL",
"if",
"(",
"empty",
"(",
"$",
"base_url",
")",
")",
"{",
"self",
"::",
"message",
"(",
"500",
",",
"'Unable to detect base URL'",
")",
";",
"return",
";",
"}",
"$",
"url",
"=",
"$",
"base_url",
".",
"ltrim",
"(",
"$",
"url",
",",
"'/'",
")",
";",
"}",
"// Check target URL",
"$",
"url",
"=",
"self",
"::",
"normaliseURL",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"url",
"==",
"''",
")",
"{",
"self",
"::",
"message",
"(",
"500",
",",
"'Invalid URL provided for redirect operation'",
")",
";",
"return",
";",
"}",
"// Automatic redirect",
"if",
"(",
"$",
"status",
"!=",
"HTTP",
"::",
"MULTIPLE_CHOICES",
")",
"{",
"self",
"::",
"status",
"(",
"$",
"status",
")",
";",
"header",
"(",
"\"Location: $url\"",
")",
";",
"}",
"// Manual redirect",
"else",
"{",
"self",
"::",
"status",
"(",
"HTTP",
"::",
"MULTIPLE_CHOICES",
")",
";",
"// Prevent the notification page from being cached",
"header",
"(",
"'Cache-Control: no-cache, must-revalidate'",
")",
";",
"header",
"(",
"'Expires: Sat, 26 Jul 1997 05:00:00 CEST'",
")",
";",
"}",
"?>\n\n\t\t\t<html>\n\t\t\t\t<head>\n\t\t\t\t\t<title>This Page has Moved</title>\n\t\t\t\t</head>\n\t\t\t\t<body>\n\t\t\t\t\t<h1>This Page has Moved</h1>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tThe page you have requested has moved to another\n\t\t\t\t\t\tlocation.\n\t\t\t\t\t</p>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tIf you are not automatically redirected to\n\t\t\t\t\t\t<a href=\"<?=",
"$",
"url",
"?>\">the page's new location</a>,\n\t\t\t\t\t\tplease click <a href=\"<?=",
"$",
"url",
"?>\">here</a> to do so\n\t\t\t\t\t\tmanually.<br>\n\t\t\t\t\t\tIf you keep seeing this message, or are otherwise unable\n\t\t\t\t\t\tto reach the new location, please return to\n\t\t\t\t\t\t<a href=\"/\">our homepage</a> and attempt to\n\t\t\t\t\t\treach the page from there.\n\t\t\t\t\t</p>\n\t\t\t\t</body>\n\t\t\t</html>\n\n\t\t<?php",
"}"
] | Redirect the browser to the provided path.
<p>The provided {@link $url} can be both a relative path, or an absolute
URL. In case the provided path is relative, the current request's base
URL is prepended.<br>
<strong>Note:</strong> This method does not terminate script execution.
Under normal circumstances you will want to terminate execution directly
after calling this method.</p>
<p>The following response codes are supported for the optional parameter
{@link $status}:</p>
<ul>
<li><b>300:</b> Multiple Choices (do not automatically redirect)</li>
<li><b>301:</b> Moved Permanently</li>
<li><b>302:</b> Found (if you want a "temporary redirect" do
<strong>not</strong> use, this status code, send 307 instead!)</li>
<li><b>303:</b> See Other (used to "transform" a POST-request
into a GET-request)</li>
<li><b>307:</b> Temporary Redirect (default, requires HTTP/1.1)</li>
</ul>
@param string $url
@param integer $status
@return void | [
"Redirect",
"the",
"browser",
"to",
"the",
"provided",
"path",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/HTTP.php#L235-L318 |
9,249 | studyportals/Utils | src/HTTP.php | HTTP.normaliseURL | public static function normaliseURL($url, array &$components = []){
$url = filter_var(trim($url), FILTER_SANITIZE_URL);
$components = @parse_url($url);
if(!$components || !isset($components['host'])){
return '';
}
// Scheme
if(!preg_match('/https*/i', $components['scheme'])){
switch($components['port']){
case 443:
$components['scheme'] = 'https';
break;
case 80:
default:
$components['scheme'] = 'http';
break;
}
}
// Remove default ports
if(!empty($components['port'])){
if($components['scheme'] == 'http' && $components['port'] == 80){
unset($components['port']);
}
elseif($components['scheme'] == 'https' &&
$components['port'] == 443){
unset($components['port']);
}
}
// Remove trailing dot from FQDN
if(substr($components['host'], -1) == '.'){
$components['host'] = substr($components['host'], 0, -1);
}
// Reconstruct URL
$normalised =
strtolower("{$components['scheme']}://{$components['host']}/");
if(isset($components['port'])){
$normalised = substr($normalised, 0, -1) . ":{$components['port']}/";
}
if(isset($components['path'])){
// Clean path
$components['path'] =
str_replace(['\\', '/./'], '/', $components['path']);
$components['path'] =
preg_replace('/[\/]+/', '/', $components['path']);
$normalised .= ltrim($components['path'], '/');
}
if(isset($components['query'])){
$normalised .= "?{$components['query']}";
}
if(isset($components['fragment'])){
$normalised .= "#{$components['fragment']}";
}
return $normalised;
} | php | public static function normaliseURL($url, array &$components = []){
$url = filter_var(trim($url), FILTER_SANITIZE_URL);
$components = @parse_url($url);
if(!$components || !isset($components['host'])){
return '';
}
// Scheme
if(!preg_match('/https*/i', $components['scheme'])){
switch($components['port']){
case 443:
$components['scheme'] = 'https';
break;
case 80:
default:
$components['scheme'] = 'http';
break;
}
}
// Remove default ports
if(!empty($components['port'])){
if($components['scheme'] == 'http' && $components['port'] == 80){
unset($components['port']);
}
elseif($components['scheme'] == 'https' &&
$components['port'] == 443){
unset($components['port']);
}
}
// Remove trailing dot from FQDN
if(substr($components['host'], -1) == '.'){
$components['host'] = substr($components['host'], 0, -1);
}
// Reconstruct URL
$normalised =
strtolower("{$components['scheme']}://{$components['host']}/");
if(isset($components['port'])){
$normalised = substr($normalised, 0, -1) . ":{$components['port']}/";
}
if(isset($components['path'])){
// Clean path
$components['path'] =
str_replace(['\\', '/./'], '/', $components['path']);
$components['path'] =
preg_replace('/[\/]+/', '/', $components['path']);
$normalised .= ltrim($components['path'], '/');
}
if(isset($components['query'])){
$normalised .= "?{$components['query']}";
}
if(isset($components['fragment'])){
$normalised .= "#{$components['fragment']}";
}
return $normalised;
} | [
"public",
"static",
"function",
"normaliseURL",
"(",
"$",
"url",
",",
"array",
"&",
"$",
"components",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"filter_var",
"(",
"trim",
"(",
"$",
"url",
")",
",",
"FILTER_SANITIZE_URL",
")",
";",
"$",
"components",
"=",
"@",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"$",
"components",
"||",
"!",
"isset",
"(",
"$",
"components",
"[",
"'host'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"// Scheme",
"if",
"(",
"!",
"preg_match",
"(",
"'/https*/i'",
",",
"$",
"components",
"[",
"'scheme'",
"]",
")",
")",
"{",
"switch",
"(",
"$",
"components",
"[",
"'port'",
"]",
")",
"{",
"case",
"443",
":",
"$",
"components",
"[",
"'scheme'",
"]",
"=",
"'https'",
";",
"break",
";",
"case",
"80",
":",
"default",
":",
"$",
"components",
"[",
"'scheme'",
"]",
"=",
"'http'",
";",
"break",
";",
"}",
"}",
"// Remove default ports",
"if",
"(",
"!",
"empty",
"(",
"$",
"components",
"[",
"'port'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"components",
"[",
"'scheme'",
"]",
"==",
"'http'",
"&&",
"$",
"components",
"[",
"'port'",
"]",
"==",
"80",
")",
"{",
"unset",
"(",
"$",
"components",
"[",
"'port'",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"components",
"[",
"'scheme'",
"]",
"==",
"'https'",
"&&",
"$",
"components",
"[",
"'port'",
"]",
"==",
"443",
")",
"{",
"unset",
"(",
"$",
"components",
"[",
"'port'",
"]",
")",
";",
"}",
"}",
"// Remove trailing dot from FQDN",
"if",
"(",
"substr",
"(",
"$",
"components",
"[",
"'host'",
"]",
",",
"-",
"1",
")",
"==",
"'.'",
")",
"{",
"$",
"components",
"[",
"'host'",
"]",
"=",
"substr",
"(",
"$",
"components",
"[",
"'host'",
"]",
",",
"0",
",",
"-",
"1",
")",
";",
"}",
"// Reconstruct URL",
"$",
"normalised",
"=",
"strtolower",
"(",
"\"{$components['scheme']}://{$components['host']}/\"",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"components",
"[",
"'port'",
"]",
")",
")",
"{",
"$",
"normalised",
"=",
"substr",
"(",
"$",
"normalised",
",",
"0",
",",
"-",
"1",
")",
".",
"\":{$components['port']}/\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"components",
"[",
"'path'",
"]",
")",
")",
"{",
"// Clean path",
"$",
"components",
"[",
"'path'",
"]",
"=",
"str_replace",
"(",
"[",
"'\\\\'",
",",
"'/./'",
"]",
",",
"'/'",
",",
"$",
"components",
"[",
"'path'",
"]",
")",
";",
"$",
"components",
"[",
"'path'",
"]",
"=",
"preg_replace",
"(",
"'/[\\/]+/'",
",",
"'/'",
",",
"$",
"components",
"[",
"'path'",
"]",
")",
";",
"$",
"normalised",
".=",
"ltrim",
"(",
"$",
"components",
"[",
"'path'",
"]",
",",
"'/'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"components",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"normalised",
".=",
"\"?{$components['query']}\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"components",
"[",
"'fragment'",
"]",
")",
")",
"{",
"$",
"normalised",
".=",
"\"#{$components['fragment']}\"",
";",
"}",
"return",
"$",
"normalised",
";",
"}"
] | Normalise a URL.
<p>This function attempts to normalise a URL as best as possible. This
function requires any URL passed to at least contain a host name and
an indication of the scheme (HTTP or HTTPS) to be used.</p>
<p>The optional, pass-by-reference, parameter {@link $components} is set
to the result of the internal call to {@link parse_url()} done by this
method (with a little bit of post-processing applied). This information
can be used to, for example, retrieve the hostname from the URL.</p>
<ul>
<li>Invalid characters are removed from the URL;</li>
<li>If no scheme information is present, "http://" is prepended;</li>
<li>If the scheme and port match, the port is removed;</li>
<li>If present, the trailing dot is removed from the host name;</li>
<li>The hostname is made all lowercase;</li>
<li>Optional path, query and fragment are appended to the URL;</li>
<li>The path component is cleaned of unnecessary and incorrect
slashes.</li>
</ul>
@param string $url
@param array &$components
@return string
@see parse_url() | [
"Normalise",
"a",
"URL",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/HTTP.php#L349-L435 |
9,250 | studyportals/Utils | src/HTTP.php | HTTP.getBaseURL | public static function getBaseURL($url){
$parsed_url = parse_url($url);
if($parsed_url === false){
throw new ErrorException('Malformed URL.');
}
$base_url = [];
if(empty($parsed_url['scheme'])){
throw new ErrorException('Malformed URL, no scheme.');
}
$base_url[] = $parsed_url['scheme'];
$base_url[] = '://';
$base_url[] = $parsed_url['host'];
// Check the path
$path = $parsed_url['path'];
$path_parts = explode('/', $path);
// Discard the first slash.
array_shift($path_parts);
$base = array_shift($path_parts);
// Check if we're on localhost
if(strpos($base, '~') !== false){
$base_url[] = '/' . $base;
};
$base_url[] = '/';
return implode('', $base_url);
} | php | public static function getBaseURL($url){
$parsed_url = parse_url($url);
if($parsed_url === false){
throw new ErrorException('Malformed URL.');
}
$base_url = [];
if(empty($parsed_url['scheme'])){
throw new ErrorException('Malformed URL, no scheme.');
}
$base_url[] = $parsed_url['scheme'];
$base_url[] = '://';
$base_url[] = $parsed_url['host'];
// Check the path
$path = $parsed_url['path'];
$path_parts = explode('/', $path);
// Discard the first slash.
array_shift($path_parts);
$base = array_shift($path_parts);
// Check if we're on localhost
if(strpos($base, '~') !== false){
$base_url[] = '/' . $base;
};
$base_url[] = '/';
return implode('', $base_url);
} | [
"public",
"static",
"function",
"getBaseURL",
"(",
"$",
"url",
")",
"{",
"$",
"parsed_url",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"parsed_url",
"===",
"false",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'Malformed URL.'",
")",
";",
"}",
"$",
"base_url",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
")",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'Malformed URL, no scheme.'",
")",
";",
"}",
"$",
"base_url",
"[",
"]",
"=",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
";",
"$",
"base_url",
"[",
"]",
"=",
"'://'",
";",
"$",
"base_url",
"[",
"]",
"=",
"$",
"parsed_url",
"[",
"'host'",
"]",
";",
"// Check the path",
"$",
"path",
"=",
"$",
"parsed_url",
"[",
"'path'",
"]",
";",
"$",
"path_parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"// Discard the first slash.",
"array_shift",
"(",
"$",
"path_parts",
")",
";",
"$",
"base",
"=",
"array_shift",
"(",
"$",
"path_parts",
")",
";",
"// Check if we're on localhost",
"if",
"(",
"strpos",
"(",
"$",
"base",
",",
"'~'",
")",
"!==",
"false",
")",
"{",
"$",
"base_url",
"[",
"]",
"=",
"'/'",
".",
"$",
"base",
";",
"}",
";",
"$",
"base_url",
"[",
"]",
"=",
"'/'",
";",
"return",
"implode",
"(",
"''",
",",
"$",
"base_url",
")",
";",
"}"
] | Get the base URL for a given site URL.
<p>This is the PHP equivalent of the JS Shared.getBaseUrl function.
It can deal with localhost as well.</p>
@param string $url
@return string
@throws ErrorException | [
"Get",
"the",
"base",
"URL",
"for",
"a",
"given",
"site",
"URL",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/HTTP.php#L448-L486 |
9,251 | studyportals/Utils | src/HTTP.php | HTTP.parsedURLToString | public static function parsedURLToString($parsed_url) {
$components = [];
if(!empty($parsed_url['scheme'])){
$components['scheme'] = $parsed_url['scheme'] . '://';
}
$components['user'] = '';
$components['pass'] = '';
if(!empty($parsed_url['user'])){
$components['user'] = $parsed_url['user'];
}
if(!empty($parsed_url['pass'])){
$components['pass'] = ':' . $parsed_url['pass'];
}
if($components['user'] || $components['pass']){
$components['pass'] = $components['pass'] . '@';
}
if(!empty($parsed_url['host'])){
$components['host'] = $parsed_url['host'];
}
if(!empty($parsed_url['port'])){
$components['port'] = ':' . $parsed_url['port'];
}
if(!empty($parsed_url['path'])){
$components['path'] = $parsed_url['path'];
}
if(!empty($parsed_url['query'])){
$components['query'] = '?' . $parsed_url['query'];
}
if(!empty($parsed_url['fragment'])){
$components['fragment'] = '#' . $parsed_url['fragment'];
}
return implode('', $components);
} | php | public static function parsedURLToString($parsed_url) {
$components = [];
if(!empty($parsed_url['scheme'])){
$components['scheme'] = $parsed_url['scheme'] . '://';
}
$components['user'] = '';
$components['pass'] = '';
if(!empty($parsed_url['user'])){
$components['user'] = $parsed_url['user'];
}
if(!empty($parsed_url['pass'])){
$components['pass'] = ':' . $parsed_url['pass'];
}
if($components['user'] || $components['pass']){
$components['pass'] = $components['pass'] . '@';
}
if(!empty($parsed_url['host'])){
$components['host'] = $parsed_url['host'];
}
if(!empty($parsed_url['port'])){
$components['port'] = ':' . $parsed_url['port'];
}
if(!empty($parsed_url['path'])){
$components['path'] = $parsed_url['path'];
}
if(!empty($parsed_url['query'])){
$components['query'] = '?' . $parsed_url['query'];
}
if(!empty($parsed_url['fragment'])){
$components['fragment'] = '#' . $parsed_url['fragment'];
}
return implode('', $components);
} | [
"public",
"static",
"function",
"parsedURLToString",
"(",
"$",
"parsed_url",
")",
"{",
"$",
"components",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
")",
")",
"{",
"$",
"components",
"[",
"'scheme'",
"]",
"=",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
".",
"'://'",
";",
"}",
"$",
"components",
"[",
"'user'",
"]",
"=",
"''",
";",
"$",
"components",
"[",
"'pass'",
"]",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed_url",
"[",
"'user'",
"]",
")",
")",
"{",
"$",
"components",
"[",
"'user'",
"]",
"=",
"$",
"parsed_url",
"[",
"'user'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed_url",
"[",
"'pass'",
"]",
")",
")",
"{",
"$",
"components",
"[",
"'pass'",
"]",
"=",
"':'",
".",
"$",
"parsed_url",
"[",
"'pass'",
"]",
";",
"}",
"if",
"(",
"$",
"components",
"[",
"'user'",
"]",
"||",
"$",
"components",
"[",
"'pass'",
"]",
")",
"{",
"$",
"components",
"[",
"'pass'",
"]",
"=",
"$",
"components",
"[",
"'pass'",
"]",
".",
"'@'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed_url",
"[",
"'host'",
"]",
")",
")",
"{",
"$",
"components",
"[",
"'host'",
"]",
"=",
"$",
"parsed_url",
"[",
"'host'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed_url",
"[",
"'port'",
"]",
")",
")",
"{",
"$",
"components",
"[",
"'port'",
"]",
"=",
"':'",
".",
"$",
"parsed_url",
"[",
"'port'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed_url",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"components",
"[",
"'path'",
"]",
"=",
"$",
"parsed_url",
"[",
"'path'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed_url",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"components",
"[",
"'query'",
"]",
"=",
"'?'",
".",
"$",
"parsed_url",
"[",
"'query'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed_url",
"[",
"'fragment'",
"]",
")",
")",
"{",
"$",
"components",
"[",
"'fragment'",
"]",
"=",
"'#'",
".",
"$",
"parsed_url",
"[",
"'fragment'",
"]",
";",
"}",
"return",
"implode",
"(",
"''",
",",
"$",
"components",
")",
";",
"}"
] | Convert a parsed URL back to a string.
<p>Basically the opposite of parse_url. Specify a set of components
and this function turns it back into a string again.</p>
@see parse_url()
@param array $parsed_url
@return string | [
"Convert",
"a",
"parsed",
"URL",
"back",
"to",
"a",
"string",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/HTTP.php#L499-L552 |
9,252 | studyportals/Utils | src/HTTP.php | HTTP.cleanPath | public static function cleanPath($path){
$path = str_replace(['\\', '/./'], '/', $path);
$path = preg_replace('/[\/]+/', '/', $path);
$path = rtrim($path, '/');
$path = preg_replace('/[^a-z0-9 \-\/]+/i', '', $path);
$path = preg_replace('/[ \-]+/', '-', $path);
return $path;
} | php | public static function cleanPath($path){
$path = str_replace(['\\', '/./'], '/', $path);
$path = preg_replace('/[\/]+/', '/', $path);
$path = rtrim($path, '/');
$path = preg_replace('/[^a-z0-9 \-\/]+/i', '', $path);
$path = preg_replace('/[ \-]+/', '-', $path);
return $path;
} | [
"public",
"static",
"function",
"cleanPath",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"[",
"'\\\\'",
",",
"'/./'",
"]",
",",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'/[\\/]+/'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'/[^a-z0-9 \\-\\/]+/i'",
",",
"''",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'/[ \\-]+/'",
",",
"'-'",
",",
"$",
"path",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Strictly clean a URL-path from any unwanted characters.
<p>Enforces a very strict "clean path"-policy, allowing only [A-Z],
[a-z], [0-9] and hyphens ("-"). All spaces are replaced with a hyphen,
all back-slashes are converted to forward-slashes and all superfluous
slashes are removed. Any other remaining, invalid, characters are also
removed.</p>
@param string $path
@return string | [
"Strictly",
"clean",
"a",
"URL",
"-",
"path",
"from",
"any",
"unwanted",
"characters",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/HTTP.php#L567-L577 |
9,253 | gamernetwork/yolk-support | src/GenericFilter.php | GenericFilter.clear | public function clear( $what = [] ) {
$defaults = [
'criteria' => [],
'offset' => 0,
'limit' => 0,
'orderby' => [],
];
$what = (array) $what;
if( empty($what) )
$what = array_keys($defaults);
foreach( $what as $k ) {
$this->$k = $defaults[$k];
}
return $this;
} | php | public function clear( $what = [] ) {
$defaults = [
'criteria' => [],
'offset' => 0,
'limit' => 0,
'orderby' => [],
];
$what = (array) $what;
if( empty($what) )
$what = array_keys($defaults);
foreach( $what as $k ) {
$this->$k = $defaults[$k];
}
return $this;
} | [
"public",
"function",
"clear",
"(",
"$",
"what",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'criteria'",
"=>",
"[",
"]",
",",
"'offset'",
"=>",
"0",
",",
"'limit'",
"=>",
"0",
",",
"'orderby'",
"=>",
"[",
"]",
",",
"]",
";",
"$",
"what",
"=",
"(",
"array",
")",
"$",
"what",
";",
"if",
"(",
"empty",
"(",
"$",
"what",
")",
")",
"$",
"what",
"=",
"array_keys",
"(",
"$",
"defaults",
")",
";",
"foreach",
"(",
"$",
"what",
"as",
"$",
"k",
")",
"{",
"$",
"this",
"->",
"$",
"k",
"=",
"$",
"defaults",
"[",
"$",
"k",
"]",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove all existing criteria from the filter.
@return self | [
"Remove",
"all",
"existing",
"criteria",
"from",
"the",
"filter",
"."
] | 83e517b9a12c6ade712ce734574d1de64bcdd0c2 | https://github.com/gamernetwork/yolk-support/blob/83e517b9a12c6ade712ce734574d1de64bcdd0c2/src/GenericFilter.php#L64-L84 |
9,254 | gamernetwork/yolk-support | src/GenericFilter.php | GenericFilter.orderBy | public function orderBy( $field, $dir = Filter::SORT_ASC ) {
$field = trim($field);
if( empty($field) )
throw new \InvalidArgumentException('No field specified');
$modifier = substr($field, 0, 1);
if( in_array($modifier, ['+', '-']) ) {
$dir = ($modifier == '+');
$field = substr($field, 1);
}
$this->orderby[$field] = $dir;
return $this;
} | php | public function orderBy( $field, $dir = Filter::SORT_ASC ) {
$field = trim($field);
if( empty($field) )
throw new \InvalidArgumentException('No field specified');
$modifier = substr($field, 0, 1);
if( in_array($modifier, ['+', '-']) ) {
$dir = ($modifier == '+');
$field = substr($field, 1);
}
$this->orderby[$field] = $dir;
return $this;
} | [
"public",
"function",
"orderBy",
"(",
"$",
"field",
",",
"$",
"dir",
"=",
"Filter",
"::",
"SORT_ASC",
")",
"{",
"$",
"field",
"=",
"trim",
"(",
"$",
"field",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"field",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'No field specified'",
")",
";",
"$",
"modifier",
"=",
"substr",
"(",
"$",
"field",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"modifier",
",",
"[",
"'+'",
",",
"'-'",
"]",
")",
")",
"{",
"$",
"dir",
"=",
"(",
"$",
"modifier",
"==",
"'+'",
")",
";",
"$",
"field",
"=",
"substr",
"(",
"$",
"field",
",",
"1",
")",
";",
"}",
"$",
"this",
"->",
"orderby",
"[",
"$",
"field",
"]",
"=",
"$",
"dir",
";",
"return",
"$",
"this",
";",
"}"
] | Specify a field to order the results by.
Multiple levels of ordering can be specified by calling this method multiple times.
@param string $field name of the field
@param boolean $dir true to sort ascending, false to sort descending
@return self | [
"Specify",
"a",
"field",
"to",
"order",
"the",
"results",
"by",
".",
"Multiple",
"levels",
"of",
"ordering",
"can",
"be",
"specified",
"by",
"calling",
"this",
"method",
"multiple",
"times",
"."
] | 83e517b9a12c6ade712ce734574d1de64bcdd0c2 | https://github.com/gamernetwork/yolk-support/blob/83e517b9a12c6ade712ce734574d1de64bcdd0c2/src/GenericFilter.php#L193-L211 |
9,255 | gamernetwork/yolk-support | src/GenericFilter.php | GenericFilter.toQuery | public function toQuery( Query $query, array $columns = [], $alias = '' ) {
foreach( $this->criteria as $column => $criteria ) {
if( !$column = $this->getColumnName($columns, $column, $alias) )
continue;
foreach( $criteria as $operator => $value ) {
$query->where($column, $operator, $value);
}
}
foreach( $this->getOrder() as $column => $ascending ) {
$column = $this->getColumnName($columns, $column, $alias);
if( !$column )
continue;
$query->orderBy($column, $ascending);
}
if( $this->offset )
$query->offset($this->offset);
if( $this->limit )
$query->limit($this->limit);
return $query;
} | php | public function toQuery( Query $query, array $columns = [], $alias = '' ) {
foreach( $this->criteria as $column => $criteria ) {
if( !$column = $this->getColumnName($columns, $column, $alias) )
continue;
foreach( $criteria as $operator => $value ) {
$query->where($column, $operator, $value);
}
}
foreach( $this->getOrder() as $column => $ascending ) {
$column = $this->getColumnName($columns, $column, $alias);
if( !$column )
continue;
$query->orderBy($column, $ascending);
}
if( $this->offset )
$query->offset($this->offset);
if( $this->limit )
$query->limit($this->limit);
return $query;
} | [
"public",
"function",
"toQuery",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"columns",
"=",
"[",
"]",
",",
"$",
"alias",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"criteria",
"as",
"$",
"column",
"=>",
"$",
"criteria",
")",
"{",
"if",
"(",
"!",
"$",
"column",
"=",
"$",
"this",
"->",
"getColumnName",
"(",
"$",
"columns",
",",
"$",
"column",
",",
"$",
"alias",
")",
")",
"continue",
";",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"operator",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getOrder",
"(",
")",
"as",
"$",
"column",
"=>",
"$",
"ascending",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getColumnName",
"(",
"$",
"columns",
",",
"$",
"column",
",",
"$",
"alias",
")",
";",
"if",
"(",
"!",
"$",
"column",
")",
"continue",
";",
"$",
"query",
"->",
"orderBy",
"(",
"$",
"column",
",",
"$",
"ascending",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"offset",
")",
"$",
"query",
"->",
"offset",
"(",
"$",
"this",
"->",
"offset",
")",
";",
"if",
"(",
"$",
"this",
"->",
"limit",
")",
"$",
"query",
"->",
"limit",
"(",
"$",
"this",
"->",
"limit",
")",
";",
"return",
"$",
"query",
";",
"}"
] | Apply the filter to a database Query
@param Query $query
@param array $columns a map of field names to database column names
@return Query | [
"Apply",
"the",
"filter",
"to",
"a",
"database",
"Query"
] | 83e517b9a12c6ade712ce734574d1de64bcdd0c2 | https://github.com/gamernetwork/yolk-support/blob/83e517b9a12c6ade712ce734574d1de64bcdd0c2/src/GenericFilter.php#L239-L267 |
9,256 | gamernetwork/yolk-support | src/GenericFilter.php | GenericFilter.addCriteria | protected function addCriteria( $field, $operator, $value ) {
$field = trim($field);
if( !isset($this->criteria[$field]) )
$this->criteria[$field] = [];
$this->criteria[$field][$operator] = $value;
return $this;
} | php | protected function addCriteria( $field, $operator, $value ) {
$field = trim($field);
if( !isset($this->criteria[$field]) )
$this->criteria[$field] = [];
$this->criteria[$field][$operator] = $value;
return $this;
} | [
"protected",
"function",
"addCriteria",
"(",
"$",
"field",
",",
"$",
"operator",
",",
"$",
"value",
")",
"{",
"$",
"field",
"=",
"trim",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"criteria",
"[",
"$",
"field",
"]",
")",
")",
"$",
"this",
"->",
"criteria",
"[",
"$",
"field",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"criteria",
"[",
"$",
"field",
"]",
"[",
"$",
"operator",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Add a criteria item to the filter.
@param string $field
@param string $operator
@param mixed $value
@return self | [
"Add",
"a",
"criteria",
"item",
"to",
"the",
"filter",
"."
] | 83e517b9a12c6ade712ce734574d1de64bcdd0c2 | https://github.com/gamernetwork/yolk-support/blob/83e517b9a12c6ade712ce734574d1de64bcdd0c2/src/GenericFilter.php#L293-L304 |
9,257 | arvici/framework | src/Arvici/Heart/Log/Logger.php | Logger.start | public static function start($skipConfiguration = false)
{
if (self::$instance !== null) {
throw new LogException("Logger already started!");
}
// Load the logger.
self::$instance = new Writer();
// Apply configuration.
if (! $skipConfiguration && Configuration::get('app.log', true)) {
// Get configuration
$logPath = Configuration::get('app.logPath');
if ($logPath === null) {// @codeCoverageIgnore
throw new ConfigurationException("app.logPath is not valid!"); // @codeCoverageIgnore
} // @codeCoverageIgnore
if (! file_exists($logPath)) { // @codeCoverageIgnore
if (! mkdir($logPath)) { // @codeCoverageIgnore
throw new PermissionDeniedException("Could not create directory '" . $logPath . "'!"); // @codeCoverageIgnore
} // @codeCoverageIgnore
} // @codeCoverageIgnore
// Get all level and log files.
self::$files = Configuration::get('app.logFile', ['app.log' => self::ERROR]);
self::$path = $logPath;
// Load all handlers.
foreach (self::$files as $file => $minimumLevel) {
self::$instance->addHandler(new StreamHandler($logPath . $file, $minimumLevel));
}
}
// Register exception/error handler
ExceptionHandler::register();
} | php | public static function start($skipConfiguration = false)
{
if (self::$instance !== null) {
throw new LogException("Logger already started!");
}
// Load the logger.
self::$instance = new Writer();
// Apply configuration.
if (! $skipConfiguration && Configuration::get('app.log', true)) {
// Get configuration
$logPath = Configuration::get('app.logPath');
if ($logPath === null) {// @codeCoverageIgnore
throw new ConfigurationException("app.logPath is not valid!"); // @codeCoverageIgnore
} // @codeCoverageIgnore
if (! file_exists($logPath)) { // @codeCoverageIgnore
if (! mkdir($logPath)) { // @codeCoverageIgnore
throw new PermissionDeniedException("Could not create directory '" . $logPath . "'!"); // @codeCoverageIgnore
} // @codeCoverageIgnore
} // @codeCoverageIgnore
// Get all level and log files.
self::$files = Configuration::get('app.logFile', ['app.log' => self::ERROR]);
self::$path = $logPath;
// Load all handlers.
foreach (self::$files as $file => $minimumLevel) {
self::$instance->addHandler(new StreamHandler($logPath . $file, $minimumLevel));
}
}
// Register exception/error handler
ExceptionHandler::register();
} | [
"public",
"static",
"function",
"start",
"(",
"$",
"skipConfiguration",
"=",
"false",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"instance",
"!==",
"null",
")",
"{",
"throw",
"new",
"LogException",
"(",
"\"Logger already started!\"",
")",
";",
"}",
"// Load the logger.",
"self",
"::",
"$",
"instance",
"=",
"new",
"Writer",
"(",
")",
";",
"// Apply configuration.",
"if",
"(",
"!",
"$",
"skipConfiguration",
"&&",
"Configuration",
"::",
"get",
"(",
"'app.log'",
",",
"true",
")",
")",
"{",
"// Get configuration",
"$",
"logPath",
"=",
"Configuration",
"::",
"get",
"(",
"'app.logPath'",
")",
";",
"if",
"(",
"$",
"logPath",
"===",
"null",
")",
"{",
"// @codeCoverageIgnore",
"throw",
"new",
"ConfigurationException",
"(",
"\"app.logPath is not valid!\"",
")",
";",
"// @codeCoverageIgnore",
"}",
"// @codeCoverageIgnore",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"logPath",
")",
")",
"{",
"// @codeCoverageIgnore",
"if",
"(",
"!",
"mkdir",
"(",
"$",
"logPath",
")",
")",
"{",
"// @codeCoverageIgnore",
"throw",
"new",
"PermissionDeniedException",
"(",
"\"Could not create directory '\"",
".",
"$",
"logPath",
".",
"\"'!\"",
")",
";",
"// @codeCoverageIgnore",
"}",
"// @codeCoverageIgnore",
"}",
"// @codeCoverageIgnore",
"// Get all level and log files.",
"self",
"::",
"$",
"files",
"=",
"Configuration",
"::",
"get",
"(",
"'app.logFile'",
",",
"[",
"'app.log'",
"=>",
"self",
"::",
"ERROR",
"]",
")",
";",
"self",
"::",
"$",
"path",
"=",
"$",
"logPath",
";",
"// Load all handlers.",
"foreach",
"(",
"self",
"::",
"$",
"files",
"as",
"$",
"file",
"=>",
"$",
"minimumLevel",
")",
"{",
"self",
"::",
"$",
"instance",
"->",
"addHandler",
"(",
"new",
"StreamHandler",
"(",
"$",
"logPath",
".",
"$",
"file",
",",
"$",
"minimumLevel",
")",
")",
";",
"}",
"}",
"// Register exception/error handler",
"ExceptionHandler",
"::",
"register",
"(",
")",
";",
"}"
] | Start function, will be called from the bootstrap file.
@param bool $skipConfiguration
@throws ConfigurationException
@throws LogException
@throws PermissionDeniedException | [
"Start",
"function",
"will",
"be",
"called",
"from",
"the",
"bootstrap",
"file",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Log/Logger.php#L65-L101 |
9,258 | arvici/framework | src/Arvici/Heart/Log/Logger.php | Logger.clearLog | public static function clearLog($level = null)
{
foreach (self::$files as $fileName => $fileLevel) {
if ($level === null || $level === $fileLevel) {
$fileName = self::$path . $fileName;
if (file_exists($fileName)) {
@unlink($fileName);
}
continue;
}
}
// Restart current logger instance.
self::$instance = null;
self::start();
} | php | public static function clearLog($level = null)
{
foreach (self::$files as $fileName => $fileLevel) {
if ($level === null || $level === $fileLevel) {
$fileName = self::$path . $fileName;
if (file_exists($fileName)) {
@unlink($fileName);
}
continue;
}
}
// Restart current logger instance.
self::$instance = null;
self::start();
} | [
"public",
"static",
"function",
"clearLog",
"(",
"$",
"level",
"=",
"null",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"files",
"as",
"$",
"fileName",
"=>",
"$",
"fileLevel",
")",
"{",
"if",
"(",
"$",
"level",
"===",
"null",
"||",
"$",
"level",
"===",
"$",
"fileLevel",
")",
"{",
"$",
"fileName",
"=",
"self",
"::",
"$",
"path",
".",
"$",
"fileName",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"fileName",
")",
";",
"}",
"continue",
";",
"}",
"}",
"// Restart current logger instance.",
"self",
"::",
"$",
"instance",
"=",
"null",
";",
"self",
"::",
"start",
"(",
")",
";",
"}"
] | Clear and delete log files.
@param mixed|null $level Null for every level (default). | [
"Clear",
"and",
"delete",
"log",
"files",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Log/Logger.php#L132-L148 |
9,259 | budkit/budkit-framework | src/Budkit/Routing/Controller.php | Controller.setView | public function setView($view)
{
if (class_exists($view)) {
//if we already have a default view
$values = [];
//grab all its parameters and store in parameters
if (isset($this->view) && $this->view instanceof View) {
$values = $this->view->getDataArray();
$layout = $this->view->getLayout();
//Load the newView;
$this->view = $this->loadView($view, $values);
if (!empty($layout)) {
$this->view->setLayout($layout);
}
}
return $this;
} else if (is_string($view)) {
$this->response->addContent($view); //so that $this->view("Hi There"); will output Hi There;
return $this;
}
return false; //no view set;
} | php | public function setView($view)
{
if (class_exists($view)) {
//if we already have a default view
$values = [];
//grab all its parameters and store in parameters
if (isset($this->view) && $this->view instanceof View) {
$values = $this->view->getDataArray();
$layout = $this->view->getLayout();
//Load the newView;
$this->view = $this->loadView($view, $values);
if (!empty($layout)) {
$this->view->setLayout($layout);
}
}
return $this;
} else if (is_string($view)) {
$this->response->addContent($view); //so that $this->view("Hi There"); will output Hi There;
return $this;
}
return false; //no view set;
} | [
"public",
"function",
"setView",
"(",
"$",
"view",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"view",
")",
")",
"{",
"//if we already have a default view",
"$",
"values",
"=",
"[",
"]",
";",
"//grab all its parameters and store in parameters",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"view",
")",
"&&",
"$",
"this",
"->",
"view",
"instanceof",
"View",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"view",
"->",
"getDataArray",
"(",
")",
";",
"$",
"layout",
"=",
"$",
"this",
"->",
"view",
"->",
"getLayout",
"(",
")",
";",
"//Load the newView;",
"$",
"this",
"->",
"view",
"=",
"$",
"this",
"->",
"loadView",
"(",
"$",
"view",
",",
"$",
"values",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"layout",
")",
")",
"{",
"$",
"this",
"->",
"view",
"->",
"setLayout",
"(",
"$",
"layout",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"view",
")",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"addContent",
"(",
"$",
"view",
")",
";",
"//so that $this->view(\"Hi There\"); will output Hi There;",
"return",
"$",
"this",
";",
"}",
"return",
"false",
";",
"//no view set;",
"}"
] | Sets the view for this controller action
@param $view
@return $this|bool | [
"Sets",
"the",
"view",
"for",
"this",
"controller",
"action"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Routing/Controller.php#L75-L107 |
9,260 | budkit/budkit-framework | src/Budkit/Routing/Controller.php | Controller.render | public function render(View $view = null)
{
if ($this->rendered) {
return true;
}
//$this->reloadResponseVars( $this->response );
$onRender = new Event('Controller.beforeRender', $this);
$this->observer->trigger($onRender);
if ($onRender->isStopped()) {
$this->autoRender = false;
return $this->response;
}
//controllers only know about one view.
//Every action uses a single view;
//views can be set with $this->setView("") or $this->display(""); //or can be set on render;
//If we are setting a really late view;
$view = !is_null($view) ? $view : $this->getView();
$this->response->addContent($view->render());
$this->rendered = true;
return true;
} | php | public function render(View $view = null)
{
if ($this->rendered) {
return true;
}
//$this->reloadResponseVars( $this->response );
$onRender = new Event('Controller.beforeRender', $this);
$this->observer->trigger($onRender);
if ($onRender->isStopped()) {
$this->autoRender = false;
return $this->response;
}
//controllers only know about one view.
//Every action uses a single view;
//views can be set with $this->setView("") or $this->display(""); //or can be set on render;
//If we are setting a really late view;
$view = !is_null($view) ? $view : $this->getView();
$this->response->addContent($view->render());
$this->rendered = true;
return true;
} | [
"public",
"function",
"render",
"(",
"View",
"$",
"view",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"rendered",
")",
"{",
"return",
"true",
";",
"}",
"//$this->reloadResponseVars( $this->response );",
"$",
"onRender",
"=",
"new",
"Event",
"(",
"'Controller.beforeRender'",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"observer",
"->",
"trigger",
"(",
"$",
"onRender",
")",
";",
"if",
"(",
"$",
"onRender",
"->",
"isStopped",
"(",
")",
")",
"{",
"$",
"this",
"->",
"autoRender",
"=",
"false",
";",
"return",
"$",
"this",
"->",
"response",
";",
"}",
"//controllers only know about one view.",
"//Every action uses a single view;",
"//views can be set with $this->setView(\"\") or $this->display(\"\"); //or can be set on render;",
"//If we are setting a really late view;",
"$",
"view",
"=",
"!",
"is_null",
"(",
"$",
"view",
")",
"?",
"$",
"view",
":",
"$",
"this",
"->",
"getView",
"(",
")",
";",
"$",
"this",
"->",
"response",
"->",
"addContent",
"(",
"$",
"view",
"->",
"render",
"(",
")",
")",
";",
"$",
"this",
"->",
"rendered",
"=",
"true",
";",
"return",
"true",
";",
"}"
] | Renders the Controller->Response;
@return void
@author Livingstone Fultang | [
"Renders",
"the",
"Controller",
"-",
">",
"Response",
";"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Routing/Controller.php#L170-L200 |
9,261 | budkit/budkit-framework | src/Budkit/Routing/Controller.php | Controller.invokeAction | public function invokeAction($action, $params = [])
{
//var_dump($this->request->getAttributes());
//Will throw an exception if the method does not exists;
$method = new ReflectionMethod($this, $action);
if (!$method->isPublic()) {
throw new Exception('Attempting to call a private method');
}
return $method->invokeArgs($this, $params);
} | php | public function invokeAction($action, $params = [])
{
//var_dump($this->request->getAttributes());
//Will throw an exception if the method does not exists;
$method = new ReflectionMethod($this, $action);
if (!$method->isPublic()) {
throw new Exception('Attempting to call a private method');
}
return $method->invokeArgs($this, $params);
} | [
"public",
"function",
"invokeAction",
"(",
"$",
"action",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"//var_dump($this->request->getAttributes());",
"//Will throw an exception if the method does not exists;",
"$",
"method",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"this",
",",
"$",
"action",
")",
";",
"if",
"(",
"!",
"$",
"method",
"->",
"isPublic",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Attempting to call a private method'",
")",
";",
"}",
"return",
"$",
"method",
"->",
"invokeArgs",
"(",
"$",
"this",
",",
"$",
"params",
")",
";",
"}"
] | Checks that the method is callable;
@param string $action
@param Route $route
@return void
@author Livingstone Fultang | [
"Checks",
"that",
"the",
"method",
"is",
"callable",
";"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Routing/Controller.php#L220-L234 |
9,262 | budkit/budkit-framework | src/Budkit/Routing/Controller.php | Controller.loadView | protected function loadView($view, $values = [])
{
if (isset($this->application[$view])) {
return $this->application[$view];
}
$instance = $this->application->createInstance($view, [$values, $this->response, $this->getHandler()]);
//Otherwise return an instance of Controller;
return $this->application->shareInstance($instance, $view);
} | php | protected function loadView($view, $values = [])
{
if (isset($this->application[$view])) {
return $this->application[$view];
}
$instance = $this->application->createInstance($view, [$values, $this->response, $this->getHandler()]);
//Otherwise return an instance of Controller;
return $this->application->shareInstance($instance, $view);
} | [
"protected",
"function",
"loadView",
"(",
"$",
"view",
",",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"application",
"[",
"$",
"view",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"application",
"[",
"$",
"view",
"]",
";",
"}",
"$",
"instance",
"=",
"$",
"this",
"->",
"application",
"->",
"createInstance",
"(",
"$",
"view",
",",
"[",
"$",
"values",
",",
"$",
"this",
"->",
"response",
",",
"$",
"this",
"->",
"getHandler",
"(",
")",
"]",
")",
";",
"//Otherwise return an instance of Controller;",
"return",
"$",
"this",
"->",
"application",
"->",
"shareInstance",
"(",
"$",
"instance",
",",
"$",
"view",
")",
";",
"}"
] | Loads a view from classname;
@param string $view
@return void
@author Livingstone Fultang | [
"Loads",
"a",
"view",
"from",
"classname",
";"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Routing/Controller.php#L249-L261 |
9,263 | traq/installer | src/Controllers/Steps.php | Steps.accountInformationAction | public function accountInformationAction()
{
$databaseInfo = $this->checkDatabaseInformation();
if ($databaseInfo) {
return $databaseInfo;
}
$this->title("Admin Account");
return $this->render("steps/account_information.phtml");
} | php | public function accountInformationAction()
{
$databaseInfo = $this->checkDatabaseInformation();
if ($databaseInfo) {
return $databaseInfo;
}
$this->title("Admin Account");
return $this->render("steps/account_information.phtml");
} | [
"public",
"function",
"accountInformationAction",
"(",
")",
"{",
"$",
"databaseInfo",
"=",
"$",
"this",
"->",
"checkDatabaseInformation",
"(",
")",
";",
"if",
"(",
"$",
"databaseInfo",
")",
"{",
"return",
"$",
"databaseInfo",
";",
"}",
"$",
"this",
"->",
"title",
"(",
"\"Admin Account\"",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"\"steps/account_information.phtml\"",
")",
";",
"}"
] | Admin account information form. | [
"Admin",
"account",
"information",
"form",
"."
] | 7d82ee13d11c59cb63bcb7739962c85a994271ef | https://github.com/traq/installer/blob/7d82ee13d11c59cb63bcb7739962c85a994271ef/src/Controllers/Steps.php#L44-L54 |
9,264 | digipolisgent/openbib-id-api | src/Value/UserActivities/Loan.php | Loan.fromXml | public static function fromXml(\DOMElement $xml)
{
$static = new static();
$static->libraryItemMetadata = LibraryItemMetadata::fromXml($xml);
$static->renewable = Renewable::fromXml($xml);
$loanDate = $xml->getElementsByTagName('loanDate');
$static->loanDate = DateTime::fromXml($loanDate);
$dueDate = $xml->getElementsByTagName('dueDate');
$static->dueDate = DateTime::fromXml($dueDate);
$returnedDate = $xml->getElementsByTagName('returnedDate');
$static->returnedDate = DateTime::fromXml($returnedDate);
$stringLiterals = array(
'pbsCode' => $xml->getElementsByTagName('pbsCode'),
'itemSequence' => $xml->getElementsByTagName('itemSequence'),
'material' => $xml->getElementsByTagName('material'),
);
foreach ($stringLiterals as $propertyName => $xmlTag) {
$static->$propertyName = StringLiteral::fromXml($xmlTag);
}
return $static;
} | php | public static function fromXml(\DOMElement $xml)
{
$static = new static();
$static->libraryItemMetadata = LibraryItemMetadata::fromXml($xml);
$static->renewable = Renewable::fromXml($xml);
$loanDate = $xml->getElementsByTagName('loanDate');
$static->loanDate = DateTime::fromXml($loanDate);
$dueDate = $xml->getElementsByTagName('dueDate');
$static->dueDate = DateTime::fromXml($dueDate);
$returnedDate = $xml->getElementsByTagName('returnedDate');
$static->returnedDate = DateTime::fromXml($returnedDate);
$stringLiterals = array(
'pbsCode' => $xml->getElementsByTagName('pbsCode'),
'itemSequence' => $xml->getElementsByTagName('itemSequence'),
'material' => $xml->getElementsByTagName('material'),
);
foreach ($stringLiterals as $propertyName => $xmlTag) {
$static->$propertyName = StringLiteral::fromXml($xmlTag);
}
return $static;
} | [
"public",
"static",
"function",
"fromXml",
"(",
"\\",
"DOMElement",
"$",
"xml",
")",
"{",
"$",
"static",
"=",
"new",
"static",
"(",
")",
";",
"$",
"static",
"->",
"libraryItemMetadata",
"=",
"LibraryItemMetadata",
"::",
"fromXml",
"(",
"$",
"xml",
")",
";",
"$",
"static",
"->",
"renewable",
"=",
"Renewable",
"::",
"fromXml",
"(",
"$",
"xml",
")",
";",
"$",
"loanDate",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'loanDate'",
")",
";",
"$",
"static",
"->",
"loanDate",
"=",
"DateTime",
"::",
"fromXml",
"(",
"$",
"loanDate",
")",
";",
"$",
"dueDate",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'dueDate'",
")",
";",
"$",
"static",
"->",
"dueDate",
"=",
"DateTime",
"::",
"fromXml",
"(",
"$",
"dueDate",
")",
";",
"$",
"returnedDate",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'returnedDate'",
")",
";",
"$",
"static",
"->",
"returnedDate",
"=",
"DateTime",
"::",
"fromXml",
"(",
"$",
"returnedDate",
")",
";",
"$",
"stringLiterals",
"=",
"array",
"(",
"'pbsCode'",
"=>",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'pbsCode'",
")",
",",
"'itemSequence'",
"=>",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'itemSequence'",
")",
",",
"'material'",
"=>",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'material'",
")",
",",
")",
";",
"foreach",
"(",
"$",
"stringLiterals",
"as",
"$",
"propertyName",
"=>",
"$",
"xmlTag",
")",
"{",
"$",
"static",
"->",
"$",
"propertyName",
"=",
"StringLiteral",
"::",
"fromXml",
"(",
"$",
"xmlTag",
")",
";",
"}",
"return",
"$",
"static",
";",
"}"
] | Builds a Loan object from XML.
@param \DOMElement $xml
The xml element containing the loan.
@return Loan
A loan object. | [
"Builds",
"a",
"Loan",
"object",
"from",
"XML",
"."
] | 79f58dec53a91f44333d10fa4ef79f85f31fc2de | https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Value/UserActivities/Loan.php#L76-L101 |
9,265 | vpg/titon.common | src/Titon/Common/Container.php | Container.& | public function &get($key) {
if ($this->has($key)) {
$object = $this->_registered[$key];
if ($object instanceof Closure) {
$object = $this->set(call_user_func($object), $key);
}
return $object;
}
throw new MissingObjectException(sprintf('Object %s does not exist in the container', $key));
} | php | public function &get($key) {
if ($this->has($key)) {
$object = $this->_registered[$key];
if ($object instanceof Closure) {
$object = $this->set(call_user_func($object), $key);
}
return $object;
}
throw new MissingObjectException(sprintf('Object %s does not exist in the container', $key));
} | [
"public",
"function",
"&",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"_registered",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"$",
"object",
"instanceof",
"Closure",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"set",
"(",
"call_user_func",
"(",
"$",
"object",
")",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"object",
";",
"}",
"throw",
"new",
"MissingObjectException",
"(",
"sprintf",
"(",
"'Object %s does not exist in the container'",
",",
"$",
"key",
")",
")",
";",
"}"
] | Return the object assigned to the given key.
@param string $key
@return object
@throws \Titon\Common\Exception\MissingObjectException | [
"Return",
"the",
"object",
"assigned",
"to",
"the",
"given",
"key",
"."
] | 41fe62bd5134bf76db3ff9caa16f280d9d534ef9 | https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Container.php#L57-L69 |
9,266 | dreadlokeur/Midi-ChloriansPHP | src/utility/Tools.php | Tools.stringToUrl | public static function stringToUrl($string, $separator = '_', $encoding = 'UTF-8', $lower = false) {
if (!Validate::isCharset($encoding))
throw new \Exception('Encoding in\'t a valid charset type');
$string = htmlentities(html_entity_decode($string, null, $encoding), ENT_NOQUOTES, $encoding);
if ($lower)
$string = strtolower($string);
$search = array('#\&(.)(?:uml|circ|tilde|acute|grave|cedil|ring)\;#', '#\&(.{2})(?:lig)\;#', '#\&[a-z]+\;#', '#[^a-zA-Z0-9_]#', '#' . $separator . '+#');
$replace = array('\1', '\1', '', $separator, $separator);
return trim(preg_replace($search, $replace, $string), $separator);
} | php | public static function stringToUrl($string, $separator = '_', $encoding = 'UTF-8', $lower = false) {
if (!Validate::isCharset($encoding))
throw new \Exception('Encoding in\'t a valid charset type');
$string = htmlentities(html_entity_decode($string, null, $encoding), ENT_NOQUOTES, $encoding);
if ($lower)
$string = strtolower($string);
$search = array('#\&(.)(?:uml|circ|tilde|acute|grave|cedil|ring)\;#', '#\&(.{2})(?:lig)\;#', '#\&[a-z]+\;#', '#[^a-zA-Z0-9_]#', '#' . $separator . '+#');
$replace = array('\1', '\1', '', $separator, $separator);
return trim(preg_replace($search, $replace, $string), $separator);
} | [
"public",
"static",
"function",
"stringToUrl",
"(",
"$",
"string",
",",
"$",
"separator",
"=",
"'_'",
",",
"$",
"encoding",
"=",
"'UTF-8'",
",",
"$",
"lower",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"Validate",
"::",
"isCharset",
"(",
"$",
"encoding",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Encoding in\\'t a valid charset type'",
")",
";",
"$",
"string",
"=",
"htmlentities",
"(",
"html_entity_decode",
"(",
"$",
"string",
",",
"null",
",",
"$",
"encoding",
")",
",",
"ENT_NOQUOTES",
",",
"$",
"encoding",
")",
";",
"if",
"(",
"$",
"lower",
")",
"$",
"string",
"=",
"strtolower",
"(",
"$",
"string",
")",
";",
"$",
"search",
"=",
"array",
"(",
"'#\\&(.)(?:uml|circ|tilde|acute|grave|cedil|ring)\\;#'",
",",
"'#\\&(.{2})(?:lig)\\;#'",
",",
"'#\\&[a-z]+\\;#'",
",",
"'#[^a-zA-Z0-9_]#'",
",",
"'#'",
".",
"$",
"separator",
".",
"'+#'",
")",
";",
"$",
"replace",
"=",
"array",
"(",
"'\\1'",
",",
"'\\1'",
",",
"''",
",",
"$",
"separator",
",",
"$",
"separator",
")",
";",
"return",
"trim",
"(",
"preg_replace",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"string",
")",
",",
"$",
"separator",
")",
";",
"}"
] | Convert a string to url format for url rewrite
@access public
@static
@param string $string String to encode
@param string $separator Separator for replacing space and ponctuation, by default "_"
@param string $encoding Set the encoding of source string
@return string | [
"Convert",
"a",
"string",
"to",
"url",
"format",
"for",
"url",
"rewrite"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/utility/Tools.php#L64-L73 |
9,267 | dreadlokeur/Midi-ChloriansPHP | src/utility/Tools.php | Tools.parseObjectToArray | public static function parseObjectToArray($object) {
$array = array();
if (is_object($object))
$array = get_object_vars($object);
elseif (is_array($object)) {
foreach ($object as $k => &$value)
$array[$k] = self::parseObjectToArray($value);
} else
$array = $object;
return $array;
} | php | public static function parseObjectToArray($object) {
$array = array();
if (is_object($object))
$array = get_object_vars($object);
elseif (is_array($object)) {
foreach ($object as $k => &$value)
$array[$k] = self::parseObjectToArray($value);
} else
$array = $object;
return $array;
} | [
"public",
"static",
"function",
"parseObjectToArray",
"(",
"$",
"object",
")",
"{",
"$",
"array",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"object",
")",
")",
"$",
"array",
"=",
"get_object_vars",
"(",
"$",
"object",
")",
";",
"elseif",
"(",
"is_array",
"(",
"$",
"object",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"as",
"$",
"k",
"=>",
"&",
"$",
"value",
")",
"$",
"array",
"[",
"$",
"k",
"]",
"=",
"self",
"::",
"parseObjectToArray",
"(",
"$",
"value",
")",
";",
"}",
"else",
"$",
"array",
"=",
"$",
"object",
";",
"return",
"$",
"array",
";",
"}"
] | Transforme un object en array
@access public
@static
@param string $object : un objet
@return array $array | [
"Transforme",
"un",
"object",
"en",
"array"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/utility/Tools.php#L106-L117 |
9,268 | dreadlokeur/Midi-ChloriansPHP | src/utility/Tools.php | Tools.httpFileExistsWithCurl | public static function httpFileExistsWithCurl($url) {
if (!extension_loaded('curl'))
throw new \Exception('Curl extension not loaded try change your PHP configuration');
return ($ch = curl_init($url)) ? @curl_close($ch) || true : false;
} | php | public static function httpFileExistsWithCurl($url) {
if (!extension_loaded('curl'))
throw new \Exception('Curl extension not loaded try change your PHP configuration');
return ($ch = curl_init($url)) ? @curl_close($ch) || true : false;
} | [
"public",
"static",
"function",
"httpFileExistsWithCurl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"extension_loaded",
"(",
"'curl'",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Curl extension not loaded try change your PHP configuration'",
")",
";",
"return",
"(",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"url",
")",
")",
"?",
"@",
"curl_close",
"(",
"$",
"ch",
")",
"||",
"true",
":",
"false",
";",
"}"
] | Permet de regarder si un fichier existe, depuis une url avec curl
@access public
@static
@param string $url l'url
@return bool | [
"Permet",
"de",
"regarder",
"si",
"un",
"fichier",
"existe",
"depuis",
"une",
"url",
"avec",
"curl"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/utility/Tools.php#L127-L131 |
9,269 | dreadlokeur/Midi-ChloriansPHP | src/utility/Tools.php | Tools.dirList | public static function dirList($dir) {
if (!is_dir($dir))
throw new \Exception('"' . $dir . '" is not a valid directory');
$l = array();
foreach (self::cleanScandir($dir) as $f) {
if (is_dir($dir . $f)) {
$l[] = $dir . $f . '/';
$l = array_merge($l, self::dirList($dir . $f . DIRECTORY_SEPARATOR));
}
}
return $l;
} | php | public static function dirList($dir) {
if (!is_dir($dir))
throw new \Exception('"' . $dir . '" is not a valid directory');
$l = array();
foreach (self::cleanScandir($dir) as $f) {
if (is_dir($dir . $f)) {
$l[] = $dir . $f . '/';
$l = array_merge($l, self::dirList($dir . $f . DIRECTORY_SEPARATOR));
}
}
return $l;
} | [
"public",
"static",
"function",
"dirList",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'\"'",
".",
"$",
"dir",
".",
"'\" is not a valid directory'",
")",
";",
"$",
"l",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"cleanScandir",
"(",
"$",
"dir",
")",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
".",
"$",
"f",
")",
")",
"{",
"$",
"l",
"[",
"]",
"=",
"$",
"dir",
".",
"$",
"f",
".",
"'/'",
";",
"$",
"l",
"=",
"array_merge",
"(",
"$",
"l",
",",
"self",
"::",
"dirList",
"(",
"$",
"dir",
".",
"$",
"f",
".",
"DIRECTORY_SEPARATOR",
")",
")",
";",
"}",
"}",
"return",
"$",
"l",
";",
"}"
] | Permet de lister les repertoires d'un dossier
@access public
@static
@param string $dir le dossier à parcourir
@return array $l: liste des dossiers dans le dossier | [
"Permet",
"de",
"lister",
"les",
"repertoires",
"d",
"un",
"dossier"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/utility/Tools.php#L235-L247 |
9,270 | dreadlokeur/Midi-ChloriansPHP | src/utility/Tools.php | Tools.getIncludeContents | public static function getIncludeContents($filename, $param_contents = false) {
//On verifie que le fichier existe, qu'il soit valid (lisible...) si ce n'est pas le cas, on genere une exception
if (!is_file($filename) && !file_exists($filename) && !is_readable($filename))
throw new \Exception('Le fichier "' . $filename . '" n\'existe pas ou est invalid');
//Attribution du nom et valeur de variables contenu dans le fichier à inclure
if ($param_contents) {
for ($i = 0; $i < count($param_contents); $i++) {
if (array_key_exists('param_name', $param_contents) && array_key_exists('param_value', $param_contents))
${$param_contents[$i]['param_name']} = $param_contents[$i]['param_value'];
}
}
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
} | php | public static function getIncludeContents($filename, $param_contents = false) {
//On verifie que le fichier existe, qu'il soit valid (lisible...) si ce n'est pas le cas, on genere une exception
if (!is_file($filename) && !file_exists($filename) && !is_readable($filename))
throw new \Exception('Le fichier "' . $filename . '" n\'existe pas ou est invalid');
//Attribution du nom et valeur de variables contenu dans le fichier à inclure
if ($param_contents) {
for ($i = 0; $i < count($param_contents); $i++) {
if (array_key_exists('param_name', $param_contents) && array_key_exists('param_value', $param_contents))
${$param_contents[$i]['param_name']} = $param_contents[$i]['param_value'];
}
}
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
} | [
"public",
"static",
"function",
"getIncludeContents",
"(",
"$",
"filename",
",",
"$",
"param_contents",
"=",
"false",
")",
"{",
"//On verifie que le fichier existe, qu'il soit valid (lisible...) si ce n'est pas le cas, on genere une exception\r",
"if",
"(",
"!",
"is_file",
"(",
"$",
"filename",
")",
"&&",
"!",
"file_exists",
"(",
"$",
"filename",
")",
"&&",
"!",
"is_readable",
"(",
"$",
"filename",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Le fichier \"'",
".",
"$",
"filename",
".",
"'\" n\\'existe pas ou est invalid'",
")",
";",
"//Attribution du nom et valeur de variables contenu dans le fichier à inclure\r",
"if",
"(",
"$",
"param_contents",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"param_contents",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'param_name'",
",",
"$",
"param_contents",
")",
"&&",
"array_key_exists",
"(",
"'param_value'",
",",
"$",
"param_contents",
")",
")",
"$",
"{",
"$",
"param_contents",
"[",
"$",
"i",
"]",
"[",
"'param_name'",
"]",
"}",
"=",
"$",
"param_contents",
"[",
"$",
"i",
"]",
"[",
"'param_value'",
"]",
";",
"}",
"}",
"ob_start",
"(",
")",
";",
"include",
"$",
"filename",
";",
"$",
"contents",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"contents",
";",
"}"
] | Permet de retourner le contenu d'un fichier inclut
@access public
@static
@param string $filename le fichier à inclure
@param array $param_contents les paramètres pour l'inclusion du fichier: sous forme d'array: array(array('param_name' => 'var1', 'param_value' => 'test1'), array('param_name' => 'var2', 'param_value' => 'test2'))
permet d'etablir les variables: $var1 et $var2 dans le fichier à inclure
(OPTIONNEL)
@return string le contenu du fichier | [
"Permet",
"de",
"retourner",
"le",
"contenu",
"d",
"un",
"fichier",
"inclut"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/utility/Tools.php#L260-L277 |
9,271 | InnoGr/FivePercent-Api | src/Handler/Builder/HandlerBuilder.php | HandlerBuilder.addCallableHandle | public function addCallableHandle()
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$loader = new CallableLoader();
$resolver = new CallableResolver();
$this->addCallableResolver($resolver);
$this->addActionLoader($loader);
return $loader;
} | php | public function addCallableHandle()
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$loader = new CallableLoader();
$resolver = new CallableResolver();
$this->addCallableResolver($resolver);
$this->addActionLoader($loader);
return $loader;
} | [
"public",
"function",
"addCallableHandle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handler",
")",
"{",
"throw",
"new",
"AlreadyBuildedException",
"(",
"'The handler already builded.'",
")",
";",
"}",
"$",
"loader",
"=",
"new",
"CallableLoader",
"(",
")",
";",
"$",
"resolver",
"=",
"new",
"CallableResolver",
"(",
")",
";",
"$",
"this",
"->",
"addCallableResolver",
"(",
"$",
"resolver",
")",
";",
"$",
"this",
"->",
"addActionLoader",
"(",
"$",
"loader",
")",
";",
"return",
"$",
"loader",
";",
"}"
] | Add closure handle
@return CallableLoader
@throws AlreadyBuildedException | [
"Add",
"closure",
"handle"
] | 57b78ddc3c9d91a7139c276711e5792824ceab9c | https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Builder/HandlerBuilder.php#L132-L145 |
9,272 | InnoGr/FivePercent-Api | src/Handler/Builder/HandlerBuilder.php | HandlerBuilder.addCallableResolver | public function addCallableResolver(CallableResolverInterface $callableResolver)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->callableResolvers[spl_object_hash($callableResolver)] = $callableResolver;
return $this;
} | php | public function addCallableResolver(CallableResolverInterface $callableResolver)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->callableResolvers[spl_object_hash($callableResolver)] = $callableResolver;
return $this;
} | [
"public",
"function",
"addCallableResolver",
"(",
"CallableResolverInterface",
"$",
"callableResolver",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handler",
")",
"{",
"throw",
"new",
"AlreadyBuildedException",
"(",
"'The handler already builded.'",
")",
";",
"}",
"$",
"this",
"->",
"callableResolvers",
"[",
"spl_object_hash",
"(",
"$",
"callableResolver",
")",
"]",
"=",
"$",
"callableResolver",
";",
"return",
"$",
"this",
";",
"}"
] | Add callable resolver
@param CallableResolverInterface $callableResolver
@return HandlerBuilder
@throws AlreadyBuildedException | [
"Add",
"callable",
"resolver"
] | 57b78ddc3c9d91a7139c276711e5792824ceab9c | https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Builder/HandlerBuilder.php#L156-L165 |
9,273 | InnoGr/FivePercent-Api | src/Handler/Builder/HandlerBuilder.php | HandlerBuilder.addActionLoader | public function addActionLoader(LoaderInterface $loader)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->actionLoaders[spl_object_hash($loader)] = $loader;
return $this;
} | php | public function addActionLoader(LoaderInterface $loader)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->actionLoaders[spl_object_hash($loader)] = $loader;
return $this;
} | [
"public",
"function",
"addActionLoader",
"(",
"LoaderInterface",
"$",
"loader",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handler",
")",
"{",
"throw",
"new",
"AlreadyBuildedException",
"(",
"'The handler already builded.'",
")",
";",
"}",
"$",
"this",
"->",
"actionLoaders",
"[",
"spl_object_hash",
"(",
"$",
"loader",
")",
"]",
"=",
"$",
"loader",
";",
"return",
"$",
"this",
";",
"}"
] | Add action loader
@param LoaderInterface $loader
@return HandlerBuilder
@throws AlreadyBuildedException | [
"Add",
"action",
"loader"
] | 57b78ddc3c9d91a7139c276711e5792824ceab9c | https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Builder/HandlerBuilder.php#L176-L185 |
9,274 | InnoGr/FivePercent-Api | src/Handler/Builder/HandlerBuilder.php | HandlerBuilder.setEventDispatcher | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->eventDispatcher = $eventDispatcher;
return $this;
} | php | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->eventDispatcher = $eventDispatcher;
return $this;
} | [
"public",
"function",
"setEventDispatcher",
"(",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handler",
")",
"{",
"throw",
"new",
"AlreadyBuildedException",
"(",
"'The handler already builded.'",
")",
";",
"}",
"$",
"this",
"->",
"eventDispatcher",
"=",
"$",
"eventDispatcher",
";",
"return",
"$",
"this",
";",
"}"
] | Set event dispatcher
@param EventDispatcherInterface $eventDispatcher
@return HandlerBuilder
@throws AlreadyBuildedException | [
"Set",
"event",
"dispatcher"
] | 57b78ddc3c9d91a7139c276711e5792824ceab9c | https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Builder/HandlerBuilder.php#L196-L205 |
9,275 | InnoGr/FivePercent-Api | src/Handler/Builder/HandlerBuilder.php | HandlerBuilder.setParameterResolver | public function setParameterResolver(ParameterResolverInterface $resolver)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->parameterResolver = $resolver;
return $this;
} | php | public function setParameterResolver(ParameterResolverInterface $resolver)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->parameterResolver = $resolver;
return $this;
} | [
"public",
"function",
"setParameterResolver",
"(",
"ParameterResolverInterface",
"$",
"resolver",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handler",
")",
"{",
"throw",
"new",
"AlreadyBuildedException",
"(",
"'The handler already builded.'",
")",
";",
"}",
"$",
"this",
"->",
"parameterResolver",
"=",
"$",
"resolver",
";",
"return",
"$",
"this",
";",
"}"
] | Set parameter resolver
@param ParameterResolverInterface $resolver
@return HandlerBuilder
@throws AlreadyBuildedException | [
"Set",
"parameter",
"resolver"
] | 57b78ddc3c9d91a7139c276711e5792824ceab9c | https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Builder/HandlerBuilder.php#L216-L225 |
9,276 | InnoGr/FivePercent-Api | src/Handler/Builder/HandlerBuilder.php | HandlerBuilder.setParameterExtractor | public function setParameterExtractor(ParameterExtractorInterface $extractor)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->parameterExtractor = $extractor;
return $this;
} | php | public function setParameterExtractor(ParameterExtractorInterface $extractor)
{
if ($this->handler) {
throw new AlreadyBuildedException('The handler already builded.');
}
$this->parameterExtractor = $extractor;
return $this;
} | [
"public",
"function",
"setParameterExtractor",
"(",
"ParameterExtractorInterface",
"$",
"extractor",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handler",
")",
"{",
"throw",
"new",
"AlreadyBuildedException",
"(",
"'The handler already builded.'",
")",
";",
"}",
"$",
"this",
"->",
"parameterExtractor",
"=",
"$",
"extractor",
";",
"return",
"$",
"this",
";",
"}"
] | Set parameter extractor
@param ParameterExtractorInterface $extractor
@return HandlerBuilder
@throws AlreadyBuildedException | [
"Set",
"parameter",
"extractor"
] | 57b78ddc3c9d91a7139c276711e5792824ceab9c | https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Handler/Builder/HandlerBuilder.php#L236-L245 |
9,277 | stubbles/stubbles-sequence | src/main/php/Collectors.php | Collectors.with | public function with(callable $supplier, callable $accumulator, callable $finisher = null)
{
return $this->sequence->collect(new Collector($supplier, $accumulator, $finisher));
} | php | public function with(callable $supplier, callable $accumulator, callable $finisher = null)
{
return $this->sequence->collect(new Collector($supplier, $accumulator, $finisher));
} | [
"public",
"function",
"with",
"(",
"callable",
"$",
"supplier",
",",
"callable",
"$",
"accumulator",
",",
"callable",
"$",
"finisher",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"sequence",
"->",
"collect",
"(",
"new",
"Collector",
"(",
"$",
"supplier",
",",
"$",
"accumulator",
",",
"$",
"finisher",
")",
")",
";",
"}"
] | collects all elements into structure defined by supplier
@api
@param callable $supplier returns a fresh structure to collect elements into
@param callable $accumulator accumulates elements into structure
@param callable $finisher optional final operation after all elements have been added to the structure
@return mixed | [
"collects",
"all",
"elements",
"into",
"structure",
"defined",
"by",
"supplier"
] | 258d2247f1cdd826818348fe15829d5a98a9de70 | https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Collectors.php#L46-L49 |
9,278 | stubbles/stubbles-sequence | src/main/php/Collectors.php | Collectors.inPartitions | public function inPartitions(callable $predicate, Collector $base = null): array
{
$collector = (null === $base) ? Collector::forList() : $base;
return $this->with(
function() use($collector)
{
return [true => $collector->fork(),
false => $collector->fork()
];
},
function(&$partitions, $element, $key) use($predicate)
{
$partitions[$predicate($element)]->accumulate($element, $key);
},
function($partitions)
{
return [true => $partitions[true]->finish(),
false => $partitions[false]->finish()
];
}
);
} | php | public function inPartitions(callable $predicate, Collector $base = null): array
{
$collector = (null === $base) ? Collector::forList() : $base;
return $this->with(
function() use($collector)
{
return [true => $collector->fork(),
false => $collector->fork()
];
},
function(&$partitions, $element, $key) use($predicate)
{
$partitions[$predicate($element)]->accumulate($element, $key);
},
function($partitions)
{
return [true => $partitions[true]->finish(),
false => $partitions[false]->finish()
];
}
);
} | [
"public",
"function",
"inPartitions",
"(",
"callable",
"$",
"predicate",
",",
"Collector",
"$",
"base",
"=",
"null",
")",
":",
"array",
"{",
"$",
"collector",
"=",
"(",
"null",
"===",
"$",
"base",
")",
"?",
"Collector",
"::",
"forList",
"(",
")",
":",
"$",
"base",
";",
"return",
"$",
"this",
"->",
"with",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"collector",
")",
"{",
"return",
"[",
"true",
"=>",
"$",
"collector",
"->",
"fork",
"(",
")",
",",
"false",
"=>",
"$",
"collector",
"->",
"fork",
"(",
")",
"]",
";",
"}",
",",
"function",
"(",
"&",
"$",
"partitions",
",",
"$",
"element",
",",
"$",
"key",
")",
"use",
"(",
"$",
"predicate",
")",
"{",
"$",
"partitions",
"[",
"$",
"predicate",
"(",
"$",
"element",
")",
"]",
"->",
"accumulate",
"(",
"$",
"element",
",",
"$",
"key",
")",
";",
"}",
",",
"function",
"(",
"$",
"partitions",
")",
"{",
"return",
"[",
"true",
"=>",
"$",
"partitions",
"[",
"true",
"]",
"->",
"finish",
"(",
")",
",",
"false",
"=>",
"$",
"partitions",
"[",
"false",
"]",
"->",
"finish",
"(",
")",
"]",
";",
"}",
")",
";",
"}"
] | creates collector which groups the elements in two partitions according to given predicate
@api
@param callable $predicate function to evaluate in which partition an element belongs
@param \stubbles\sequence\Collector $base optional defaults to Collector::forList()
@return array | [
"creates",
"collector",
"which",
"groups",
"the",
"elements",
"in",
"two",
"partitions",
"according",
"to",
"given",
"predicate"
] | 258d2247f1cdd826818348fe15829d5a98a9de70 | https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Collectors.php#L81-L102 |
9,279 | stubbles/stubbles-sequence | src/main/php/Collectors.php | Collectors.inGroups | public function inGroups(callable $classifier, Collector $base = null): array
{
$collector = (null === $base) ? Collector::forList() : $base;
return $this->with(
function() { return []; },
function(&$groups, $element) use($classifier, $collector)
{
$key = $classifier($element);
if (!isset($groups[$key])) {
$groups[$key] = $collector->fork();
}
$groups[$key]->accumulate($element, $key);
},
function($groups)
{
foreach ($groups as $key => $group) {
$groups[$key] = $group->finish();
}
return $groups;
}
);
} | php | public function inGroups(callable $classifier, Collector $base = null): array
{
$collector = (null === $base) ? Collector::forList() : $base;
return $this->with(
function() { return []; },
function(&$groups, $element) use($classifier, $collector)
{
$key = $classifier($element);
if (!isset($groups[$key])) {
$groups[$key] = $collector->fork();
}
$groups[$key]->accumulate($element, $key);
},
function($groups)
{
foreach ($groups as $key => $group) {
$groups[$key] = $group->finish();
}
return $groups;
}
);
} | [
"public",
"function",
"inGroups",
"(",
"callable",
"$",
"classifier",
",",
"Collector",
"$",
"base",
"=",
"null",
")",
":",
"array",
"{",
"$",
"collector",
"=",
"(",
"null",
"===",
"$",
"base",
")",
"?",
"Collector",
"::",
"forList",
"(",
")",
":",
"$",
"base",
";",
"return",
"$",
"this",
"->",
"with",
"(",
"function",
"(",
")",
"{",
"return",
"[",
"]",
";",
"}",
",",
"function",
"(",
"&",
"$",
"groups",
",",
"$",
"element",
")",
"use",
"(",
"$",
"classifier",
",",
"$",
"collector",
")",
"{",
"$",
"key",
"=",
"$",
"classifier",
"(",
"$",
"element",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"groups",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"groups",
"[",
"$",
"key",
"]",
"=",
"$",
"collector",
"->",
"fork",
"(",
")",
";",
"}",
"$",
"groups",
"[",
"$",
"key",
"]",
"->",
"accumulate",
"(",
"$",
"element",
",",
"$",
"key",
")",
";",
"}",
",",
"function",
"(",
"$",
"groups",
")",
"{",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"key",
"=>",
"$",
"group",
")",
"{",
"$",
"groups",
"[",
"$",
"key",
"]",
"=",
"$",
"group",
"->",
"finish",
"(",
")",
";",
"}",
"return",
"$",
"groups",
";",
"}",
")",
";",
"}"
] | creates collector which groups the elements according to given classifier
@api
@param callable $classifier function to map elements to keys
@param \stubbles\sequence\Collector $base optional defaults to Collector::forList()
@return array | [
"creates",
"collector",
"which",
"groups",
"the",
"elements",
"according",
"to",
"given",
"classifier"
] | 258d2247f1cdd826818348fe15829d5a98a9de70 | https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Collectors.php#L112-L135 |
9,280 | stubbles/stubbles-sequence | src/main/php/Collectors.php | Collectors.byJoining | public function byJoining(
string $delimiter = ', ',
string $prefix = '',
string $suffix = '',
string $keySeparator = null
): string {
return $this->with(
function () { return null; },
function(&$joinedElements, $element, $key) use($prefix, $delimiter, $keySeparator)
{
if (null === $joinedElements) {
$joinedElements = $prefix;
} else {
$joinedElements .= $delimiter;
}
$joinedElements .= (null !== $keySeparator ? $key . $keySeparator : null) . $element;
},
function($joinedElements) use($suffix) { return $joinedElements . $suffix; }
);
} | php | public function byJoining(
string $delimiter = ', ',
string $prefix = '',
string $suffix = '',
string $keySeparator = null
): string {
return $this->with(
function () { return null; },
function(&$joinedElements, $element, $key) use($prefix, $delimiter, $keySeparator)
{
if (null === $joinedElements) {
$joinedElements = $prefix;
} else {
$joinedElements .= $delimiter;
}
$joinedElements .= (null !== $keySeparator ? $key . $keySeparator : null) . $element;
},
function($joinedElements) use($suffix) { return $joinedElements . $suffix; }
);
} | [
"public",
"function",
"byJoining",
"(",
"string",
"$",
"delimiter",
"=",
"', '",
",",
"string",
"$",
"prefix",
"=",
"''",
",",
"string",
"$",
"suffix",
"=",
"''",
",",
"string",
"$",
"keySeparator",
"=",
"null",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"with",
"(",
"function",
"(",
")",
"{",
"return",
"null",
";",
"}",
",",
"function",
"(",
"&",
"$",
"joinedElements",
",",
"$",
"element",
",",
"$",
"key",
")",
"use",
"(",
"$",
"prefix",
",",
"$",
"delimiter",
",",
"$",
"keySeparator",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"joinedElements",
")",
"{",
"$",
"joinedElements",
"=",
"$",
"prefix",
";",
"}",
"else",
"{",
"$",
"joinedElements",
".=",
"$",
"delimiter",
";",
"}",
"$",
"joinedElements",
".=",
"(",
"null",
"!==",
"$",
"keySeparator",
"?",
"$",
"key",
".",
"$",
"keySeparator",
":",
"null",
")",
".",
"$",
"element",
";",
"}",
",",
"function",
"(",
"$",
"joinedElements",
")",
"use",
"(",
"$",
"suffix",
")",
"{",
"return",
"$",
"joinedElements",
".",
"$",
"suffix",
";",
"}",
")",
";",
"}"
] | creates collector which concatenates all elements into a single string
If no key separator is provided keys will not be part of the resulting
string.
<code>
Sequence::of(['foo' => 303, 'bar' => 808, 'baz'=> 909])
->collect()
->byJoining(); // results in '303, 808, 9090'
Sequence::of(['foo' => 303, 'bar' => 808, 'baz'=> 909])
->collect()
->byJoining(', ', '', '', ': '); // results in 'foo: 303, bar: 808, baz: 9090'
</code>
@api
@param string $delimiter delimiter between elements, defaults to ', '
@param string $prefix optional prefix for complete string, empty by default
@param string $suffix optional suffix for complete string, empty by default
@param string $keySeparator optional separator between key and element
@return string | [
"creates",
"collector",
"which",
"concatenates",
"all",
"elements",
"into",
"a",
"single",
"string"
] | 258d2247f1cdd826818348fe15829d5a98a9de70 | https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Collectors.php#L159-L179 |
9,281 | fimsi/php-dbal | src/Fimsi/DBAL/Mysqli.php | Fimsi_DBAL_Mysqli.bind | function bind($orig,$b,$wanted){
$result = array($b);
foreach($wanted as $k => $field){
if(isset($orig[$field])&&strlen("".$orig[$field])){
$result[$field] = $orig[$field];
}else{
$result[$field] = null;
}
}
return $result;
} | php | function bind($orig,$b,$wanted){
$result = array($b);
foreach($wanted as $k => $field){
if(isset($orig[$field])&&strlen("".$orig[$field])){
$result[$field] = $orig[$field];
}else{
$result[$field] = null;
}
}
return $result;
} | [
"function",
"bind",
"(",
"$",
"orig",
",",
"$",
"b",
",",
"$",
"wanted",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"$",
"b",
")",
";",
"foreach",
"(",
"$",
"wanted",
"as",
"$",
"k",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"orig",
"[",
"$",
"field",
"]",
")",
"&&",
"strlen",
"(",
"\"\"",
".",
"$",
"orig",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"field",
"]",
"=",
"$",
"orig",
"[",
"$",
"field",
"]",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"field",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | get the bound values, using null if not defined in the orig | [
"get",
"the",
"bound",
"values",
"using",
"null",
"if",
"not",
"defined",
"in",
"the",
"orig"
] | e1e0726d73035b73930f88d541356a12583498ff | https://github.com/fimsi/php-dbal/blob/e1e0726d73035b73930f88d541356a12583498ff/src/Fimsi/DBAL/Mysqli.php#L68-L78 |
9,282 | fimsi/php-dbal | src/Fimsi/DBAL/Mysqli.php | Fimsi_DBAL_Mysqli.id_insert | function id_insert($table,$query,$bind_arr = null){
$stmt = $this->mysqli->prepare($query);
if(!$stmt){
throw new Exception("can't prepare query:[$query] because [".$this->mysqli->error."]");
}
if(isset($bind_arr) && $bind_arr != null){
call_user_func_array(array($stmt,'bind_param'),$this->makeValuesReferenced($bind_arr));
}
if(!$stmt->execute()){
throw new Exception( $this->mysqli->error );
}
if(!$id = $stmt->insert_id){
throw new Exception("no id returned for insert $query");
}
/* close statement and connection */
$stmt->close();
$rows = $this->query("select * from $table where id = ?",array("i",$id));
return $rows[0];
} | php | function id_insert($table,$query,$bind_arr = null){
$stmt = $this->mysqli->prepare($query);
if(!$stmt){
throw new Exception("can't prepare query:[$query] because [".$this->mysqli->error."]");
}
if(isset($bind_arr) && $bind_arr != null){
call_user_func_array(array($stmt,'bind_param'),$this->makeValuesReferenced($bind_arr));
}
if(!$stmt->execute()){
throw new Exception( $this->mysqli->error );
}
if(!$id = $stmt->insert_id){
throw new Exception("no id returned for insert $query");
}
/* close statement and connection */
$stmt->close();
$rows = $this->query("select * from $table where id = ?",array("i",$id));
return $rows[0];
} | [
"function",
"id_insert",
"(",
"$",
"table",
",",
"$",
"query",
",",
"$",
"bind_arr",
"=",
"null",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"mysqli",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"if",
"(",
"!",
"$",
"stmt",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"can't prepare query:[$query] because [\"",
".",
"$",
"this",
"->",
"mysqli",
"->",
"error",
".",
"\"]\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"bind_arr",
")",
"&&",
"$",
"bind_arr",
"!=",
"null",
")",
"{",
"call_user_func_array",
"(",
"array",
"(",
"$",
"stmt",
",",
"'bind_param'",
")",
",",
"$",
"this",
"->",
"makeValuesReferenced",
"(",
"$",
"bind_arr",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"stmt",
"->",
"execute",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"this",
"->",
"mysqli",
"->",
"error",
")",
";",
"}",
"if",
"(",
"!",
"$",
"id",
"=",
"$",
"stmt",
"->",
"insert_id",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"no id returned for insert $query\"",
")",
";",
"}",
"/* close statement and connection */",
"$",
"stmt",
"->",
"close",
"(",
")",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"query",
"(",
"\"select * from $table where id = ?\"",
",",
"array",
"(",
"\"i\"",
",",
"$",
"id",
")",
")",
";",
"return",
"$",
"rows",
"[",
"0",
"]",
";",
"}"
] | insert a row of data and return it back | [
"insert",
"a",
"row",
"of",
"data",
"and",
"return",
"it",
"back"
] | e1e0726d73035b73930f88d541356a12583498ff | https://github.com/fimsi/php-dbal/blob/e1e0726d73035b73930f88d541356a12583498ff/src/Fimsi/DBAL/Mysqli.php#L99-L119 |
9,283 | fimsi/php-dbal | src/Fimsi/DBAL/Mysqli.php | Fimsi_DBAL_Mysqli.id_update | function id_update($table, $id, $query,$bind_arr = null){
$stmt = $this->mysqli->prepare($query) or die("can't prepare query:[$query] because [".$this->mysqli->error."]");
if(isset($bind_arr) && $bind_arr != null){
call_user_func_array(array($stmt,'bind_param'),$this->makeValuesReferenced($bind_arr));
}
$stmt->execute();
/* close statement and connection */
$stmt->close();
$rows = $this->query("select * from $table where id = ?",array("i",$id));
return $rows[0];
} | php | function id_update($table, $id, $query,$bind_arr = null){
$stmt = $this->mysqli->prepare($query) or die("can't prepare query:[$query] because [".$this->mysqli->error."]");
if(isset($bind_arr) && $bind_arr != null){
call_user_func_array(array($stmt,'bind_param'),$this->makeValuesReferenced($bind_arr));
}
$stmt->execute();
/* close statement and connection */
$stmt->close();
$rows = $this->query("select * from $table where id = ?",array("i",$id));
return $rows[0];
} | [
"function",
"id_update",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"query",
",",
"$",
"bind_arr",
"=",
"null",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"mysqli",
"->",
"prepare",
"(",
"$",
"query",
")",
"or",
"die",
"(",
"\"can't prepare query:[$query] because [\"",
".",
"$",
"this",
"->",
"mysqli",
"->",
"error",
".",
"\"]\"",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"bind_arr",
")",
"&&",
"$",
"bind_arr",
"!=",
"null",
")",
"{",
"call_user_func_array",
"(",
"array",
"(",
"$",
"stmt",
",",
"'bind_param'",
")",
",",
"$",
"this",
"->",
"makeValuesReferenced",
"(",
"$",
"bind_arr",
")",
")",
";",
"}",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"/* close statement and connection */",
"$",
"stmt",
"->",
"close",
"(",
")",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"query",
"(",
"\"select * from $table where id = ?\"",
",",
"array",
"(",
"\"i\"",
",",
"$",
"id",
")",
")",
";",
"return",
"$",
"rows",
"[",
"0",
"]",
";",
"}"
] | update the row having the given id, and return back the same row. | [
"update",
"the",
"row",
"having",
"the",
"given",
"id",
"and",
"return",
"back",
"the",
"same",
"row",
"."
] | e1e0726d73035b73930f88d541356a12583498ff | https://github.com/fimsi/php-dbal/blob/e1e0726d73035b73930f88d541356a12583498ff/src/Fimsi/DBAL/Mysqli.php#L122-L134 |
9,284 | thecodingmachine/utils.i18n.fine | src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php | EditLabelController.editionMode | public function editionMode() {
if (isset($_SESSION["FINE_MESSAGE_EDITION_MODE"])) {
$this->isMessageEditionMode = true;
}
$this->content->addFile('../utils.i18n.fine/src/views/enableDisableEdition.php', $this);
$this->template->toHtml();
} | php | public function editionMode() {
if (isset($_SESSION["FINE_MESSAGE_EDITION_MODE"])) {
$this->isMessageEditionMode = true;
}
$this->content->addFile('../utils.i18n.fine/src/views/enableDisableEdition.php', $this);
$this->template->toHtml();
} | [
"public",
"function",
"editionMode",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"\"FINE_MESSAGE_EDITION_MODE\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"isMessageEditionMode",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"content",
"->",
"addFile",
"(",
"'../utils.i18n.fine/src/views/enableDisableEdition.php'",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"template",
"->",
"toHtml",
"(",
")",
";",
"}"
] | Admin page used to enable or disable label edition.
@Action
@Logged | [
"Admin",
"page",
"used",
"to",
"enable",
"or",
"disable",
"label",
"edition",
"."
] | 69c165497bc5c202892fdc8022591eddbb8e0e3b | https://github.com/thecodingmachine/utils.i18n.fine/blob/69c165497bc5c202892fdc8022591eddbb8e0e3b/src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php#L72-L78 |
9,285 | thecodingmachine/utils.i18n.fine | src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php | EditLabelController.setMode | public function setMode($mode) {
$editMode = ($mode=="on")?true:false;
//SessionUtils::setMessageEditionMode($editMode);
if ($editMode) {
$_SESSION["FINE_MESSAGE_EDITION_MODE"] = true;
$this->isMessageEditionMode = true;
} else {
unset($_SESSION["FINE_MESSAGE_EDITION_MODE"]);
}
$this->content->addFile('../utils.i18n.fine/src/views/enableDisableEdition.php', $this);
$this->template->toHtml();
} | php | public function setMode($mode) {
$editMode = ($mode=="on")?true:false;
//SessionUtils::setMessageEditionMode($editMode);
if ($editMode) {
$_SESSION["FINE_MESSAGE_EDITION_MODE"] = true;
$this->isMessageEditionMode = true;
} else {
unset($_SESSION["FINE_MESSAGE_EDITION_MODE"]);
}
$this->content->addFile('../utils.i18n.fine/src/views/enableDisableEdition.php', $this);
$this->template->toHtml();
} | [
"public",
"function",
"setMode",
"(",
"$",
"mode",
")",
"{",
"$",
"editMode",
"=",
"(",
"$",
"mode",
"==",
"\"on\"",
")",
"?",
"true",
":",
"false",
";",
"//SessionUtils::setMessageEditionMode($editMode);",
"if",
"(",
"$",
"editMode",
")",
"{",
"$",
"_SESSION",
"[",
"\"FINE_MESSAGE_EDITION_MODE\"",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"isMessageEditionMode",
"=",
"true",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"_SESSION",
"[",
"\"FINE_MESSAGE_EDITION_MODE\"",
"]",
")",
";",
"}",
"$",
"this",
"->",
"content",
"->",
"addFile",
"(",
"'../utils.i18n.fine/src/views/enableDisableEdition.php'",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"template",
"->",
"toHtml",
"(",
")",
";",
"}"
] | Action used to set the mode of label edition.
@Action
//@Admin | [
"Action",
"used",
"to",
"set",
"the",
"mode",
"of",
"label",
"edition",
"."
] | 69c165497bc5c202892fdc8022591eddbb8e0e3b | https://github.com/thecodingmachine/utils.i18n.fine/blob/69c165497bc5c202892fdc8022591eddbb8e0e3b/src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php#L86-L98 |
9,286 | thecodingmachine/utils.i18n.fine | src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php | EditLabelController.addSupportedLanguage | public function addSupportedLanguage($language, $name = "defaultTranslationService", $selfedit="false") {
$this->addTranslationLanguageFromService(($selfedit == "true"), $name, $language);
// Once more to reaload languages list
$this->supportedLanguages($name, $selfedit);
} | php | public function addSupportedLanguage($language, $name = "defaultTranslationService", $selfedit="false") {
$this->addTranslationLanguageFromService(($selfedit == "true"), $name, $language);
// Once more to reaload languages list
$this->supportedLanguages($name, $selfedit);
} | [
"public",
"function",
"addSupportedLanguage",
"(",
"$",
"language",
",",
"$",
"name",
"=",
"\"defaultTranslationService\"",
",",
"$",
"selfedit",
"=",
"\"false\"",
")",
"{",
"$",
"this",
"->",
"addTranslationLanguageFromService",
"(",
"(",
"$",
"selfedit",
"==",
"\"true\"",
")",
",",
"$",
"name",
",",
"$",
"language",
")",
";",
"// Once more to reaload languages list",
"$",
"this",
"->",
"supportedLanguages",
"(",
"$",
"name",
",",
"$",
"selfedit",
")",
";",
"}"
] | Adds a language to the list of supported languages
@Action
@Logged
@param string $language | [
"Adds",
"a",
"language",
"to",
"the",
"list",
"of",
"supported",
"languages"
] | 69c165497bc5c202892fdc8022591eddbb8e0e3b | https://github.com/thecodingmachine/utils.i18n.fine/blob/69c165497bc5c202892fdc8022591eddbb8e0e3b/src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php#L211-L216 |
9,287 | thecodingmachine/utils.i18n.fine | src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php | EditLabelController.searchLabel | public function searchLabel($msginstancename = "defaultTranslationService", $selfedit = "false", $search, $language_search = null) {
$this->msgInstanceName = $msginstancename;
$this->selfedit = $selfedit;
$array = $this->getAllMessagesFromService(($selfedit == "true"), $msginstancename, $language_search);
$this->languages = $array["languages"];
$this->search = $search;
$this->language_search = $language_search;
if($search) {
$this->msgs = $array["msgs"];
$regex = $this->stripRegexMetaChars($this->stripAccents($search));
$this->results = $this->regex_search_array($array["msgs"], $regex);
$this->error = false;
}
else
$this->error = true;
$webLibriary = new WebLibrary(array(), array('../utils.i18n.fine/src/views/css/style.css'));
$this->template->getWebLibraryManager()->addLibrary($webLibriary);
$this->content->addFile('../utils.i18n.fine/src/views/searchLabel.php', $this);
$this->template->toHtml();
} | php | public function searchLabel($msginstancename = "defaultTranslationService", $selfedit = "false", $search, $language_search = null) {
$this->msgInstanceName = $msginstancename;
$this->selfedit = $selfedit;
$array = $this->getAllMessagesFromService(($selfedit == "true"), $msginstancename, $language_search);
$this->languages = $array["languages"];
$this->search = $search;
$this->language_search = $language_search;
if($search) {
$this->msgs = $array["msgs"];
$regex = $this->stripRegexMetaChars($this->stripAccents($search));
$this->results = $this->regex_search_array($array["msgs"], $regex);
$this->error = false;
}
else
$this->error = true;
$webLibriary = new WebLibrary(array(), array('../utils.i18n.fine/src/views/css/style.css'));
$this->template->getWebLibraryManager()->addLibrary($webLibriary);
$this->content->addFile('../utils.i18n.fine/src/views/searchLabel.php', $this);
$this->template->toHtml();
} | [
"public",
"function",
"searchLabel",
"(",
"$",
"msginstancename",
"=",
"\"defaultTranslationService\"",
",",
"$",
"selfedit",
"=",
"\"false\"",
",",
"$",
"search",
",",
"$",
"language_search",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"msgInstanceName",
"=",
"$",
"msginstancename",
";",
"$",
"this",
"->",
"selfedit",
"=",
"$",
"selfedit",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"getAllMessagesFromService",
"(",
"(",
"$",
"selfedit",
"==",
"\"true\"",
")",
",",
"$",
"msginstancename",
",",
"$",
"language_search",
")",
";",
"$",
"this",
"->",
"languages",
"=",
"$",
"array",
"[",
"\"languages\"",
"]",
";",
"$",
"this",
"->",
"search",
"=",
"$",
"search",
";",
"$",
"this",
"->",
"language_search",
"=",
"$",
"language_search",
";",
"if",
"(",
"$",
"search",
")",
"{",
"$",
"this",
"->",
"msgs",
"=",
"$",
"array",
"[",
"\"msgs\"",
"]",
";",
"$",
"regex",
"=",
"$",
"this",
"->",
"stripRegexMetaChars",
"(",
"$",
"this",
"->",
"stripAccents",
"(",
"$",
"search",
")",
")",
";",
"$",
"this",
"->",
"results",
"=",
"$",
"this",
"->",
"regex_search_array",
"(",
"$",
"array",
"[",
"\"msgs\"",
"]",
",",
"$",
"regex",
")",
";",
"$",
"this",
"->",
"error",
"=",
"false",
";",
"}",
"else",
"$",
"this",
"->",
"error",
"=",
"true",
";",
"$",
"webLibriary",
"=",
"new",
"WebLibrary",
"(",
"array",
"(",
")",
",",
"array",
"(",
"'../utils.i18n.fine/src/views/css/style.css'",
")",
")",
";",
"$",
"this",
"->",
"template",
"->",
"getWebLibraryManager",
"(",
")",
"->",
"addLibrary",
"(",
"$",
"webLibriary",
")",
";",
"$",
"this",
"->",
"content",
"->",
"addFile",
"(",
"'../utils.i18n.fine/src/views/searchLabel.php'",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"template",
"->",
"toHtml",
"(",
")",
";",
"}"
] | Search All label with the value
@Action
@Logged
@param string $name
@param string $search | [
"Search",
"All",
"label",
"with",
"the",
"value"
] | 69c165497bc5c202892fdc8022591eddbb8e0e3b | https://github.com/thecodingmachine/utils.i18n.fine/blob/69c165497bc5c202892fdc8022591eddbb8e0e3b/src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php#L227-L252 |
9,288 | thecodingmachine/utils.i18n.fine | src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php | EditLabelController.setTranslationsForMessageFromService | protected static function setTranslationsForMessageFromService($selfEdit, $msgInstanceName, $language, $translations) {
$translationService = new InstanceProxy($msgInstanceName, $selfEdit);
return $translationService->setMessages($translations, $language);
} | php | protected static function setTranslationsForMessageFromService($selfEdit, $msgInstanceName, $language, $translations) {
$translationService = new InstanceProxy($msgInstanceName, $selfEdit);
return $translationService->setMessages($translations, $language);
} | [
"protected",
"static",
"function",
"setTranslationsForMessageFromService",
"(",
"$",
"selfEdit",
",",
"$",
"msgInstanceName",
",",
"$",
"language",
",",
"$",
"translations",
")",
"{",
"$",
"translationService",
"=",
"new",
"InstanceProxy",
"(",
"$",
"msgInstanceName",
",",
"$",
"selfEdit",
")",
";",
"return",
"$",
"translationService",
"->",
"setMessages",
"(",
"$",
"translations",
",",
"$",
"language",
")",
";",
"}"
] | Saves many translations for one key and one language using CURL.
@param bool $selfEdit
@param string $msgInstanceName
@param string $language
@param array $translations
@return boolean
@throws Exception | [
"Saves",
"many",
"translations",
"for",
"one",
"key",
"and",
"one",
"language",
"using",
"CURL",
"."
] | 69c165497bc5c202892fdc8022591eddbb8e0e3b | https://github.com/thecodingmachine/utils.i18n.fine/blob/69c165497bc5c202892fdc8022591eddbb8e0e3b/src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php#L333-L336 |
9,289 | thecodingmachine/utils.i18n.fine | src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php | EditLabelController.regex_search_array | private function regex_search_array($array, $regex) {
$return = array();
foreach ($array as $key => $item) {
if(is_array($item)) {
$tmp = $this->regex_search_array($item, $regex);
if($tmp)
$return[$key] = $tmp;
} elseif(!is_object($item)) {
//if (preg_match("/^.*".$regex.".*$/", $this->stripAccents($item))) {
if (preg_match("/".$regex."/i", $this->stripAccents($item))) {
$return[$key] = $item;
}
}
}
return $return;
} | php | private function regex_search_array($array, $regex) {
$return = array();
foreach ($array as $key => $item) {
if(is_array($item)) {
$tmp = $this->regex_search_array($item, $regex);
if($tmp)
$return[$key] = $tmp;
} elseif(!is_object($item)) {
//if (preg_match("/^.*".$regex.".*$/", $this->stripAccents($item))) {
if (preg_match("/".$regex."/i", $this->stripAccents($item))) {
$return[$key] = $item;
}
}
}
return $return;
} | [
"private",
"function",
"regex_search_array",
"(",
"$",
"array",
",",
"$",
"regex",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"$",
"tmp",
"=",
"$",
"this",
"->",
"regex_search_array",
"(",
"$",
"item",
",",
"$",
"regex",
")",
";",
"if",
"(",
"$",
"tmp",
")",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"tmp",
";",
"}",
"elseif",
"(",
"!",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"//if (preg_match(\"/^.*\".$regex.\".*$/\", $this->stripAccents($item))) {",
"if",
"(",
"preg_match",
"(",
"\"/\"",
".",
"$",
"regex",
".",
"\"/i\"",
",",
"$",
"this",
"->",
"stripAccents",
"(",
"$",
"item",
")",
")",
")",
"{",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Search the regex in all the array. Return an array with all result
Enter description here ...
@param array $array
@param string $regex
@return array | [
"Search",
"the",
"regex",
"in",
"all",
"the",
"array",
".",
"Return",
"an",
"array",
"with",
"all",
"result"
] | 69c165497bc5c202892fdc8022591eddbb8e0e3b | https://github.com/thecodingmachine/utils.i18n.fine/blob/69c165497bc5c202892fdc8022591eddbb8e0e3b/src/Mouf/Utils/I18n/Fine/Controllers/EditLabelController.php#L384-L400 |
9,290 | stubbles/stubbles-sequence | src/main/php/Reducer.php | Reducer.toSum | public function toSum(callable $summer = null)
{
if (null === $summer) {
$summer = function($sum, $element) { return $sum += $element; };
}
return $this->with($summer, 0);
} | php | public function toSum(callable $summer = null)
{
if (null === $summer) {
$summer = function($sum, $element) { return $sum += $element; };
}
return $this->with($summer, 0);
} | [
"public",
"function",
"toSum",
"(",
"callable",
"$",
"summer",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"summer",
")",
"{",
"$",
"summer",
"=",
"function",
"(",
"$",
"sum",
",",
"$",
"element",
")",
"{",
"return",
"$",
"sum",
"+=",
"$",
"element",
";",
"}",
";",
"}",
"return",
"$",
"this",
"->",
"with",
"(",
"$",
"summer",
",",
"0",
")",
";",
"}"
] | reduce to sum of all elements
@api
@param callable $summer optional different summing function, i.e. when elements are not numbers
@return int | [
"reduce",
"to",
"sum",
"of",
"all",
"elements"
] | 258d2247f1cdd826818348fe15829d5a98a9de70 | https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Reducer.php#L63-L70 |
9,291 | stubbles/stubbles-sequence | src/main/php/Reducer.php | Reducer.toMin | public function toMin(callable $min = null)
{
if (null === $min) {
// can't use min() as $smallest is initially null but actual
// elements were not checked yet, and min() considers null to always
// be the minimum value
$min = function($smallest, $element)
{
return (null === $smallest || $element < $smallest) ? $element : $smallest;
};
}
return $this->with($min);
} | php | public function toMin(callable $min = null)
{
if (null === $min) {
// can't use min() as $smallest is initially null but actual
// elements were not checked yet, and min() considers null to always
// be the minimum value
$min = function($smallest, $element)
{
return (null === $smallest || $element < $smallest) ? $element : $smallest;
};
}
return $this->with($min);
} | [
"public",
"function",
"toMin",
"(",
"callable",
"$",
"min",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"min",
")",
"{",
"// can't use min() as $smallest is initially null but actual",
"// elements were not checked yet, and min() considers null to always",
"// be the minimum value",
"$",
"min",
"=",
"function",
"(",
"$",
"smallest",
",",
"$",
"element",
")",
"{",
"return",
"(",
"null",
"===",
"$",
"smallest",
"||",
"$",
"element",
"<",
"$",
"smallest",
")",
"?",
"$",
"element",
":",
"$",
"smallest",
";",
"}",
";",
"}",
"return",
"$",
"this",
"->",
"with",
"(",
"$",
"min",
")",
";",
"}"
] | reduce to smallest element
@api
@param callable $min optional different function to calculate the minimum, i.e. when elements are not numbers
@return mixed | [
"reduce",
"to",
"smallest",
"element"
] | 258d2247f1cdd826818348fe15829d5a98a9de70 | https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Reducer.php#L79-L92 |
9,292 | tenside/core | src/Util/ProcessBuilder.php | ProcessBuilder.setWorkingDirectory | public function setWorkingDirectory($workingDirectory)
{
if ((null !== $workingDirectory) && !is_dir($workingDirectory)) {
throw new InvalidArgumentException('The working directory must exist.');
}
$this->workingDirectory = $workingDirectory;
return $this;
} | php | public function setWorkingDirectory($workingDirectory)
{
if ((null !== $workingDirectory) && !is_dir($workingDirectory)) {
throw new InvalidArgumentException('The working directory must exist.');
}
$this->workingDirectory = $workingDirectory;
return $this;
} | [
"public",
"function",
"setWorkingDirectory",
"(",
"$",
"workingDirectory",
")",
"{",
"if",
"(",
"(",
"null",
"!==",
"$",
"workingDirectory",
")",
"&&",
"!",
"is_dir",
"(",
"$",
"workingDirectory",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The working directory must exist.'",
")",
";",
"}",
"$",
"this",
"->",
"workingDirectory",
"=",
"$",
"workingDirectory",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the working directory.
@param null|string $workingDirectory The working directory.
@return ProcessBuilder
@throws InvalidArgumentException When the working directory is non null and does not exist. | [
"Sets",
"the",
"working",
"directory",
"."
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Util/ProcessBuilder.php#L190-L199 |
9,293 | tenside/core | src/Util/ProcessBuilder.php | ProcessBuilder.generate | public function generate()
{
$options = $this->options;
$arguments = array_merge([$this->binary], (array) $this->arguments);
$script = implode(' ', array_map([ProcessUtils::class, 'escapeArgument'], $arguments));
$process = new Process(
$this->applyForceToBackground($script),
$this->workingDirectory,
$this->getEnvironmentVariables(),
$this->input,
$this->timeout,
$options
);
if ($this->outputDisabled) {
$process->disableOutput();
}
return $process;
} | php | public function generate()
{
$options = $this->options;
$arguments = array_merge([$this->binary], (array) $this->arguments);
$script = implode(' ', array_map([ProcessUtils::class, 'escapeArgument'], $arguments));
$process = new Process(
$this->applyForceToBackground($script),
$this->workingDirectory,
$this->getEnvironmentVariables(),
$this->input,
$this->timeout,
$options
);
if ($this->outputDisabled) {
$process->disableOutput();
}
return $process;
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"options",
";",
"$",
"arguments",
"=",
"array_merge",
"(",
"[",
"$",
"this",
"->",
"binary",
"]",
",",
"(",
"array",
")",
"$",
"this",
"->",
"arguments",
")",
";",
"$",
"script",
"=",
"implode",
"(",
"' '",
",",
"array_map",
"(",
"[",
"ProcessUtils",
"::",
"class",
",",
"'escapeArgument'",
"]",
",",
"$",
"arguments",
")",
")",
";",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"this",
"->",
"applyForceToBackground",
"(",
"$",
"script",
")",
",",
"$",
"this",
"->",
"workingDirectory",
",",
"$",
"this",
"->",
"getEnvironmentVariables",
"(",
")",
",",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"timeout",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"this",
"->",
"outputDisabled",
")",
"{",
"$",
"process",
"->",
"disableOutput",
"(",
")",
";",
"}",
"return",
"$",
"process",
";",
"}"
] | Generate the process.
@return Process | [
"Generate",
"the",
"process",
"."
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Util/ProcessBuilder.php#L357-L377 |
9,294 | tenside/core | src/Util/ProcessBuilder.php | ProcessBuilder.getEnvironmentVariables | private function getEnvironmentVariables()
{
// Initialize from globals, allow override of special keys via putenv calls.
$variables = $this->inheritEnvironment
? array_replace($_ENV, $_SERVER, $this->environment)
: $this->environment;
foreach (array_keys($variables) as $name) {
if (false !== ($value = getenv($name))) {
$variables[$name] = $value;
}
}
return $variables;
} | php | private function getEnvironmentVariables()
{
// Initialize from globals, allow override of special keys via putenv calls.
$variables = $this->inheritEnvironment
? array_replace($_ENV, $_SERVER, $this->environment)
: $this->environment;
foreach (array_keys($variables) as $name) {
if (false !== ($value = getenv($name))) {
$variables[$name] = $value;
}
}
return $variables;
} | [
"private",
"function",
"getEnvironmentVariables",
"(",
")",
"{",
"// Initialize from globals, allow override of special keys via putenv calls.",
"$",
"variables",
"=",
"$",
"this",
"->",
"inheritEnvironment",
"?",
"array_replace",
"(",
"$",
"_ENV",
",",
"$",
"_SERVER",
",",
"$",
"this",
"->",
"environment",
")",
":",
"$",
"this",
"->",
"environment",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"variables",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"value",
"=",
"getenv",
"(",
"$",
"name",
")",
")",
")",
"{",
"$",
"variables",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"variables",
";",
"}"
] | Retrieve the passed environment variables from the current session and return them.
@return array
@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName) | [
"Retrieve",
"the",
"passed",
"environment",
"variables",
"from",
"the",
"current",
"session",
"and",
"return",
"them",
"."
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Util/ProcessBuilder.php#L387-L401 |
9,295 | AnonymPHP/Anonym-Library | src/Anonym/Constructors/DatabaseConstructor.php | DatabaseConstructor.register | public function register()
{
$app = $this->app;
if (true === $this->app['config']->get('database.autostart')) {
$configs = Config::get('database');
$connection = $configs['connection'];
$connectionConfigs = Arr::get($configs['connections'], $connection, []);
Query::configs($connectionConfigs);
$this->singleton(
'database.base',
function () {
return new Database();
}
);
$this->singleton(Base::class, function () {
return App::make('database.base');
});
}
} | php | public function register()
{
$app = $this->app;
if (true === $this->app['config']->get('database.autostart')) {
$configs = Config::get('database');
$connection = $configs['connection'];
$connectionConfigs = Arr::get($configs['connections'], $connection, []);
Query::configs($connectionConfigs);
$this->singleton(
'database.base',
function () {
return new Database();
}
);
$this->singleton(Base::class, function () {
return App::make('database.base');
});
}
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'database.autostart'",
")",
")",
"{",
"$",
"configs",
"=",
"Config",
"::",
"get",
"(",
"'database'",
")",
";",
"$",
"connection",
"=",
"$",
"configs",
"[",
"'connection'",
"]",
";",
"$",
"connectionConfigs",
"=",
"Arr",
"::",
"get",
"(",
"$",
"configs",
"[",
"'connections'",
"]",
",",
"$",
"connection",
",",
"[",
"]",
")",
";",
"Query",
"::",
"configs",
"(",
"$",
"connectionConfigs",
")",
";",
"$",
"this",
"->",
"singleton",
"(",
"'database.base'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"Database",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"singleton",
"(",
"Base",
"::",
"class",
",",
"function",
"(",
")",
"{",
"return",
"App",
"::",
"make",
"(",
"'database.base'",
")",
";",
"}",
")",
";",
"}",
"}"
] | register the database base | [
"register",
"the",
"database",
"base"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Constructors/DatabaseConstructor.php#L33-L59 |
9,296 | jeromeklam/freefw | src/FreeFW/Core/StorageModel.php | StorageModel.getQuery | public static function getQuery(string $p_type = \FreeFW\Model\Query::QUERY_SELECT)
{
$cls = get_called_class();
$cls = rtrim(ltrim($cls, '\\'), '\\');
$query = \FreeFW\DI\DI::get('FreeFW::Model::Query');
$query
->setType($p_type)
->setMainModel(str_replace('\\', '::', $cls))
;
return $query;
} | php | public static function getQuery(string $p_type = \FreeFW\Model\Query::QUERY_SELECT)
{
$cls = get_called_class();
$cls = rtrim(ltrim($cls, '\\'), '\\');
$query = \FreeFW\DI\DI::get('FreeFW::Model::Query');
$query
->setType($p_type)
->setMainModel(str_replace('\\', '::', $cls))
;
return $query;
} | [
"public",
"static",
"function",
"getQuery",
"(",
"string",
"$",
"p_type",
"=",
"\\",
"FreeFW",
"\\",
"Model",
"\\",
"Query",
"::",
"QUERY_SELECT",
")",
"{",
"$",
"cls",
"=",
"get_called_class",
"(",
")",
";",
"$",
"cls",
"=",
"rtrim",
"(",
"ltrim",
"(",
"$",
"cls",
",",
"'\\\\'",
")",
",",
"'\\\\'",
")",
";",
"$",
"query",
"=",
"\\",
"FreeFW",
"\\",
"DI",
"\\",
"DI",
"::",
"get",
"(",
"'FreeFW::Model::Query'",
")",
";",
"$",
"query",
"->",
"setType",
"(",
"$",
"p_type",
")",
"->",
"setMainModel",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'::'",
",",
"$",
"cls",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] | Get new Query Model
@param string $p_type
@return \FreeFW\Model\Query | [
"Get",
"new",
"Query",
"Model"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Core/StorageModel.php#L142-L152 |
9,297 | lucidphp/mux | src/Router.php | Router.dispatchMatch | public function dispatchMatch(MatchContextInterface $match)
{
// store the previous request context.
$request = $this->url->getRequestContext();
$this->url->setRequestContext($match->getRequest());
$this->routeStack->push($match->getName());
$response = $this->mapper->mapResponse($this->dispatcher->dispatch($match));
$this->routeStack->pop();
// restore the previous request context.
if (null !== $request) {
$this->url->setRequestContext($request);
}
return $response;
} | php | public function dispatchMatch(MatchContextInterface $match)
{
// store the previous request context.
$request = $this->url->getRequestContext();
$this->url->setRequestContext($match->getRequest());
$this->routeStack->push($match->getName());
$response = $this->mapper->mapResponse($this->dispatcher->dispatch($match));
$this->routeStack->pop();
// restore the previous request context.
if (null !== $request) {
$this->url->setRequestContext($request);
}
return $response;
} | [
"public",
"function",
"dispatchMatch",
"(",
"MatchContextInterface",
"$",
"match",
")",
"{",
"// store the previous request context.",
"$",
"request",
"=",
"$",
"this",
"->",
"url",
"->",
"getRequestContext",
"(",
")",
";",
"$",
"this",
"->",
"url",
"->",
"setRequestContext",
"(",
"$",
"match",
"->",
"getRequest",
"(",
")",
")",
";",
"$",
"this",
"->",
"routeStack",
"->",
"push",
"(",
"$",
"match",
"->",
"getName",
"(",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"mapper",
"->",
"mapResponse",
"(",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"$",
"match",
")",
")",
";",
"$",
"this",
"->",
"routeStack",
"->",
"pop",
"(",
")",
";",
"// restore the previous request context.",
"if",
"(",
"null",
"!==",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"url",
"->",
"setRequestContext",
"(",
"$",
"request",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Dispatches a request.
@param RequestContextInterface $request
@param MatchContextInterface $match
@return mixed the request response. | [
"Dispatches",
"a",
"request",
"."
] | 2d054ea01450bdad6a4af8198ca6f10705e1c327 | https://github.com/lucidphp/mux/blob/2d054ea01450bdad6a4af8198ca6f10705e1c327/src/Router.php#L109-L127 |
9,298 | joaogl/comments | src/commentsServiceProvider.php | commentsServiceProvider.registerComment | protected function registerComment()
{
$this->app->singleton('jlourenco.comments.comment', function ($app) {
$baseConfig = $app['config']->get('jlourenco.base');
$config = $app['config']->get('jlourenco.comments');
$model = array_get($config, 'models.comment');
$users = array_get($baseConfig, 'models.User');
if (class_exists($model) && method_exists($model, 'setUsersModel'))
forward_static_call_array([$model, 'setUsersModel'], [$users]);
return new CommentRepository($model);
});
} | php | protected function registerComment()
{
$this->app->singleton('jlourenco.comments.comment', function ($app) {
$baseConfig = $app['config']->get('jlourenco.base');
$config = $app['config']->get('jlourenco.comments');
$model = array_get($config, 'models.comment');
$users = array_get($baseConfig, 'models.User');
if (class_exists($model) && method_exists($model, 'setUsersModel'))
forward_static_call_array([$model, 'setUsersModel'], [$users]);
return new CommentRepository($model);
});
} | [
"protected",
"function",
"registerComment",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'jlourenco.comments.comment'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"baseConfig",
"=",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'jlourenco.base'",
")",
";",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'jlourenco.comments'",
")",
";",
"$",
"model",
"=",
"array_get",
"(",
"$",
"config",
",",
"'models.comment'",
")",
";",
"$",
"users",
"=",
"array_get",
"(",
"$",
"baseConfig",
",",
"'models.User'",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"model",
")",
"&&",
"method_exists",
"(",
"$",
"model",
",",
"'setUsersModel'",
")",
")",
"forward_static_call_array",
"(",
"[",
"$",
"model",
",",
"'setUsersModel'",
"]",
",",
"[",
"$",
"users",
"]",
")",
";",
"return",
"new",
"CommentRepository",
"(",
"$",
"model",
")",
";",
"}",
")",
";",
"}"
] | Registers the blog posts.
@return void | [
"Registers",
"the",
"blog",
"posts",
"."
] | 66fabe1ad4a8977a0933f8310ee6dcb38a72cbc3 | https://github.com/joaogl/comments/blob/66fabe1ad4a8977a0933f8310ee6dcb38a72cbc3/src/commentsServiceProvider.php#L70-L84 |
9,299 | joaogl/comments | src/commentsServiceProvider.php | commentsServiceProvider.registerComments | protected function registerComments()
{
$this->app->singleton('comments', function ($app) {
$blog = new Comments($app['jlourenco.comments.comment']);
return $blog;
});
$this->app->alias('comments', 'jlourenco\comments\Comments');
} | php | protected function registerComments()
{
$this->app->singleton('comments', function ($app) {
$blog = new Comments($app['jlourenco.comments.comment']);
return $blog;
});
$this->app->alias('comments', 'jlourenco\comments\Comments');
} | [
"protected",
"function",
"registerComments",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'comments'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"blog",
"=",
"new",
"Comments",
"(",
"$",
"app",
"[",
"'jlourenco.comments.comment'",
"]",
")",
";",
"return",
"$",
"blog",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"'comments'",
",",
"'jlourenco\\comments\\Comments'",
")",
";",
"}"
] | Registers log.
@return void | [
"Registers",
"log",
"."
] | 66fabe1ad4a8977a0933f8310ee6dcb38a72cbc3 | https://github.com/joaogl/comments/blob/66fabe1ad4a8977a0933f8310ee6dcb38a72cbc3/src/commentsServiceProvider.php#L91-L100 |
Subsets and Splits