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
|
---|---|---|---|---|---|---|---|---|---|---|---|
4,400 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.instance | public static function instance($name = null, array $config = null, $writable = true)
{
\Config::load('db', true);
if ($name === null)
{
// Use the default instance name
$name = \Config::get('db.active');
}
if ( ! $writable and ($readonly = \Config::get('db.'.$name.'.readonly', false)))
{
! isset(static::$_readonly[$name]) and static::$_readonly[$name] = \Arr::get($readonly, array_rand($readonly));
$name = static::$_readonly[$name];
}
if ( ! isset(static::$instances[$name]))
{
if ($config === null)
{
// Load the configuration for this database
$config = \Config::get('db.'.$name);
}
if ( ! isset($config['type']))
{
throw new \FuelException('Database type not defined in "'.$name.'" configuration or "'.$name.'" configuration does not exist');
}
// Set the driver class name
$driver = '\\Database_' . ucfirst($config['type']) . '_Connection';
// Create the database connection instance
new $driver($name, $config);
}
return static::$instances[$name];
} | php | public static function instance($name = null, array $config = null, $writable = true)
{
\Config::load('db', true);
if ($name === null)
{
// Use the default instance name
$name = \Config::get('db.active');
}
if ( ! $writable and ($readonly = \Config::get('db.'.$name.'.readonly', false)))
{
! isset(static::$_readonly[$name]) and static::$_readonly[$name] = \Arr::get($readonly, array_rand($readonly));
$name = static::$_readonly[$name];
}
if ( ! isset(static::$instances[$name]))
{
if ($config === null)
{
// Load the configuration for this database
$config = \Config::get('db.'.$name);
}
if ( ! isset($config['type']))
{
throw new \FuelException('Database type not defined in "'.$name.'" configuration or "'.$name.'" configuration does not exist');
}
// Set the driver class name
$driver = '\\Database_' . ucfirst($config['type']) . '_Connection';
// Create the database connection instance
new $driver($name, $config);
}
return static::$instances[$name];
} | [
"public",
"static",
"function",
"instance",
"(",
"$",
"name",
"=",
"null",
",",
"array",
"$",
"config",
"=",
"null",
",",
"$",
"writable",
"=",
"true",
")",
"{",
"\\",
"Config",
"::",
"load",
"(",
"'db'",
",",
"true",
")",
";",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"// Use the default instance name",
"$",
"name",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'db.active'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"writable",
"and",
"(",
"$",
"readonly",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'db.'",
".",
"$",
"name",
".",
"'.readonly'",
",",
"false",
")",
")",
")",
"{",
"!",
"isset",
"(",
"static",
"::",
"$",
"_readonly",
"[",
"$",
"name",
"]",
")",
"and",
"static",
"::",
"$",
"_readonly",
"[",
"$",
"name",
"]",
"=",
"\\",
"Arr",
"::",
"get",
"(",
"$",
"readonly",
",",
"array_rand",
"(",
"$",
"readonly",
")",
")",
";",
"$",
"name",
"=",
"static",
"::",
"$",
"_readonly",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"config",
"===",
"null",
")",
"{",
"// Load the configuration for this database",
"$",
"config",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'db.'",
".",
"$",
"name",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"FuelException",
"(",
"'Database type not defined in \"'",
".",
"$",
"name",
".",
"'\" configuration or \"'",
".",
"$",
"name",
".",
"'\" configuration does not exist'",
")",
";",
"}",
"// Set the driver class name",
"$",
"driver",
"=",
"'\\\\Database_'",
".",
"ucfirst",
"(",
"$",
"config",
"[",
"'type'",
"]",
")",
".",
"'_Connection'",
";",
"// Create the database connection instance",
"new",
"$",
"driver",
"(",
"$",
"name",
",",
"$",
"config",
")",
";",
"}",
"return",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
";",
"}"
] | Get a singleton Database instance. If configuration is not specified,
it will be loaded from the database configuration file using the same
group as the name.
// Load the default database
$db = static::instance();
// Create a custom configured instance
$db = static::instance('custom', $config);
@param string $name instance name
@param array $config configuration parameters
@param bool $writable when replication is enabled, whether to return the master connection
@return Database_Connection
@throws \FuelException | [
"Get",
"a",
"singleton",
"Database",
"instance",
".",
"If",
"configuration",
"is",
"not",
"specified",
"it",
"will",
"be",
"loaded",
"from",
"the",
"database",
"configuration",
"file",
"using",
"the",
"same",
"group",
"as",
"the",
"name",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L50-L86 |
4,401 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.count_last_query | public function count_last_query()
{
if ($sql = $this->last_query)
{
$sql = trim($sql);
if (stripos($sql, 'SELECT') !== 0)
{
return false;
}
if (stripos($sql, 'LIMIT') !== false)
{
// Remove LIMIT from the SQL
$sql = preg_replace('/\sLIMIT\s+[^a-z]+/i', ' ', $sql);
}
if (stripos($sql, 'OFFSET') !== false)
{
// Remove OFFSET from the SQL
$sql = preg_replace('/\sOFFSET\s+\d+/i', '', $sql);
}
// Get the total rows from the last query executed
$result = $this->query
(
\DB::SELECT,
'SELECT COUNT(*) AS '.$this->quote_identifier('total_rows').' '.
'FROM ('.$sql.') AS '.$this->quote_table('counted_results'),
true
);
// Return the total number of rows from the query
return (int) $result->current()->total_rows;
}
return false;
} | php | public function count_last_query()
{
if ($sql = $this->last_query)
{
$sql = trim($sql);
if (stripos($sql, 'SELECT') !== 0)
{
return false;
}
if (stripos($sql, 'LIMIT') !== false)
{
// Remove LIMIT from the SQL
$sql = preg_replace('/\sLIMIT\s+[^a-z]+/i', ' ', $sql);
}
if (stripos($sql, 'OFFSET') !== false)
{
// Remove OFFSET from the SQL
$sql = preg_replace('/\sOFFSET\s+\d+/i', '', $sql);
}
// Get the total rows from the last query executed
$result = $this->query
(
\DB::SELECT,
'SELECT COUNT(*) AS '.$this->quote_identifier('total_rows').' '.
'FROM ('.$sql.') AS '.$this->quote_table('counted_results'),
true
);
// Return the total number of rows from the query
return (int) $result->current()->total_rows;
}
return false;
} | [
"public",
"function",
"count_last_query",
"(",
")",
"{",
"if",
"(",
"$",
"sql",
"=",
"$",
"this",
"->",
"last_query",
")",
"{",
"$",
"sql",
"=",
"trim",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"stripos",
"(",
"$",
"sql",
",",
"'SELECT'",
")",
"!==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"stripos",
"(",
"$",
"sql",
",",
"'LIMIT'",
")",
"!==",
"false",
")",
"{",
"// Remove LIMIT from the SQL",
"$",
"sql",
"=",
"preg_replace",
"(",
"'/\\sLIMIT\\s+[^a-z]+/i'",
",",
"' '",
",",
"$",
"sql",
")",
";",
"}",
"if",
"(",
"stripos",
"(",
"$",
"sql",
",",
"'OFFSET'",
")",
"!==",
"false",
")",
"{",
"// Remove OFFSET from the SQL",
"$",
"sql",
"=",
"preg_replace",
"(",
"'/\\sOFFSET\\s+\\d+/i'",
",",
"''",
",",
"$",
"sql",
")",
";",
"}",
"// Get the total rows from the last query executed",
"$",
"result",
"=",
"$",
"this",
"->",
"query",
"(",
"\\",
"DB",
"::",
"SELECT",
",",
"'SELECT COUNT(*) AS '",
".",
"$",
"this",
"->",
"quote_identifier",
"(",
"'total_rows'",
")",
".",
"' '",
".",
"'FROM ('",
".",
"$",
"sql",
".",
"') AS '",
".",
"$",
"this",
"->",
"quote_table",
"(",
"'counted_results'",
")",
",",
"true",
")",
";",
"// Return the total number of rows from the query",
"return",
"(",
"int",
")",
"$",
"result",
"->",
"current",
"(",
")",
"->",
"total_rows",
";",
"}",
"return",
"false",
";",
"}"
] | Count the number of records in the last query, without LIMIT or OFFSET applied.
// Get the total number of records that match the last query
$count = $db->count_last_query();
@return integer | [
"Count",
"the",
"number",
"of",
"records",
"in",
"the",
"last",
"query",
"without",
"LIMIT",
"or",
"OFFSET",
"applied",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L232-L268 |
4,402 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.count_records | public function count_records($table)
{
// Quote the table name
$table = $this->quote_table($table);
return $this->query(\DB::SELECT, 'SELECT COUNT(*) AS total_row_count FROM '.$table, false)
->get('total_row_count');
} | php | public function count_records($table)
{
// Quote the table name
$table = $this->quote_table($table);
return $this->query(\DB::SELECT, 'SELECT COUNT(*) AS total_row_count FROM '.$table, false)
->get('total_row_count');
} | [
"public",
"function",
"count_records",
"(",
"$",
"table",
")",
"{",
"// Quote the table name",
"$",
"table",
"=",
"$",
"this",
"->",
"quote_table",
"(",
"$",
"table",
")",
";",
"return",
"$",
"this",
"->",
"query",
"(",
"\\",
"DB",
"::",
"SELECT",
",",
"'SELECT COUNT(*) AS total_row_count FROM '",
".",
"$",
"table",
",",
"false",
")",
"->",
"get",
"(",
"'total_row_count'",
")",
";",
"}"
] | Count the number of records in a table.
// Get the total number of records in the "users" table
$count = $db->count_records('users');
@param mixed $table table name string or array(query, alias)
@return integer | [
"Count",
"the",
"number",
"of",
"records",
"in",
"a",
"table",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L297-L304 |
4,403 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection._parse_type | protected function _parse_type($type)
{
if (($open = strpos($type, '(')) === false)
{
// No length specified
return array($type, null);
}
// Closing parenthesis
$close = strpos($type, ')', $open);
// Length without parentheses
$length = substr($type, $open + 1, $close - 1 - $open);
// Type without the length
$type = substr($type, 0, $open).substr($type, $close + 1);
return array($type, $length);
} | php | protected function _parse_type($type)
{
if (($open = strpos($type, '(')) === false)
{
// No length specified
return array($type, null);
}
// Closing parenthesis
$close = strpos($type, ')', $open);
// Length without parentheses
$length = substr($type, $open + 1, $close - 1 - $open);
// Type without the length
$type = substr($type, 0, $open).substr($type, $close + 1);
return array($type, $length);
} | [
"protected",
"function",
"_parse_type",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"(",
"$",
"open",
"=",
"strpos",
"(",
"$",
"type",
",",
"'('",
")",
")",
"===",
"false",
")",
"{",
"// No length specified",
"return",
"array",
"(",
"$",
"type",
",",
"null",
")",
";",
"}",
"// Closing parenthesis",
"$",
"close",
"=",
"strpos",
"(",
"$",
"type",
",",
"')'",
",",
"$",
"open",
")",
";",
"// Length without parentheses",
"$",
"length",
"=",
"substr",
"(",
"$",
"type",
",",
"$",
"open",
"+",
"1",
",",
"$",
"close",
"-",
"1",
"-",
"$",
"open",
")",
";",
"// Type without the length",
"$",
"type",
"=",
"substr",
"(",
"$",
"type",
",",
"0",
",",
"$",
"open",
")",
".",
"substr",
"(",
"$",
"type",
",",
"$",
"close",
"+",
"1",
")",
";",
"return",
"array",
"(",
"$",
"type",
",",
"$",
"length",
")",
";",
"}"
] | Extracts the text between parentheses, if any.
// Returns: array('CHAR', '6')
list($type, $length) = $db->_parse_type('CHAR(6)');
@param string $type
@return array list containing the type and length, if any | [
"Extracts",
"the",
"text",
"between",
"parentheses",
"if",
"any",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L420-L438 |
4,404 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.table_prefix | public function table_prefix($table = null)
{
if ($table !== null)
{
return $this->_config['table_prefix'] .$table;
}
return $this->_config['table_prefix'];
} | php | public function table_prefix($table = null)
{
if ($table !== null)
{
return $this->_config['table_prefix'] .$table;
}
return $this->_config['table_prefix'];
} | [
"public",
"function",
"table_prefix",
"(",
"$",
"table",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"table",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_config",
"[",
"'table_prefix'",
"]",
".",
"$",
"table",
";",
"}",
"return",
"$",
"this",
"->",
"_config",
"[",
"'table_prefix'",
"]",
";",
"}"
] | Return the table prefix defined in the current configuration.
$prefix = $db->table_prefix();
@param string $table
@return string | [
"Return",
"the",
"table",
"prefix",
"defined",
"in",
"the",
"current",
"configuration",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L449-L457 |
4,405 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.quote | public function quote($value)
{
if ($value === null)
{
return 'null';
}
elseif ($value === true)
{
return "'1'";
}
elseif ($value === false)
{
return "'0'";
}
elseif (is_object($value))
{
if ($value instanceof Database_Query)
{
// Create a sub-query
return '('.$value->compile($this).')';
}
elseif ($value instanceof Database_Expression)
{
// Use a raw expression
return $value->value();
}
else
{
// Convert the object to a string
return $this->quote((string) $value);
}
}
elseif (is_array($value))
{
return '('.implode(', ', array_map(array($this, __FUNCTION__), $value)).')';
}
elseif (is_int($value))
{
return (int) $value;
}
elseif (is_float($value))
{
// Convert to non-locale aware float to prevent possible commas
return sprintf('%F', $value);
}
return $this->escape($value);
} | php | public function quote($value)
{
if ($value === null)
{
return 'null';
}
elseif ($value === true)
{
return "'1'";
}
elseif ($value === false)
{
return "'0'";
}
elseif (is_object($value))
{
if ($value instanceof Database_Query)
{
// Create a sub-query
return '('.$value->compile($this).')';
}
elseif ($value instanceof Database_Expression)
{
// Use a raw expression
return $value->value();
}
else
{
// Convert the object to a string
return $this->quote((string) $value);
}
}
elseif (is_array($value))
{
return '('.implode(', ', array_map(array($this, __FUNCTION__), $value)).')';
}
elseif (is_int($value))
{
return (int) $value;
}
elseif (is_float($value))
{
// Convert to non-locale aware float to prevent possible commas
return sprintf('%F', $value);
}
return $this->escape($value);
} | [
"public",
"function",
"quote",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"'null'",
";",
"}",
"elseif",
"(",
"$",
"value",
"===",
"true",
")",
"{",
"return",
"\"'1'\"",
";",
"}",
"elseif",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"\"'0'\"",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Database_Query",
")",
"{",
"// Create a sub-query",
"return",
"'('",
".",
"$",
"value",
"->",
"compile",
"(",
"$",
"this",
")",
".",
"')'",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Database_Expression",
")",
"{",
"// Use a raw expression",
"return",
"$",
"value",
"->",
"value",
"(",
")",
";",
"}",
"else",
"{",
"// Convert the object to a string",
"return",
"$",
"this",
"->",
"quote",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'('",
".",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"__FUNCTION__",
")",
",",
"$",
"value",
")",
")",
".",
"')'",
";",
"}",
"elseif",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"// Convert to non-locale aware float to prevent possible commas",
"return",
"sprintf",
"(",
"'%F'",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"escape",
"(",
"$",
"value",
")",
";",
"}"
] | Quote a value for an SQL query.
$db->quote(null); // 'null'
$db->quote(10); // 10
$db->quote('fred'); // 'fred'
Objects passed to this function will be converted to strings.
[Database_Expression] objects will use the value of the expression.
[Database_Query] objects will be compiled and converted to a sub-query.
All other objects will be converted using the `__toString` method.
@param mixed $value any value to quote
@return string
@uses static::escape | [
"Quote",
"a",
"value",
"for",
"an",
"SQL",
"query",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L477-L524 |
4,406 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.quote_identifier | public function quote_identifier($value)
{
if ($value === '*')
{
return $value;
}
elseif (is_object($value))
{
if ($value instanceof Database_Query)
{
// Create a sub-query
return '('.$value->compile($this).')';
}
elseif ($value instanceof Database_Expression)
{
// Use a raw expression
return $value->value();
}
else
{
// Convert the object to a string
return $this->quote_identifier((string) $value);
}
}
elseif (is_array($value))
{
// Separate the column and alias
list ($value, $alias) = $value;
return $this->quote_identifier($value).' AS '.$this->quote_identifier($alias);
}
if (preg_match('/^(["\']).*\1$/m', $value))
{
return $value;
}
if (strpos($value, '.') !== false)
{
// Split the identifier into the individual parts
// This is slightly broken, because a table or column name
// (or user-defined alias!) might legitimately contain a period.
$parts = explode('.', $value);
if ($prefix = $this->table_prefix())
{
// Get the offset of the table name, 2nd-to-last part
// This works for databases that can have 3 identifiers (Postgre)
$offset = count($parts) - 2;
// Add the table prefix to the table name
$parts[$offset] = $prefix.$parts[$offset];
}
// Quote each of the parts
return implode('.', array_map(array($this, __FUNCTION__), $parts));
}
// That you can simply escape the identifier by doubling
// it is a built-in assumption which may not be valid for
// all connection types! However, it's true for MySQL,
// SQLite, Postgres and other ANSI SQL-compliant DBs.
return $this->_identifier.str_replace($this->_identifier, $this->_identifier.$this->_identifier, $value).$this->_identifier;
} | php | public function quote_identifier($value)
{
if ($value === '*')
{
return $value;
}
elseif (is_object($value))
{
if ($value instanceof Database_Query)
{
// Create a sub-query
return '('.$value->compile($this).')';
}
elseif ($value instanceof Database_Expression)
{
// Use a raw expression
return $value->value();
}
else
{
// Convert the object to a string
return $this->quote_identifier((string) $value);
}
}
elseif (is_array($value))
{
// Separate the column and alias
list ($value, $alias) = $value;
return $this->quote_identifier($value).' AS '.$this->quote_identifier($alias);
}
if (preg_match('/^(["\']).*\1$/m', $value))
{
return $value;
}
if (strpos($value, '.') !== false)
{
// Split the identifier into the individual parts
// This is slightly broken, because a table or column name
// (or user-defined alias!) might legitimately contain a period.
$parts = explode('.', $value);
if ($prefix = $this->table_prefix())
{
// Get the offset of the table name, 2nd-to-last part
// This works for databases that can have 3 identifiers (Postgre)
$offset = count($parts) - 2;
// Add the table prefix to the table name
$parts[$offset] = $prefix.$parts[$offset];
}
// Quote each of the parts
return implode('.', array_map(array($this, __FUNCTION__), $parts));
}
// That you can simply escape the identifier by doubling
// it is a built-in assumption which may not be valid for
// all connection types! However, it's true for MySQL,
// SQLite, Postgres and other ANSI SQL-compliant DBs.
return $this->_identifier.str_replace($this->_identifier, $this->_identifier.$this->_identifier, $value).$this->_identifier;
} | [
"public",
"function",
"quote_identifier",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"'*'",
")",
"{",
"return",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Database_Query",
")",
"{",
"// Create a sub-query",
"return",
"'('",
".",
"$",
"value",
"->",
"compile",
"(",
"$",
"this",
")",
".",
"')'",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Database_Expression",
")",
"{",
"// Use a raw expression",
"return",
"$",
"value",
"->",
"value",
"(",
")",
";",
"}",
"else",
"{",
"// Convert the object to a string",
"return",
"$",
"this",
"->",
"quote_identifier",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"// Separate the column and alias",
"list",
"(",
"$",
"value",
",",
"$",
"alias",
")",
"=",
"$",
"value",
";",
"return",
"$",
"this",
"->",
"quote_identifier",
"(",
"$",
"value",
")",
".",
"' AS '",
".",
"$",
"this",
"->",
"quote_identifier",
"(",
"$",
"alias",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^([\"\\']).*\\1$/m'",
",",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"// Split the identifier into the individual parts",
"// This is slightly broken, because a table or column name",
"// (or user-defined alias!) might legitimately contain a period.",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"prefix",
"=",
"$",
"this",
"->",
"table_prefix",
"(",
")",
")",
"{",
"// Get the offset of the table name, 2nd-to-last part",
"// This works for databases that can have 3 identifiers (Postgre)",
"$",
"offset",
"=",
"count",
"(",
"$",
"parts",
")",
"-",
"2",
";",
"// Add the table prefix to the table name",
"$",
"parts",
"[",
"$",
"offset",
"]",
"=",
"$",
"prefix",
".",
"$",
"parts",
"[",
"$",
"offset",
"]",
";",
"}",
"// Quote each of the parts",
"return",
"implode",
"(",
"'.'",
",",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"__FUNCTION__",
")",
",",
"$",
"parts",
")",
")",
";",
"}",
"// That you can simply escape the identifier by doubling",
"// it is a built-in assumption which may not be valid for",
"// all connection types! However, it's true for MySQL,",
"// SQLite, Postgres and other ANSI SQL-compliant DBs.",
"return",
"$",
"this",
"->",
"_identifier",
".",
"str_replace",
"(",
"$",
"this",
"->",
"_identifier",
",",
"$",
"this",
"->",
"_identifier",
".",
"$",
"this",
"->",
"_identifier",
",",
"$",
"value",
")",
".",
"$",
"this",
"->",
"_identifier",
";",
"}"
] | Quote a database identifier, such as a column name. Adds the
table prefix to the identifier if a table name is present.
$column = $db->quote_identifier($column);
You can also use SQL methods within identifiers.
// The value of "column" will be quoted
$column = $db->quote_identifier('COUNT("column")');
Objects passed to this function will be converted to strings.
[Database_Expression] objects will use the value of the expression.
[Database_Query] objects will be compiled and converted to a sub-query.
All other objects will be converted using the `__toString` method.
@param mixed $value any identifier
@return string
@uses static::table_prefix | [
"Quote",
"a",
"database",
"identifier",
"such",
"as",
"a",
"column",
"name",
".",
"Adds",
"the",
"table",
"prefix",
"to",
"the",
"identifier",
"if",
"a",
"table",
"name",
"is",
"present",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L630-L693 |
4,407 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.start_transaction | public function start_transaction()
{
$result = true;
if ($this->_transaction_depth == 0)
{
if ($this->driver_start_transaction())
{
$this->_in_transaction = true;
}
else
{
$result = false;
}
}
else
{
$result = $this->set_savepoint($this->_transaction_depth);
// If savepoint is not supported it is not an error
isset($result) or $result = true;
}
$result and $this->_transaction_depth ++;
return $result;
} | php | public function start_transaction()
{
$result = true;
if ($this->_transaction_depth == 0)
{
if ($this->driver_start_transaction())
{
$this->_in_transaction = true;
}
else
{
$result = false;
}
}
else
{
$result = $this->set_savepoint($this->_transaction_depth);
// If savepoint is not supported it is not an error
isset($result) or $result = true;
}
$result and $this->_transaction_depth ++;
return $result;
} | [
"public",
"function",
"start_transaction",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"_transaction_depth",
"==",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"driver_start_transaction",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_in_transaction",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"set_savepoint",
"(",
"$",
"this",
"->",
"_transaction_depth",
")",
";",
"// If savepoint is not supported it is not an error",
"isset",
"(",
"$",
"result",
")",
"or",
"$",
"result",
"=",
"true",
";",
"}",
"$",
"result",
"and",
"$",
"this",
"->",
"_transaction_depth",
"++",
";",
"return",
"$",
"result",
";",
"}"
] | Begins a nested transaction on instance
$db->start_transaction();
@return bool | [
"Begins",
"a",
"nested",
"transaction",
"on",
"instance"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L726-L751 |
4,408 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.commit_transaction | public function commit_transaction()
{
// Fake call of the commit
if ($this->_transaction_depth <= 0)
{
return false;
}
if ($this->_transaction_depth - 1)
{
$result = $this->release_savepoint($this->_transaction_depth - 1);
// If savepoint is not supported it is not an error
! isset($result) and $result = true;
}
else
{
$this->_in_transaction = false;
$result = $this->driver_commit();
}
$result and $this->_transaction_depth --;
return $result;
} | php | public function commit_transaction()
{
// Fake call of the commit
if ($this->_transaction_depth <= 0)
{
return false;
}
if ($this->_transaction_depth - 1)
{
$result = $this->release_savepoint($this->_transaction_depth - 1);
// If savepoint is not supported it is not an error
! isset($result) and $result = true;
}
else
{
$this->_in_transaction = false;
$result = $this->driver_commit();
}
$result and $this->_transaction_depth --;
return $result;
} | [
"public",
"function",
"commit_transaction",
"(",
")",
"{",
"// Fake call of the commit",
"if",
"(",
"$",
"this",
"->",
"_transaction_depth",
"<=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_transaction_depth",
"-",
"1",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"release_savepoint",
"(",
"$",
"this",
"->",
"_transaction_depth",
"-",
"1",
")",
";",
"// If savepoint is not supported it is not an error",
"!",
"isset",
"(",
"$",
"result",
")",
"and",
"$",
"result",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_in_transaction",
"=",
"false",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"driver_commit",
"(",
")",
";",
"}",
"$",
"result",
"and",
"$",
"this",
"->",
"_transaction_depth",
"--",
";",
"return",
"$",
"result",
";",
"}"
] | Commits nested transaction
$db->commit_transaction();
@return bool | [
"Commits",
"nested",
"transaction"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L760-L783 |
4,409 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/connection.php | Database_Connection.rollback_transaction | public function rollback_transaction($rollback_all = true)
{
if ($this->_transaction_depth > 0)
{
if($rollback_all or $this->_transaction_depth == 1)
{
if($result = $this->driver_rollback())
{
$this->_transaction_depth = 0;
$this->_in_transaction = false;
}
}
else
{
$result = $this->rollback_savepoint($this->_transaction_depth - 1);
// If savepoint is not supported it is not an error
isset($result) or $result = true;
$result and $this->_transaction_depth -- ;
}
}
else
{
$result = false;
}
return $result;
} | php | public function rollback_transaction($rollback_all = true)
{
if ($this->_transaction_depth > 0)
{
if($rollback_all or $this->_transaction_depth == 1)
{
if($result = $this->driver_rollback())
{
$this->_transaction_depth = 0;
$this->_in_transaction = false;
}
}
else
{
$result = $this->rollback_savepoint($this->_transaction_depth - 1);
// If savepoint is not supported it is not an error
isset($result) or $result = true;
$result and $this->_transaction_depth -- ;
}
}
else
{
$result = false;
}
return $result;
} | [
"public",
"function",
"rollback_transaction",
"(",
"$",
"rollback_all",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_transaction_depth",
">",
"0",
")",
"{",
"if",
"(",
"$",
"rollback_all",
"or",
"$",
"this",
"->",
"_transaction_depth",
"==",
"1",
")",
"{",
"if",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"driver_rollback",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_transaction_depth",
"=",
"0",
";",
"$",
"this",
"->",
"_in_transaction",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"rollback_savepoint",
"(",
"$",
"this",
"->",
"_transaction_depth",
"-",
"1",
")",
";",
"// If savepoint is not supported it is not an error",
"isset",
"(",
"$",
"result",
")",
"or",
"$",
"result",
"=",
"true",
";",
"$",
"result",
"and",
"$",
"this",
"->",
"_transaction_depth",
"--",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Rollsback nested pending transaction queries.
Rollback to the current level uses SAVEPOINT,
it does not work if current RDBMS does not support them.
In this case system rollbacks all queries and closes the transaction
$db->rollback_transaction();
@param bool $rollback_all:
true - rollback everything and close transaction;
false - rollback only current level
@return bool | [
"Rollsback",
"nested",
"pending",
"transaction",
"queries",
".",
"Rollback",
"to",
"the",
"current",
"level",
"uses",
"SAVEPOINT",
"it",
"does",
"not",
"work",
"if",
"current",
"RDBMS",
"does",
"not",
"support",
"them",
".",
"In",
"this",
"case",
"system",
"rollbacks",
"all",
"queries",
"and",
"closes",
"the",
"transaction"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/connection.php#L799-L826 |
4,410 | humweb/widgets | src/WidgetFactory.php | WidgetFactory.render | public function render($name, array $args = array())
{
if ($this->has($name)) {
$callback = $this->widgets[$name];
return $this->executeCallback($callback, $args);
}
return '';
} | php | public function render($name, array $args = array())
{
if ($this->has($name)) {
$callback = $this->widgets[$name];
return $this->executeCallback($callback, $args);
}
return '';
} | [
"public",
"function",
"render",
"(",
"$",
"name",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"widgets",
"[",
"$",
"name",
"]",
";",
"return",
"$",
"this",
"->",
"executeCallback",
"(",
"$",
"callback",
",",
"$",
"args",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Render widget instance
@param string $name
@param array $args
@return string | [
"Render",
"widget",
"instance"
] | c68f19b3a46d08f8e4d6ef6f722204532e5608e5 | https://github.com/humweb/widgets/blob/c68f19b3a46d08f8e4d6ef6f722204532e5608e5/src/WidgetFactory.php#L38-L47 |
4,411 | humweb/widgets | src/WidgetFactory.php | WidgetFactory.callStringCallback | protected function callStringCallback($callback, $args = [])
{
if (strpos($callback, '@')) {
list($klass, $method) = explode('@', $callback);
} else {
$klass = $callback;
$method = 'render';
}
$klass = isset($this->instantiatedWidgets[$klass]) ? $this->instantiatedWidgets[$klass] : new $klass;
return call_user_func_array([$klass, $method], $args);
} | php | protected function callStringCallback($callback, $args = [])
{
if (strpos($callback, '@')) {
list($klass, $method) = explode('@', $callback);
} else {
$klass = $callback;
$method = 'render';
}
$klass = isset($this->instantiatedWidgets[$klass]) ? $this->instantiatedWidgets[$klass] : new $klass;
return call_user_func_array([$klass, $method], $args);
} | [
"protected",
"function",
"callStringCallback",
"(",
"$",
"callback",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"callback",
",",
"'@'",
")",
")",
"{",
"list",
"(",
"$",
"klass",
",",
"$",
"method",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"callback",
")",
";",
"}",
"else",
"{",
"$",
"klass",
"=",
"$",
"callback",
";",
"$",
"method",
"=",
"'render'",
";",
"}",
"$",
"klass",
"=",
"isset",
"(",
"$",
"this",
"->",
"instantiatedWidgets",
"[",
"$",
"klass",
"]",
")",
"?",
"$",
"this",
"->",
"instantiatedWidgets",
"[",
"$",
"klass",
"]",
":",
"new",
"$",
"klass",
";",
"return",
"call_user_func_array",
"(",
"[",
"$",
"klass",
",",
"$",
"method",
"]",
",",
"$",
"args",
")",
";",
"}"
] | Execute string callback
@param string $callback
@param array $args
@return string | [
"Execute",
"string",
"callback"
] | c68f19b3a46d08f8e4d6ef6f722204532e5608e5 | https://github.com/humweb/widgets/blob/c68f19b3a46d08f8e4d6ef6f722204532e5608e5/src/WidgetFactory.php#L91-L103 |
4,412 | edunola13/core-modules | src/Authorization/AuthDbMiddleware.php | AuthDbMiddleware.getModules | public function getModules(){
if($this->loadModules != 'ALL'){
$this->connection->select('name');
$this->connection->from($this->tableModule);
$modules= $this->connection->get()->fetchAll(\PDO::FETCH_ASSOC);
foreach ($modules as $module) {
$this->getModule($module['name']);
}
$this->loadModules= 'ALL';
}
return $this->modules;
} | php | public function getModules(){
if($this->loadModules != 'ALL'){
$this->connection->select('name');
$this->connection->from($this->tableModule);
$modules= $this->connection->get()->fetchAll(\PDO::FETCH_ASSOC);
foreach ($modules as $module) {
$this->getModule($module['name']);
}
$this->loadModules= 'ALL';
}
return $this->modules;
} | [
"public",
"function",
"getModules",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loadModules",
"!=",
"'ALL'",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"select",
"(",
"'name'",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"from",
"(",
"$",
"this",
"->",
"tableModule",
")",
";",
"$",
"modules",
"=",
"$",
"this",
"->",
"connection",
"->",
"get",
"(",
")",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"this",
"->",
"getModule",
"(",
"$",
"module",
"[",
"'name'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"loadModules",
"=",
"'ALL'",
";",
"}",
"return",
"$",
"this",
"->",
"modules",
";",
"}"
] | Retorna todos los modulos de la aplicacion
@return array | [
"Retorna",
"todos",
"los",
"modulos",
"de",
"la",
"aplicacion"
] | 2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364 | https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/Authorization/AuthDbMiddleware.php#L77-L88 |
4,413 | edunola13/core-modules | src/Authorization/AuthDbMiddleware.php | AuthDbMiddleware.getProfiles | public function getProfiles(){
if($this->loadProfiles != 'ALL'){
$this->connection->select('name');
$this->connection->from($this->tableProfile);
$profiles= $this->connection->get()->fetchAll(\PDO::FETCH_ASSOC);
foreach ($profiles as $profile) {
$this->getProfile($profile['name']);
}
$this->loadModules= 'ALL';
}
return $this->profiles;
} | php | public function getProfiles(){
if($this->loadProfiles != 'ALL'){
$this->connection->select('name');
$this->connection->from($this->tableProfile);
$profiles= $this->connection->get()->fetchAll(\PDO::FETCH_ASSOC);
foreach ($profiles as $profile) {
$this->getProfile($profile['name']);
}
$this->loadModules= 'ALL';
}
return $this->profiles;
} | [
"public",
"function",
"getProfiles",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loadProfiles",
"!=",
"'ALL'",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"select",
"(",
"'name'",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"from",
"(",
"$",
"this",
"->",
"tableProfile",
")",
";",
"$",
"profiles",
"=",
"$",
"this",
"->",
"connection",
"->",
"get",
"(",
")",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"foreach",
"(",
"$",
"profiles",
"as",
"$",
"profile",
")",
"{",
"$",
"this",
"->",
"getProfile",
"(",
"$",
"profile",
"[",
"'name'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"loadModules",
"=",
"'ALL'",
";",
"}",
"return",
"$",
"this",
"->",
"profiles",
";",
"}"
] | Retorna todos los profiles de la aplicacion
@return array | [
"Retorna",
"todos",
"los",
"profiles",
"de",
"la",
"aplicacion"
] | 2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364 | https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/Authorization/AuthDbMiddleware.php#L110-L121 |
4,414 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.string | public function string($name, $length = 255, $default = null)
{
$cmnd = $name.' varchar('.$length.')';
//
if (!empty($default)) {
$cmnd .= " DEFAULT '$default' ";
}
//
self::$colmuns[] = $cmnd;
return $this;
} | php | public function string($name, $length = 255, $default = null)
{
$cmnd = $name.' varchar('.$length.')';
//
if (!empty($default)) {
$cmnd .= " DEFAULT '$default' ";
}
//
self::$colmuns[] = $cmnd;
return $this;
} | [
"public",
"function",
"string",
"(",
"$",
"name",
",",
"$",
"length",
"=",
"255",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"cmnd",
"=",
"$",
"name",
".",
"' varchar('",
".",
"$",
"length",
".",
"')'",
";",
"//",
"if",
"(",
"!",
"empty",
"(",
"$",
"default",
")",
")",
"{",
"$",
"cmnd",
".=",
"\" DEFAULT '$default' \"",
";",
"}",
"//",
"self",
"::",
"$",
"colmuns",
"[",
"]",
"=",
"$",
"cmnd",
";",
"return",
"$",
"this",
";",
"}"
] | function to add varchar column.
@param string name
@param int length
@param string $default
@return schema | [
"function",
"to",
"add",
"varchar",
"column",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L40-L51 |
4,415 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.bool | public function bool($name, $default = null)
{
$cmnd = $name.' tinyint(1)';
//
if (!empty($default)) {
$default = $default ? '1' : '0';
$cmnd .= " DEFAULT $default ";
}
//
self::$colmuns[] = $cmnd;
//
return $this;
} | php | public function bool($name, $default = null)
{
$cmnd = $name.' tinyint(1)';
//
if (!empty($default)) {
$default = $default ? '1' : '0';
$cmnd .= " DEFAULT $default ";
}
//
self::$colmuns[] = $cmnd;
//
return $this;
} | [
"public",
"function",
"bool",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"cmnd",
"=",
"$",
"name",
".",
"' tinyint(1)'",
";",
"//",
"if",
"(",
"!",
"empty",
"(",
"$",
"default",
")",
")",
"{",
"$",
"default",
"=",
"$",
"default",
"?",
"'1'",
":",
"'0'",
";",
"$",
"cmnd",
".=",
"\" DEFAULT $default \"",
";",
"}",
"//",
"self",
"::",
"$",
"colmuns",
"[",
"]",
"=",
"$",
"cmnd",
";",
"//",
"return",
"$",
"this",
";",
"}"
] | function to add bool column.
@param string name
@param bool default
@return schema | [
"function",
"to",
"add",
"bool",
"column",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L141-L153 |
4,416 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.timestamp | public function timestamp($name, $default = '')
{
$cmnd = $name.' int(15)';
//
if (!empty($default)) {
$cmnd .= " DEFAULT $default ";
}
//
self::$colmuns[] = $cmnd;
//
return $this;
} | php | public function timestamp($name, $default = '')
{
$cmnd = $name.' int(15)';
//
if (!empty($default)) {
$cmnd .= " DEFAULT $default ";
}
//
self::$colmuns[] = $cmnd;
//
return $this;
} | [
"public",
"function",
"timestamp",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"''",
")",
"{",
"$",
"cmnd",
"=",
"$",
"name",
".",
"' int(15)'",
";",
"//",
"if",
"(",
"!",
"empty",
"(",
"$",
"default",
")",
")",
"{",
"$",
"cmnd",
".=",
"\" DEFAULT $default \"",
";",
"}",
"//",
"self",
"::",
"$",
"colmuns",
"[",
"]",
"=",
"$",
"cmnd",
";",
"//",
"return",
"$",
"this",
";",
"}"
] | function to add timestamp column.
@param string name
@param string default
@return schema | [
"function",
"to",
"add",
"timestamp",
"column",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L205-L216 |
4,417 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.affect | public function affect($value)
{
$i = Collection::count(self::$colmuns) - 1;
self::$colmuns[$i] .= " default '".$value."'";
//
return $this;
} | php | public function affect($value)
{
$i = Collection::count(self::$colmuns) - 1;
self::$colmuns[$i] .= " default '".$value."'";
//
return $this;
} | [
"public",
"function",
"affect",
"(",
"$",
"value",
")",
"{",
"$",
"i",
"=",
"Collection",
"::",
"count",
"(",
"self",
"::",
"$",
"colmuns",
")",
"-",
"1",
";",
"self",
"::",
"$",
"colmuns",
"[",
"$",
"i",
"]",
".=",
"\" default '\"",
".",
"$",
"value",
".",
"\"'\"",
";",
"//",
"return",
"$",
"this",
";",
"}"
] | function to add default constraint.
@param string $value
@return schema | [
"function",
"to",
"add",
"default",
"constraint",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L282-L288 |
4,418 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.notnull | public function notnull()
{
$i = Collection::count(self::$colmuns) - 1;
self::$colmuns[$i] .= ' not null';
//
return $this;
} | php | public function notnull()
{
$i = Collection::count(self::$colmuns) - 1;
self::$colmuns[$i] .= ' not null';
//
return $this;
} | [
"public",
"function",
"notnull",
"(",
")",
"{",
"$",
"i",
"=",
"Collection",
"::",
"count",
"(",
"self",
"::",
"$",
"colmuns",
")",
"-",
"1",
";",
"self",
"::",
"$",
"colmuns",
"[",
"$",
"i",
"]",
".=",
"' not null'",
";",
"//",
"return",
"$",
"this",
";",
"}"
] | function to add not null constraint.
@return schema | [
"function",
"to",
"add",
"not",
"null",
"constraint",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L295-L301 |
4,419 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.foreignkey | public function foreignkey($table, $colmun = null)
{
$i = Collection::count(self::$colmuns) - 1;
//
self::$colmuns[$i] .= ' references '.$table;
if (!empty($colmun)) {
self::$colmuns[$i] .= '('.$colmun.')';
}
//
return $this;
} | php | public function foreignkey($table, $colmun = null)
{
$i = Collection::count(self::$colmuns) - 1;
//
self::$colmuns[$i] .= ' references '.$table;
if (!empty($colmun)) {
self::$colmuns[$i] .= '('.$colmun.')';
}
//
return $this;
} | [
"public",
"function",
"foreignkey",
"(",
"$",
"table",
",",
"$",
"colmun",
"=",
"null",
")",
"{",
"$",
"i",
"=",
"Collection",
"::",
"count",
"(",
"self",
"::",
"$",
"colmuns",
")",
"-",
"1",
";",
"//",
"self",
"::",
"$",
"colmuns",
"[",
"$",
"i",
"]",
".=",
"' references '",
".",
"$",
"table",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"colmun",
")",
")",
"{",
"self",
"::",
"$",
"colmuns",
"[",
"$",
"i",
"]",
".=",
"'('",
".",
"$",
"colmun",
".",
"')'",
";",
"}",
"//",
"return",
"$",
"this",
";",
"}"
] | function to add foreign key constraint.
@param string $table
@param string $colmun
@return schema | [
"function",
"to",
"add",
"foreign",
"key",
"constraint",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L311-L321 |
4,420 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.unique | public function unique($name, array $colmuns)
{
if (is_array($colmuns)) {
$query = "CONSTRAINT $name UNIQUE (";
//
for ($i = 0; $i < Collection::count($colmuns); $i++) {
if ($i == Collection::count($colmuns) - 1) {
$query .= $colmuns[$i];
} else {
$query .= $colmuns[$i].',';
}
}
$query .= ')';
//
self::$colmuns[] = $query;
}
//
return $this;
} | php | public function unique($name, array $colmuns)
{
if (is_array($colmuns)) {
$query = "CONSTRAINT $name UNIQUE (";
//
for ($i = 0; $i < Collection::count($colmuns); $i++) {
if ($i == Collection::count($colmuns) - 1) {
$query .= $colmuns[$i];
} else {
$query .= $colmuns[$i].',';
}
}
$query .= ')';
//
self::$colmuns[] = $query;
}
//
return $this;
} | [
"public",
"function",
"unique",
"(",
"$",
"name",
",",
"array",
"$",
"colmuns",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"colmuns",
")",
")",
"{",
"$",
"query",
"=",
"\"CONSTRAINT $name UNIQUE (\"",
";",
"//",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"Collection",
"::",
"count",
"(",
"$",
"colmuns",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"==",
"Collection",
"::",
"count",
"(",
"$",
"colmuns",
")",
"-",
"1",
")",
"{",
"$",
"query",
".=",
"$",
"colmuns",
"[",
"$",
"i",
"]",
";",
"}",
"else",
"{",
"$",
"query",
".=",
"$",
"colmuns",
"[",
"$",
"i",
"]",
".",
"','",
";",
"}",
"}",
"$",
"query",
".=",
"')'",
";",
"//",
"self",
"::",
"$",
"colmuns",
"[",
"]",
"=",
"$",
"query",
";",
"}",
"//",
"return",
"$",
"this",
";",
"}"
] | function to add unique constraint.
@param string $table
@param array $colmuns
@return schema | [
"function",
"to",
"add",
"unique",
"constraint",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L331-L349 |
4,421 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.drop | public static function drop($name)
{
if (self::existe($name)) {
$name = self::table($name);
//
return Database::exec('DROP TABLE '.$name);
} else {
throw new SchemaTableNotExistException($name);
}
} | php | public static function drop($name)
{
if (self::existe($name)) {
$name = self::table($name);
//
return Database::exec('DROP TABLE '.$name);
} else {
throw new SchemaTableNotExistException($name);
}
} | [
"public",
"static",
"function",
"drop",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"self",
"::",
"existe",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"table",
"(",
"$",
"name",
")",
";",
"//",
"return",
"Database",
"::",
"exec",
"(",
"'DROP TABLE '",
".",
"$",
"name",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"SchemaTableNotExistException",
"(",
"$",
"name",
")",
";",
"}",
"}"
] | function to build query of table erasing.
@param string $name
@return bool | [
"function",
"to",
"build",
"query",
"of",
"table",
"erasing",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L410-L419 |
4,422 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.add | public static function add($name, $script)
{
if (self::existe($name)) {
$name = self::table($name);
//
self::$query = 'alter table '.$name.' ';
//
$object = new self();
$script($object);
//
$query = '';
for ($i = 0; $i < Collection::count(self::$colmuns); $i++) {
$query .= ' add '.self::$colmuns[$i].(($i == (Collection::count(self::$colmuns) - 1)) ? '' : ',');
}
//
self::$query .= $query;
//
return Database::exec(self::$query);
} else {
throw new SchemaTableNotExistException($name);
}
} | php | public static function add($name, $script)
{
if (self::existe($name)) {
$name = self::table($name);
//
self::$query = 'alter table '.$name.' ';
//
$object = new self();
$script($object);
//
$query = '';
for ($i = 0; $i < Collection::count(self::$colmuns); $i++) {
$query .= ' add '.self::$colmuns[$i].(($i == (Collection::count(self::$colmuns) - 1)) ? '' : ',');
}
//
self::$query .= $query;
//
return Database::exec(self::$query);
} else {
throw new SchemaTableNotExistException($name);
}
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"script",
")",
"{",
"if",
"(",
"self",
"::",
"existe",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"table",
"(",
"$",
"name",
")",
";",
"//",
"self",
"::",
"$",
"query",
"=",
"'alter table '",
".",
"$",
"name",
".",
"' '",
";",
"//",
"$",
"object",
"=",
"new",
"self",
"(",
")",
";",
"$",
"script",
"(",
"$",
"object",
")",
";",
"//",
"$",
"query",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"Collection",
"::",
"count",
"(",
"self",
"::",
"$",
"colmuns",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"query",
".=",
"' add '",
".",
"self",
"::",
"$",
"colmuns",
"[",
"$",
"i",
"]",
".",
"(",
"(",
"$",
"i",
"==",
"(",
"Collection",
"::",
"count",
"(",
"self",
"::",
"$",
"colmuns",
")",
"-",
"1",
")",
")",
"?",
"''",
":",
"','",
")",
";",
"}",
"//",
"self",
"::",
"$",
"query",
".=",
"$",
"query",
";",
"//",
"return",
"Database",
"::",
"exec",
"(",
"self",
"::",
"$",
"query",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"SchemaTableNotExistException",
"(",
"$",
"name",
")",
";",
"}",
"}"
] | function to build query for adding column to table.
@param string $name
@param callable $script
@return bool | [
"function",
"to",
"build",
"query",
"for",
"adding",
"column",
"to",
"table",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L477-L498 |
4,423 | vinala/kernel | src/Database/Schemas/MysqlSchema.php | MysqlSchema.remove | public static function remove($name, $colmuns)
{
if (self::existe($name)) {
$name = self::table($name);
//
self::$query = 'alter table '.$name.' ';
//
if (is_array($colmuns)) {
for ($i = 0; $i < Collection::count($colmuns); $i++) {
self::$query .= ' drop '.$colmuns[$i].(($i == (Collection::count($colmuns) - 1)) ? '' : ',');
}
} else {
self::$query .= ' drop '.$colmuns;
}
//
return Database::exec(self::$query);
} else {
throw new SchemaTableNotExistException($name);
}
} | php | public static function remove($name, $colmuns)
{
if (self::existe($name)) {
$name = self::table($name);
//
self::$query = 'alter table '.$name.' ';
//
if (is_array($colmuns)) {
for ($i = 0; $i < Collection::count($colmuns); $i++) {
self::$query .= ' drop '.$colmuns[$i].(($i == (Collection::count($colmuns) - 1)) ? '' : ',');
}
} else {
self::$query .= ' drop '.$colmuns;
}
//
return Database::exec(self::$query);
} else {
throw new SchemaTableNotExistException($name);
}
} | [
"public",
"static",
"function",
"remove",
"(",
"$",
"name",
",",
"$",
"colmuns",
")",
"{",
"if",
"(",
"self",
"::",
"existe",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"table",
"(",
"$",
"name",
")",
";",
"//",
"self",
"::",
"$",
"query",
"=",
"'alter table '",
".",
"$",
"name",
".",
"' '",
";",
"//",
"if",
"(",
"is_array",
"(",
"$",
"colmuns",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"Collection",
"::",
"count",
"(",
"$",
"colmuns",
")",
";",
"$",
"i",
"++",
")",
"{",
"self",
"::",
"$",
"query",
".=",
"' drop '",
".",
"$",
"colmuns",
"[",
"$",
"i",
"]",
".",
"(",
"(",
"$",
"i",
"==",
"(",
"Collection",
"::",
"count",
"(",
"$",
"colmuns",
")",
"-",
"1",
")",
")",
"?",
"''",
":",
"','",
")",
";",
"}",
"}",
"else",
"{",
"self",
"::",
"$",
"query",
".=",
"' drop '",
".",
"$",
"colmuns",
";",
"}",
"//",
"return",
"Database",
"::",
"exec",
"(",
"self",
"::",
"$",
"query",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"SchemaTableNotExistException",
"(",
"$",
"name",
")",
";",
"}",
"}"
] | function to build query for removing column to table.
@param string $name
@param callable $script
@return bool | [
"function",
"to",
"build",
"query",
"for",
"removing",
"column",
"to",
"table",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Schemas/MysqlSchema.php#L508-L527 |
4,424 | InfiniteDevelopers/Base64Bundle | Twig/ImageExtension.php | ImageExtension.image64 | public function image64($path)
{
$file = new File($path, false);
if (!$file->isFile() || 0 !== strpos($file->getMimeType(), 'image/')) {
return;
}
$binary = file_get_contents($path);
return sprintf('data:image/%s;base64,%s', $file->guessExtension(), base64_encode($binary));
} | php | public function image64($path)
{
$file = new File($path, false);
if (!$file->isFile() || 0 !== strpos($file->getMimeType(), 'image/')) {
return;
}
$binary = file_get_contents($path);
return sprintf('data:image/%s;base64,%s', $file->guessExtension(), base64_encode($binary));
} | [
"public",
"function",
"image64",
"(",
"$",
"path",
")",
"{",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"path",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"file",
"->",
"isFile",
"(",
")",
"||",
"0",
"!==",
"strpos",
"(",
"$",
"file",
"->",
"getMimeType",
"(",
")",
",",
"'image/'",
")",
")",
"{",
"return",
";",
"}",
"$",
"binary",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"return",
"sprintf",
"(",
"'data:image/%s;base64,%s'",
",",
"$",
"file",
"->",
"guessExtension",
"(",
")",
",",
"base64_encode",
"(",
"$",
"binary",
")",
")",
";",
"}"
] | Transform image to base 64
@param string $path relative path to image from bundle directory
@return string base64 encoded image | [
"Transform",
"image",
"to",
"base",
"64"
] | 4279aefbd937adbed7ee97818fd893e72b8de216 | https://github.com/InfiniteDevelopers/Base64Bundle/blob/4279aefbd937adbed7ee97818fd893e72b8de216/Twig/ImageExtension.php#L21-L32 |
4,425 | dmeikle/pesedget | src/Gossamer/Pesedget/Commands/DeleteCommand.php | DeleteCommand.execute | public function execute($params = array(), $requestParams = array()){
$deleteParams = $params;
if(count($requestParams) > 0) {
$deleteParams = $requestParams;
}
$this->beginTransaction();
$firstResult = null;
try{
//first delete the child tables
$this->deleteI18nLocales($deleteParams);
$this->deleteOneToOneRows($deleteParams);
//now delete the main tables
$this->getQueryBuilder()->where($deleteParams);
$query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::DELETE_QUERY);
$firstResult = $this->query($query);
$this->commitTransaction();
}catch(Exception $e){
$this->logger->addError($e->getMessage());
$this->rollbackTransaction();
}
return $firstResult;
} | php | public function execute($params = array(), $requestParams = array()){
$deleteParams = $params;
if(count($requestParams) > 0) {
$deleteParams = $requestParams;
}
$this->beginTransaction();
$firstResult = null;
try{
//first delete the child tables
$this->deleteI18nLocales($deleteParams);
$this->deleteOneToOneRows($deleteParams);
//now delete the main tables
$this->getQueryBuilder()->where($deleteParams);
$query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::DELETE_QUERY);
$firstResult = $this->query($query);
$this->commitTransaction();
}catch(Exception $e){
$this->logger->addError($e->getMessage());
$this->rollbackTransaction();
}
return $firstResult;
} | [
"public",
"function",
"execute",
"(",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"requestParams",
"=",
"array",
"(",
")",
")",
"{",
"$",
"deleteParams",
"=",
"$",
"params",
";",
"if",
"(",
"count",
"(",
"$",
"requestParams",
")",
">",
"0",
")",
"{",
"$",
"deleteParams",
"=",
"$",
"requestParams",
";",
"}",
"$",
"this",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"firstResult",
"=",
"null",
";",
"try",
"{",
"//first delete the child tables",
"$",
"this",
"->",
"deleteI18nLocales",
"(",
"$",
"deleteParams",
")",
";",
"$",
"this",
"->",
"deleteOneToOneRows",
"(",
"$",
"deleteParams",
")",
";",
"//now delete the main tables",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"where",
"(",
"$",
"deleteParams",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"getQuery",
"(",
"$",
"this",
"->",
"entity",
",",
"QueryBuilder",
"::",
"DELETE_QUERY",
")",
";",
"$",
"firstResult",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"query",
")",
";",
"$",
"this",
"->",
"commitTransaction",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"rollbackTransaction",
"(",
")",
";",
"}",
"return",
"$",
"firstResult",
";",
"}"
] | Deletes an entity row from the database
@param array URI params
@param array POST params | [
"Deletes",
"an",
"entity",
"row",
"from",
"the",
"database"
] | bcfca25569d1f47c073f08906a710ed895f77b4d | https://github.com/dmeikle/pesedget/blob/bcfca25569d1f47c073f08906a710ed895f77b4d/src/Gossamer/Pesedget/Commands/DeleteCommand.php#L25-L51 |
4,426 | dmeikle/pesedget | src/Gossamer/Pesedget/Commands/DeleteCommand.php | DeleteCommand.deleteI18nLocales | private function deleteI18nLocales($params) {
if(!$this->entity instanceof AbstractI18nEntity) {
return;
}
$filter = array($this->entity->getI18nIdentifier() => $params['id']);
$this->getQueryBuilder()->where($filter);
$this->query($this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::DELETE_QUERY, QueryBuilder::CHILD_ONLY));
} | php | private function deleteI18nLocales($params) {
if(!$this->entity instanceof AbstractI18nEntity) {
return;
}
$filter = array($this->entity->getI18nIdentifier() => $params['id']);
$this->getQueryBuilder()->where($filter);
$this->query($this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::DELETE_QUERY, QueryBuilder::CHILD_ONLY));
} | [
"private",
"function",
"deleteI18nLocales",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"entity",
"instanceof",
"AbstractI18nEntity",
")",
"{",
"return",
";",
"}",
"$",
"filter",
"=",
"array",
"(",
"$",
"this",
"->",
"entity",
"->",
"getI18nIdentifier",
"(",
")",
"=>",
"$",
"params",
"[",
"'id'",
"]",
")",
";",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"where",
"(",
"$",
"filter",
")",
";",
"$",
"this",
"->",
"query",
"(",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"getQuery",
"(",
"$",
"this",
"->",
"entity",
",",
"QueryBuilder",
"::",
"DELETE_QUERY",
",",
"QueryBuilder",
"::",
"CHILD_ONLY",
")",
")",
";",
"}"
] | deletes a row from the I18n table
@param array URI params | [
"deletes",
"a",
"row",
"from",
"the",
"I18n",
"table"
] | bcfca25569d1f47c073f08906a710ed895f77b4d | https://github.com/dmeikle/pesedget/blob/bcfca25569d1f47c073f08906a710ed895f77b4d/src/Gossamer/Pesedget/Commands/DeleteCommand.php#L58-L67 |
4,427 | polary/polary | src/polary/extension/devkit/ide/Controller.php | Controller.actionGenerate | public function actionGenerate()
{
$this->stdout("Polary Devkit Tool (based on Yii)\n\n");
try {
$component = $this->getComponent();
$configList = $this->getConfig($component);
$config = new Config([
'files' => $configList,
]);
$builder = new Builder([
'components' => $config->getComponents(),
'template' => require __DIR__ . '/templates/helper.php',
]);
if ($component->result === null) {
$component->result = ($this->getDetector()->detect() === 'basic') ?
'@app/_ide_components.php' :
'@console/../_ide_components.php';
}
$result = Yii::getAlias($component->result);
$result = FileHelper::normalizePath($result);
$this->stdout("Generate new IDE auto-completion code '{$result}'\n");
$time = microtime(true);
$builder->build($result);
$this->stdout('New auto-completion code created successfully. (time: ' . sprintf('%.3f', microtime
(true) - $time) . "s)\n", Console::FG_GREEN);
} catch (Exception $exception) {
$this->stdout('Generate failed ' . $exception->getMessage() . "\n", Console::FG_RED);
}
} | php | public function actionGenerate()
{
$this->stdout("Polary Devkit Tool (based on Yii)\n\n");
try {
$component = $this->getComponent();
$configList = $this->getConfig($component);
$config = new Config([
'files' => $configList,
]);
$builder = new Builder([
'components' => $config->getComponents(),
'template' => require __DIR__ . '/templates/helper.php',
]);
if ($component->result === null) {
$component->result = ($this->getDetector()->detect() === 'basic') ?
'@app/_ide_components.php' :
'@console/../_ide_components.php';
}
$result = Yii::getAlias($component->result);
$result = FileHelper::normalizePath($result);
$this->stdout("Generate new IDE auto-completion code '{$result}'\n");
$time = microtime(true);
$builder->build($result);
$this->stdout('New auto-completion code created successfully. (time: ' . sprintf('%.3f', microtime
(true) - $time) . "s)\n", Console::FG_GREEN);
} catch (Exception $exception) {
$this->stdout('Generate failed ' . $exception->getMessage() . "\n", Console::FG_RED);
}
} | [
"public",
"function",
"actionGenerate",
"(",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"\"Polary Devkit Tool (based on Yii)\\n\\n\"",
")",
";",
"try",
"{",
"$",
"component",
"=",
"$",
"this",
"->",
"getComponent",
"(",
")",
";",
"$",
"configList",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"$",
"component",
")",
";",
"$",
"config",
"=",
"new",
"Config",
"(",
"[",
"'files'",
"=>",
"$",
"configList",
",",
"]",
")",
";",
"$",
"builder",
"=",
"new",
"Builder",
"(",
"[",
"'components'",
"=>",
"$",
"config",
"->",
"getComponents",
"(",
")",
",",
"'template'",
"=>",
"require",
"__DIR__",
".",
"'/templates/helper.php'",
",",
"]",
")",
";",
"if",
"(",
"$",
"component",
"->",
"result",
"===",
"null",
")",
"{",
"$",
"component",
"->",
"result",
"=",
"(",
"$",
"this",
"->",
"getDetector",
"(",
")",
"->",
"detect",
"(",
")",
"===",
"'basic'",
")",
"?",
"'@app/_ide_components.php'",
":",
"'@console/../_ide_components.php'",
";",
"}",
"$",
"result",
"=",
"Yii",
"::",
"getAlias",
"(",
"$",
"component",
"->",
"result",
")",
";",
"$",
"result",
"=",
"FileHelper",
"::",
"normalizePath",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"stdout",
"(",
"\"Generate new IDE auto-completion code '{$result}'\\n\"",
")",
";",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"builder",
"->",
"build",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"stdout",
"(",
"'New auto-completion code created successfully. (time: '",
".",
"sprintf",
"(",
"'%.3f'",
",",
"microtime",
"(",
"true",
")",
"-",
"$",
"time",
")",
".",
"\"s)\\n\"",
",",
"Console",
"::",
"FG_GREEN",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"'Generate failed '",
".",
"$",
"exception",
"->",
"getMessage",
"(",
")",
".",
"\"\\n\"",
",",
"Console",
"::",
"FG_RED",
")",
";",
"}",
"}"
] | Generate IDE auto-completion code. | [
"Generate",
"IDE",
"auto",
"-",
"completion",
"code",
"."
] | 683212e631e59faedce488f0d2cea82c94a83aae | https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/extension/devkit/ide/Controller.php#L64-L94 |
4,428 | docit/core | src/Menus/MenuFactory.php | MenuFactory.add | public function add($id)
{
if ($this->has($id)) {
return $this->get($id);
}
$menu = $this->container->make(Menu::class, [
'menuFactory' => $this
]);
$this->runHook('menu-factory:add', [$this, $menu]);
$this->menus->put($id, $menu);
return $menu;
} | php | public function add($id)
{
if ($this->has($id)) {
return $this->get($id);
}
$menu = $this->container->make(Menu::class, [
'menuFactory' => $this
]);
$this->runHook('menu-factory:add', [$this, $menu]);
$this->menus->put($id, $menu);
return $menu;
} | [
"public",
"function",
"add",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"}",
"$",
"menu",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"Menu",
"::",
"class",
",",
"[",
"'menuFactory'",
"=>",
"$",
"this",
"]",
")",
";",
"$",
"this",
"->",
"runHook",
"(",
"'menu-factory:add'",
",",
"[",
"$",
"this",
",",
"$",
"menu",
"]",
")",
";",
"$",
"this",
"->",
"menus",
"->",
"put",
"(",
"$",
"id",
",",
"$",
"menu",
")",
";",
"return",
"$",
"menu",
";",
"}"
] | Creates a new menu or returns an existing
@param string $id
@return \Docit\Core\Menus\Menu | [
"Creates",
"a",
"new",
"menu",
"or",
"returns",
"an",
"existing"
] | 448e1cdca18a8ffb6c08430cad8d22162171ac35 | https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Menus/MenuFactory.php#L94-L106 |
4,429 | docit/core | src/Menus/MenuFactory.php | MenuFactory.forget | public function forget($id)
{
$this->runHook('menu-factory:forget', [$this, $id]);
$this->menus->forget($id);
return $this;
} | php | public function forget($id)
{
$this->runHook('menu-factory:forget', [$this, $id]);
$this->menus->forget($id);
return $this;
} | [
"public",
"function",
"forget",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"runHook",
"(",
"'menu-factory:forget'",
",",
"[",
"$",
"this",
",",
"$",
"id",
"]",
")",
";",
"$",
"this",
"->",
"menus",
"->",
"forget",
"(",
"$",
"id",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes a menu
@param $id
@return MenuFactory | [
"Removes",
"a",
"menu"
] | 448e1cdca18a8ffb6c08430cad8d22162171ac35 | https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Menus/MenuFactory.php#L138-L143 |
4,430 | SlabPHP/concatenator | src/Manager.php | Manager.setCache | public function setCache(\Psr\SimpleCache\CacheInterface $cache, $key, $ttl = 86400)
{
$this->cache = $cache;
$this->cacheKey = $key;
$this->cacheTime = $ttl;
if (empty($this->cacheKey))
{
$this->cacheKey = 'concatenate-'.md5(serialize($this));
}
return $this;
} | php | public function setCache(\Psr\SimpleCache\CacheInterface $cache, $key, $ttl = 86400)
{
$this->cache = $cache;
$this->cacheKey = $key;
$this->cacheTime = $ttl;
if (empty($this->cacheKey))
{
$this->cacheKey = 'concatenate-'.md5(serialize($this));
}
return $this;
} | [
"public",
"function",
"setCache",
"(",
"\\",
"Psr",
"\\",
"SimpleCache",
"\\",
"CacheInterface",
"$",
"cache",
",",
"$",
"key",
",",
"$",
"ttl",
"=",
"86400",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"$",
"cache",
";",
"$",
"this",
"->",
"cacheKey",
"=",
"$",
"key",
";",
"$",
"this",
"->",
"cacheTime",
"=",
"$",
"ttl",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"cacheKey",
")",
")",
"{",
"$",
"this",
"->",
"cacheKey",
"=",
"'concatenate-'",
".",
"md5",
"(",
"serialize",
"(",
"$",
"this",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set cache manager
@param \Psr\SimpleCache\CacheInterface $cache
@param $key
@param $ttl
@return $this | [
"Set",
"cache",
"manager"
] | 7ea1f29822a766ecb423845c549a9f9eec6594dd | https://github.com/SlabPHP/concatenator/blob/7ea1f29822a766ecb423845c549a9f9eec6594dd/src/Manager.php#L72-L84 |
4,431 | SlabPHP/concatenator | src/Manager.php | Manager.addObject | public function addObject($objectValue, $filters)
{
if (empty($objectValue)) {
throw new \Exception("Failed to add empty object value!");
}
$object = null;
if (strpos($objectValue, 'http') !== false) {
/**
* @var \Slab\Concatenator\Items\Base $object
*/
$object = new Items\URL();
} else {
/**
* @var \Slab\Concatenator\Items\Base $object
*/
$object = new Items\File($this->fileSearchDirectories);
}
$object->initialize($objectValue, $filters);
$this->objectList[] = $object;
return $this;
} | php | public function addObject($objectValue, $filters)
{
if (empty($objectValue)) {
throw new \Exception("Failed to add empty object value!");
}
$object = null;
if (strpos($objectValue, 'http') !== false) {
/**
* @var \Slab\Concatenator\Items\Base $object
*/
$object = new Items\URL();
} else {
/**
* @var \Slab\Concatenator\Items\Base $object
*/
$object = new Items\File($this->fileSearchDirectories);
}
$object->initialize($objectValue, $filters);
$this->objectList[] = $object;
return $this;
} | [
"public",
"function",
"addObject",
"(",
"$",
"objectValue",
",",
"$",
"filters",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"objectValue",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Failed to add empty object value!\"",
")",
";",
"}",
"$",
"object",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"objectValue",
",",
"'http'",
")",
"!==",
"false",
")",
"{",
"/**\n * @var \\Slab\\Concatenator\\Items\\Base $object\n */",
"$",
"object",
"=",
"new",
"Items",
"\\",
"URL",
"(",
")",
";",
"}",
"else",
"{",
"/**\n * @var \\Slab\\Concatenator\\Items\\Base $object\n */",
"$",
"object",
"=",
"new",
"Items",
"\\",
"File",
"(",
"$",
"this",
"->",
"fileSearchDirectories",
")",
";",
"}",
"$",
"object",
"->",
"initialize",
"(",
"$",
"objectValue",
",",
"$",
"filters",
")",
";",
"$",
"this",
"->",
"objectList",
"[",
"]",
"=",
"$",
"object",
";",
"return",
"$",
"this",
";",
"}"
] | Add an object to the list
@param $objectValue
@param $filters
@return $this | [
"Add",
"an",
"object",
"to",
"the",
"list"
] | 7ea1f29822a766ecb423845c549a9f9eec6594dd | https://github.com/SlabPHP/concatenator/blob/7ea1f29822a766ecb423845c549a9f9eec6594dd/src/Manager.php#L138-L162 |
4,432 | SlabPHP/concatenator | src/Manager.php | Manager.concatenateObjectList | public function concatenateObjectList()
{
//Short circuit if cache is disabled
if (empty($this->cache) || empty($this->cacheKey) || empty($this->cacheTime)) {
$this->source = 'raw';
$this->output = $this->concatenateObjects();
return;
}
//See if you can grab it from cache, unless cache refresh param is set
if (!$this->cacheRefresh &&
($this->output = $this->cache->get($this->cacheKey)) !== null
) {
$this->getActualLastModifiedTime();
$lastCacheModifiedTime = $this->extractLastModifiedTime($this->output);
if ($lastCacheModifiedTime == $this->lastModifiedTime) {
//The cached timestamp is the same as what's in the cached copy so we can return it,
//otherwise we can skip this and re-fetch since the source files are newer
$this->source = 'cache';
return;
}
}
//Short circuit failed, get from cache failed, grab it and cache it
$this->output = $this->concatenateObjects();
$this->cache->set($this->cacheKey, $this->output, $this->cacheTime);
$this->source = 'fetched';
} | php | public function concatenateObjectList()
{
//Short circuit if cache is disabled
if (empty($this->cache) || empty($this->cacheKey) || empty($this->cacheTime)) {
$this->source = 'raw';
$this->output = $this->concatenateObjects();
return;
}
//See if you can grab it from cache, unless cache refresh param is set
if (!$this->cacheRefresh &&
($this->output = $this->cache->get($this->cacheKey)) !== null
) {
$this->getActualLastModifiedTime();
$lastCacheModifiedTime = $this->extractLastModifiedTime($this->output);
if ($lastCacheModifiedTime == $this->lastModifiedTime) {
//The cached timestamp is the same as what's in the cached copy so we can return it,
//otherwise we can skip this and re-fetch since the source files are newer
$this->source = 'cache';
return;
}
}
//Short circuit failed, get from cache failed, grab it and cache it
$this->output = $this->concatenateObjects();
$this->cache->set($this->cacheKey, $this->output, $this->cacheTime);
$this->source = 'fetched';
} | [
"public",
"function",
"concatenateObjectList",
"(",
")",
"{",
"//Short circuit if cache is disabled",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"cache",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"cacheKey",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"cacheTime",
")",
")",
"{",
"$",
"this",
"->",
"source",
"=",
"'raw'",
";",
"$",
"this",
"->",
"output",
"=",
"$",
"this",
"->",
"concatenateObjects",
"(",
")",
";",
"return",
";",
"}",
"//See if you can grab it from cache, unless cache refresh param is set",
"if",
"(",
"!",
"$",
"this",
"->",
"cacheRefresh",
"&&",
"(",
"$",
"this",
"->",
"output",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"this",
"->",
"cacheKey",
")",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"getActualLastModifiedTime",
"(",
")",
";",
"$",
"lastCacheModifiedTime",
"=",
"$",
"this",
"->",
"extractLastModifiedTime",
"(",
"$",
"this",
"->",
"output",
")",
";",
"if",
"(",
"$",
"lastCacheModifiedTime",
"==",
"$",
"this",
"->",
"lastModifiedTime",
")",
"{",
"//The cached timestamp is the same as what's in the cached copy so we can return it,",
"//otherwise we can skip this and re-fetch since the source files are newer",
"$",
"this",
"->",
"source",
"=",
"'cache'",
";",
"return",
";",
"}",
"}",
"//Short circuit failed, get from cache failed, grab it and cache it",
"$",
"this",
"->",
"output",
"=",
"$",
"this",
"->",
"concatenateObjects",
"(",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"$",
"this",
"->",
"cacheKey",
",",
"$",
"this",
"->",
"output",
",",
"$",
"this",
"->",
"cacheTime",
")",
";",
"$",
"this",
"->",
"source",
"=",
"'fetched'",
";",
"}"
] | Concatenate the object list
@param $objects | [
"Concatenate",
"the",
"object",
"list"
] | 7ea1f29822a766ecb423845c549a9f9eec6594dd | https://github.com/SlabPHP/concatenator/blob/7ea1f29822a766ecb423845c549a9f9eec6594dd/src/Manager.php#L179-L211 |
4,433 | SlabPHP/concatenator | src/Manager.php | Manager.getActualLastModifiedTime | private function getActualLastModifiedTime()
{
if (empty($this->objectList)) return;
foreach ($this->objectList as $object) {
$modifiedTime = $object->getLastModifiedTimestamp();
if (!empty($modifiedTime) && $modifiedTime > $this->lastModifiedTime) {
$this->lastModifiedTime = $modifiedTime;
}
}
} | php | private function getActualLastModifiedTime()
{
if (empty($this->objectList)) return;
foreach ($this->objectList as $object) {
$modifiedTime = $object->getLastModifiedTimestamp();
if (!empty($modifiedTime) && $modifiedTime > $this->lastModifiedTime) {
$this->lastModifiedTime = $modifiedTime;
}
}
} | [
"private",
"function",
"getActualLastModifiedTime",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"objectList",
")",
")",
"return",
";",
"foreach",
"(",
"$",
"this",
"->",
"objectList",
"as",
"$",
"object",
")",
"{",
"$",
"modifiedTime",
"=",
"$",
"object",
"->",
"getLastModifiedTimestamp",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"modifiedTime",
")",
"&&",
"$",
"modifiedTime",
">",
"$",
"this",
"->",
"lastModifiedTime",
")",
"{",
"$",
"this",
"->",
"lastModifiedTime",
"=",
"$",
"modifiedTime",
";",
"}",
"}",
"}"
] | Gets actual last modified time of files to see if we need to bust cache | [
"Gets",
"actual",
"last",
"modified",
"time",
"of",
"files",
"to",
"see",
"if",
"we",
"need",
"to",
"bust",
"cache"
] | 7ea1f29822a766ecb423845c549a9f9eec6594dd | https://github.com/SlabPHP/concatenator/blob/7ea1f29822a766ecb423845c549a9f9eec6594dd/src/Manager.php#L216-L227 |
4,434 | SlabPHP/concatenator | src/Manager.php | Manager.concatenateObjects | private function concatenateObjects()
{
$output = "";
if (empty($this->objectList)) return $output;
foreach ($this->objectList as $object) {
if ($object->isValid()) {
$output .= $object->getData();
$modifiedTime = $object->getLastModifiedTimestamp();
if (!empty($modifiedTime) && $modifiedTime > $this->lastModifiedTime) {
$this->lastModifiedTime = $modifiedTime;
}
} else {
$output .= $this->handleInvalidFile($object->getValue());
}
}
if (!empty($this->lastModifiedTime)) {
$output = $this->formatLastModifiedTime() . $output;
}
return $output;
} | php | private function concatenateObjects()
{
$output = "";
if (empty($this->objectList)) return $output;
foreach ($this->objectList as $object) {
if ($object->isValid()) {
$output .= $object->getData();
$modifiedTime = $object->getLastModifiedTimestamp();
if (!empty($modifiedTime) && $modifiedTime > $this->lastModifiedTime) {
$this->lastModifiedTime = $modifiedTime;
}
} else {
$output .= $this->handleInvalidFile($object->getValue());
}
}
if (!empty($this->lastModifiedTime)) {
$output = $this->formatLastModifiedTime() . $output;
}
return $output;
} | [
"private",
"function",
"concatenateObjects",
"(",
")",
"{",
"$",
"output",
"=",
"\"\"",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"objectList",
")",
")",
"return",
"$",
"output",
";",
"foreach",
"(",
"$",
"this",
"->",
"objectList",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"output",
".=",
"$",
"object",
"->",
"getData",
"(",
")",
";",
"$",
"modifiedTime",
"=",
"$",
"object",
"->",
"getLastModifiedTimestamp",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"modifiedTime",
")",
"&&",
"$",
"modifiedTime",
">",
"$",
"this",
"->",
"lastModifiedTime",
")",
"{",
"$",
"this",
"->",
"lastModifiedTime",
"=",
"$",
"modifiedTime",
";",
"}",
"}",
"else",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"handleInvalidFile",
"(",
"$",
"object",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"lastModifiedTime",
")",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"formatLastModifiedTime",
"(",
")",
".",
"$",
"output",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Concatenate the actual files and set output | [
"Concatenate",
"the",
"actual",
"files",
"and",
"set",
"output"
] | 7ea1f29822a766ecb423845c549a9f9eec6594dd | https://github.com/SlabPHP/concatenator/blob/7ea1f29822a766ecb423845c549a9f9eec6594dd/src/Manager.php#L232-L257 |
4,435 | SlabPHP/concatenator | src/Manager.php | Manager.extractLastModifiedTime | private function extractLastModifiedTime($cacheData)
{
$matches = array();
preg_match('#modified:([a-z0-9:-]*)#i', $cacheData, $matches);
if (!empty($matches[1])) {
return strtotime($matches[1]);
}
return 0;
} | php | private function extractLastModifiedTime($cacheData)
{
$matches = array();
preg_match('#modified:([a-z0-9:-]*)#i', $cacheData, $matches);
if (!empty($matches[1])) {
return strtotime($matches[1]);
}
return 0;
} | [
"private",
"function",
"extractLastModifiedTime",
"(",
"$",
"cacheData",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match",
"(",
"'#modified:([a-z0-9:-]*)#i'",
",",
"$",
"cacheData",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"strtotime",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"return",
"0",
";",
"}"
] | Retrieve the last modified date from cached data
@param $cacheData
@return int | [
"Retrieve",
"the",
"last",
"modified",
"date",
"from",
"cached",
"data"
] | 7ea1f29822a766ecb423845c549a9f9eec6594dd | https://github.com/SlabPHP/concatenator/blob/7ea1f29822a766ecb423845c549a9f9eec6594dd/src/Manager.php#L275-L285 |
4,436 | liftkit/core | src/Application/Hook/Action.php | Action.trigger | public function trigger ($value, $precedence = null)
{
if (is_null($precedence)) {
$functions = array();
ksort($this->hooks);
foreach ($this->hooks as $function_set) {
foreach ($function_set as $function) {
$functions[] = $function;
}
}
foreach ($functions as $function) {
$value = call_user_func_array($function, array($value));
}
return $value;
} else {
if (isset($this->hooks[$precedence])) {
foreach ($this->hooks[$precedence] as $function) {
$value = call_user_func_array($function, array($value));
}
}
return $value;
}
} | php | public function trigger ($value, $precedence = null)
{
if (is_null($precedence)) {
$functions = array();
ksort($this->hooks);
foreach ($this->hooks as $function_set) {
foreach ($function_set as $function) {
$functions[] = $function;
}
}
foreach ($functions as $function) {
$value = call_user_func_array($function, array($value));
}
return $value;
} else {
if (isset($this->hooks[$precedence])) {
foreach ($this->hooks[$precedence] as $function) {
$value = call_user_func_array($function, array($value));
}
}
return $value;
}
} | [
"public",
"function",
"trigger",
"(",
"$",
"value",
",",
"$",
"precedence",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"precedence",
")",
")",
"{",
"$",
"functions",
"=",
"array",
"(",
")",
";",
"ksort",
"(",
"$",
"this",
"->",
"hooks",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"hooks",
"as",
"$",
"function_set",
")",
"{",
"foreach",
"(",
"$",
"function_set",
"as",
"$",
"function",
")",
"{",
"$",
"functions",
"[",
"]",
"=",
"$",
"function",
";",
"}",
"}",
"foreach",
"(",
"$",
"functions",
"as",
"$",
"function",
")",
"{",
"$",
"value",
"=",
"call_user_func_array",
"(",
"$",
"function",
",",
"array",
"(",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"value",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"hooks",
"[",
"$",
"precedence",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"hooks",
"[",
"$",
"precedence",
"]",
"as",
"$",
"function",
")",
"{",
"$",
"value",
"=",
"call_user_func_array",
"(",
"$",
"function",
",",
"array",
"(",
"$",
"value",
")",
")",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}",
"}"
] | Invokes all hooks of a given precedence for a given event.
If null precedence is provided, invokes all hooks for a given event, regardless of precedence.
@api
@param mixed $value The value to be transformed.
@param mixed $precedence (default: null) If provided, only callbacks of this precedence will be executed.
@return mixed | [
"Invokes",
"all",
"hooks",
"of",
"a",
"given",
"precedence",
"for",
"a",
"given",
"event",
"."
] | c98dcffa65450bd11332dbffe2064650c3a72aae | https://github.com/liftkit/core/blob/c98dcffa65450bd11332dbffe2064650c3a72aae/src/Application/Hook/Action.php#L37-L65 |
4,437 | kingcoyote/domi | src/Domi/Domi.php | Domi.attachToXml | public function attachToXml($data, $prefix, &$parentNode = false)
{
if (!$parentNode) {
$parentNode = &$this->mainNode;
}
// i don't like how this is done, but i can't see an easy alternative
// that is clean. if the prefix is attributes, instead of creating
// a node, just put all of the data onto the parent node as attributes
if (strtolower($prefix) == 'attributes') {
// set all of the attributes onto the node
foreach ($data as $key=>$val) {
$parentNode->setAttribute($key, $val);
}
$node = &$parentNode;
} else {
$node = $this->convertToXml($data, $prefix);
$parentNode->appendChild($node);
}
return $node;
} | php | public function attachToXml($data, $prefix, &$parentNode = false)
{
if (!$parentNode) {
$parentNode = &$this->mainNode;
}
// i don't like how this is done, but i can't see an easy alternative
// that is clean. if the prefix is attributes, instead of creating
// a node, just put all of the data onto the parent node as attributes
if (strtolower($prefix) == 'attributes') {
// set all of the attributes onto the node
foreach ($data as $key=>$val) {
$parentNode->setAttribute($key, $val);
}
$node = &$parentNode;
} else {
$node = $this->convertToXml($data, $prefix);
$parentNode->appendChild($node);
}
return $node;
} | [
"public",
"function",
"attachToXml",
"(",
"$",
"data",
",",
"$",
"prefix",
",",
"&",
"$",
"parentNode",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"parentNode",
")",
"{",
"$",
"parentNode",
"=",
"&",
"$",
"this",
"->",
"mainNode",
";",
"}",
"// i don't like how this is done, but i can't see an easy alternative",
"// that is clean. if the prefix is attributes, instead of creating",
"// a node, just put all of the data onto the parent node as attributes",
"if",
"(",
"strtolower",
"(",
"$",
"prefix",
")",
"==",
"'attributes'",
")",
"{",
"// set all of the attributes onto the node",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"parentNode",
"->",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"val",
")",
";",
"}",
"$",
"node",
"=",
"&",
"$",
"parentNode",
";",
"}",
"else",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"convertToXml",
"(",
"$",
"data",
",",
"$",
"prefix",
")",
";",
"$",
"parentNode",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"return",
"$",
"node",
";",
"}"
] | the heart of DOMi - take a complex data tree and build it into an
XML tree with the specified prefix and attach it to either the
specified node or the root node
@param mixed any PHP data type that is being converted to XML
@param string the name of the node that the data will be built onto
@param DOMNode node to attach the newly created onto
@retval DOMNode the newly created node | [
"the",
"heart",
"of",
"DOMi",
"-",
"take",
"a",
"complex",
"data",
"tree",
"and",
"build",
"it",
"into",
"an",
"XML",
"tree",
"with",
"the",
"specified",
"prefix",
"and",
"attach",
"it",
"to",
"either",
"the",
"specified",
"node",
"or",
"the",
"root",
"node"
] | 79f7f95c81536f704650aaf8584cf7eb4bfff410 | https://github.com/kingcoyote/domi/blob/79f7f95c81536f704650aaf8584cf7eb4bfff410/src/Domi/Domi.php#L77-L97 |
4,438 | kingcoyote/domi | src/Domi/Domi.php | Domi.convertToXml | public function convertToXml($data, $prefix)
{
$nodeName = $prefix;
// figure out the prefix
if (!self::isValidPrefix($prefix)) {
throw new DomiException("invalid prefix '$prefix'");
}
// if the data needs a list node, change the name to use the list-suffix
if (self::isListNode($data)) {
$nodeName = $prefix . $this->listSuffix;
}
switch (self::getDataType($data)) {
// if this array has attributes, do some additional work
case self::DT_ATTR_ARRAY:
// create the node, with the optionally specified value
$node = $this->createElement(
$nodeName,
isset($data['values']) ? $data['values'] : null
);
$data['attributes'] =
isset($data['attributes']) ?
$data['attributes'] :
array();
// set all of the attributes onto the node
foreach ($data['attributes'] as $key=>$val) {
$node->setAttribute($key, $val);
}
// remove the attributes and value so they aren't repeated
// as children of the element
unset($data['attributes']);
unset($data['values']);
case self::DT_ARRAY:
// in the case of DT_ATTR_ARRAY, the node is already created
if (!isset($node)) {
$node = $this->createElement($nodeName);
}
// attach each child as a subnode
foreach ($data as $k=>$d) {
// figure out the child prefix
$childPrefix = self::isValidPrefix($k) ? $k : $prefix;
// recurse and attach
$node->appendChild($this->convertToXml($d, $childPrefix));
}
break;
// when converting DOMi or DOMDocuments, just get the root node
case self::DT_DOMI:
// no break
case self::DT_DOMDOCUMENT:
$data = $data->childNodes->item(0);
// no break
case self::DT_DOMNODE:
// the node must be imported to be usable in this DOMDocument
$domNode = $this->importNode($data, true);
// only create a new node if the prefix and current root
// node name aren't the same
if ($prefix == $domNode->nodeName) {
$node = $domNode;
} else {
$node = $this->createElement($prefix);
$node->appendChild($domNode);
}
break;
case self::DT_OBJECT:
$node = $this->convertToXml(
$this->convertObjectToArray($data),
$prefix
);
break;
case self::DT_BOOL:
$data = $data ? 'TRUE' : 'FALSE';
// no break
default:
$node = $this->createElement(
$nodeName,
htmlspecialchars((string)$data)
);
break;
}
return $node;
} | php | public function convertToXml($data, $prefix)
{
$nodeName = $prefix;
// figure out the prefix
if (!self::isValidPrefix($prefix)) {
throw new DomiException("invalid prefix '$prefix'");
}
// if the data needs a list node, change the name to use the list-suffix
if (self::isListNode($data)) {
$nodeName = $prefix . $this->listSuffix;
}
switch (self::getDataType($data)) {
// if this array has attributes, do some additional work
case self::DT_ATTR_ARRAY:
// create the node, with the optionally specified value
$node = $this->createElement(
$nodeName,
isset($data['values']) ? $data['values'] : null
);
$data['attributes'] =
isset($data['attributes']) ?
$data['attributes'] :
array();
// set all of the attributes onto the node
foreach ($data['attributes'] as $key=>$val) {
$node->setAttribute($key, $val);
}
// remove the attributes and value so they aren't repeated
// as children of the element
unset($data['attributes']);
unset($data['values']);
case self::DT_ARRAY:
// in the case of DT_ATTR_ARRAY, the node is already created
if (!isset($node)) {
$node = $this->createElement($nodeName);
}
// attach each child as a subnode
foreach ($data as $k=>$d) {
// figure out the child prefix
$childPrefix = self::isValidPrefix($k) ? $k : $prefix;
// recurse and attach
$node->appendChild($this->convertToXml($d, $childPrefix));
}
break;
// when converting DOMi or DOMDocuments, just get the root node
case self::DT_DOMI:
// no break
case self::DT_DOMDOCUMENT:
$data = $data->childNodes->item(0);
// no break
case self::DT_DOMNODE:
// the node must be imported to be usable in this DOMDocument
$domNode = $this->importNode($data, true);
// only create a new node if the prefix and current root
// node name aren't the same
if ($prefix == $domNode->nodeName) {
$node = $domNode;
} else {
$node = $this->createElement($prefix);
$node->appendChild($domNode);
}
break;
case self::DT_OBJECT:
$node = $this->convertToXml(
$this->convertObjectToArray($data),
$prefix
);
break;
case self::DT_BOOL:
$data = $data ? 'TRUE' : 'FALSE';
// no break
default:
$node = $this->createElement(
$nodeName,
htmlspecialchars((string)$data)
);
break;
}
return $node;
} | [
"public",
"function",
"convertToXml",
"(",
"$",
"data",
",",
"$",
"prefix",
")",
"{",
"$",
"nodeName",
"=",
"$",
"prefix",
";",
"// figure out the prefix",
"if",
"(",
"!",
"self",
"::",
"isValidPrefix",
"(",
"$",
"prefix",
")",
")",
"{",
"throw",
"new",
"DomiException",
"(",
"\"invalid prefix '$prefix'\"",
")",
";",
"}",
"// if the data needs a list node, change the name to use the list-suffix",
"if",
"(",
"self",
"::",
"isListNode",
"(",
"$",
"data",
")",
")",
"{",
"$",
"nodeName",
"=",
"$",
"prefix",
".",
"$",
"this",
"->",
"listSuffix",
";",
"}",
"switch",
"(",
"self",
"::",
"getDataType",
"(",
"$",
"data",
")",
")",
"{",
"// if this array has attributes, do some additional work",
"case",
"self",
"::",
"DT_ATTR_ARRAY",
":",
"// create the node, with the optionally specified value",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"nodeName",
",",
"isset",
"(",
"$",
"data",
"[",
"'values'",
"]",
")",
"?",
"$",
"data",
"[",
"'values'",
"]",
":",
"null",
")",
";",
"$",
"data",
"[",
"'attributes'",
"]",
"=",
"isset",
"(",
"$",
"data",
"[",
"'attributes'",
"]",
")",
"?",
"$",
"data",
"[",
"'attributes'",
"]",
":",
"array",
"(",
")",
";",
"// set all of the attributes onto the node",
"foreach",
"(",
"$",
"data",
"[",
"'attributes'",
"]",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"node",
"->",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"val",
")",
";",
"}",
"// remove the attributes and value so they aren't repeated",
"// as children of the element",
"unset",
"(",
"$",
"data",
"[",
"'attributes'",
"]",
")",
";",
"unset",
"(",
"$",
"data",
"[",
"'values'",
"]",
")",
";",
"case",
"self",
"::",
"DT_ARRAY",
":",
"// in the case of DT_ATTR_ARRAY, the node is already created",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
")",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"nodeName",
")",
";",
"}",
"// attach each child as a subnode",
"foreach",
"(",
"$",
"data",
"as",
"$",
"k",
"=>",
"$",
"d",
")",
"{",
"// figure out the child prefix",
"$",
"childPrefix",
"=",
"self",
"::",
"isValidPrefix",
"(",
"$",
"k",
")",
"?",
"$",
"k",
":",
"$",
"prefix",
";",
"// recurse and attach",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"convertToXml",
"(",
"$",
"d",
",",
"$",
"childPrefix",
")",
")",
";",
"}",
"break",
";",
"// when converting DOMi or DOMDocuments, just get the root node",
"case",
"self",
"::",
"DT_DOMI",
":",
"// no break",
"case",
"self",
"::",
"DT_DOMDOCUMENT",
":",
"$",
"data",
"=",
"$",
"data",
"->",
"childNodes",
"->",
"item",
"(",
"0",
")",
";",
"// no break",
"case",
"self",
"::",
"DT_DOMNODE",
":",
"// the node must be imported to be usable in this DOMDocument",
"$",
"domNode",
"=",
"$",
"this",
"->",
"importNode",
"(",
"$",
"data",
",",
"true",
")",
";",
"// only create a new node if the prefix and current root",
"// node name aren't the same",
"if",
"(",
"$",
"prefix",
"==",
"$",
"domNode",
"->",
"nodeName",
")",
"{",
"$",
"node",
"=",
"$",
"domNode",
";",
"}",
"else",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"prefix",
")",
";",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"domNode",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"DT_OBJECT",
":",
"$",
"node",
"=",
"$",
"this",
"->",
"convertToXml",
"(",
"$",
"this",
"->",
"convertObjectToArray",
"(",
"$",
"data",
")",
",",
"$",
"prefix",
")",
";",
"break",
";",
"case",
"self",
"::",
"DT_BOOL",
":",
"$",
"data",
"=",
"$",
"data",
"?",
"'TRUE'",
":",
"'FALSE'",
";",
"// no break",
"default",
":",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"nodeName",
",",
"htmlspecialchars",
"(",
"(",
"string",
")",
"$",
"data",
")",
")",
";",
"break",
";",
"}",
"return",
"$",
"node",
";",
"}"
] | convert a data tree to an XML tree with the name specified as the
prefix
@param mixed any PHP data type that is being converted to XML
@param string the name of the node that the data will be built onto
@retval DOMNode the newly created node | [
"convert",
"a",
"data",
"tree",
"to",
"an",
"XML",
"tree",
"with",
"the",
"name",
"specified",
"as",
"the",
"prefix"
] | 79f7f95c81536f704650aaf8584cf7eb4bfff410 | https://github.com/kingcoyote/domi/blob/79f7f95c81536f704650aaf8584cf7eb4bfff410/src/Domi/Domi.php#L107-L195 |
4,439 | kingcoyote/domi | src/Domi/Domi.php | Domi.render | public function render($stylesheets=false, $mode=self::RENDER_HTML)
{
$this->xslt->importStylesheet($this->generateXsl($stylesheets));
return $this->generateOutput($mode);
} | php | public function render($stylesheets=false, $mode=self::RENDER_HTML)
{
$this->xslt->importStylesheet($this->generateXsl($stylesheets));
return $this->generateOutput($mode);
} | [
"public",
"function",
"render",
"(",
"$",
"stylesheets",
"=",
"false",
",",
"$",
"mode",
"=",
"self",
"::",
"RENDER_HTML",
")",
"{",
"$",
"this",
"->",
"xslt",
"->",
"importStylesheet",
"(",
"$",
"this",
"->",
"generateXsl",
"(",
"$",
"stylesheets",
")",
")",
";",
"return",
"$",
"this",
"->",
"generateOutput",
"(",
"$",
"mode",
")",
";",
"}"
] | process and return the output that will be sent to screen during
the display process
@param mixed a string or array listing the XSL stylesheets to be used
for the rendering process
@param int a flag indicating the rendering type. acceptable values
are DOMi::RENDER_HTML and DOMi::RENDER_XML
@retval string the result of the processing based on the stylesheets
and the rendering mode | [
"process",
"and",
"return",
"the",
"output",
"that",
"will",
"be",
"sent",
"to",
"screen",
"during",
"the",
"display",
"process"
] | 79f7f95c81536f704650aaf8584cf7eb4bfff410 | https://github.com/kingcoyote/domi/blob/79f7f95c81536f704650aaf8584cf7eb4bfff410/src/Domi/Domi.php#L209-L213 |
4,440 | PowerOnSystem/WebFramework | src/Network/Response.php | Response.render | public function render($response_sent, $status = NULL) {
$response = $this->_parse($response_sent);
if (is_null($status)) {
$status = $this->getStatus($this->_default_header);
} elseif ( !is_null($status) ) {
$status = $this->getStatus($status);
} elseif ( !is_null($response['status']) ) {
$status = $this->getStatus($response['status']);
} else {
$status = $this->getStatus(500);
}
if ( !headers_sent() ) {
if (!strpos(PHP_SAPI, 'cgi')) {
header($status);
}
foreach ( $response['headers'] as $header ) {
header($header, false);
}
}
$length = strlen($response['body']);
for ( $i = 0; $i < $length; $i += $this->_config['buffer_size'] ) {
echo substr($response['body'], $i, $this->_config['buffer_size']);
}
} | php | public function render($response_sent, $status = NULL) {
$response = $this->_parse($response_sent);
if (is_null($status)) {
$status = $this->getStatus($this->_default_header);
} elseif ( !is_null($status) ) {
$status = $this->getStatus($status);
} elseif ( !is_null($response['status']) ) {
$status = $this->getStatus($response['status']);
} else {
$status = $this->getStatus(500);
}
if ( !headers_sent() ) {
if (!strpos(PHP_SAPI, 'cgi')) {
header($status);
}
foreach ( $response['headers'] as $header ) {
header($header, false);
}
}
$length = strlen($response['body']);
for ( $i = 0; $i < $length; $i += $this->_config['buffer_size'] ) {
echo substr($response['body'], $i, $this->_config['buffer_size']);
}
} | [
"public",
"function",
"render",
"(",
"$",
"response_sent",
",",
"$",
"status",
"=",
"NULL",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_parse",
"(",
"$",
"response_sent",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"status",
")",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"getStatus",
"(",
"$",
"this",
"->",
"_default_header",
")",
";",
"}",
"elseif",
"(",
"!",
"is_null",
"(",
"$",
"status",
")",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"getStatus",
"(",
"$",
"status",
")",
";",
"}",
"elseif",
"(",
"!",
"is_null",
"(",
"$",
"response",
"[",
"'status'",
"]",
")",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"getStatus",
"(",
"$",
"response",
"[",
"'status'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"getStatus",
"(",
"500",
")",
";",
"}",
"if",
"(",
"!",
"headers_sent",
"(",
")",
")",
"{",
"if",
"(",
"!",
"strpos",
"(",
"PHP_SAPI",
",",
"'cgi'",
")",
")",
"{",
"header",
"(",
"$",
"status",
")",
";",
"}",
"foreach",
"(",
"$",
"response",
"[",
"'headers'",
"]",
"as",
"$",
"header",
")",
"{",
"header",
"(",
"$",
"header",
",",
"false",
")",
";",
"}",
"}",
"$",
"length",
"=",
"strlen",
"(",
"$",
"response",
"[",
"'body'",
"]",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"+=",
"$",
"this",
"->",
"_config",
"[",
"'buffer_size'",
"]",
")",
"{",
"echo",
"substr",
"(",
"$",
"response",
"[",
"'body'",
"]",
",",
"$",
"i",
",",
"$",
"this",
"->",
"_config",
"[",
"'buffer_size'",
"]",
")",
";",
"}",
"}"
] | Renderiza la respuesta completa
@param mix $response_sent La respuesta puede ser un string con el body o un array
['body' => BODY_CONTENT, 'headers' => [HEADER_TO_SEND], 'status' => STATUS_CODE ]
@param integer $status [Opcional] El codigo de estado HTTP, por defecto es 200 | [
"Renderiza",
"la",
"respuesta",
"completa"
] | 3b885a390adc42d6ad93d7900d33d97c66a6c2a9 | https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Network/Response.php#L139-L164 |
4,441 | consigliere/components | src/Process/Updater.php | Updater.update | public function update($component)
{
$component = $this->component->findOrFail($component);
$packages = $component->getComposerAttr('require', []);
chdir(base_path());
foreach ($packages as $name => $version) {
$package = "\"{$name}:{$version}\"";
$this->run("composer require {$package}");
}
} | php | public function update($component)
{
$component = $this->component->findOrFail($component);
$packages = $component->getComposerAttr('require', []);
chdir(base_path());
foreach ($packages as $name => $version) {
$package = "\"{$name}:{$version}\"";
$this->run("composer require {$package}");
}
} | [
"public",
"function",
"update",
"(",
"$",
"component",
")",
"{",
"$",
"component",
"=",
"$",
"this",
"->",
"component",
"->",
"findOrFail",
"(",
"$",
"component",
")",
";",
"$",
"packages",
"=",
"$",
"component",
"->",
"getComposerAttr",
"(",
"'require'",
",",
"[",
"]",
")",
";",
"chdir",
"(",
"base_path",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"name",
"=>",
"$",
"version",
")",
"{",
"$",
"package",
"=",
"\"\\\"{$name}:{$version}\\\"\"",
";",
"$",
"this",
"->",
"run",
"(",
"\"composer require {$package}\"",
")",
";",
"}",
"}"
] | Update the dependencies for the specified component by given the component name.
@param string $component | [
"Update",
"the",
"dependencies",
"for",
"the",
"specified",
"component",
"by",
"given",
"the",
"component",
"name",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Process/Updater.php#L12-L25 |
4,442 | CatLabInteractive/Neuron | src/Neuron/Net/Entity.php | Entity.setFromData | public function setFromData ($data)
{
// Check signature
$model = $this;
$chk = self::CHECK_SIGNATURE;
if ($chk && !isset ($data['signature']))
{
throw new InvalidParameter ("All decoded requests must have a signature.");
}
if ($chk && $data['signature'] != self::calculateSignature ($data))
{
throw new InvalidParameter ("Leave now, and Never come Back! *gollem, gollem* (Decoded request signature mismatch).");
}
// The body. If data is found, body is not used.
if (isset ($data['data']) && !empty ($data['data']))
{
$model->setData ($data['data']);
}
else if (isset ($data['body']))
{
$model->setBody ($data['body']);
}
if (isset ($data['headers']))
{
$model->setHeaders ($data['headers']);
}
if (isset ($data['cookies']))
{
$model->setCookies ($data['cookies']);
}
if (isset ($data['post']))
{
$model->setPost ($data['post']);
}
if (isset ($data['status']))
{
$model->setStatus ($data['status']);
}
return $model;
} | php | public function setFromData ($data)
{
// Check signature
$model = $this;
$chk = self::CHECK_SIGNATURE;
if ($chk && !isset ($data['signature']))
{
throw new InvalidParameter ("All decoded requests must have a signature.");
}
if ($chk && $data['signature'] != self::calculateSignature ($data))
{
throw new InvalidParameter ("Leave now, and Never come Back! *gollem, gollem* (Decoded request signature mismatch).");
}
// The body. If data is found, body is not used.
if (isset ($data['data']) && !empty ($data['data']))
{
$model->setData ($data['data']);
}
else if (isset ($data['body']))
{
$model->setBody ($data['body']);
}
if (isset ($data['headers']))
{
$model->setHeaders ($data['headers']);
}
if (isset ($data['cookies']))
{
$model->setCookies ($data['cookies']);
}
if (isset ($data['post']))
{
$model->setPost ($data['post']);
}
if (isset ($data['status']))
{
$model->setStatus ($data['status']);
}
return $model;
} | [
"public",
"function",
"setFromData",
"(",
"$",
"data",
")",
"{",
"// Check signature",
"$",
"model",
"=",
"$",
"this",
";",
"$",
"chk",
"=",
"self",
"::",
"CHECK_SIGNATURE",
";",
"if",
"(",
"$",
"chk",
"&&",
"!",
"isset",
"(",
"$",
"data",
"[",
"'signature'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidParameter",
"(",
"\"All decoded requests must have a signature.\"",
")",
";",
"}",
"if",
"(",
"$",
"chk",
"&&",
"$",
"data",
"[",
"'signature'",
"]",
"!=",
"self",
"::",
"calculateSignature",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"InvalidParameter",
"(",
"\"Leave now, and Never come Back! *gollem, gollem* (Decoded request signature mismatch).\"",
")",
";",
"}",
"// The body. If data is found, body is not used.",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'data'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"data",
"[",
"'data'",
"]",
")",
")",
"{",
"$",
"model",
"->",
"setData",
"(",
"$",
"data",
"[",
"'data'",
"]",
")",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'body'",
"]",
")",
")",
"{",
"$",
"model",
"->",
"setBody",
"(",
"$",
"data",
"[",
"'body'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'headers'",
"]",
")",
")",
"{",
"$",
"model",
"->",
"setHeaders",
"(",
"$",
"data",
"[",
"'headers'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'cookies'",
"]",
")",
")",
"{",
"$",
"model",
"->",
"setCookies",
"(",
"$",
"data",
"[",
"'cookies'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'post'",
"]",
")",
")",
"{",
"$",
"model",
"->",
"setPost",
"(",
"$",
"data",
"[",
"'post'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'status'",
"]",
")",
")",
"{",
"$",
"model",
"->",
"setStatus",
"(",
"$",
"data",
"[",
"'status'",
"]",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
] | Serialize & deserialize requests
@param $data
@return \Neuron\Net\Request
@throws \Neuron\Exceptions\InvalidParameter | [
"Serialize",
"&",
"deserialize",
"requests"
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Net/Entity.php#L50-L99 |
4,443 | CatLabInteractive/Neuron | src/Neuron/Net/Entity.php | Entity.hasData | public function hasData ()
{
if (!isset ($this->data))
{
if (!isset ($this->error))
$this->setError ('No input data set');
return false;
}
else {
return true;
}
} | php | public function hasData ()
{
if (!isset ($this->data))
{
if (!isset ($this->error))
$this->setError ('No input data set');
return false;
}
else {
return true;
}
} | [
"public",
"function",
"hasData",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"error",
")",
")",
"$",
"this",
"->",
"setError",
"(",
"'No input data set'",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | Check if request has data | [
"Check",
"if",
"request",
"has",
"data"
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Net/Entity.php#L316-L328 |
4,444 | easy-system/es-container | src/ParametricTree/RecursiveTree.php | RecursiveTree.buildLeaf | public function buildLeaf($uniqueKey = null, $parentKey = null)
{
if (isset($this->crown[$uniqueKey])) {
throw new InvalidArgumentException(sprintf(
'The leaf with key "%s" is already exists.',
$uniqueKey
));
}
if ($parentKey && ! isset($this->crown[$parentKey])) {
throw new InvalidArgumentException(sprintf(
'Unknown leaf "%s" specified as parent.',
$parentKey
));
}
$leaf = clone $this->getLeafPrototype();
$this->injectInCrown($leaf, $uniqueKey);
if ($parentKey) {
$parent = $this->crown[$parentKey];
$parent->addChild($leaf);
} else {
$this->branch[$leaf->getUniqueKey()] = $leaf;
$leaf->setDepth(0);
}
return $leaf;
} | php | public function buildLeaf($uniqueKey = null, $parentKey = null)
{
if (isset($this->crown[$uniqueKey])) {
throw new InvalidArgumentException(sprintf(
'The leaf with key "%s" is already exists.',
$uniqueKey
));
}
if ($parentKey && ! isset($this->crown[$parentKey])) {
throw new InvalidArgumentException(sprintf(
'Unknown leaf "%s" specified as parent.',
$parentKey
));
}
$leaf = clone $this->getLeafPrototype();
$this->injectInCrown($leaf, $uniqueKey);
if ($parentKey) {
$parent = $this->crown[$parentKey];
$parent->addChild($leaf);
} else {
$this->branch[$leaf->getUniqueKey()] = $leaf;
$leaf->setDepth(0);
}
return $leaf;
} | [
"public",
"function",
"buildLeaf",
"(",
"$",
"uniqueKey",
"=",
"null",
",",
"$",
"parentKey",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"crown",
"[",
"$",
"uniqueKey",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The leaf with key \"%s\" is already exists.'",
",",
"$",
"uniqueKey",
")",
")",
";",
"}",
"if",
"(",
"$",
"parentKey",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"crown",
"[",
"$",
"parentKey",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unknown leaf \"%s\" specified as parent.'",
",",
"$",
"parentKey",
")",
")",
";",
"}",
"$",
"leaf",
"=",
"clone",
"$",
"this",
"->",
"getLeafPrototype",
"(",
")",
";",
"$",
"this",
"->",
"injectInCrown",
"(",
"$",
"leaf",
",",
"$",
"uniqueKey",
")",
";",
"if",
"(",
"$",
"parentKey",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"crown",
"[",
"$",
"parentKey",
"]",
";",
"$",
"parent",
"->",
"addChild",
"(",
"$",
"leaf",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"branch",
"[",
"$",
"leaf",
"->",
"getUniqueKey",
"(",
")",
"]",
"=",
"$",
"leaf",
";",
"$",
"leaf",
"->",
"setDepth",
"(",
"0",
")",
";",
"}",
"return",
"$",
"leaf",
";",
"}"
] | Builds the leaf.
@param null|int|string $uniqueKey Optional; null by default. The key,
which is unique within the tree
@param null|int|string $parentKey Optional; null by default. The key of
parent leaf
@throws \InvalidArgumentException | [
"Builds",
"the",
"leaf",
"."
] | 0e917d8ff2c3622f53b82d34436295539858be7d | https://github.com/easy-system/es-container/blob/0e917d8ff2c3622f53b82d34436295539858be7d/src/ParametricTree/RecursiveTree.php#L82-L108 |
4,445 | easy-system/es-container | src/ParametricTree/RecursiveTree.php | RecursiveTree.getLeaf | public function getLeaf($uniqueKey)
{
if (! isset($this->crown[$uniqueKey])) {
throw new InvalidArgumentException(sprintf(
'The leaf with unique key "%s" not exists.',
$uniqueKey
));
}
return $this->crown[$uniqueKey];
} | php | public function getLeaf($uniqueKey)
{
if (! isset($this->crown[$uniqueKey])) {
throw new InvalidArgumentException(sprintf(
'The leaf with unique key "%s" not exists.',
$uniqueKey
));
}
return $this->crown[$uniqueKey];
} | [
"public",
"function",
"getLeaf",
"(",
"$",
"uniqueKey",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"crown",
"[",
"$",
"uniqueKey",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The leaf with unique key \"%s\" not exists.'",
",",
"$",
"uniqueKey",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"crown",
"[",
"$",
"uniqueKey",
"]",
";",
"}"
] | Gets the specified leaf.
@param int|string $uniqueKey The unique key of leaf
@throws \InvalidArgumentException If the specified leaf not exists
@return RecursiveLeafInterface The specified leaf | [
"Gets",
"the",
"specified",
"leaf",
"."
] | 0e917d8ff2c3622f53b82d34436295539858be7d | https://github.com/easy-system/es-container/blob/0e917d8ff2c3622f53b82d34436295539858be7d/src/ParametricTree/RecursiveTree.php#L131-L141 |
4,446 | easy-system/es-container | src/ParametricTree/RecursiveTree.php | RecursiveTree.current | public function current()
{
if (is_null($this->current)) {
$this->current = current($this->branch);
}
if ($this->current instanceof RecursiveLeafInterface) {
return $this->current->current();
}
return false;
} | php | public function current()
{
if (is_null($this->current)) {
$this->current = current($this->branch);
}
if ($this->current instanceof RecursiveLeafInterface) {
return $this->current->current();
}
return false;
} | [
"public",
"function",
"current",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"current",
")",
")",
"{",
"$",
"this",
"->",
"current",
"=",
"current",
"(",
"$",
"this",
"->",
"branch",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"current",
"instanceof",
"RecursiveLeafInterface",
")",
"{",
"return",
"$",
"this",
"->",
"current",
"->",
"current",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns the current leaf.
@return false|RecursiveLeafInterface Returns the current leaf on success,
false otherwise | [
"Returns",
"the",
"current",
"leaf",
"."
] | 0e917d8ff2c3622f53b82d34436295539858be7d | https://github.com/easy-system/es-container/blob/0e917d8ff2c3622f53b82d34436295539858be7d/src/ParametricTree/RecursiveTree.php#L169-L179 |
4,447 | easy-system/es-container | src/ParametricTree/RecursiveTree.php | RecursiveTree.injectInCrown | protected function injectInCrown(RecursiveLeafInterface $leaf, $uniqueKey = null)
{
if (is_null($uniqueKey)) {
$this->crown[] = null;
$uniqueKey = key(array_slice($this->crown, -1, 1, true));
}
$leaf->setUniqueKey($uniqueKey);
$this->crown[$uniqueKey] = $leaf;
} | php | protected function injectInCrown(RecursiveLeafInterface $leaf, $uniqueKey = null)
{
if (is_null($uniqueKey)) {
$this->crown[] = null;
$uniqueKey = key(array_slice($this->crown, -1, 1, true));
}
$leaf->setUniqueKey($uniqueKey);
$this->crown[$uniqueKey] = $leaf;
} | [
"protected",
"function",
"injectInCrown",
"(",
"RecursiveLeafInterface",
"$",
"leaf",
",",
"$",
"uniqueKey",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"uniqueKey",
")",
")",
"{",
"$",
"this",
"->",
"crown",
"[",
"]",
"=",
"null",
";",
"$",
"uniqueKey",
"=",
"key",
"(",
"array_slice",
"(",
"$",
"this",
"->",
"crown",
",",
"-",
"1",
",",
"1",
",",
"true",
")",
")",
";",
"}",
"$",
"leaf",
"->",
"setUniqueKey",
"(",
"$",
"uniqueKey",
")",
";",
"$",
"this",
"->",
"crown",
"[",
"$",
"uniqueKey",
"]",
"=",
"$",
"leaf",
";",
"}"
] | Injects leaf in crown of the tree.
@param RecursiveLeafInterface $leaf The leaf
@param int|string $uniqueKey The unique key of leaf | [
"Injects",
"leaf",
"in",
"crown",
"of",
"the",
"tree",
"."
] | 0e917d8ff2c3622f53b82d34436295539858be7d | https://github.com/easy-system/es-container/blob/0e917d8ff2c3622f53b82d34436295539858be7d/src/ParametricTree/RecursiveTree.php#L253-L262 |
4,448 | mszewcz/php-light-framework | src/Text/WordCount.php | WordCount.count | public static function count(string $text = '', int $minWorldLength = 0): int
{
if (\trim($text) === '') {
return 0;
}
$text = StripTags::strip($text);
$text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5);
$text = \preg_replace('/[^\w[:space:]]/u', '', $text);
if ($minWorldLength > 1) {
$text = \preg_replace('/(\b\w{1,'.($minWorldLength - 1).'}\b)/u', ' ', $text);
}
$text = \trim(\preg_replace('/\s+/', ' ', $text));
if ($text === '') {
return 0;
}
$words = \explode(' ', $text);
return \count($words);
} | php | public static function count(string $text = '', int $minWorldLength = 0): int
{
if (\trim($text) === '') {
return 0;
}
$text = StripTags::strip($text);
$text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5);
$text = \preg_replace('/[^\w[:space:]]/u', '', $text);
if ($minWorldLength > 1) {
$text = \preg_replace('/(\b\w{1,'.($minWorldLength - 1).'}\b)/u', ' ', $text);
}
$text = \trim(\preg_replace('/\s+/', ' ', $text));
if ($text === '') {
return 0;
}
$words = \explode(' ', $text);
return \count($words);
} | [
"public",
"static",
"function",
"count",
"(",
"string",
"$",
"text",
"=",
"''",
",",
"int",
"$",
"minWorldLength",
"=",
"0",
")",
":",
"int",
"{",
"if",
"(",
"\\",
"trim",
"(",
"$",
"text",
")",
"===",
"''",
")",
"{",
"return",
"0",
";",
"}",
"$",
"text",
"=",
"StripTags",
"::",
"strip",
"(",
"$",
"text",
")",
";",
"$",
"text",
"=",
"\\",
"htmlspecialchars_decode",
"(",
"(",
"string",
")",
"$",
"text",
",",
"ENT_COMPAT",
"|",
"ENT_HTML5",
")",
";",
"$",
"text",
"=",
"\\",
"preg_replace",
"(",
"'/[^\\w[:space:]]/u'",
",",
"''",
",",
"$",
"text",
")",
";",
"if",
"(",
"$",
"minWorldLength",
">",
"1",
")",
"{",
"$",
"text",
"=",
"\\",
"preg_replace",
"(",
"'/(\\b\\w{1,'",
".",
"(",
"$",
"minWorldLength",
"-",
"1",
")",
".",
"'}\\b)/u'",
",",
"' '",
",",
"$",
"text",
")",
";",
"}",
"$",
"text",
"=",
"\\",
"trim",
"(",
"\\",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"text",
")",
")",
";",
"if",
"(",
"$",
"text",
"===",
"''",
")",
"{",
"return",
"0",
";",
"}",
"$",
"words",
"=",
"\\",
"explode",
"(",
"' '",
",",
"$",
"text",
")",
";",
"return",
"\\",
"count",
"(",
"$",
"words",
")",
";",
"}"
] | Counts words with provided min length
@param string $text
@param int $minWorldLength
@return int | [
"Counts",
"words",
"with",
"provided",
"min",
"length"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Text/WordCount.php#L28-L46 |
4,449 | strident/Trident | src/Trident/Module/DebugModule/Toolbar/Event/ToolbarSubscriptionManager.php | ToolbarSubscriptionManager.registerSubscriptions | public function registerSubscriptions(EventDispatcher $dispatcher)
{
if ($this->registered) {
throw new \RuntimeException('Cannot register debug toolbar subscriptions when already registered.');
}
foreach ($this->toolbar->getExtensions() as $extension) {
if ( ! $extension instanceof EventSubscriberInterface) {
continue;
}
$dispatcher->addSubscriber($extension);
}
$this->registered = true;
} | php | public function registerSubscriptions(EventDispatcher $dispatcher)
{
if ($this->registered) {
throw new \RuntimeException('Cannot register debug toolbar subscriptions when already registered.');
}
foreach ($this->toolbar->getExtensions() as $extension) {
if ( ! $extension instanceof EventSubscriberInterface) {
continue;
}
$dispatcher->addSubscriber($extension);
}
$this->registered = true;
} | [
"public",
"function",
"registerSubscriptions",
"(",
"EventDispatcher",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"registered",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot register debug toolbar subscriptions when already registered.'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"toolbar",
"->",
"getExtensions",
"(",
")",
"as",
"$",
"extension",
")",
"{",
"if",
"(",
"!",
"$",
"extension",
"instanceof",
"EventSubscriberInterface",
")",
"{",
"continue",
";",
"}",
"$",
"dispatcher",
"->",
"addSubscriber",
"(",
"$",
"extension",
")",
";",
"}",
"$",
"this",
"->",
"registered",
"=",
"true",
";",
"}"
] | Register the subscriptions for extensions that have them. | [
"Register",
"the",
"subscriptions",
"for",
"extensions",
"that",
"have",
"them",
"."
] | a112f0b75601b897c470a49d85791dc386c29952 | https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Module/DebugModule/Toolbar/Event/ToolbarSubscriptionManager.php#L41-L56 |
4,450 | JamesRezo/webhelper-parser | src/Compiler.php | Compiler.doCompile | public function doCompile($activeConfig, $context = 'main', $value = '')
{
$tempConfig = [];
while (!empty($activeConfig)) {
$lineConfig = array_shift($activeConfig);
$tempConfig[] = $this->subCompile($activeConfig, $lineConfig);
}
return $this->buildBlockDirective($context, $value, $tempConfig);
} | php | public function doCompile($activeConfig, $context = 'main', $value = '')
{
$tempConfig = [];
while (!empty($activeConfig)) {
$lineConfig = array_shift($activeConfig);
$tempConfig[] = $this->subCompile($activeConfig, $lineConfig);
}
return $this->buildBlockDirective($context, $value, $tempConfig);
} | [
"public",
"function",
"doCompile",
"(",
"$",
"activeConfig",
",",
"$",
"context",
"=",
"'main'",
",",
"$",
"value",
"=",
"''",
")",
"{",
"$",
"tempConfig",
"=",
"[",
"]",
";",
"while",
"(",
"!",
"empty",
"(",
"$",
"activeConfig",
")",
")",
"{",
"$",
"lineConfig",
"=",
"array_shift",
"(",
"$",
"activeConfig",
")",
";",
"$",
"tempConfig",
"[",
"]",
"=",
"$",
"this",
"->",
"subCompile",
"(",
"$",
"activeConfig",
",",
"$",
"lineConfig",
")",
";",
"}",
"return",
"$",
"this",
"->",
"buildBlockDirective",
"(",
"$",
"context",
",",
"$",
"value",
",",
"$",
"tempConfig",
")",
";",
"}"
] | Does a nested array of lines depending on container Directives.
@param array $activeConfig a clean config array of lines
@param string $context the context name
@param string $value an optional context value
@return Directive\BlockDirective a full context of directives | [
"Does",
"a",
"nested",
"array",
"of",
"lines",
"depending",
"on",
"container",
"Directives",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Compiler.php#L86-L96 |
4,451 | JamesRezo/webhelper-parser | src/Compiler.php | Compiler.subCompile | private function subCompile(&$activeConfig, $lineConfig)
{
if (preg_match($this->startMultiLine, $lineConfig, $container)) {
return $this->findEndingKey(trim($container['key']), trim($container['value']), $activeConfig);
}
if (!preg_match($this->simpleDirective, $lineConfig, $container)) {
throw InvalidConfigException::forSimpleDirectiveSyntaxError($lineConfig);
}
return $this->buildSimpleDirective(trim($container['key']), trim($container['value']));
} | php | private function subCompile(&$activeConfig, $lineConfig)
{
if (preg_match($this->startMultiLine, $lineConfig, $container)) {
return $this->findEndingKey(trim($container['key']), trim($container['value']), $activeConfig);
}
if (!preg_match($this->simpleDirective, $lineConfig, $container)) {
throw InvalidConfigException::forSimpleDirectiveSyntaxError($lineConfig);
}
return $this->buildSimpleDirective(trim($container['key']), trim($container['value']));
} | [
"private",
"function",
"subCompile",
"(",
"&",
"$",
"activeConfig",
",",
"$",
"lineConfig",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"startMultiLine",
",",
"$",
"lineConfig",
",",
"$",
"container",
")",
")",
"{",
"return",
"$",
"this",
"->",
"findEndingKey",
"(",
"trim",
"(",
"$",
"container",
"[",
"'key'",
"]",
")",
",",
"trim",
"(",
"$",
"container",
"[",
"'value'",
"]",
")",
",",
"$",
"activeConfig",
")",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"this",
"->",
"simpleDirective",
",",
"$",
"lineConfig",
",",
"$",
"container",
")",
")",
"{",
"throw",
"InvalidConfigException",
"::",
"forSimpleDirectiveSyntaxError",
"(",
"$",
"lineConfig",
")",
";",
"}",
"return",
"$",
"this",
"->",
"buildSimpleDirective",
"(",
"trim",
"(",
"$",
"container",
"[",
"'key'",
"]",
")",
",",
"trim",
"(",
"$",
"container",
"[",
"'value'",
"]",
")",
")",
";",
"}"
] | Looks for a container directive.
@param array $activeConfig a clean config array of directives
@param string $lineConfig a line
@throws Exception\InvalidConfigException if a simple directive has invalid syntax
@return Directive\DirectiveInterface a directive or a container of directives | [
"Looks",
"for",
"a",
"container",
"directive",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Compiler.php#L108-L119 |
4,452 | JamesRezo/webhelper-parser | src/Compiler.php | Compiler.findEndingKey | private function findEndingKey($context, $contextValue, &$activeConfig)
{
$lines = [];
$endMultiLine = sprintf($this->endMultiLine, $context);
while (!empty($activeConfig)) {
$lineConfig = array_shift($activeConfig);
if (preg_match($endMultiLine, $lineConfig)) {
return $this->buildBlockDirective($context, $contextValue, $lines);
}
$lines[] = $this->subCompile($activeConfig, $lineConfig);
}
throw InvalidConfigException::forEndingKeyNotFound($context);
} | php | private function findEndingKey($context, $contextValue, &$activeConfig)
{
$lines = [];
$endMultiLine = sprintf($this->endMultiLine, $context);
while (!empty($activeConfig)) {
$lineConfig = array_shift($activeConfig);
if (preg_match($endMultiLine, $lineConfig)) {
return $this->buildBlockDirective($context, $contextValue, $lines);
}
$lines[] = $this->subCompile($activeConfig, $lineConfig);
}
throw InvalidConfigException::forEndingKeyNotFound($context);
} | [
"private",
"function",
"findEndingKey",
"(",
"$",
"context",
",",
"$",
"contextValue",
",",
"&",
"$",
"activeConfig",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"endMultiLine",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"endMultiLine",
",",
"$",
"context",
")",
";",
"while",
"(",
"!",
"empty",
"(",
"$",
"activeConfig",
")",
")",
"{",
"$",
"lineConfig",
"=",
"array_shift",
"(",
"$",
"activeConfig",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"endMultiLine",
",",
"$",
"lineConfig",
")",
")",
"{",
"return",
"$",
"this",
"->",
"buildBlockDirective",
"(",
"$",
"context",
",",
"$",
"contextValue",
",",
"$",
"lines",
")",
";",
"}",
"$",
"lines",
"[",
"]",
"=",
"$",
"this",
"->",
"subCompile",
"(",
"$",
"activeConfig",
",",
"$",
"lineConfig",
")",
";",
"}",
"throw",
"InvalidConfigException",
"::",
"forEndingKeyNotFound",
"(",
"$",
"context",
")",
";",
"}"
] | Finds the end of a container directive.
@param string $context a container's name
@param string $contextValue a container's value
@param array $activeConfig a clean config array of lines
@throws Exception\InvalidConfigException if a container does not end correctly
@return Directive\BlockDirective a container of directives | [
"Finds",
"the",
"end",
"of",
"a",
"container",
"directive",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Compiler.php#L132-L148 |
4,453 | JamesRezo/webhelper-parser | src/Compiler.php | Compiler.buildBlockDirective | private function buildBlockDirective($context, $contextValue, $lines)
{
$class = 'WebHelper\Parser\Directive\BlockDirective';
$known = $this->parser->getServer()->getKnownDirectives();
if (in_array($context, array_keys($known))) {
if (isset($known[$context]['class'])) {
$class = 'WebHelper\Parser\Directive\\'.$known[$context]['class'];
}
}
$block = new $class($context, $contextValue);
foreach ($lines as $directive) {
$block->add($directive);
}
return $block;
} | php | private function buildBlockDirective($context, $contextValue, $lines)
{
$class = 'WebHelper\Parser\Directive\BlockDirective';
$known = $this->parser->getServer()->getKnownDirectives();
if (in_array($context, array_keys($known))) {
if (isset($known[$context]['class'])) {
$class = 'WebHelper\Parser\Directive\\'.$known[$context]['class'];
}
}
$block = new $class($context, $contextValue);
foreach ($lines as $directive) {
$block->add($directive);
}
return $block;
} | [
"private",
"function",
"buildBlockDirective",
"(",
"$",
"context",
",",
"$",
"contextValue",
",",
"$",
"lines",
")",
"{",
"$",
"class",
"=",
"'WebHelper\\Parser\\Directive\\BlockDirective'",
";",
"$",
"known",
"=",
"$",
"this",
"->",
"parser",
"->",
"getServer",
"(",
")",
"->",
"getKnownDirectives",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"context",
",",
"array_keys",
"(",
"$",
"known",
")",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"known",
"[",
"$",
"context",
"]",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"'WebHelper\\Parser\\Directive\\\\'",
".",
"$",
"known",
"[",
"$",
"context",
"]",
"[",
"'class'",
"]",
";",
"}",
"}",
"$",
"block",
"=",
"new",
"$",
"class",
"(",
"$",
"context",
",",
"$",
"contextValue",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"directive",
")",
"{",
"$",
"block",
"->",
"add",
"(",
"$",
"directive",
")",
";",
"}",
"return",
"$",
"block",
";",
"}"
] | Builds a BlockDirective.
@param string $context a container's name
@param string $contextValue a container's value
@param array $lines an array of directives
@return Directive\BlockDirective the BlockDirective | [
"Builds",
"a",
"BlockDirective",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Compiler.php#L159-L174 |
4,454 | JamesRezo/webhelper-parser | src/Compiler.php | Compiler.buildSimpleDirective | private function buildSimpleDirective($key, $value)
{
$known = $this->parser->getServer()->getKnownDirectives();
if (in_array($key, array_keys($known))) {
if (isset($known[$key]['class'])) {
$class = 'WebHelper\Parser\Directive\\'.$known[$key]['class'];
return new $class($key, $value, $this->parser);
}
}
return new SimpleDirective($key, $value);
} | php | private function buildSimpleDirective($key, $value)
{
$known = $this->parser->getServer()->getKnownDirectives();
if (in_array($key, array_keys($known))) {
if (isset($known[$key]['class'])) {
$class = 'WebHelper\Parser\Directive\\'.$known[$key]['class'];
return new $class($key, $value, $this->parser);
}
}
return new SimpleDirective($key, $value);
} | [
"private",
"function",
"buildSimpleDirective",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"known",
"=",
"$",
"this",
"->",
"parser",
"->",
"getServer",
"(",
")",
"->",
"getKnownDirectives",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"array_keys",
"(",
"$",
"known",
")",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"known",
"[",
"$",
"key",
"]",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"'WebHelper\\Parser\\Directive\\\\'",
".",
"$",
"known",
"[",
"$",
"key",
"]",
"[",
"'class'",
"]",
";",
"return",
"new",
"$",
"class",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"this",
"->",
"parser",
")",
";",
"}",
"}",
"return",
"new",
"SimpleDirective",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Build a SimpleDirective or an InclusionDirective.
Remember that inclusion are parsed as simple directives but are block directives
@see Directive\InclusionDirective Inclusion Doc
@param string $key a directive's name
@param string $value a directive's value
@return Directive\SimpleDirective|Directive\InclusionDirective the Directive | [
"Build",
"a",
"SimpleDirective",
"or",
"an",
"InclusionDirective",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Compiler.php#L188-L199 |
4,455 | gap-db/orm | GapOrm/Mapper/Model.php | Model.instance | public static function instance($className = __CLASS__)
{
if (!isset(self::$instances[$className])) {
self::$instances[$className] = new $className;
}
return self::$instances[$className];
} | php | public static function instance($className = __CLASS__)
{
if (!isset(self::$instances[$className])) {
self::$instances[$className] = new $className;
}
return self::$instances[$className];
} | [
"public",
"static",
"function",
"instance",
"(",
"$",
"className",
"=",
"__CLASS__",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"className",
"]",
")",
")",
"{",
"self",
"::",
"$",
"instances",
"[",
"$",
"className",
"]",
"=",
"new",
"$",
"className",
";",
"}",
"return",
"self",
"::",
"$",
"instances",
"[",
"$",
"className",
"]",
";",
"}"
] | Get Model instance
@param string $className
@return mixed | [
"Get",
"Model",
"instance"
] | bcd8e3d27b19b14814d3207489071c4a250a6ac5 | https://github.com/gap-db/orm/blob/bcd8e3d27b19b14814d3207489071c4a250a6ac5/GapOrm/Mapper/Model.php#L27-L34 |
4,456 | thecsea/twofactor-dir | src/twofactorDir.php | twofactorDir.redirectCheck | public function redirectCheck()
{
if(isset($_COOKIE['twofactorDir-'.$this->dir]) && $_COOKIE['twofactorDir-'.$this->dir] == $this->cookieCode)
{
self::redirect();
return true;
}else
{
return false;
}
} | php | public function redirectCheck()
{
if(isset($_COOKIE['twofactorDir-'.$this->dir]) && $_COOKIE['twofactorDir-'.$this->dir] == $this->cookieCode)
{
self::redirect();
return true;
}else
{
return false;
}
} | [
"public",
"function",
"redirectCheck",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_COOKIE",
"[",
"'twofactorDir-'",
".",
"$",
"this",
"->",
"dir",
"]",
")",
"&&",
"$",
"_COOKIE",
"[",
"'twofactorDir-'",
".",
"$",
"this",
"->",
"dir",
"]",
"==",
"$",
"this",
"->",
"cookieCode",
")",
"{",
"self",
"::",
"redirect",
"(",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | CAUTION this method uses cookie, it must be called before any print
this method check if the cookie exists and if it is correct, if it is correct the method perform redirect
@return bool true if the redirect is done | [
"CAUTION",
"this",
"method",
"uses",
"cookie",
"it",
"must",
"be",
"called",
"before",
"any",
"print",
"this",
"method",
"check",
"if",
"the",
"cookie",
"exists",
"and",
"if",
"it",
"is",
"correct",
"if",
"it",
"is",
"correct",
"the",
"method",
"perform",
"redirect"
] | 4fe91b7d178fa705b560eb906e79a91d8d5d3de8 | https://github.com/thecsea/twofactor-dir/blob/4fe91b7d178fa705b560eb906e79a91d8d5d3de8/src/twofactorDir.php#L91-L101 |
4,457 | thecsea/twofactor-dir | src/twofactorDir.php | twofactorDir.checkCode | public function checkCode($code)
{
$res = $this->twofactorAdapter->check($code);
if($res)
{
setcookie('twofactorDir-' . $this->dir, $this->cookieCode, 0, "/");
self::redirect();
}
return $res;
} | php | public function checkCode($code)
{
$res = $this->twofactorAdapter->check($code);
if($res)
{
setcookie('twofactorDir-' . $this->dir, $this->cookieCode, 0, "/");
self::redirect();
}
return $res;
} | [
"public",
"function",
"checkCode",
"(",
"$",
"code",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"twofactorAdapter",
"->",
"check",
"(",
"$",
"code",
")",
";",
"if",
"(",
"$",
"res",
")",
"{",
"setcookie",
"(",
"'twofactorDir-'",
".",
"$",
"this",
"->",
"dir",
",",
"$",
"this",
"->",
"cookieCode",
",",
"0",
",",
"\"/\"",
")",
";",
"self",
"::",
"redirect",
"(",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | CAUTION this method uses cookie, it must be called before any print
this method checks code and performs login
this method perform redirect if the code is correct, after setting the cookie
@param string $code
@return bool true if the code is corret | [
"CAUTION",
"this",
"method",
"uses",
"cookie",
"it",
"must",
"be",
"called",
"before",
"any",
"print",
"this",
"method",
"checks",
"code",
"and",
"performs",
"login",
"this",
"method",
"perform",
"redirect",
"if",
"the",
"code",
"is",
"correct",
"after",
"setting",
"the",
"cookie"
] | 4fe91b7d178fa705b560eb906e79a91d8d5d3de8 | https://github.com/thecsea/twofactor-dir/blob/4fe91b7d178fa705b560eb906e79a91d8d5d3de8/src/twofactorDir.php#L120-L131 |
4,458 | thecsea/twofactor-dir | src/twofactorDir.php | twofactorDir.install | static public function install($dir = ".")
{
$cookieCode = md5(rand());
$strReplaceS = array("{SRC_DIR}", "{CUR_DIR}", "{COOKIE_CODE}");
$strReplaceR = array(__DIR__."/..", $dir, $cookieCode);
$f = fopen($dir . "/.htaccess", "a");
if(strpos(file_get_contents($dir."/.htaccess"), "##START twofactor-dir")===false)
{
fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__ . "/../files/x.htaccess")));
}
else
{
//I get the old cookie code
$preg = "/RewriteCond %{HTTP_COOKIE} !twofactorDir-.*=(.*)/";
$ret = array();
preg_match($preg, file_get_contents($dir."/.htaccess"),$ret);
$strReplaceR[2] = $ret[1];
}
fclose($f);
$f = fopen($dir . "/redirect.php", "w");
fwrite($f, str_replace($strReplaceS,$strReplaceR,file_get_contents(__DIR__ . "/../files/redirect.php")));
fclose($f);
$f = fopen($dir . "/get_qr.php", "w");
fwrite($f, str_replace($strReplaceS,$strReplaceR,file_get_contents(__DIR__ . "/../files/get_qr.php")));
fclose($f);
fclose(fopen($dir . "/secret.php", "a")); //create secret if it doesn't exists
} | php | static public function install($dir = ".")
{
$cookieCode = md5(rand());
$strReplaceS = array("{SRC_DIR}", "{CUR_DIR}", "{COOKIE_CODE}");
$strReplaceR = array(__DIR__."/..", $dir, $cookieCode);
$f = fopen($dir . "/.htaccess", "a");
if(strpos(file_get_contents($dir."/.htaccess"), "##START twofactor-dir")===false)
{
fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__ . "/../files/x.htaccess")));
}
else
{
//I get the old cookie code
$preg = "/RewriteCond %{HTTP_COOKIE} !twofactorDir-.*=(.*)/";
$ret = array();
preg_match($preg, file_get_contents($dir."/.htaccess"),$ret);
$strReplaceR[2] = $ret[1];
}
fclose($f);
$f = fopen($dir . "/redirect.php", "w");
fwrite($f, str_replace($strReplaceS,$strReplaceR,file_get_contents(__DIR__ . "/../files/redirect.php")));
fclose($f);
$f = fopen($dir . "/get_qr.php", "w");
fwrite($f, str_replace($strReplaceS,$strReplaceR,file_get_contents(__DIR__ . "/../files/get_qr.php")));
fclose($f);
fclose(fopen($dir . "/secret.php", "a")); //create secret if it doesn't exists
} | [
"static",
"public",
"function",
"install",
"(",
"$",
"dir",
"=",
"\".\"",
")",
"{",
"$",
"cookieCode",
"=",
"md5",
"(",
"rand",
"(",
")",
")",
";",
"$",
"strReplaceS",
"=",
"array",
"(",
"\"{SRC_DIR}\"",
",",
"\"{CUR_DIR}\"",
",",
"\"{COOKIE_CODE}\"",
")",
";",
"$",
"strReplaceR",
"=",
"array",
"(",
"__DIR__",
".",
"\"/..\"",
",",
"$",
"dir",
",",
"$",
"cookieCode",
")",
";",
"$",
"f",
"=",
"fopen",
"(",
"$",
"dir",
".",
"\"/.htaccess\"",
",",
"\"a\"",
")",
";",
"if",
"(",
"strpos",
"(",
"file_get_contents",
"(",
"$",
"dir",
".",
"\"/.htaccess\"",
")",
",",
"\"##START twofactor-dir\"",
")",
"===",
"false",
")",
"{",
"fwrite",
"(",
"$",
"f",
",",
"str_replace",
"(",
"$",
"strReplaceS",
",",
"$",
"strReplaceR",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"\"/../files/x.htaccess\"",
")",
")",
")",
";",
"}",
"else",
"{",
"//I get the old cookie code",
"$",
"preg",
"=",
"\"/RewriteCond %{HTTP_COOKIE} !twofactorDir-.*=(.*)/\"",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"preg_match",
"(",
"$",
"preg",
",",
"file_get_contents",
"(",
"$",
"dir",
".",
"\"/.htaccess\"",
")",
",",
"$",
"ret",
")",
";",
"$",
"strReplaceR",
"[",
"2",
"]",
"=",
"$",
"ret",
"[",
"1",
"]",
";",
"}",
"fclose",
"(",
"$",
"f",
")",
";",
"$",
"f",
"=",
"fopen",
"(",
"$",
"dir",
".",
"\"/redirect.php\"",
",",
"\"w\"",
")",
";",
"fwrite",
"(",
"$",
"f",
",",
"str_replace",
"(",
"$",
"strReplaceS",
",",
"$",
"strReplaceR",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"\"/../files/redirect.php\"",
")",
")",
")",
";",
"fclose",
"(",
"$",
"f",
")",
";",
"$",
"f",
"=",
"fopen",
"(",
"$",
"dir",
".",
"\"/get_qr.php\"",
",",
"\"w\"",
")",
";",
"fwrite",
"(",
"$",
"f",
",",
"str_replace",
"(",
"$",
"strReplaceS",
",",
"$",
"strReplaceR",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"\"/../files/get_qr.php\"",
")",
")",
")",
";",
"fclose",
"(",
"$",
"f",
")",
";",
"fclose",
"(",
"fopen",
"(",
"$",
"dir",
".",
"\"/secret.php\"",
",",
"\"a\"",
")",
")",
";",
"//create secret if it doesn't exists",
"}"
] | Install library into a dir
@param string $dir dir must be absolute link | [
"Install",
"library",
"into",
"a",
"dir"
] | 4fe91b7d178fa705b560eb906e79a91d8d5d3de8 | https://github.com/thecsea/twofactor-dir/blob/4fe91b7d178fa705b560eb906e79a91d8d5d3de8/src/twofactorDir.php#L168-L197 |
4,459 | garkavenkov/db-connector | src/DBConnect.php | DBConnect.closeCursor | private function closeCursor()
{
try {
if ($this->stmt) {
$this->stmt->closeCursor();
}
} catch (\PDOException $e) {
die("Error: " . $e->getMessage());
}
} | php | private function closeCursor()
{
try {
if ($this->stmt) {
$this->stmt->closeCursor();
}
} catch (\PDOException $e) {
die("Error: " . $e->getMessage());
}
} | [
"private",
"function",
"closeCursor",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"stmt",
")",
"{",
"$",
"this",
"->",
"stmt",
"->",
"closeCursor",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"die",
"(",
"\"Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Closes cursor for next execution | [
"Closes",
"cursor",
"for",
"next",
"execution"
] | afe80d80b3377ef1fbeecd370bbf46568ae699ba | https://github.com/garkavenkov/db-connector/blob/afe80d80b3377ef1fbeecd370bbf46568ae699ba/src/DBConnect.php#L116-L125 |
4,460 | garkavenkov/db-connector | src/DBConnect.php | DBConnect.getRow | public function getRow($fetch_style = null)
{
if (is_null($fetch_style)) {
$fetch_style = \PDO::FETCH_ASSOC;
}
try {
return $this->stmt->fetch($fetch_style);
} catch (\PDOException $e) {
die("Error: " . $e->getMessage());
}
} | php | public function getRow($fetch_style = null)
{
if (is_null($fetch_style)) {
$fetch_style = \PDO::FETCH_ASSOC;
}
try {
return $this->stmt->fetch($fetch_style);
} catch (\PDOException $e) {
die("Error: " . $e->getMessage());
}
} | [
"public",
"function",
"getRow",
"(",
"$",
"fetch_style",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fetch_style",
")",
")",
"{",
"$",
"fetch_style",
"=",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
";",
"}",
"try",
"{",
"return",
"$",
"this",
"->",
"stmt",
"->",
"fetch",
"(",
"$",
"fetch_style",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"die",
"(",
"\"Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Returns a next row from a result set
@param int $fetch_style PDO fetch style
@return mixed Record from result set depending on PDO fetch style | [
"Returns",
"a",
"next",
"row",
"from",
"a",
"result",
"set"
] | afe80d80b3377ef1fbeecd370bbf46568ae699ba | https://github.com/garkavenkov/db-connector/blob/afe80d80b3377ef1fbeecd370bbf46568ae699ba/src/DBConnect.php#L149-L159 |
4,461 | garkavenkov/db-connector | src/DBConnect.php | DBConnect.prepare | public function prepare(string $sql, $standalone = false)
{
try {
$stmt = $this->dbh->prepare($sql);
if ($standalone) {
return $stmt;
} else {
$this->stmt = $stmt;
}
return $this;
} catch (\PDOException $e) {
die("Error: " . $e->getMessage());
}
} | php | public function prepare(string $sql, $standalone = false)
{
try {
$stmt = $this->dbh->prepare($sql);
if ($standalone) {
return $stmt;
} else {
$this->stmt = $stmt;
}
return $this;
} catch (\PDOException $e) {
die("Error: " . $e->getMessage());
}
} | [
"public",
"function",
"prepare",
"(",
"string",
"$",
"sql",
",",
"$",
"standalone",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"dbh",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"standalone",
")",
"{",
"return",
"$",
"stmt",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"stmt",
"=",
"$",
"stmt",
";",
"}",
"return",
"$",
"this",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"die",
"(",
"\"Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Prepares an SQL statement
@param string $sql SQL statement
@param boolean $standalone
@return self | [
"Prepares",
"an",
"SQL",
"statement"
] | afe80d80b3377ef1fbeecd370bbf46568ae699ba | https://github.com/garkavenkov/db-connector/blob/afe80d80b3377ef1fbeecd370bbf46568ae699ba/src/DBConnect.php#L186-L199 |
4,462 | garkavenkov/db-connector | src/DBConnect.php | DBConnect.getFieldValue | public function getFieldValue(string $field_name)
{
try {
$value = null;
$fields = $this->stmt->fetch(\PDO::FETCH_ASSOC);
if (array_key_exists($field_name, $fields)) {
$value = $fields[$field_name];
} else {
throw new \Exception("Field '$field_name' is not present in the current result set.\n");
}
return $value;
} catch (\PDOException $e) {
die('Error: ' . $e->getMessage());
} catch (\Exception $e) {
die("Error: " . $e->getMessage());
}
} | php | public function getFieldValue(string $field_name)
{
try {
$value = null;
$fields = $this->stmt->fetch(\PDO::FETCH_ASSOC);
if (array_key_exists($field_name, $fields)) {
$value = $fields[$field_name];
} else {
throw new \Exception("Field '$field_name' is not present in the current result set.\n");
}
return $value;
} catch (\PDOException $e) {
die('Error: ' . $e->getMessage());
} catch (\Exception $e) {
die("Error: " . $e->getMessage());
}
} | [
"public",
"function",
"getFieldValue",
"(",
"string",
"$",
"field_name",
")",
"{",
"try",
"{",
"$",
"value",
"=",
"null",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"stmt",
"->",
"fetch",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"field_name",
",",
"$",
"fields",
")",
")",
"{",
"$",
"value",
"=",
"$",
"fields",
"[",
"$",
"field_name",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Field '$field_name' is not present in the current result set.\\n\"",
")",
";",
"}",
"return",
"$",
"value",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"die",
"(",
"'Error: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"die",
"(",
"\"Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Returns field's value
@param string $field_name Field's name
@return mixed Field's value | [
"Returns",
"field",
"s",
"value"
] | afe80d80b3377ef1fbeecd370bbf46568ae699ba | https://github.com/garkavenkov/db-connector/blob/afe80d80b3377ef1fbeecd370bbf46568ae699ba/src/DBConnect.php#L248-L264 |
4,463 | garkavenkov/db-connector | src/DBConnect.php | DBConnect.getFieldValues | public function getFieldValues(string $field_name)
{
try {
$field = [];
$result = $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
if (array_key_exists($field_name, $result[0])) {
foreach ($result as $row) {
$field[] = $row[$field_name];
}
} else {
throw new \Exception("Field '$field_name' is not present in the current result set.\n");
}
return $field;
} catch (\PDOException $e) {
die('Error: ' . $e->getMessage());
} catch (\Exception $e) {
die("Error: " . $e->getMessage());
}
} | php | public function getFieldValues(string $field_name)
{
try {
$field = [];
$result = $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
if (array_key_exists($field_name, $result[0])) {
foreach ($result as $row) {
$field[] = $row[$field_name];
}
} else {
throw new \Exception("Field '$field_name' is not present in the current result set.\n");
}
return $field;
} catch (\PDOException $e) {
die('Error: ' . $e->getMessage());
} catch (\Exception $e) {
die("Error: " . $e->getMessage());
}
} | [
"public",
"function",
"getFieldValues",
"(",
"string",
"$",
"field_name",
")",
"{",
"try",
"{",
"$",
"field",
"=",
"[",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"stmt",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"field_name",
",",
"$",
"result",
"[",
"0",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"result",
"as",
"$",
"row",
")",
"{",
"$",
"field",
"[",
"]",
"=",
"$",
"row",
"[",
"$",
"field_name",
"]",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Field '$field_name' is not present in the current result set.\\n\"",
")",
";",
"}",
"return",
"$",
"field",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"die",
"(",
"'Error: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"die",
"(",
"\"Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Returns field's values
@param string $field_name Field's name
@return array Array with field's values | [
"Returns",
"field",
"s",
"values"
] | afe80d80b3377ef1fbeecd370bbf46568ae699ba | https://github.com/garkavenkov/db-connector/blob/afe80d80b3377ef1fbeecd370bbf46568ae699ba/src/DBConnect.php#L272-L290 |
4,464 | FiveLab/Transactional | src/Proxy/Generator/ProxyFileGenerator.php | ProxyFileGenerator.generate | public function generate(): string
{
$namespace = $this->reflectionClass->getNamespaceName();
$fileDirectory = \rtrim($this->directory, '/') . '/Proxy/' . \str_replace('\\', '/', $namespace);
$fileName = $this->reflectionClass->getShortName() . 'Proxy.php';
$filePath = $fileDirectory . '/' . $fileName;
if (!\is_dir($fileDirectory)) {
// Try create directory
if (false === @\mkdir($fileDirectory, 0777, true)) {
throw new \RuntimeException(sprintf(
'Could not create directory "%s" for proxy file. Maybe not rights?',
$fileDirectory
));
}
} else if (!\is_writable($fileDirectory)) {
throw new \RuntimeException(sprintf(
'Cannot write to "%s" directory for save proxy file.',
$fileDirectory
));
}
// Create file
if (false === @\touch($filePath)) {
throw new \RuntimeException(sprintf(
'Could not create file "%s" for proxy class. Maybe not rights?',
$filePath
));
}
\file_put_contents($filePath, $this->codeGenerator->generate());
return $filePath;
} | php | public function generate(): string
{
$namespace = $this->reflectionClass->getNamespaceName();
$fileDirectory = \rtrim($this->directory, '/') . '/Proxy/' . \str_replace('\\', '/', $namespace);
$fileName = $this->reflectionClass->getShortName() . 'Proxy.php';
$filePath = $fileDirectory . '/' . $fileName;
if (!\is_dir($fileDirectory)) {
// Try create directory
if (false === @\mkdir($fileDirectory, 0777, true)) {
throw new \RuntimeException(sprintf(
'Could not create directory "%s" for proxy file. Maybe not rights?',
$fileDirectory
));
}
} else if (!\is_writable($fileDirectory)) {
throw new \RuntimeException(sprintf(
'Cannot write to "%s" directory for save proxy file.',
$fileDirectory
));
}
// Create file
if (false === @\touch($filePath)) {
throw new \RuntimeException(sprintf(
'Could not create file "%s" for proxy class. Maybe not rights?',
$filePath
));
}
\file_put_contents($filePath, $this->codeGenerator->generate());
return $filePath;
} | [
"public",
"function",
"generate",
"(",
")",
":",
"string",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getNamespaceName",
"(",
")",
";",
"$",
"fileDirectory",
"=",
"\\",
"rtrim",
"(",
"$",
"this",
"->",
"directory",
",",
"'/'",
")",
".",
"'/Proxy/'",
".",
"\\",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"namespace",
")",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getShortName",
"(",
")",
".",
"'Proxy.php'",
";",
"$",
"filePath",
"=",
"$",
"fileDirectory",
".",
"'/'",
".",
"$",
"fileName",
";",
"if",
"(",
"!",
"\\",
"is_dir",
"(",
"$",
"fileDirectory",
")",
")",
"{",
"// Try create directory",
"if",
"(",
"false",
"===",
"@",
"\\",
"mkdir",
"(",
"$",
"fileDirectory",
",",
"0777",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Could not create directory \"%s\" for proxy file. Maybe not rights?'",
",",
"$",
"fileDirectory",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"\\",
"is_writable",
"(",
"$",
"fileDirectory",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Cannot write to \"%s\" directory for save proxy file.'",
",",
"$",
"fileDirectory",
")",
")",
";",
"}",
"// Create file",
"if",
"(",
"false",
"===",
"@",
"\\",
"touch",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Could not create file \"%s\" for proxy class. Maybe not rights?'",
",",
"$",
"filePath",
")",
")",
";",
"}",
"\\",
"file_put_contents",
"(",
"$",
"filePath",
",",
"$",
"this",
"->",
"codeGenerator",
"->",
"generate",
"(",
")",
")",
";",
"return",
"$",
"filePath",
";",
"}"
] | Generate proxy file
@return string | [
"Generate",
"proxy",
"file"
] | d2a406543f9eab35ad618d7f4436090487508fc9 | https://github.com/FiveLab/Transactional/blob/d2a406543f9eab35ad618d7f4436090487508fc9/src/Proxy/Generator/ProxyFileGenerator.php#L66-L99 |
4,465 | WellCommerce/DataSet | Context/TreeContext.php | TreeContext.buildTree | private function buildTree(array $rows, $parent = null)
{
$tree = [];
foreach ($rows as &$row) {
if ($row['parent'] == $parent) {
$hasChildren = $this->propertyAccessor->getValue($row, "[{$this->options['children_column']}]");
$row['hasChildren'] = (bool)($hasChildren > 0);
$row['children'] = $this->buildTree($rows, $row['id']);
$tree[] = $row;
}
}
return $tree;
} | php | private function buildTree(array $rows, $parent = null)
{
$tree = [];
foreach ($rows as &$row) {
if ($row['parent'] == $parent) {
$hasChildren = $this->propertyAccessor->getValue($row, "[{$this->options['children_column']}]");
$row['hasChildren'] = (bool)($hasChildren > 0);
$row['children'] = $this->buildTree($rows, $row['id']);
$tree[] = $row;
}
}
return $tree;
} | [
"private",
"function",
"buildTree",
"(",
"array",
"$",
"rows",
",",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"tree",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rows",
"as",
"&",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"[",
"'parent'",
"]",
"==",
"$",
"parent",
")",
"{",
"$",
"hasChildren",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"row",
",",
"\"[{$this->options['children_column']}]\"",
")",
";",
"$",
"row",
"[",
"'hasChildren'",
"]",
"=",
"(",
"bool",
")",
"(",
"$",
"hasChildren",
">",
"0",
")",
";",
"$",
"row",
"[",
"'children'",
"]",
"=",
"$",
"this",
"->",
"buildTree",
"(",
"$",
"rows",
",",
"$",
"row",
"[",
"'id'",
"]",
")",
";",
"$",
"tree",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"}",
"return",
"$",
"tree",
";",
"}"
] | Creates nested tree structure from result rows
@param array $rows
@param null $parent
@return array | [
"Creates",
"nested",
"tree",
"structure",
"from",
"result",
"rows"
] | 18720dc5416f245d22c502ceafce1a1b2db2b905 | https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Context/TreeContext.php#L46-L60 |
4,466 | nirix/radium | src/Application.php | Application.loadDatabaseConfig | protected function loadDatabaseConfig()
{
if (!$this->databaseConfigFile) {
return null;
}
$configPath = "{$this->path}/{$this->databaseConfigFile}";
if (file_exists($configPath)) {
$this->databaseConfig = require $configPath;
} else {
throw new Exception("Unable to load database configuration.");
}
} | php | protected function loadDatabaseConfig()
{
if (!$this->databaseConfigFile) {
return null;
}
$configPath = "{$this->path}/{$this->databaseConfigFile}";
if (file_exists($configPath)) {
$this->databaseConfig = require $configPath;
} else {
throw new Exception("Unable to load database configuration.");
}
} | [
"protected",
"function",
"loadDatabaseConfig",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"databaseConfigFile",
")",
"{",
"return",
"null",
";",
"}",
"$",
"configPath",
"=",
"\"{$this->path}/{$this->databaseConfigFile}\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"configPath",
")",
")",
"{",
"$",
"this",
"->",
"databaseConfig",
"=",
"require",
"$",
"configPath",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Unable to load database configuration.\"",
")",
";",
"}",
"}"
] | Loads the database configuration file. | [
"Loads",
"the",
"database",
"configuration",
"file",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Application.php#L98-L110 |
4,467 | CupOfTea696/WordPress-Lib | src/View/Blade.php | Blade.compileWhile | public function compileWhile($expression)
{
$expression = $this->normalizeExpression($expression);
preg_match('/ *(.*?) *(?:, *(.*))? *$/is', $expression, $matches);
$iteration = isset($matches[2]) ? trim($matches[1]) : $expression;
$length = isset($matches[2]) ? trim($matches[2]) : '';
$initLoop = '$loop = new ' . Counter::class . "(); \$__currentLoopData = \$loop->start({$length}); \$__loops->addLoop(\$__currentLoopData);";
return "<?php {$initLoop} while({$iteration}): ?>";
} | php | public function compileWhile($expression)
{
$expression = $this->normalizeExpression($expression);
preg_match('/ *(.*?) *(?:, *(.*))? *$/is', $expression, $matches);
$iteration = isset($matches[2]) ? trim($matches[1]) : $expression;
$length = isset($matches[2]) ? trim($matches[2]) : '';
$initLoop = '$loop = new ' . Counter::class . "(); \$__currentLoopData = \$loop->start({$length}); \$__loops->addLoop(\$__currentLoopData);";
return "<?php {$initLoop} while({$iteration}): ?>";
} | [
"public",
"function",
"compileWhile",
"(",
"$",
"expression",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"normalizeExpression",
"(",
"$",
"expression",
")",
";",
"preg_match",
"(",
"'/ *(.*?) *(?:, *(.*))? *$/is'",
",",
"$",
"expression",
",",
"$",
"matches",
")",
";",
"$",
"iteration",
"=",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"?",
"trim",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
":",
"$",
"expression",
";",
"$",
"length",
"=",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"?",
"trim",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
":",
"''",
";",
"$",
"initLoop",
"=",
"'$loop = new '",
".",
"Counter",
"::",
"class",
".",
"\"(); \\$__currentLoopData = \\$loop->start({$length}); \\$__loops->addLoop(\\$__currentLoopData);\"",
";",
"return",
"\"<?php {$initLoop} while({$iteration}): ?>\"",
";",
"}"
] | Compile the while statements into valid PHP.
@param string $expression
@return string | [
"Compile",
"the",
"while",
"statements",
"into",
"valid",
"PHP",
"."
] | 7b31413dff6f4f70b3e2a2fc8172d0721152891d | https://github.com/CupOfTea696/WordPress-Lib/blob/7b31413dff6f4f70b3e2a2fc8172d0721152891d/src/View/Blade.php#L200-L212 |
4,468 | sulazix/SeanceBundle | Controller/ExportController.php | ExportController.exportToPDFAction | public function exportToPDFAction(Meeting $meeting) {
$html = $this->render("InterneSeanceBundle:Export:pdf_export.html.twig", ["meeting" => $meeting])->getContent();
//return new Response($html);
//*
$html2pdf = $this->get('html2pdf_factory')->create();
$html2pdf->WriteHTML($html);
$html2pdf->pdf->SetTitle($meeting->getName());
$file = $html2pdf->Output("export_". strtolower($meeting->getName()) . ".pdf", "I");
//*/
} | php | public function exportToPDFAction(Meeting $meeting) {
$html = $this->render("InterneSeanceBundle:Export:pdf_export.html.twig", ["meeting" => $meeting])->getContent();
//return new Response($html);
//*
$html2pdf = $this->get('html2pdf_factory')->create();
$html2pdf->WriteHTML($html);
$html2pdf->pdf->SetTitle($meeting->getName());
$file = $html2pdf->Output("export_". strtolower($meeting->getName()) . ".pdf", "I");
//*/
} | [
"public",
"function",
"exportToPDFAction",
"(",
"Meeting",
"$",
"meeting",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"render",
"(",
"\"InterneSeanceBundle:Export:pdf_export.html.twig\"",
",",
"[",
"\"meeting\"",
"=>",
"$",
"meeting",
"]",
")",
"->",
"getContent",
"(",
")",
";",
"//return new Response($html);",
"//*",
"$",
"html2pdf",
"=",
"$",
"this",
"->",
"get",
"(",
"'html2pdf_factory'",
")",
"->",
"create",
"(",
")",
";",
"$",
"html2pdf",
"->",
"WriteHTML",
"(",
"$",
"html",
")",
";",
"$",
"html2pdf",
"->",
"pdf",
"->",
"SetTitle",
"(",
"$",
"meeting",
"->",
"getName",
"(",
")",
")",
";",
"$",
"file",
"=",
"$",
"html2pdf",
"->",
"Output",
"(",
"\"export_\"",
".",
"strtolower",
"(",
"$",
"meeting",
"->",
"getName",
"(",
")",
")",
".",
"\".pdf\"",
",",
"\"I\"",
")",
";",
"//*/",
"}"
] | Generate a PDF for a given Meeting entity | [
"Generate",
"a",
"PDF",
"for",
"a",
"given",
"Meeting",
"entity"
] | 6818f261dc5ca13a8f9664a46fad9bba273559c1 | https://github.com/sulazix/SeanceBundle/blob/6818f261dc5ca13a8f9664a46fad9bba273559c1/Controller/ExportController.php#L27-L39 |
4,469 | mszewcz/php-light-framework | src/Db/MySQL.php | MySQL.getInstance | public static function getInstance($driverName = null): AbstractMySQL
{
if (!static::$initialized) {
static::$baseClass = Base::getInstance();
}
$driverName = $driverName!==null
? '\\MS\\LightFramework\\Db\\MySQL\\Drivers\\'.$driverName
: '\\MS\\LightFramework\\Db\\MySQL\\Drivers\\'.((string) static::$baseClass->Database->MySQL->driverClass);
/** @noinspection PhpUndefinedMethodInspection */
$driver = $driverName::getInstance();
// @codeCoverageIgnoreStart
if (!($driver instanceof AbstractMySQL)) {
throw new RuntimeException('MySQL driver must extend \\MS\\LightFramework\\Db\\MySQL\\AbstractMySQL');
}
// @codeCoverageIgnoreEnd
return $driver;
} | php | public static function getInstance($driverName = null): AbstractMySQL
{
if (!static::$initialized) {
static::$baseClass = Base::getInstance();
}
$driverName = $driverName!==null
? '\\MS\\LightFramework\\Db\\MySQL\\Drivers\\'.$driverName
: '\\MS\\LightFramework\\Db\\MySQL\\Drivers\\'.((string) static::$baseClass->Database->MySQL->driverClass);
/** @noinspection PhpUndefinedMethodInspection */
$driver = $driverName::getInstance();
// @codeCoverageIgnoreStart
if (!($driver instanceof AbstractMySQL)) {
throw new RuntimeException('MySQL driver must extend \\MS\\LightFramework\\Db\\MySQL\\AbstractMySQL');
}
// @codeCoverageIgnoreEnd
return $driver;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"driverName",
"=",
"null",
")",
":",
"AbstractMySQL",
"{",
"if",
"(",
"!",
"static",
"::",
"$",
"initialized",
")",
"{",
"static",
"::",
"$",
"baseClass",
"=",
"Base",
"::",
"getInstance",
"(",
")",
";",
"}",
"$",
"driverName",
"=",
"$",
"driverName",
"!==",
"null",
"?",
"'\\\\MS\\\\LightFramework\\\\Db\\\\MySQL\\\\Drivers\\\\'",
".",
"$",
"driverName",
":",
"'\\\\MS\\\\LightFramework\\\\Db\\\\MySQL\\\\Drivers\\\\'",
".",
"(",
"(",
"string",
")",
"static",
"::",
"$",
"baseClass",
"->",
"Database",
"->",
"MySQL",
"->",
"driverClass",
")",
";",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"driver",
"=",
"$",
"driverName",
"::",
"getInstance",
"(",
")",
";",
"// @codeCoverageIgnoreStart",
"if",
"(",
"!",
"(",
"$",
"driver",
"instanceof",
"AbstractMySQL",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'MySQL driver must extend \\\\MS\\\\LightFramework\\\\Db\\\\MySQL\\\\AbstractMySQL'",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"return",
"$",
"driver",
";",
"}"
] | Returns MySQL driver according to configuration.
@param string|null $driverName
@return AbstractMySQL | [
"Returns",
"MySQL",
"driver",
"according",
"to",
"configuration",
"."
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL.php#L34-L52 |
4,470 | mtoolkit/mtoolkit-core | src/MCoreApplication.php | MCoreApplication.setIsDebug | public static function setIsDebug(bool $bool): void
{
if (self::isCliApp()) {
self::$IS_DEBUG = $bool;
} else {
MSession::set(MCoreApplication::DEBUG, $bool);
}
} | php | public static function setIsDebug(bool $bool): void
{
if (self::isCliApp()) {
self::$IS_DEBUG = $bool;
} else {
MSession::set(MCoreApplication::DEBUG, $bool);
}
} | [
"public",
"static",
"function",
"setIsDebug",
"(",
"bool",
"$",
"bool",
")",
":",
"void",
"{",
"if",
"(",
"self",
"::",
"isCliApp",
"(",
")",
")",
"{",
"self",
"::",
"$",
"IS_DEBUG",
"=",
"$",
"bool",
";",
"}",
"else",
"{",
"MSession",
"::",
"set",
"(",
"MCoreApplication",
"::",
"DEBUG",
",",
"$",
"bool",
")",
";",
"}",
"}"
] | Set the debug mode.
@param bool $bool | [
"Set",
"the",
"debug",
"mode",
"."
] | 66c53273288a8652ff38240e063bdcffdf7c30aa | https://github.com/mtoolkit/mtoolkit-core/blob/66c53273288a8652ff38240e063bdcffdf7c30aa/src/MCoreApplication.php#L86-L93 |
4,471 | mtoolkit/mtoolkit-core | src/MCoreApplication.php | MCoreApplication.getApplicationDirPath | public static function getApplicationDirPath():?MApplicationDir
{
if (self::isCliApp()) {
return self::$APPLICATION_DIR_PATH;
}
return MSession::get(MCoreApplication::APPLICATION_DIR_PATH);
} | php | public static function getApplicationDirPath():?MApplicationDir
{
if (self::isCliApp()) {
return self::$APPLICATION_DIR_PATH;
}
return MSession::get(MCoreApplication::APPLICATION_DIR_PATH);
} | [
"public",
"static",
"function",
"getApplicationDirPath",
"(",
")",
":",
"?",
"MApplicationDir",
"{",
"if",
"(",
"self",
"::",
"isCliApp",
"(",
")",
")",
"{",
"return",
"self",
"::",
"$",
"APPLICATION_DIR_PATH",
";",
"}",
"return",
"MSession",
"::",
"get",
"(",
"MCoreApplication",
"::",
"APPLICATION_DIR_PATH",
")",
";",
"}"
] | Return the root path of the project.
@return MApplicationDir|null | [
"Return",
"the",
"root",
"path",
"of",
"the",
"project",
"."
] | 66c53273288a8652ff38240e063bdcffdf7c30aa | https://github.com/mtoolkit/mtoolkit-core/blob/66c53273288a8652ff38240e063bdcffdf7c30aa/src/MCoreApplication.php#L150-L157 |
4,472 | veonik/VeonikBlogBundle | src/Controller/Admin/AuthorController.php | AuthorController.newAction | public function newAction()
{
$entity = new Author();
$form = $this->createForm(new AuthorType(), $entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | php | public function newAction()
{
$entity = new Author();
$form = $this->createForm(new AuthorType(), $entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"entity",
"=",
"new",
"Author",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"AuthorType",
"(",
")",
",",
"$",
"entity",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to create a new Author entity.
@Route("/new", name="manage_author_new")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Author",
"entity",
"."
] | 52cca6b37feadd77fa564600b4db0e8e196099dd | https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/Admin/AuthorController.php#L71-L80 |
4,473 | easy-system/es-view-helpers | src/ViewHelpers.php | ViewHelpers.getHelper | public function getHelper($name, array $options = [])
{
$helper = $this->get($name);
if (! empty($options) && is_callable([$helper, 'setOptions'])) {
$helper->setOptions($options);
}
return $helper;
} | php | public function getHelper($name, array $options = [])
{
$helper = $this->get($name);
if (! empty($options) && is_callable([$helper, 'setOptions'])) {
$helper->setOptions($options);
}
return $helper;
} | [
"public",
"function",
"getHelper",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"helper",
",",
"'setOptions'",
"]",
")",
")",
"{",
"$",
"helper",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"}",
"return",
"$",
"helper",
";",
"}"
] | Gets the helper and sets its options.
@param string $name The helper name
@param array $options Optional; the helper options
@return mixed The requested helper | [
"Gets",
"the",
"helper",
"and",
"sets",
"its",
"options",
"."
] | 39755d07dea63d525fb85d989bb095c89d805e9a | https://github.com/easy-system/es-view-helpers/blob/39755d07dea63d525fb85d989bb095c89d805e9a/src/ViewHelpers.php#L58-L66 |
4,474 | easy-system/es-view-helpers | src/ViewHelpers.php | ViewHelpers.merge | public function merge(ViewHelpersInterface $source)
{
$this->registry = array_merge($this->registry, $source->getRegistry());
$this->instances = array_merge($this->instances, $source->getInstances());
return $this;
} | php | public function merge(ViewHelpersInterface $source)
{
$this->registry = array_merge($this->registry, $source->getRegistry());
$this->instances = array_merge($this->instances, $source->getInstances());
return $this;
} | [
"public",
"function",
"merge",
"(",
"ViewHelpersInterface",
"$",
"source",
")",
"{",
"$",
"this",
"->",
"registry",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"registry",
",",
"$",
"source",
"->",
"getRegistry",
"(",
")",
")",
";",
"$",
"this",
"->",
"instances",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"instances",
",",
"$",
"source",
"->",
"getInstances",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Merges with other view helpers.
@param \Es\Mvc\ViewHelpersInterface $source The data source
@return self | [
"Merges",
"with",
"other",
"view",
"helpers",
"."
] | 39755d07dea63d525fb85d989bb095c89d805e9a | https://github.com/easy-system/es-view-helpers/blob/39755d07dea63d525fb85d989bb095c89d805e9a/src/ViewHelpers.php#L75-L81 |
4,475 | phossa2/libs | src/Phossa2/Route/Parser/ParserStd.php | ParserStd.removeNumericAndEmpty | protected function removeNumericAndEmpty(array &$matches)
{
foreach ($matches as $idx => $val) {
if (is_int($idx) || '' === $val) {
unset($matches[$idx]);
}
}
} | php | protected function removeNumericAndEmpty(array &$matches)
{
foreach ($matches as $idx => $val) {
if (is_int($idx) || '' === $val) {
unset($matches[$idx]);
}
}
} | [
"protected",
"function",
"removeNumericAndEmpty",
"(",
"array",
"&",
"$",
"matches",
")",
"{",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"idx",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"idx",
")",
"||",
"''",
"===",
"$",
"val",
")",
"{",
"unset",
"(",
"$",
"matches",
"[",
"$",
"idx",
"]",
")",
";",
"}",
"}",
"}"
] | remove numeric keys and empty group match
@param array $matches
@access protected | [
"remove",
"numeric",
"keys",
"and",
"empty",
"group",
"match"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Parser/ParserStd.php#L159-L166 |
4,476 | OpenResourceManager/client-php | src/Client/MobilePhone.php | MobilePhone.store | public function store(
$account_id = null,
$identifier = null,
$username = null,
$number,
$country_code = null,
$mobile_carrier_id = null,
$mobile_carrier_code = null,
$verified = null,
$upstream_app_name = null,
$verification_callback = null
)
{
$fields = [];
//@todo validate params, throw exception when they are missing
if (!is_null($account_id)) $fields['account_id'] = $account_id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
$fields['number'] = $number;
if (!is_null($country_code)) $fields['country_code'] = $country_code;
if (!is_null($mobile_carrier_id)) $fields['mobile_carrier_id'] = $mobile_carrier_id;
if (!is_null($mobile_carrier_code)) $fields['mobile_carrier_code'] = $mobile_carrier_code;
if (!is_null($verified)) $fields['verified'] = $verified;
if (!is_null($upstream_app_name)) $fields['upstream_app_name'] = $upstream_app_name;
if (!is_null($verification_callback)) $fields['verification_callback'] = $verification_callback;
return $this->_post($fields);
} | php | public function store(
$account_id = null,
$identifier = null,
$username = null,
$number,
$country_code = null,
$mobile_carrier_id = null,
$mobile_carrier_code = null,
$verified = null,
$upstream_app_name = null,
$verification_callback = null
)
{
$fields = [];
//@todo validate params, throw exception when they are missing
if (!is_null($account_id)) $fields['account_id'] = $account_id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
$fields['number'] = $number;
if (!is_null($country_code)) $fields['country_code'] = $country_code;
if (!is_null($mobile_carrier_id)) $fields['mobile_carrier_id'] = $mobile_carrier_id;
if (!is_null($mobile_carrier_code)) $fields['mobile_carrier_code'] = $mobile_carrier_code;
if (!is_null($verified)) $fields['verified'] = $verified;
if (!is_null($upstream_app_name)) $fields['upstream_app_name'] = $upstream_app_name;
if (!is_null($verification_callback)) $fields['verification_callback'] = $verification_callback;
return $this->_post($fields);
} | [
"public",
"function",
"store",
"(",
"$",
"account_id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"number",
",",
"$",
"country_code",
"=",
"null",
",",
"$",
"mobile_carrier_id",
"=",
"null",
",",
"$",
"mobile_carrier_code",
"=",
"null",
",",
"$",
"verified",
"=",
"null",
",",
"$",
"upstream_app_name",
"=",
"null",
",",
"$",
"verification_callback",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"//@todo validate params, throw exception when they are missing",
"if",
"(",
"!",
"is_null",
"(",
"$",
"account_id",
")",
")",
"$",
"fields",
"[",
"'account_id'",
"]",
"=",
"$",
"account_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"$",
"fields",
"[",
"'number'",
"]",
"=",
"$",
"number",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"country_code",
")",
")",
"$",
"fields",
"[",
"'country_code'",
"]",
"=",
"$",
"country_code",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"mobile_carrier_id",
")",
")",
"$",
"fields",
"[",
"'mobile_carrier_id'",
"]",
"=",
"$",
"mobile_carrier_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"mobile_carrier_code",
")",
")",
"$",
"fields",
"[",
"'mobile_carrier_code'",
"]",
"=",
"$",
"mobile_carrier_code",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"verified",
")",
")",
"$",
"fields",
"[",
"'verified'",
"]",
"=",
"$",
"verified",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"upstream_app_name",
")",
")",
"$",
"fields",
"[",
"'upstream_app_name'",
"]",
"=",
"$",
"upstream_app_name",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"verification_callback",
")",
")",
"$",
"fields",
"[",
"'verification_callback'",
"]",
"=",
"$",
"verification_callback",
";",
"return",
"$",
"this",
"->",
"_post",
"(",
"$",
"fields",
")",
";",
"}"
] | Create Or Update Mobile Phone
Create or update a mobile phone, based the phone number.
An account ID, identifier, or username can be provided to associate the mobile phone with an account.
@param int $account_id
@param string $identifier
@param string $username
@param string $number
@param string $country_code
@param int $mobile_carrier_id
@param string $mobile_carrier_code
@param boolean $verified
@param string $upstream_app_name
@param string $verification_callback
@return \Unirest\Response | [
"Create",
"Or",
"Update",
"Mobile",
"Phone"
] | fa468e3425d32f97294fefed77a7f096f3f8cc86 | https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/MobilePhone.php#L198-L225 |
4,477 | aaronsaray/wordpress-plugin-on-github | src/UpdateWatcher.php | UpdateWatcher.filterPreSetSiteTransientUpdatePlugins | public function filterPreSetSiteTransientUpdatePlugins($transient)
{
$this->updatePluginData();
$this->updateGithubData();
if (version_compare($this->githubLatestRelease['tag_name'], $this->pluginData['Version']) === 1) {
$update = new \stdClass();
$update->slug = $this->pluginSlug;
$update->new_version = $this->githubLatestRelease['tag_name'];
$update->url = $this->pluginData['PluginURI'];
$update->package = $this->githubLatestRelease['zipball_url'];
$transient->response[$this->pluginBaseName] = $update;
}
return $transient;
} | php | public function filterPreSetSiteTransientUpdatePlugins($transient)
{
$this->updatePluginData();
$this->updateGithubData();
if (version_compare($this->githubLatestRelease['tag_name'], $this->pluginData['Version']) === 1) {
$update = new \stdClass();
$update->slug = $this->pluginSlug;
$update->new_version = $this->githubLatestRelease['tag_name'];
$update->url = $this->pluginData['PluginURI'];
$update->package = $this->githubLatestRelease['zipball_url'];
$transient->response[$this->pluginBaseName] = $update;
}
return $transient;
} | [
"public",
"function",
"filterPreSetSiteTransientUpdatePlugins",
"(",
"$",
"transient",
")",
"{",
"$",
"this",
"->",
"updatePluginData",
"(",
")",
";",
"$",
"this",
"->",
"updateGithubData",
"(",
")",
";",
"if",
"(",
"version_compare",
"(",
"$",
"this",
"->",
"githubLatestRelease",
"[",
"'tag_name'",
"]",
",",
"$",
"this",
"->",
"pluginData",
"[",
"'Version'",
"]",
")",
"===",
"1",
")",
"{",
"$",
"update",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"update",
"->",
"slug",
"=",
"$",
"this",
"->",
"pluginSlug",
";",
"$",
"update",
"->",
"new_version",
"=",
"$",
"this",
"->",
"githubLatestRelease",
"[",
"'tag_name'",
"]",
";",
"$",
"update",
"->",
"url",
"=",
"$",
"this",
"->",
"pluginData",
"[",
"'PluginURI'",
"]",
";",
"$",
"update",
"->",
"package",
"=",
"$",
"this",
"->",
"githubLatestRelease",
"[",
"'zipball_url'",
"]",
";",
"$",
"transient",
"->",
"response",
"[",
"$",
"this",
"->",
"pluginBaseName",
"]",
"=",
"$",
"update",
";",
"}",
"return",
"$",
"transient",
";",
"}"
] | Add in plugin information in order to get updates
@param $transient object
@return object | [
"Add",
"in",
"plugin",
"information",
"in",
"order",
"to",
"get",
"updates"
] | b79a81a5316f26cad6f0a5e992ccc9252187f9b5 | https://github.com/aaronsaray/wordpress-plugin-on-github/blob/b79a81a5316f26cad6f0a5e992ccc9252187f9b5/src/UpdateWatcher.php#L73-L89 |
4,478 | aaronsaray/wordpress-plugin-on-github | src/UpdateWatcher.php | UpdateWatcher.filterPluginsApi | public function filterPluginsApi($false, $action, $response)
{
// basically, verify we're working with our plugin
if (empty($response->slug)) return false;
$this->updatePluginData();
if ($response->slug != $this->pluginSlug) return false;
// it's ours, so update the data
$this->updateGithubData();
$response->last_updated = $this->githubLatestRelease['published_at'];
$response->slug = $this->pluginSlug;
$response->name = $this->pluginData["Name"];
$response->version = $this->githubLatestRelease['tag_name'];
$response->author = $this->pluginData["AuthorName"];
$response->homepage = $this->pluginData["PluginURI"];
$response->download_link = $this->githubLatestRelease['zipball_url'];
$parsedown = new \Parsedown();
$response->sections = [
'description' => $this->pluginData['Description'],
'changelog' => $parsedown->text($this->githubLatestRelease['body'])
];
return $response;
} | php | public function filterPluginsApi($false, $action, $response)
{
// basically, verify we're working with our plugin
if (empty($response->slug)) return false;
$this->updatePluginData();
if ($response->slug != $this->pluginSlug) return false;
// it's ours, so update the data
$this->updateGithubData();
$response->last_updated = $this->githubLatestRelease['published_at'];
$response->slug = $this->pluginSlug;
$response->name = $this->pluginData["Name"];
$response->version = $this->githubLatestRelease['tag_name'];
$response->author = $this->pluginData["AuthorName"];
$response->homepage = $this->pluginData["PluginURI"];
$response->download_link = $this->githubLatestRelease['zipball_url'];
$parsedown = new \Parsedown();
$response->sections = [
'description' => $this->pluginData['Description'],
'changelog' => $parsedown->text($this->githubLatestRelease['body'])
];
return $response;
} | [
"public",
"function",
"filterPluginsApi",
"(",
"$",
"false",
",",
"$",
"action",
",",
"$",
"response",
")",
"{",
"// basically, verify we're working with our plugin",
"if",
"(",
"empty",
"(",
"$",
"response",
"->",
"slug",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"updatePluginData",
"(",
")",
";",
"if",
"(",
"$",
"response",
"->",
"slug",
"!=",
"$",
"this",
"->",
"pluginSlug",
")",
"return",
"false",
";",
"// it's ours, so update the data",
"$",
"this",
"->",
"updateGithubData",
"(",
")",
";",
"$",
"response",
"->",
"last_updated",
"=",
"$",
"this",
"->",
"githubLatestRelease",
"[",
"'published_at'",
"]",
";",
"$",
"response",
"->",
"slug",
"=",
"$",
"this",
"->",
"pluginSlug",
";",
"$",
"response",
"->",
"name",
"=",
"$",
"this",
"->",
"pluginData",
"[",
"\"Name\"",
"]",
";",
"$",
"response",
"->",
"version",
"=",
"$",
"this",
"->",
"githubLatestRelease",
"[",
"'tag_name'",
"]",
";",
"$",
"response",
"->",
"author",
"=",
"$",
"this",
"->",
"pluginData",
"[",
"\"AuthorName\"",
"]",
";",
"$",
"response",
"->",
"homepage",
"=",
"$",
"this",
"->",
"pluginData",
"[",
"\"PluginURI\"",
"]",
";",
"$",
"response",
"->",
"download_link",
"=",
"$",
"this",
"->",
"githubLatestRelease",
"[",
"'zipball_url'",
"]",
";",
"$",
"parsedown",
"=",
"new",
"\\",
"Parsedown",
"(",
")",
";",
"$",
"response",
"->",
"sections",
"=",
"[",
"'description'",
"=>",
"$",
"this",
"->",
"pluginData",
"[",
"'Description'",
"]",
",",
"'changelog'",
"=>",
"$",
"parsedown",
"->",
"text",
"(",
"$",
"this",
"->",
"githubLatestRelease",
"[",
"'body'",
"]",
")",
"]",
";",
"return",
"$",
"response",
";",
"}"
] | This updates the details for showing information in the modal
@param $false
@param $action
@param $response
@return mixed | [
"This",
"updates",
"the",
"details",
"for",
"showing",
"information",
"in",
"the",
"modal"
] | b79a81a5316f26cad6f0a5e992ccc9252187f9b5 | https://github.com/aaronsaray/wordpress-plugin-on-github/blob/b79a81a5316f26cad6f0a5e992ccc9252187f9b5/src/UpdateWatcher.php#L99-L125 |
4,479 | aaronsaray/wordpress-plugin-on-github | src/UpdateWatcher.php | UpdateWatcher.filterUpgraderPostInstall | public function filterUpgraderPostInstall($true, $hookExtra, $result) {
$this->updatePluginData();
$wasPluginActive = is_plugin_active($this->pluginBaseName);
global $wp_filesystem;
$pluginFolder = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . dirname($this->pluginBaseName);
$wp_filesystem->move($result['destination'], $pluginFolder);
$result['destination'] = $pluginFolder;
if ($wasPluginActive) {
$activation = activate_plugin($this->pluginBaseName);
if (is_wp_error($activation)) {
throw new \Exception('Unable to reactivate plugin: ' . $activation->get_error_message());
}
}
return $result;
} | php | public function filterUpgraderPostInstall($true, $hookExtra, $result) {
$this->updatePluginData();
$wasPluginActive = is_plugin_active($this->pluginBaseName);
global $wp_filesystem;
$pluginFolder = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . dirname($this->pluginBaseName);
$wp_filesystem->move($result['destination'], $pluginFolder);
$result['destination'] = $pluginFolder;
if ($wasPluginActive) {
$activation = activate_plugin($this->pluginBaseName);
if (is_wp_error($activation)) {
throw new \Exception('Unable to reactivate plugin: ' . $activation->get_error_message());
}
}
return $result;
} | [
"public",
"function",
"filterUpgraderPostInstall",
"(",
"$",
"true",
",",
"$",
"hookExtra",
",",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"updatePluginData",
"(",
")",
";",
"$",
"wasPluginActive",
"=",
"is_plugin_active",
"(",
"$",
"this",
"->",
"pluginBaseName",
")",
";",
"global",
"$",
"wp_filesystem",
";",
"$",
"pluginFolder",
"=",
"WP_PLUGIN_DIR",
".",
"DIRECTORY_SEPARATOR",
".",
"dirname",
"(",
"$",
"this",
"->",
"pluginBaseName",
")",
";",
"$",
"wp_filesystem",
"->",
"move",
"(",
"$",
"result",
"[",
"'destination'",
"]",
",",
"$",
"pluginFolder",
")",
";",
"$",
"result",
"[",
"'destination'",
"]",
"=",
"$",
"pluginFolder",
";",
"if",
"(",
"$",
"wasPluginActive",
")",
"{",
"$",
"activation",
"=",
"activate_plugin",
"(",
"$",
"this",
"->",
"pluginBaseName",
")",
";",
"if",
"(",
"is_wp_error",
"(",
"$",
"activation",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unable to reactivate plugin: '",
".",
"$",
"activation",
"->",
"get_error_message",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Handles the post upgrade moving of files and what not
@param $true
@param $hookExtra
@param $result
@return mixed
@throws \Exception | [
"Handles",
"the",
"post",
"upgrade",
"moving",
"of",
"files",
"and",
"what",
"not"
] | b79a81a5316f26cad6f0a5e992ccc9252187f9b5 | https://github.com/aaronsaray/wordpress-plugin-on-github/blob/b79a81a5316f26cad6f0a5e992ccc9252187f9b5/src/UpdateWatcher.php#L136-L153 |
4,480 | aaronsaray/wordpress-plugin-on-github | src/UpdateWatcher.php | UpdateWatcher.updatePluginData | protected function updatePluginData()
{
$this->pluginBaseName = \plugin_basename($this->pluginFile);
$this->pluginSlug = dirname($this->pluginBaseName);
$this->pluginData = \get_plugin_data($this->pluginFile);
} | php | protected function updatePluginData()
{
$this->pluginBaseName = \plugin_basename($this->pluginFile);
$this->pluginSlug = dirname($this->pluginBaseName);
$this->pluginData = \get_plugin_data($this->pluginFile);
} | [
"protected",
"function",
"updatePluginData",
"(",
")",
"{",
"$",
"this",
"->",
"pluginBaseName",
"=",
"\\",
"plugin_basename",
"(",
"$",
"this",
"->",
"pluginFile",
")",
";",
"$",
"this",
"->",
"pluginSlug",
"=",
"dirname",
"(",
"$",
"this",
"->",
"pluginBaseName",
")",
";",
"$",
"this",
"->",
"pluginData",
"=",
"\\",
"get_plugin_data",
"(",
"$",
"this",
"->",
"pluginFile",
")",
";",
"}"
] | Gather plugin data from the file
@note This is in a separate method because it doesn't need to be ran each time the constructor is initialized, only when callbacks are used | [
"Gather",
"plugin",
"data",
"from",
"the",
"file"
] | b79a81a5316f26cad6f0a5e992ccc9252187f9b5 | https://github.com/aaronsaray/wordpress-plugin-on-github/blob/b79a81a5316f26cad6f0a5e992ccc9252187f9b5/src/UpdateWatcher.php#L160-L165 |
4,481 | aaronsaray/wordpress-plugin-on-github | src/UpdateWatcher.php | UpdateWatcher.updateGithubData | protected function updateGithubData()
{
if (!empty($this->githubLatestRelease)) return false; // this filter gets called twice, so the second time bail.
$url = \esc_url_raw("https://api.github.com/repos/{$this->githubNamespace}/{$this->githubProject}/releases");
$response = \wp_remote_retrieve_body(\wp_remote_get($url));
if (is_wp_error($response)) {
error_log($response->get_error_message());
return false;
}
$jsonDecodedResponse = json_decode($response, true);
if (is_null($jsonDecodedResponse)) {
error_log('Unable to parse response: ' . json_last_error_msg());
return false;
}
if (empty($jsonDecodedResponse[0])) {
error_log('There is no release information gathered.');
return false;
}
$this->githubLatestRelease = $jsonDecodedResponse[0];
return true;
} | php | protected function updateGithubData()
{
if (!empty($this->githubLatestRelease)) return false; // this filter gets called twice, so the second time bail.
$url = \esc_url_raw("https://api.github.com/repos/{$this->githubNamespace}/{$this->githubProject}/releases");
$response = \wp_remote_retrieve_body(\wp_remote_get($url));
if (is_wp_error($response)) {
error_log($response->get_error_message());
return false;
}
$jsonDecodedResponse = json_decode($response, true);
if (is_null($jsonDecodedResponse)) {
error_log('Unable to parse response: ' . json_last_error_msg());
return false;
}
if (empty($jsonDecodedResponse[0])) {
error_log('There is no release information gathered.');
return false;
}
$this->githubLatestRelease = $jsonDecodedResponse[0];
return true;
} | [
"protected",
"function",
"updateGithubData",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"githubLatestRelease",
")",
")",
"return",
"false",
";",
"// this filter gets called twice, so the second time bail.",
"$",
"url",
"=",
"\\",
"esc_url_raw",
"(",
"\"https://api.github.com/repos/{$this->githubNamespace}/{$this->githubProject}/releases\"",
")",
";",
"$",
"response",
"=",
"\\",
"wp_remote_retrieve_body",
"(",
"\\",
"wp_remote_get",
"(",
"$",
"url",
")",
")",
";",
"if",
"(",
"is_wp_error",
"(",
"$",
"response",
")",
")",
"{",
"error_log",
"(",
"$",
"response",
"->",
"get_error_message",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"jsonDecodedResponse",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"jsonDecodedResponse",
")",
")",
"{",
"error_log",
"(",
"'Unable to parse response: '",
".",
"json_last_error_msg",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"jsonDecodedResponse",
"[",
"0",
"]",
")",
")",
"{",
"error_log",
"(",
"'There is no release information gathered.'",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"githubLatestRelease",
"=",
"$",
"jsonDecodedResponse",
"[",
"0",
"]",
";",
"return",
"true",
";",
"}"
] | Update the data from GitHub
@return bool | [
"Update",
"the",
"data",
"from",
"GitHub"
] | b79a81a5316f26cad6f0a5e992ccc9252187f9b5 | https://github.com/aaronsaray/wordpress-plugin-on-github/blob/b79a81a5316f26cad6f0a5e992ccc9252187f9b5/src/UpdateWatcher.php#L172-L197 |
4,482 | searsaw/Drawbridge | src/commands/MigrationsCommand.php | MigrationsCommand.createMigration | public function createMigration()
{
$migration = $this->laravel->path . '/database/migrations/' . date('Y_m_d_His') . '_drawbridge_migrations_tables.php';
$view = $this->laravel->make('view')->make('drawbridge::migration')->render();
if (! file_exists($migration))
{
$fs = fopen($migration, 'x');
if ($fs)
{
fwrite($fs, $view);
fclose($fs);
return true;
}
}
return false;
} | php | public function createMigration()
{
$migration = $this->laravel->path . '/database/migrations/' . date('Y_m_d_His') . '_drawbridge_migrations_tables.php';
$view = $this->laravel->make('view')->make('drawbridge::migration')->render();
if (! file_exists($migration))
{
$fs = fopen($migration, 'x');
if ($fs)
{
fwrite($fs, $view);
fclose($fs);
return true;
}
}
return false;
} | [
"public",
"function",
"createMigration",
"(",
")",
"{",
"$",
"migration",
"=",
"$",
"this",
"->",
"laravel",
"->",
"path",
".",
"'/database/migrations/'",
".",
"date",
"(",
"'Y_m_d_His'",
")",
".",
"'_drawbridge_migrations_tables.php'",
";",
"$",
"view",
"=",
"$",
"this",
"->",
"laravel",
"->",
"make",
"(",
"'view'",
")",
"->",
"make",
"(",
"'drawbridge::migration'",
")",
"->",
"render",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"migration",
")",
")",
"{",
"$",
"fs",
"=",
"fopen",
"(",
"$",
"migration",
",",
"'x'",
")",
";",
"if",
"(",
"$",
"fs",
")",
"{",
"fwrite",
"(",
"$",
"fs",
",",
"$",
"view",
")",
";",
"fclose",
"(",
"$",
"fs",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Create migration for tables
@return bool | [
"Create",
"migration",
"for",
"tables"
] | 156bd8238a623d245fbbbb509eb5dd148338f5a6 | https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/commands/MigrationsCommand.php#L57-L74 |
4,483 | netgen/ngclasslist | datatypes/ngclasslist/ngclasslisttype.php | NgClassListType.validateObjectAttributeHTTPInput | function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
{
$classList = $http->postVariable( $base . self::CLASS_LIST_VARIABLE . $contentObjectAttribute->attribute( "id" ), array() );
$classList = !is_array( $classList ) ? array() : $classList;
if ( empty( $classList ) && $contentObjectAttribute->validateIsRequired() )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( "kernel/classes/datatypes", "Input required." ) );
return eZInputValidator::STATE_INVALID;
}
$invalidClassIdentifiers = array();
foreach ( $classList as $classIdentifier )
{
if ( !eZContentClass::exists( $classIdentifier, eZContentClass::VERSION_STATUS_DEFINED, false, true ) )
{
$invalidClassIdentifiers[] = $classIdentifier;
}
}
if ( !empty( $invalidClassIdentifiers ) )
{
if ( count( $invalidClassIdentifiers ) == 1 )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( "extension/ngclasslist/datatypes", "Class with identifier '%identifier%' does not exist", null, array( "%identifier%" => $invalidClassIdentifiers[0] ) ) );
}
else
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( "extension/ngclasslist/datatypes", "Classes with '%identifiers%' identifiers do not exist", null, array( "%identifiers%" => implode( ", ", $invalidClassIdentifiers ) ) ) );
}
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
} | php | function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
{
$classList = $http->postVariable( $base . self::CLASS_LIST_VARIABLE . $contentObjectAttribute->attribute( "id" ), array() );
$classList = !is_array( $classList ) ? array() : $classList;
if ( empty( $classList ) && $contentObjectAttribute->validateIsRequired() )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( "kernel/classes/datatypes", "Input required." ) );
return eZInputValidator::STATE_INVALID;
}
$invalidClassIdentifiers = array();
foreach ( $classList as $classIdentifier )
{
if ( !eZContentClass::exists( $classIdentifier, eZContentClass::VERSION_STATUS_DEFINED, false, true ) )
{
$invalidClassIdentifiers[] = $classIdentifier;
}
}
if ( !empty( $invalidClassIdentifiers ) )
{
if ( count( $invalidClassIdentifiers ) == 1 )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( "extension/ngclasslist/datatypes", "Class with identifier '%identifier%' does not exist", null, array( "%identifier%" => $invalidClassIdentifiers[0] ) ) );
}
else
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( "extension/ngclasslist/datatypes", "Classes with '%identifiers%' identifiers do not exist", null, array( "%identifiers%" => implode( ", ", $invalidClassIdentifiers ) ) ) );
}
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
} | [
"function",
"validateObjectAttributeHTTPInput",
"(",
"$",
"http",
",",
"$",
"base",
",",
"$",
"contentObjectAttribute",
")",
"{",
"$",
"classList",
"=",
"$",
"http",
"->",
"postVariable",
"(",
"$",
"base",
".",
"self",
"::",
"CLASS_LIST_VARIABLE",
".",
"$",
"contentObjectAttribute",
"->",
"attribute",
"(",
"\"id\"",
")",
",",
"array",
"(",
")",
")",
";",
"$",
"classList",
"=",
"!",
"is_array",
"(",
"$",
"classList",
")",
"?",
"array",
"(",
")",
":",
"$",
"classList",
";",
"if",
"(",
"empty",
"(",
"$",
"classList",
")",
"&&",
"$",
"contentObjectAttribute",
"->",
"validateIsRequired",
"(",
")",
")",
"{",
"$",
"contentObjectAttribute",
"->",
"setValidationError",
"(",
"ezpI18n",
"::",
"tr",
"(",
"\"kernel/classes/datatypes\"",
",",
"\"Input required.\"",
")",
")",
";",
"return",
"eZInputValidator",
"::",
"STATE_INVALID",
";",
"}",
"$",
"invalidClassIdentifiers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"classList",
"as",
"$",
"classIdentifier",
")",
"{",
"if",
"(",
"!",
"eZContentClass",
"::",
"exists",
"(",
"$",
"classIdentifier",
",",
"eZContentClass",
"::",
"VERSION_STATUS_DEFINED",
",",
"false",
",",
"true",
")",
")",
"{",
"$",
"invalidClassIdentifiers",
"[",
"]",
"=",
"$",
"classIdentifier",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"invalidClassIdentifiers",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"invalidClassIdentifiers",
")",
"==",
"1",
")",
"{",
"$",
"contentObjectAttribute",
"->",
"setValidationError",
"(",
"ezpI18n",
"::",
"tr",
"(",
"\"extension/ngclasslist/datatypes\"",
",",
"\"Class with identifier '%identifier%' does not exist\"",
",",
"null",
",",
"array",
"(",
"\"%identifier%\"",
"=>",
"$",
"invalidClassIdentifiers",
"[",
"0",
"]",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"contentObjectAttribute",
"->",
"setValidationError",
"(",
"ezpI18n",
"::",
"tr",
"(",
"\"extension/ngclasslist/datatypes\"",
",",
"\"Classes with '%identifiers%' identifiers do not exist\"",
",",
"null",
",",
"array",
"(",
"\"%identifiers%\"",
"=>",
"implode",
"(",
"\", \"",
",",
"$",
"invalidClassIdentifiers",
")",
")",
")",
")",
";",
"}",
"return",
"eZInputValidator",
"::",
"STATE_INVALID",
";",
"}",
"return",
"eZInputValidator",
"::",
"STATE_ACCEPTED",
";",
"}"
] | Validates the input and returns the validity status code
@param eZHTTPTool $http
@param string $base
@param eZContentObjectAttribute $contentObjectAttribute
@return int | [
"Validates",
"the",
"input",
"and",
"returns",
"the",
"validity",
"status",
"code"
] | 9fa5fc88bfb021982e206a6d3a0d82546752e6b7 | https://github.com/netgen/ngclasslist/blob/9fa5fc88bfb021982e206a6d3a0d82546752e6b7/datatypes/ngclasslist/ngclasslisttype.php#L50-L86 |
4,484 | mirko-pagliai/reflection | src/ReflectionTrait.php | ReflectionTrait.getProperty | public function getProperty(&$object, $propertyName)
{
$property = $this->getPropertyInstance($object, $propertyName);
$property->setAccessible(true);
return $property->getValue($object);
} | php | public function getProperty(&$object, $propertyName)
{
$property = $this->getPropertyInstance($object, $propertyName);
$property->setAccessible(true);
return $property->getValue($object);
} | [
"public",
"function",
"getProperty",
"(",
"&",
"$",
"object",
",",
"$",
"propertyName",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"getPropertyInstance",
"(",
"$",
"object",
",",
"$",
"propertyName",
")",
";",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"return",
"$",
"property",
"->",
"getValue",
"(",
"$",
"object",
")",
";",
"}"
] | Gets a property value
@param object $object Instantiated object that has the property
@param string $propertyName Property name
@return mixed Property value
@uses getPropertyInstance() | [
"Gets",
"a",
"property",
"value"
] | 40462184304e455d9d367b4a14e9cb0eb39a1d99 | https://github.com/mirko-pagliai/reflection/blob/40462184304e455d9d367b4a14e9cb0eb39a1d99/src/ReflectionTrait.php#L52-L58 |
4,485 | phossa2/libs | src/Phossa2/Route/Route.php | Route.validatePattern | protected function validatePattern(/*# string */ $pattern)
{
if (!is_string($pattern) ||
substr_count($pattern, '[') !== substr_count($pattern, ']') ||
substr_count($pattern, '{') !== substr_count($pattern, '}')
) {
throw new LogicException(
Message::get(Message::RTE_PATTERN_MALFORM, $pattern),
Message::RTE_PATTERN_MALFORM
);
}
} | php | protected function validatePattern(/*# string */ $pattern)
{
if (!is_string($pattern) ||
substr_count($pattern, '[') !== substr_count($pattern, ']') ||
substr_count($pattern, '{') !== substr_count($pattern, '}')
) {
throw new LogicException(
Message::get(Message::RTE_PATTERN_MALFORM, $pattern),
Message::RTE_PATTERN_MALFORM
);
}
} | [
"protected",
"function",
"validatePattern",
"(",
"/*# string */",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"pattern",
")",
"||",
"substr_count",
"(",
"$",
"pattern",
",",
"'['",
")",
"!==",
"substr_count",
"(",
"$",
"pattern",
",",
"']'",
")",
"||",
"substr_count",
"(",
"$",
"pattern",
",",
"'{'",
")",
"!==",
"substr_count",
"(",
"$",
"pattern",
",",
"'}'",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"RTE_PATTERN_MALFORM",
",",
"$",
"pattern",
")",
",",
"Message",
"::",
"RTE_PATTERN_MALFORM",
")",
";",
"}",
"}"
] | Validate the pattern
@param string $pattern
@throws LogicException
@access protected | [
"Validate",
"the",
"pattern"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Route.php#L167-L178 |
4,486 | jjpmann/ee-addons | src/Extension/BaseExtension.php | BaseExtension.applyConfigOverrides | public function applyConfigOverrides()
{
// init
$config_items = [];
foreach ($this->settings_default as $key => $value) {
if (ee()->config->item($key)) {
$config_items[$key] = ee()->config->item($key);
}
}
if (is_array($this->settings)) {
$this->settings = array_merge($this->settings, $config_items);
}
} | php | public function applyConfigOverrides()
{
// init
$config_items = [];
foreach ($this->settings_default as $key => $value) {
if (ee()->config->item($key)) {
$config_items[$key] = ee()->config->item($key);
}
}
if (is_array($this->settings)) {
$this->settings = array_merge($this->settings, $config_items);
}
} | [
"public",
"function",
"applyConfigOverrides",
"(",
")",
"{",
"// init",
"$",
"config_items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"settings_default",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"ee",
"(",
")",
"->",
"config",
"->",
"item",
"(",
"$",
"key",
")",
")",
"{",
"$",
"config_items",
"[",
"$",
"key",
"]",
"=",
"ee",
"(",
")",
"->",
"config",
"->",
"item",
"(",
"$",
"key",
")",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"settings",
")",
")",
"{",
"$",
"this",
"->",
"settings",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"settings",
",",
"$",
"config_items",
")",
";",
"}",
"}"
] | Config Overrides.
This function will merge with config overrides
@return void | [
"Config",
"Overrides",
"."
] | 239fff4022e0d1c401a1af5b9b97fc518751ab4a | https://github.com/jjpmann/ee-addons/blob/239fff4022e0d1c401a1af5b9b97fc518751ab4a/src/Extension/BaseExtension.php#L97-L111 |
4,487 | jjpmann/ee-addons | src/Extension/BaseExtension.php | BaseExtension._log | public function _log($message)
{
ee()->load->library('logger');
ee()->load->library('user_agent');
ee()->logger->developer($this->package.' - '.$message);
} | php | public function _log($message)
{
ee()->load->library('logger');
ee()->load->library('user_agent');
ee()->logger->developer($this->package.' - '.$message);
} | [
"public",
"function",
"_log",
"(",
"$",
"message",
")",
"{",
"ee",
"(",
")",
"->",
"load",
"->",
"library",
"(",
"'logger'",
")",
";",
"ee",
"(",
")",
"->",
"load",
"->",
"library",
"(",
"'user_agent'",
")",
";",
"ee",
"(",
")",
"->",
"logger",
"->",
"developer",
"(",
"$",
"this",
"->",
"package",
".",
"' - '",
".",
"$",
"message",
")",
";",
"}"
] | Log to the developer log if the setting is turned on.
@return void | [
"Log",
"to",
"the",
"developer",
"log",
"if",
"the",
"setting",
"is",
"turned",
"on",
"."
] | 239fff4022e0d1c401a1af5b9b97fc518751ab4a | https://github.com/jjpmann/ee-addons/blob/239fff4022e0d1c401a1af5b9b97fc518751ab4a/src/Extension/BaseExtension.php#L118-L124 |
4,488 | jjpmann/ee-addons | src/Extension/BaseExtension.php | BaseExtension.add_new_hooks | private function add_new_hooks()
{
// ADD New Actions
foreach ($this->hooks as $hook => $method) {
// check if its not installed
if (!isset($this->current_hooks[$hook])) {
$data = [
'class' => $this->package,
'method' => $method,
'hook' => $hook,
'settings' => serialize($this->settings()),
'priority' => 10,
'version' => $this->version,
'enabled' => 'y',
];
ee()->db->insert('extensions', $data);
}
}
} | php | private function add_new_hooks()
{
// ADD New Actions
foreach ($this->hooks as $hook => $method) {
// check if its not installed
if (!isset($this->current_hooks[$hook])) {
$data = [
'class' => $this->package,
'method' => $method,
'hook' => $hook,
'settings' => serialize($this->settings()),
'priority' => 10,
'version' => $this->version,
'enabled' => 'y',
];
ee()->db->insert('extensions', $data);
}
}
} | [
"private",
"function",
"add_new_hooks",
"(",
")",
"{",
"// ADD New Actions",
"foreach",
"(",
"$",
"this",
"->",
"hooks",
"as",
"$",
"hook",
"=>",
"$",
"method",
")",
"{",
"// check if its not installed",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"current_hooks",
"[",
"$",
"hook",
"]",
")",
")",
"{",
"$",
"data",
"=",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"package",
",",
"'method'",
"=>",
"$",
"method",
",",
"'hook'",
"=>",
"$",
"hook",
",",
"'settings'",
"=>",
"serialize",
"(",
"$",
"this",
"->",
"settings",
"(",
")",
")",
",",
"'priority'",
"=>",
"10",
",",
"'version'",
"=>",
"$",
"this",
"->",
"version",
",",
"'enabled'",
"=>",
"'y'",
",",
"]",
";",
"ee",
"(",
")",
"->",
"db",
"->",
"insert",
"(",
"'extensions'",
",",
"$",
"data",
")",
";",
"}",
"}",
"}"
] | Add New Hooks. | [
"Add",
"New",
"Hooks",
"."
] | 239fff4022e0d1c401a1af5b9b97fc518751ab4a | https://github.com/jjpmann/ee-addons/blob/239fff4022e0d1c401a1af5b9b97fc518751ab4a/src/Extension/BaseExtension.php#L145-L165 |
4,489 | jjpmann/ee-addons | src/Extension/BaseExtension.php | BaseExtension.update_extension | public function update_extension($current = '')
{
if ($current == '' || $current == $this->version) {
return false;
}
if ($current < '0.1') {
// Update to version 1.0
}
// Add any new hooks
$this->add_new_hooks();
ee()->db->where('class', $this->package);
ee()->db->update(
'extensions',
['version' => $this->version]
);
} | php | public function update_extension($current = '')
{
if ($current == '' || $current == $this->version) {
return false;
}
if ($current < '0.1') {
// Update to version 1.0
}
// Add any new hooks
$this->add_new_hooks();
ee()->db->where('class', $this->package);
ee()->db->update(
'extensions',
['version' => $this->version]
);
} | [
"public",
"function",
"update_extension",
"(",
"$",
"current",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"current",
"==",
"''",
"||",
"$",
"current",
"==",
"$",
"this",
"->",
"version",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"current",
"<",
"'0.1'",
")",
"{",
"// Update to version 1.0",
"}",
"// Add any new hooks",
"$",
"this",
"->",
"add_new_hooks",
"(",
")",
";",
"ee",
"(",
")",
"->",
"db",
"->",
"where",
"(",
"'class'",
",",
"$",
"this",
"->",
"package",
")",
";",
"ee",
"(",
")",
"->",
"db",
"->",
"update",
"(",
"'extensions'",
",",
"[",
"'version'",
"=>",
"$",
"this",
"->",
"version",
"]",
")",
";",
"}"
] | Update Extension.
This function performs any necessary db updates when the extension
page is visited
@return mixed void on update / false if none | [
"Update",
"Extension",
"."
] | 239fff4022e0d1c401a1af5b9b97fc518751ab4a | https://github.com/jjpmann/ee-addons/blob/239fff4022e0d1c401a1af5b9b97fc518751ab4a/src/Extension/BaseExtension.php#L177-L195 |
4,490 | marando/phpSOFA | src/Marando/IAU/iauApci13.php | iauApci13.Apci13 | public static function Apci13($date1, $date2, iauASTROM &$astrom, &$eo) {
$ehpv = [];
$ebpv = [];
$r = [];
$x;
$y;
$s;
/* Earth barycentric & heliocentric position/velocity (au, au/d). */
IAU::Epv00($date1, $date2, $ehpv, $ebpv);
/* Form the equinox based BPN matrix, IAU 2006/2000A. */
IAU::Pnm06a($date1, $date2, $r);
/* Extract CIP X,Y. */
IAU::Bpn2xy($r, $x, $y);
/* Obtain CIO locator s. */
$s = IAU::S06($date1, $date2, $x, $y);
/* Compute the star-independent astrometry parameters. */
IAU::Apci($date1, $date2, $ebpv, $ehpv[0], $x, $y, $s, $astrom);
/* Equation of the origins. */
$eo = IAU::Eors($r, $s);
/* Finished. */
} | php | public static function Apci13($date1, $date2, iauASTROM &$astrom, &$eo) {
$ehpv = [];
$ebpv = [];
$r = [];
$x;
$y;
$s;
/* Earth barycentric & heliocentric position/velocity (au, au/d). */
IAU::Epv00($date1, $date2, $ehpv, $ebpv);
/* Form the equinox based BPN matrix, IAU 2006/2000A. */
IAU::Pnm06a($date1, $date2, $r);
/* Extract CIP X,Y. */
IAU::Bpn2xy($r, $x, $y);
/* Obtain CIO locator s. */
$s = IAU::S06($date1, $date2, $x, $y);
/* Compute the star-independent astrometry parameters. */
IAU::Apci($date1, $date2, $ebpv, $ehpv[0], $x, $y, $s, $astrom);
/* Equation of the origins. */
$eo = IAU::Eors($r, $s);
/* Finished. */
} | [
"public",
"static",
"function",
"Apci13",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"iauASTROM",
"&",
"$",
"astrom",
",",
"&",
"$",
"eo",
")",
"{",
"$",
"ehpv",
"=",
"[",
"]",
";",
"$",
"ebpv",
"=",
"[",
"]",
";",
"$",
"r",
"=",
"[",
"]",
";",
"$",
"x",
";",
"$",
"y",
";",
"$",
"s",
";",
"/* Earth barycentric & heliocentric position/velocity (au, au/d). */",
"IAU",
"::",
"Epv00",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"ehpv",
",",
"$",
"ebpv",
")",
";",
"/* Form the equinox based BPN matrix, IAU 2006/2000A. */",
"IAU",
"::",
"Pnm06a",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"r",
")",
";",
"/* Extract CIP X,Y. */",
"IAU",
"::",
"Bpn2xy",
"(",
"$",
"r",
",",
"$",
"x",
",",
"$",
"y",
")",
";",
"/* Obtain CIO locator s. */",
"$",
"s",
"=",
"IAU",
"::",
"S06",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"x",
",",
"$",
"y",
")",
";",
"/* Compute the star-independent astrometry parameters. */",
"IAU",
"::",
"Apci",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"ebpv",
",",
"$",
"ehpv",
"[",
"0",
"]",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"s",
",",
"$",
"astrom",
")",
";",
"/* Equation of the origins. */",
"$",
"eo",
"=",
"IAU",
"::",
"Eors",
"(",
"$",
"r",
",",
"$",
"s",
")",
";",
"/* Finished. */",
"}"
] | - - - - - - - - - -
i a u A p c i 1 3
- - - - - - - - - -
For a terrestrial observer, prepare star-independent astrometry
parameters for transformations between ICRS and geocentric CIRS
coordinates. The caller supplies the date, and SOFA models are used
to predict the Earth ephemeris and CIP/CIO.
The parameters produced by this function are required in the
parallax, light deflection, aberration, and bias-precession-nutation
parts of the astrometric transformation chain.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
date1 double TDB as a 2-part...
date2 double ...Julian Date (Note 1)
Returned:
astrom iauASTROM* star-independent astrometry parameters:
pmt double PM time interval (SSB, Julian years)
eb double[3] SSB to observer (vector, au)
eh double[3] Sun to observer (unit vector)
em double distance from Sun to observer (au)
v double[3] barycentric observer velocity (vector, c)
bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor
bpn double[3][3] bias-precession-nutation matrix
along double unchanged
xpl double unchanged
ypl double unchanged
sphi double unchanged
cphi double unchanged
diurab double unchanged
eral double unchanged
refa double unchanged
refb double unchanged
eo double* equation of the origins (ERA-GST)
Notes:
1) The TDB date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TDB)=2450123.7 could be expressed in any of these ways, among
others:
date1 date2
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in cases
where the loss of several decimal digits of resolution is
acceptable. The J2000 method is best matched to the way the
argument is handled internally and will deliver the optimum
resolution. The MJD method and the date & time methods are both
good compromises between resolution and convenience. For most
applications of this function the choice will not be at all
critical.
TT can be used instead of TDB without any significant impact on
accuracy.
2) All the vectors are with respect to BCRS axes.
3) In cases where the caller wishes to supply his own Earth
ephemeris and CIP/CIO, the function iauApci can be used instead
of the present function.
4) This is one of several functions that inserts into the astrom
structure star-independent parameters needed for the chain of
astrometric transformations ICRS <-> GCRS <-> CIRS <-> observed.
The various functions support different classes of observer and
portions of the transformation chain:
functions observer transformation
iauApcg iauApcg13 geocentric ICRS <-> GCRS
iauApci iauApci13 terrestrial ICRS <-> CIRS
iauApco iauApco13 terrestrial ICRS <-> observed
iauApcs iauApcs13 space ICRS <-> GCRS
iauAper iauAper13 terrestrial update Earth rotation
iauApio iauApio13 terrestrial CIRS <-> observed
Those with names ending in "13" use contemporary SOFA models to
compute the various ephemerides. The others accept ephemerides
supplied by the caller.
The transformation from ICRS to GCRS covers space motion,
parallax, light deflection, and aberration. From GCRS to CIRS
comprises frame bias and precession-nutation. From CIRS to
observed takes account of Earth rotation, polar motion, diurnal
aberration and parallax (unless subsumed into the ICRS <-> GCRS
transformation), and atmospheric refraction.
5) The context structure astrom produced by this function is used by
iauAtciq* and iauAticq*.
Called:
iauEpv00 Earth position and velocity
iauPnm06a classical NPB matrix, IAU 2006/2000A
iauBpn2xy extract CIP X,Y coordinates from NPB matrix
iauS06 the CIO locator s, given X,Y, IAU 2006
iauApci astrometry parameters, ICRS-CIRS
iauEors equation of the origins, given NPB matrix and s
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"A",
"p",
"c",
"i",
"1",
"3",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauApci13.php#L126-L153 |
4,491 | phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Field/AbstractField.php | AbstractField.fromRaw | public function fromRaw($value)
{
$type = $this->getDataType();
if ($type === 'json') {
$value = json_decode($value, true);
} elseif ($type === 'array') {
$value = (array) $value;
} elseif ($type === 'list') {
$value = explode(',', $value);
} elseif ($type === 'boolean') {
$value = $value ? '1' : '0';
} elseif ($type === 'integer') {
if (strlen($value)) {
$value = (int) $value;
} else {
$value = null;
}
} elseif ($type === 'float') {
if (strlen($value)) {
$value = (float) $value;
} else {
$value = null;
}
}
return $value;
} | php | public function fromRaw($value)
{
$type = $this->getDataType();
if ($type === 'json') {
$value = json_decode($value, true);
} elseif ($type === 'array') {
$value = (array) $value;
} elseif ($type === 'list') {
$value = explode(',', $value);
} elseif ($type === 'boolean') {
$value = $value ? '1' : '0';
} elseif ($type === 'integer') {
if (strlen($value)) {
$value = (int) $value;
} else {
$value = null;
}
} elseif ($type === 'float') {
if (strlen($value)) {
$value = (float) $value;
} else {
$value = null;
}
}
return $value;
} | [
"public",
"function",
"fromRaw",
"(",
"$",
"value",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getDataType",
"(",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'json'",
")",
"{",
"$",
"value",
"=",
"json_decode",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'array'",
")",
"{",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"value",
";",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'list'",
")",
"{",
"$",
"value",
"=",
"explode",
"(",
"','",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'boolean'",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"?",
"'1'",
":",
"'0'",
";",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'integer'",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'float'",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"(",
"float",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | From submitted value to object.
@param string $value
@return mixed | [
"From",
"submitted",
"value",
"to",
"object",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Field/AbstractField.php#L52-L79 |
4,492 | phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Field/AbstractField.php | AbstractField.serialize | public function serialize($value)
{
if ($this->getDataType() === 'json') {
return json_encode($value);
} elseif ($this->getDataType() === 'array') {
return json_encode($value);
} elseif ($this->getDataType() === 'list') {
return implode(',', $value);
}
return trim($value);
} | php | public function serialize($value)
{
if ($this->getDataType() === 'json') {
return json_encode($value);
} elseif ($this->getDataType() === 'array') {
return json_encode($value);
} elseif ($this->getDataType() === 'list') {
return implode(',', $value);
}
return trim($value);
} | [
"public",
"function",
"serialize",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDataType",
"(",
")",
"===",
"'json'",
")",
"{",
"return",
"json_encode",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getDataType",
"(",
")",
"===",
"'array'",
")",
"{",
"return",
"json_encode",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getDataType",
"(",
")",
"===",
"'list'",
")",
"{",
"return",
"implode",
"(",
"','",
",",
"$",
"value",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"value",
")",
";",
"}"
] | From object to database.
@param mixed $value
@return string | [
"From",
"object",
"to",
"database",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Field/AbstractField.php#L88-L99 |
4,493 | phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Field/AbstractField.php | AbstractField.unserialize | public function unserialize($value)
{
$type = $this->getDataType();
if ($type === 'json') {
$value = json_decode($value, true);
} elseif ($type === 'array') {
$value = json_decode($value, true);
} elseif ($type === 'list') {
$value = explode(',', $value);
} elseif ($type === 'boolean') {
$value = (bool) $value;
} elseif ($type === 'integer') {
if (strlen($value)) {
$value = (int) $value;
} else {
$value = null;
}
} elseif ($type === 'float') {
if (strlen($value)) {
$value = (float) $value;
} else {
$value = null;
}
}
return $value;
} | php | public function unserialize($value)
{
$type = $this->getDataType();
if ($type === 'json') {
$value = json_decode($value, true);
} elseif ($type === 'array') {
$value = json_decode($value, true);
} elseif ($type === 'list') {
$value = explode(',', $value);
} elseif ($type === 'boolean') {
$value = (bool) $value;
} elseif ($type === 'integer') {
if (strlen($value)) {
$value = (int) $value;
} else {
$value = null;
}
} elseif ($type === 'float') {
if (strlen($value)) {
$value = (float) $value;
} else {
$value = null;
}
}
return $value;
} | [
"public",
"function",
"unserialize",
"(",
"$",
"value",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getDataType",
"(",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'json'",
")",
"{",
"$",
"value",
"=",
"json_decode",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'array'",
")",
"{",
"$",
"value",
"=",
"json_decode",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'list'",
")",
"{",
"$",
"value",
"=",
"explode",
"(",
"','",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'boolean'",
")",
"{",
"$",
"value",
"=",
"(",
"bool",
")",
"$",
"value",
";",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'integer'",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'float'",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"(",
"float",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | From database to object.
@param string $value
@return mixed | [
"From",
"database",
"to",
"object",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Field/AbstractField.php#L108-L135 |
4,494 | avoo/QcmAdminBundle | Statistics/QuestionnaireStatistics.php | QuestionnaireStatistics.getScoreByCategory | public function getScoreByCategory()
{
$categories = array();
/** @var TemplateInterface $template */
foreach ($this->getData() as $template) {
$category = $template->getQuestion()->getCategory();
if (!isset($categories[$category->getId()])) {
$categories[$category->getId()] = array(
'name' => $category->getName(),
'valid' => 0,
'total' => 0,
'color' => '#' . substr('00000' . dechex(mt_rand(0, 0xffffff)), -6)
);
}
if ($template->isValid()) {
$categories[$category->getId()]['valid']++;
}
$categories[$category->getId()]['total']++;
}
return $categories;
} | php | public function getScoreByCategory()
{
$categories = array();
/** @var TemplateInterface $template */
foreach ($this->getData() as $template) {
$category = $template->getQuestion()->getCategory();
if (!isset($categories[$category->getId()])) {
$categories[$category->getId()] = array(
'name' => $category->getName(),
'valid' => 0,
'total' => 0,
'color' => '#' . substr('00000' . dechex(mt_rand(0, 0xffffff)), -6)
);
}
if ($template->isValid()) {
$categories[$category->getId()]['valid']++;
}
$categories[$category->getId()]['total']++;
}
return $categories;
} | [
"public",
"function",
"getScoreByCategory",
"(",
")",
"{",
"$",
"categories",
"=",
"array",
"(",
")",
";",
"/** @var TemplateInterface $template */",
"foreach",
"(",
"$",
"this",
"->",
"getData",
"(",
")",
"as",
"$",
"template",
")",
"{",
"$",
"category",
"=",
"$",
"template",
"->",
"getQuestion",
"(",
")",
"->",
"getCategory",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"categories",
"[",
"$",
"category",
"->",
"getId",
"(",
")",
"]",
")",
")",
"{",
"$",
"categories",
"[",
"$",
"category",
"->",
"getId",
"(",
")",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"category",
"->",
"getName",
"(",
")",
",",
"'valid'",
"=>",
"0",
",",
"'total'",
"=>",
"0",
",",
"'color'",
"=>",
"'#'",
".",
"substr",
"(",
"'00000'",
".",
"dechex",
"(",
"mt_rand",
"(",
"0",
",",
"0xffffff",
")",
")",
",",
"-",
"6",
")",
")",
";",
"}",
"if",
"(",
"$",
"template",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"categories",
"[",
"$",
"category",
"->",
"getId",
"(",
")",
"]",
"[",
"'valid'",
"]",
"++",
";",
"}",
"$",
"categories",
"[",
"$",
"category",
"->",
"getId",
"(",
")",
"]",
"[",
"'total'",
"]",
"++",
";",
"}",
"return",
"$",
"categories",
";",
"}"
] | Get score by category
@return array | [
"Get",
"score",
"by",
"category"
] | fa0ec22d79c46580e09cc821f8b711babf1d09d5 | https://github.com/avoo/QcmAdminBundle/blob/fa0ec22d79c46580e09cc821f8b711babf1d09d5/Statistics/QuestionnaireStatistics.php#L18-L43 |
4,495 | avoo/QcmAdminBundle | Statistics/QuestionnaireStatistics.php | QuestionnaireStatistics.getScoreByLevel | public function getScoreByLevel()
{
$levels = array();
/** @var TemplateInterface $template */
foreach ($this->getData() as $template) {
$question = $template->getQuestion();
if (!isset($levels[$question->getLevel()])) {
$levels[$question->getLevel()] = array(
'name' => $question->getLevel(),
'valid' => 0,
'total' => 0,
'color' => '#'.substr('00000'.dechex(mt_rand(0, 0xffffff)), -6)
);
}
if ($template->isValid()) {
$levels[$question->getLevel()]['valid']++;
}
$levels[$question->getLevel()]['total']++;
}
sort($levels);
return $levels;
} | php | public function getScoreByLevel()
{
$levels = array();
/** @var TemplateInterface $template */
foreach ($this->getData() as $template) {
$question = $template->getQuestion();
if (!isset($levels[$question->getLevel()])) {
$levels[$question->getLevel()] = array(
'name' => $question->getLevel(),
'valid' => 0,
'total' => 0,
'color' => '#'.substr('00000'.dechex(mt_rand(0, 0xffffff)), -6)
);
}
if ($template->isValid()) {
$levels[$question->getLevel()]['valid']++;
}
$levels[$question->getLevel()]['total']++;
}
sort($levels);
return $levels;
} | [
"public",
"function",
"getScoreByLevel",
"(",
")",
"{",
"$",
"levels",
"=",
"array",
"(",
")",
";",
"/** @var TemplateInterface $template */",
"foreach",
"(",
"$",
"this",
"->",
"getData",
"(",
")",
"as",
"$",
"template",
")",
"{",
"$",
"question",
"=",
"$",
"template",
"->",
"getQuestion",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"levels",
"[",
"$",
"question",
"->",
"getLevel",
"(",
")",
"]",
")",
")",
"{",
"$",
"levels",
"[",
"$",
"question",
"->",
"getLevel",
"(",
")",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"question",
"->",
"getLevel",
"(",
")",
",",
"'valid'",
"=>",
"0",
",",
"'total'",
"=>",
"0",
",",
"'color'",
"=>",
"'#'",
".",
"substr",
"(",
"'00000'",
".",
"dechex",
"(",
"mt_rand",
"(",
"0",
",",
"0xffffff",
")",
")",
",",
"-",
"6",
")",
")",
";",
"}",
"if",
"(",
"$",
"template",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"levels",
"[",
"$",
"question",
"->",
"getLevel",
"(",
")",
"]",
"[",
"'valid'",
"]",
"++",
";",
"}",
"$",
"levels",
"[",
"$",
"question",
"->",
"getLevel",
"(",
")",
"]",
"[",
"'total'",
"]",
"++",
";",
"}",
"sort",
"(",
"$",
"levels",
")",
";",
"return",
"$",
"levels",
";",
"}"
] | Get Score by question level
@return array | [
"Get",
"Score",
"by",
"question",
"level"
] | fa0ec22d79c46580e09cc821f8b711babf1d09d5 | https://github.com/avoo/QcmAdminBundle/blob/fa0ec22d79c46580e09cc821f8b711babf1d09d5/Statistics/QuestionnaireStatistics.php#L50-L77 |
4,496 | avoo/QcmAdminBundle | Statistics/QuestionnaireStatistics.php | QuestionnaireStatistics.getPercentagePartial | public function getPercentagePartial()
{
$total = $this->getTotal();
return round((($this->score->getValid() + $this->score->getPartial())/$total) * 100);
} | php | public function getPercentagePartial()
{
$total = $this->getTotal();
return round((($this->score->getValid() + $this->score->getPartial())/$total) * 100);
} | [
"public",
"function",
"getPercentagePartial",
"(",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"getTotal",
"(",
")",
";",
"return",
"round",
"(",
"(",
"(",
"$",
"this",
"->",
"score",
"->",
"getValid",
"(",
")",
"+",
"$",
"this",
"->",
"score",
"->",
"getPartial",
"(",
")",
")",
"/",
"$",
"total",
")",
"*",
"100",
")",
";",
"}"
] | Get percentage valid + partial | [
"Get",
"percentage",
"valid",
"+",
"partial"
] | fa0ec22d79c46580e09cc821f8b711babf1d09d5 | https://github.com/avoo/QcmAdminBundle/blob/fa0ec22d79c46580e09cc821f8b711babf1d09d5/Statistics/QuestionnaireStatistics.php#L94-L99 |
4,497 | avoo/QcmAdminBundle | Statistics/QuestionnaireStatistics.php | QuestionnaireStatistics.getTotal | public function getTotal()
{
return $this->score->getValid() + $this->score->getPartial() + $this->score->getNotValid();
} | php | public function getTotal()
{
return $this->score->getValid() + $this->score->getPartial() + $this->score->getNotValid();
} | [
"public",
"function",
"getTotal",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"score",
"->",
"getValid",
"(",
")",
"+",
"$",
"this",
"->",
"score",
"->",
"getPartial",
"(",
")",
"+",
"$",
"this",
"->",
"score",
"->",
"getNotValid",
"(",
")",
";",
"}"
] | Get total answers
@return integer | [
"Get",
"total",
"answers"
] | fa0ec22d79c46580e09cc821f8b711babf1d09d5 | https://github.com/avoo/QcmAdminBundle/blob/fa0ec22d79c46580e09cc821f8b711babf1d09d5/Statistics/QuestionnaireStatistics.php#L106-L109 |
4,498 | devbr/database | Model.php | Model.doIndex | final public function doIndex($start = 0, $len = 30, $search = null)
{
//SEarch
if ($search !== null && is_array($search)) {
$tmp = ' WHERE ';
$and = '';
foreach ($search as $k => $v) {
$tmp .= $and.$k.' LIKE "%'.$v.'%" ';
$and = ' AND ';
}
$search = $tmp;
} else {
$search = '';
}
//Execute
$this->db->query('SELECT * FROM '.$this->table.$search.' LIMIT '.(0+$start).', '.(0+$len));
return $this->db->result();
} | php | final public function doIndex($start = 0, $len = 30, $search = null)
{
//SEarch
if ($search !== null && is_array($search)) {
$tmp = ' WHERE ';
$and = '';
foreach ($search as $k => $v) {
$tmp .= $and.$k.' LIKE "%'.$v.'%" ';
$and = ' AND ';
}
$search = $tmp;
} else {
$search = '';
}
//Execute
$this->db->query('SELECT * FROM '.$this->table.$search.' LIMIT '.(0+$start).', '.(0+$len));
return $this->db->result();
} | [
"final",
"public",
"function",
"doIndex",
"(",
"$",
"start",
"=",
"0",
",",
"$",
"len",
"=",
"30",
",",
"$",
"search",
"=",
"null",
")",
"{",
"//SEarch",
"if",
"(",
"$",
"search",
"!==",
"null",
"&&",
"is_array",
"(",
"$",
"search",
")",
")",
"{",
"$",
"tmp",
"=",
"' WHERE '",
";",
"$",
"and",
"=",
"''",
";",
"foreach",
"(",
"$",
"search",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"tmp",
".=",
"$",
"and",
".",
"$",
"k",
".",
"' LIKE \"%'",
".",
"$",
"v",
".",
"'%\" '",
";",
"$",
"and",
"=",
"' AND '",
";",
"}",
"$",
"search",
"=",
"$",
"tmp",
";",
"}",
"else",
"{",
"$",
"search",
"=",
"''",
";",
"}",
"//Execute",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SELECT * FROM '",
".",
"$",
"this",
"->",
"table",
".",
"$",
"search",
".",
"' LIMIT '",
".",
"(",
"0",
"+",
"$",
"start",
")",
".",
"', '",
".",
"(",
"0",
"+",
"$",
"len",
")",
")",
";",
"return",
"$",
"this",
"->",
"db",
"->",
"result",
"(",
")",
";",
"}"
] | Lista todos || paginado | [
"Lista",
"todos",
"||",
"paginado"
] | 09269a39be6dd70d68cc3e6ffa18c23a09205238 | https://github.com/devbr/database/blob/09269a39be6dd70d68cc3e6ffa18c23a09205238/Model.php#L57-L75 |
4,499 | devbr/database | Model.php | Model.doShow | final public function doShow($id)
{
$this->db->query('SELECT * FROM '.$this->table.' WHERE id = :id', [':id'=>$id]);
$result = $this->db->result();
return $result ? $result : false;
} | php | final public function doShow($id)
{
$this->db->query('SELECT * FROM '.$this->table.' WHERE id = :id', [':id'=>$id]);
$result = $this->db->result();
return $result ? $result : false;
} | [
"final",
"public",
"function",
"doShow",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SELECT * FROM '",
".",
"$",
"this",
"->",
"table",
".",
"' WHERE id = :id'",
",",
"[",
"':id'",
"=>",
"$",
"id",
"]",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"db",
"->",
"result",
"(",
")",
";",
"return",
"$",
"result",
"?",
"$",
"result",
":",
"false",
";",
"}"
] | Lista o selecionado | [
"Lista",
"o",
"selecionado"
] | 09269a39be6dd70d68cc3e6ffa18c23a09205238 | https://github.com/devbr/database/blob/09269a39be6dd70d68cc3e6ffa18c23a09205238/Model.php#L78-L83 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.