repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.update | public function update($table, array $data)
{
$conditions = array();
foreach ($data as $key => $value) {
// Wrap column names into back-ticks
$conditions[] = sprintf('%s = %s', $this->quote($key), $value);
}
$query = sprintf('UPDATE %s SET %s', $this->quote($table), implode(', ', $conditions));
$this->append($query);
return $this;
} | php | public function update($table, array $data)
{
$conditions = array();
foreach ($data as $key => $value) {
// Wrap column names into back-ticks
$conditions[] = sprintf('%s = %s', $this->quote($key), $value);
}
$query = sprintf('UPDATE %s SET %s', $this->quote($table), implode(', ', $conditions));
$this->append($query);
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"array",
"$",
"data",
")",
"{",
"$",
"conditions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// Wrap column names into back-ticks",
... | Builds UPDATE query
@param string $table
@param array $data Data to be updated
@return \Krystal\Db\Sql\QueryBuilder | [
"Builds",
"UPDATE",
"query"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L500-L513 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.recountColumn | private function recountColumn($table, $column, $operator, $step = 1)
{
// Make sure expected value is going to be updated
$step = (int) $step;
$step = (string) $step;
return $this->update($table, array($column => $column . sprintf(' %s ', $operator) . $step));
} | php | private function recountColumn($table, $column, $operator, $step = 1)
{
// Make sure expected value is going to be updated
$step = (int) $step;
$step = (string) $step;
return $this->update($table, array($column => $column . sprintf(' %s ', $operator) . $step));
} | [
"private",
"function",
"recountColumn",
"(",
"$",
"table",
",",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"step",
"=",
"1",
")",
"{",
"// Make sure expected value is going to be updated",
"$",
"step",
"=",
"(",
"int",
")",
"$",
"step",
";",
"$",
"step... | Re-counts a column
@param string $table
@param string $column
@param string $operator
@param integer $step
@return \Krystal\Db\Sql\QueryBuilder | [
"Re",
"-",
"counts",
"a",
"column"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L524-L531 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.createSelectData | private function createSelectData($type)
{
// * is a special keyword, which doesn't need to be wrapped
if ($type !== '*' && $type !== null && !is_array($type)) {
$type = $this->quote($type);
}
// Special case when $type is array
if (is_array($type)) {
$collection = array();
foreach ($type as $column => $alias) {
// Did we receive an alias?
if (!is_numeric($column)) {
$push = sprintf('%s AS %s', $this->quote($column), $this->quote($alias));
} else if ($alias instanceof RawSqlFragmentInterface) {
// Is raw SQL fragment needs to selected?
$push = $alias->getFragment();
} else {
// In case received a regular column name
$push = $this->quote($alias);
}
array_push($collection, $push);
}
// And finally, separate via commas
$type = implode(', ', $collection);
}
return $type;
} | php | private function createSelectData($type)
{
// * is a special keyword, which doesn't need to be wrapped
if ($type !== '*' && $type !== null && !is_array($type)) {
$type = $this->quote($type);
}
// Special case when $type is array
if (is_array($type)) {
$collection = array();
foreach ($type as $column => $alias) {
// Did we receive an alias?
if (!is_numeric($column)) {
$push = sprintf('%s AS %s', $this->quote($column), $this->quote($alias));
} else if ($alias instanceof RawSqlFragmentInterface) {
// Is raw SQL fragment needs to selected?
$push = $alias->getFragment();
} else {
// In case received a regular column name
$push = $this->quote($alias);
}
array_push($collection, $push);
}
// And finally, separate via commas
$type = implode(', ', $collection);
}
return $type;
} | [
"private",
"function",
"createSelectData",
"(",
"$",
"type",
")",
"{",
"// * is a special keyword, which doesn't need to be wrapped",
"if",
"(",
"$",
"type",
"!==",
"'*'",
"&&",
"$",
"type",
"!==",
"null",
"&&",
"!",
"is_array",
"(",
"$",
"type",
")",
")",
"{"... | Returns expression which needs to be followed right after SELECT
@param mixed $type
@return string | [
"Returns",
"expression",
"which",
"needs",
"to",
"be",
"followed",
"right",
"after",
"SELECT"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L697-L728 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.limit | public function limit($offset, $amount = null)
{
if (is_null($amount)) {
$this->append(' LIMIT ' . $offset);
} else {
$this->append(sprintf(' LIMIT %s, %s', $offset, $amount));
}
return $this;
} | php | public function limit($offset, $amount = null)
{
if (is_null($amount)) {
$this->append(' LIMIT ' . $offset);
} else {
$this->append(sprintf(' LIMIT %s, %s', $offset, $amount));
}
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"offset",
",",
"$",
"amount",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"amount",
")",
")",
"{",
"$",
"this",
"->",
"append",
"(",
"' LIMIT '",
".",
"$",
"offset",
")",
";",
"}",
"else",
"{",
... | Appends LIMIT expression
@param integer $offset
@param integer $amount Amount of rows to be returned
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"LIMIT",
"expression"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L737-L746 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.from | public function from($table = null)
{
if ($table !== null) {
$this->table = $table;
$table = $this->quote($table);
}
$this->append(' FROM ' . $table);
return $this;
} | php | public function from($table = null)
{
if ($table !== null) {
$this->table = $table;
$table = $this->quote($table);
}
$this->append(' FROM ' . $table);
return $this;
} | [
"public",
"function",
"from",
"(",
"$",
"table",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"table",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"table",
"=",
"$",
"table",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"quote",
"(",
"$",
"table",
")",... | Appends FROM expression
@param string $table Optional table name
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"FROM",
"expression"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L754-L763 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.compare | public function compare($column, $operator, $value, $filter = false)
{
if (!$this->isFilterable($filter, $value)) {
return $this;
}
if ($value instanceof RawSqlFragmentInterface) {
$value = $value->getFragment();
}
if ($value instanceof RawBindingInterface) {
$value = $value->getTarget();
}
$this->append(sprintf(' %s %s %s ', $this->quote($column), $operator, $value));
return $this;
} | php | public function compare($column, $operator, $value, $filter = false)
{
if (!$this->isFilterable($filter, $value)) {
return $this;
}
if ($value instanceof RawSqlFragmentInterface) {
$value = $value->getFragment();
}
if ($value instanceof RawBindingInterface) {
$value = $value->getTarget();
}
$this->append(sprintf(' %s %s %s ', $this->quote($column), $operator, $value));
return $this;
} | [
"public",
"function",
"compare",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
",",
"$",
"filter",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFilterable",
"(",
"$",
"filter",
",",
"$",
"value",
")",
")",
"{",
"re... | Appends a raw comparison
@param string $column
@param string $operator
@param string $value
@param boolean $filter Whether to filter by value
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"a",
"raw",
"comparison"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L774-L790 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.createConstraint | private function createConstraint($token, $column, $operator, $value, $filter)
{
if (!$this->isFilterable($filter, $value)) {
return $this;
}
$this->append(sprintf('%s %s %s %s ', $token, $this->quote($column), $operator, $value));
return $this;
} | php | private function createConstraint($token, $column, $operator, $value, $filter)
{
if (!$this->isFilterable($filter, $value)) {
return $this;
}
$this->append(sprintf('%s %s %s %s ', $token, $this->quote($column), $operator, $value));
return $this;
} | [
"private",
"function",
"createConstraint",
"(",
"$",
"token",
",",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
",",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFilterable",
"(",
"$",
"filter",
",",
"$",
"value",
")",
... | Appends constraint string
@param string $token
@param string $column
@param string $operator
@param string $value
@param boolean $filter Whether to filter by value
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"constraint",
"string"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L924-L932 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.where | public function where($column, $operator, $value, $filter = false)
{
return $this->createConstraint(' WHERE', $column, $operator, $value, $filter);
} | php | public function where($column, $operator, $value, $filter = false)
{
return $this->createConstraint(' WHERE', $column, $operator, $value, $filter);
} | [
"public",
"function",
"where",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
",",
"$",
"filter",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"createConstraint",
"(",
"' WHERE'",
",",
"$",
"column",
",",
"$",
"operator",
",",
"... | Appends WHERE expression
@param string $column
@param string $operator
@param string $value
@param boolean $filter Whether to filter by value
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"WHERE",
"expression"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L943-L946 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.whereEqualsOrGreaterThan | public function whereEqualsOrGreaterThan($column, $value, $filter = false)
{
return $this->where($column, '>=', $value, $filter);
} | php | public function whereEqualsOrGreaterThan($column, $value, $filter = false)
{
return $this->where($column, '>=', $value, $filter);
} | [
"public",
"function",
"whereEqualsOrGreaterThan",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"filter",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"where",
"(",
"$",
"column",
",",
"'>='",
",",
"$",
"value",
",",
"$",
"filter",
")",
";... | Appends WHERE clause with "Greater than or equals" operator
@param string $column
@param string $value
@param boolean $filter Whether to filter by value
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"WHERE",
"clause",
"with",
"Greater",
"than",
"or",
"equals",
"operator"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1206-L1209 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.whereEqualsOrLessThan | public function whereEqualsOrLessThan($column, $value, $filter = false)
{
return $this->where($column, '<=', $value, $filter);
} | php | public function whereEqualsOrLessThan($column, $value, $filter = false)
{
return $this->where($column, '<=', $value, $filter);
} | [
"public",
"function",
"whereEqualsOrLessThan",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"filter",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"where",
"(",
"$",
"column",
",",
"'<='",
",",
"$",
"value",
",",
"$",
"filter",
")",
";",
... | Appends WHERE clause with "Less than or equals" operator
@param string $column
@param string $value
@param boolean $filter Whether to filter by value
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"WHERE",
"clause",
"with",
"Less",
"than",
"or",
"equals",
"operator"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1219-L1222 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.join | public function join($type, $table, array $relations = array())
{
$this->append(sprintf(' %s JOIN %s ', $type, $table));
// Append relations if provided
if (!empty($relations)) {
// First on
$this->on();
$i = 0; // Iteration counter
$count = count($relations);
foreach ($relations as $column => $value) {
// Increment iteration count
$i++;
$this->equals($column, $value);
// If last iteration
if ($i != $count) {
$this->rawAnd();
}
}
}
return $this;
} | php | public function join($type, $table, array $relations = array())
{
$this->append(sprintf(' %s JOIN %s ', $type, $table));
// Append relations if provided
if (!empty($relations)) {
// First on
$this->on();
$i = 0; // Iteration counter
$count = count($relations);
foreach ($relations as $column => $value) {
// Increment iteration count
$i++;
$this->equals($column, $value);
// If last iteration
if ($i != $count) {
$this->rawAnd();
}
}
}
return $this;
} | [
"public",
"function",
"join",
"(",
"$",
"type",
",",
"$",
"table",
",",
"array",
"$",
"relations",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"append",
"(",
"sprintf",
"(",
"' %s JOIN %s '",
",",
"$",
"type",
",",
"$",
"table",
")",
")",
... | Appends JOIN statement
@param string $type JOIN type
@param string $table Right table (second)
@param array $relations
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"JOIN",
"statement"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1371-L1397 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.groupBy | public function groupBy($target)
{
$columns = null;
if (is_string($target)) {
$columns = $target;
} elseif (is_array($target)) {
$columns = implode(', ', $target);
} else {
throw new InvalidArgumentException(sprintf(
'groupBy() accepts only an array of columns or a plain column name. You supplied "%s"', gettype($target)
));
}
$this->append(sprintf(' GROUP BY %s ', $columns));
return $this;
} | php | public function groupBy($target)
{
$columns = null;
if (is_string($target)) {
$columns = $target;
} elseif (is_array($target)) {
$columns = implode(', ', $target);
} else {
throw new InvalidArgumentException(sprintf(
'groupBy() accepts only an array of columns or a plain column name. You supplied "%s"', gettype($target)
));
}
$this->append(sprintf(' GROUP BY %s ', $columns));
return $this;
} | [
"public",
"function",
"groupBy",
"(",
"$",
"target",
")",
"{",
"$",
"columns",
"=",
"null",
";",
"if",
"(",
"is_string",
"(",
"$",
"target",
")",
")",
"{",
"$",
"columns",
"=",
"$",
"target",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"target",... | Appends GROUP BY statement
@param string|array $target
@throws \InvalidArgumentException If $target isn't either a string or an array
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"GROUP",
"BY",
"statement"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1480-L1498 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.orderBy | public function orderBy($type = null)
{
if ($type === null) {
$target = null;
} elseif ($type instanceof RawSqlFragmentInterface) {
$target = $type->getFragment();
} elseif (is_array($type)) {
// Special case for non-associative array
if (!ArrayUtils::isAssoc($type)) {
// Check if at least one value represents a raw fragment
foreach ($type as &$option) {
// If raw, then do nothing but get it
if ($option instanceof RawSqlFragmentInterface) {
$option = $option->getFragment();
} else {
// Not raw - OK, then just quote it
$option = $this->quote($option);
}
}
} else {
// If associative array supplied then assume that values represent sort orders
$result = array();
foreach ($type as $column => $sortOrder) {
// Force sorting method to be in upper case
$sortOrder = strtoupper($sortOrder);
// Ensure that only valid sorting methods provided
if (!in_array($sortOrder, array('ASC', 'DESC'))) {
throw new LogicException(sprintf(
'Only ASC and DESC methods are supported. You provided "%s"', $sortOrder
));
}
// Only column names should be wrapped around backticks
array_push($result, sprintf('%s %s', $this->quote($column), $sortOrder));
}
$type = $result;
}
$target = implode(', ', $type);
} else {
$target = $this->quote($type);
}
$this->append(' ORDER BY '.$target);
return $this;
} | php | public function orderBy($type = null)
{
if ($type === null) {
$target = null;
} elseif ($type instanceof RawSqlFragmentInterface) {
$target = $type->getFragment();
} elseif (is_array($type)) {
// Special case for non-associative array
if (!ArrayUtils::isAssoc($type)) {
// Check if at least one value represents a raw fragment
foreach ($type as &$option) {
// If raw, then do nothing but get it
if ($option instanceof RawSqlFragmentInterface) {
$option = $option->getFragment();
} else {
// Not raw - OK, then just quote it
$option = $this->quote($option);
}
}
} else {
// If associative array supplied then assume that values represent sort orders
$result = array();
foreach ($type as $column => $sortOrder) {
// Force sorting method to be in upper case
$sortOrder = strtoupper($sortOrder);
// Ensure that only valid sorting methods provided
if (!in_array($sortOrder, array('ASC', 'DESC'))) {
throw new LogicException(sprintf(
'Only ASC and DESC methods are supported. You provided "%s"', $sortOrder
));
}
// Only column names should be wrapped around backticks
array_push($result, sprintf('%s %s', $this->quote($column), $sortOrder));
}
$type = $result;
}
$target = implode(', ', $type);
} else {
$target = $this->quote($type);
}
$this->append(' ORDER BY '.$target);
return $this;
} | [
"public",
"function",
"orderBy",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
")",
"{",
"$",
"target",
"=",
"null",
";",
"}",
"elseif",
"(",
"$",
"type",
"instanceof",
"RawSqlFragmentInterface",
")",
"{",
"$",
"targ... | Appends ORDER BY expression
@param string|array|\Krystal\Db\Sql\RawSqlFragmentInterface $type
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"ORDER",
"BY",
"expression"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1506-L1557 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.between | private function between($column, $a, $b, $prefix, $not = false, $operator = null, $filter = false)
{
if (!$this->isFilterable($filter, array($a, $b))) {
return $this;
}
if ($operator !== null) {
// A space before the operator is preferred
$operator = sprintf(' %s', $operator);
}
// Handle NOT prefix
if ($not === true) {
$not = 'NOT';
} else {
$not = '';
}
$this->append($operator.sprintf(' %s %s %s BETWEEN %s AND %s ', $prefix, $this->quote($column), $not, $a, $b));
return $this;
} | php | private function between($column, $a, $b, $prefix, $not = false, $operator = null, $filter = false)
{
if (!$this->isFilterable($filter, array($a, $b))) {
return $this;
}
if ($operator !== null) {
// A space before the operator is preferred
$operator = sprintf(' %s', $operator);
}
// Handle NOT prefix
if ($not === true) {
$not = 'NOT';
} else {
$not = '';
}
$this->append($operator.sprintf(' %s %s %s BETWEEN %s AND %s ', $prefix, $this->quote($column), $not, $a, $b));
return $this;
} | [
"private",
"function",
"between",
"(",
"$",
"column",
",",
"$",
"a",
",",
"$",
"b",
",",
"$",
"prefix",
",",
"$",
"not",
"=",
"false",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"filter",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
... | Appends WHERE with BETWEEN operator
@param string $column
@param string $a First value
@param string $b Second value
@param string $prefix The first prefix such as WHERE or AND or OR
@param boolean $not Whether it must be NOT BETWEEN or not
@param string $operator Optional operator to be prep-ended before WHERE clause
@param boolean $filter Whether to rely on filter
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"WHERE",
"with",
"BETWEEN",
"operator"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1709-L1729 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.andWhereNotBetween | public function andWhereNotBetween($column, $a, $b, $filter = false)
{
return $this->between($column, $a, $b, null, true, 'AND', $filter);
} | php | public function andWhereNotBetween($column, $a, $b, $filter = false)
{
return $this->between($column, $a, $b, null, true, 'AND', $filter);
} | [
"public",
"function",
"andWhereNotBetween",
"(",
"$",
"column",
",",
"$",
"a",
",",
"$",
"b",
",",
"$",
"filter",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"between",
"(",
"$",
"column",
",",
"$",
"a",
",",
"$",
"b",
",",
"null",
",",
... | Appends AND WHERE with NOT BETWEEN operator
@param string $column
@param string $a First value
@param string $b Second value
@param boolean $filter Whether to rely on filter
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"AND",
"WHERE",
"with",
"NOT",
"BETWEEN",
"operator"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1782-L1785 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.delete | public function delete(array $tables = array())
{
$this->append(' DELETE ');
if (!empty($tables)) {
$tablesSequence = implode(', ', $tables);
$this->append($tablesSequence);
}
return $this;
} | php | public function delete(array $tables = array())
{
$this->append(' DELETE ');
if (!empty($tables)) {
$tablesSequence = implode(', ', $tables);
$this->append($tablesSequence);
}
return $this;
} | [
"public",
"function",
"delete",
"(",
"array",
"$",
"tables",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"append",
"(",
"' DELETE '",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tables",
")",
")",
"{",
"$",
"tablesSequence",
"=",
"implod... | Appends DELETE expression
@param array $tables Optional tables
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"DELETE",
"expression"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1821-L1831 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.renameTable | public function renameTable($old, $new)
{
$this->append(sprintf('RENAME TABLE %s TO %s ', $this->quote($old), $this->quote($new)));
return $this;
} | php | public function renameTable($old, $new)
{
$this->append(sprintf('RENAME TABLE %s TO %s ', $this->quote($old), $this->quote($new)));
return $this;
} | [
"public",
"function",
"renameTable",
"(",
"$",
"old",
",",
"$",
"new",
")",
"{",
"$",
"this",
"->",
"append",
"(",
"sprintf",
"(",
"'RENAME TABLE %s TO %s '",
",",
"$",
"this",
"->",
"quote",
"(",
"$",
"old",
")",
",",
"$",
"this",
"->",
"quote",
"("... | Appends "RENAME TO" statement
@param string $old
@param string $new
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"RENAME",
"TO",
"statement"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1930-L1934 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.dropTable | public function dropTable($target, $ifExists = true)
{
$query = 'DROP TABLE ';
if ($ifExists === true) {
$query .= 'IF EXISTS ';
}
if (!is_array($target)) {
$target = array($target);
}
$target = $this->quote($target);
$query .= sprintf('%s;', implode(', ', $target));
$this->append($query);
return $this;
} | php | public function dropTable($target, $ifExists = true)
{
$query = 'DROP TABLE ';
if ($ifExists === true) {
$query .= 'IF EXISTS ';
}
if (!is_array($target)) {
$target = array($target);
}
$target = $this->quote($target);
$query .= sprintf('%s;', implode(', ', $target));
$this->append($query);
return $this;
} | [
"public",
"function",
"dropTable",
"(",
"$",
"target",
",",
"$",
"ifExists",
"=",
"true",
")",
"{",
"$",
"query",
"=",
"'DROP TABLE '",
";",
"if",
"(",
"$",
"ifExists",
"===",
"true",
")",
"{",
"$",
"query",
".=",
"'IF EXISTS '",
";",
"}",
"if",
"(",... | Generates DROP TABLE statement
@param string|array $table Table name
@param boolean $ifExists Whether to generate IF EXIST condition as well
@return \Krystal\Db\Sql\QueryBuilder | [
"Generates",
"DROP",
"TABLE",
"statement"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L1943-L1960 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.renameColumn | public function renameColumn($old, $new)
{
$this->append(sprintf(' RENAME COLUMN %s TO %s ', $this->quote($old), $this->quote($new)));
return $this;
} | php | public function renameColumn($old, $new)
{
$this->append(sprintf(' RENAME COLUMN %s TO %s ', $this->quote($old), $this->quote($new)));
return $this;
} | [
"public",
"function",
"renameColumn",
"(",
"$",
"old",
",",
"$",
"new",
")",
"{",
"$",
"this",
"->",
"append",
"(",
"sprintf",
"(",
"' RENAME COLUMN %s TO %s '",
",",
"$",
"this",
"->",
"quote",
"(",
"$",
"old",
")",
",",
"$",
"this",
"->",
"quote",
... | Appends "RENAME COLUMN TO" statement
@param string $old Old name
@param string $new New name
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"RENAME",
"COLUMN",
"TO",
"statement"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L2006-L2010 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.alterColumn | public function alterColumn($column, $type)
{
$column = $this->quote($column);
$this->append(sprintf(' CHANGE %s %s %s ', $column, $column, $type));
return $this;
} | php | public function alterColumn($column, $type)
{
$column = $this->quote($column);
$this->append(sprintf(' CHANGE %s %s %s ', $column, $column, $type));
return $this;
} | [
"public",
"function",
"alterColumn",
"(",
"$",
"column",
",",
"$",
"type",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"quote",
"(",
"$",
"column",
")",
";",
"$",
"this",
"->",
"append",
"(",
"sprintf",
"(",
"' CHANGE %s %s %s '",
",",
"$",
"col... | Appends "CHANGE" statement
@param string $column
@param string $type
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"CHANGE",
"statement"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L2019-L2025 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/QueryBuilder.php | QueryBuilder.dropIndex | public function dropIndex($table, $name)
{
$query = sprintf('DROP INDEX %s ON %s ;', $this->quote($name), $this->quote($table));
$this->append($query);
return $this;
} | php | public function dropIndex($table, $name)
{
$query = sprintf('DROP INDEX %s ON %s ;', $this->quote($name), $this->quote($table));
$this->append($query);
return $this;
} | [
"public",
"function",
"dropIndex",
"(",
"$",
"table",
",",
"$",
"name",
")",
"{",
"$",
"query",
"=",
"sprintf",
"(",
"'DROP INDEX %s ON %s ;'",
",",
"$",
"this",
"->",
"quote",
"(",
"$",
"name",
")",
",",
"$",
"this",
"->",
"quote",
"(",
"$",
"table"... | Appends "DROP INDEX" expression
@param string $table Target table
@param string $name Index name
@return \Krystal\Db\Sql\QueryBuilder | [
"Appends",
"DROP",
"INDEX",
"expression"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/QueryBuilder.php#L2153-L2159 | train |
inc2734/mimizuku-core | src/App/Model/CSS_Block.php | CSS_Block.get_inline_css | public function get_inline_css() {
if ( $this->get_pre_selectors() ) {
$inline_css = sprintf(
'%1$s { %2$s }',
implode( ',', $this->get_selectors() ),
$this->get_properties()
);
foreach ( $this->get_pre_selectors() as $pre_selector ) {
$inline_css = sprintf(
'%1$s { %2$s }',
$pre_selector,
$inline_css
);
}
return $inline_css;
}
return sprintf(
'%1$s { %2$s }',
implode( ',', $this->get_selectors() ),
$this->get_properties()
);
} | php | public function get_inline_css() {
if ( $this->get_pre_selectors() ) {
$inline_css = sprintf(
'%1$s { %2$s }',
implode( ',', $this->get_selectors() ),
$this->get_properties()
);
foreach ( $this->get_pre_selectors() as $pre_selector ) {
$inline_css = sprintf(
'%1$s { %2$s }',
$pre_selector,
$inline_css
);
}
return $inline_css;
}
return sprintf(
'%1$s { %2$s }',
implode( ',', $this->get_selectors() ),
$this->get_properties()
);
} | [
"public",
"function",
"get_inline_css",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get_pre_selectors",
"(",
")",
")",
"{",
"$",
"inline_css",
"=",
"sprintf",
"(",
"'%1$s { %2$s }'",
",",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"get_selectors",
... | Return inline CSS
@return string | [
"Return",
"inline",
"CSS"
] | d192a01f4a730e53bced3dfcd0ef29fbecc80330 | https://github.com/inc2734/mimizuku-core/blob/d192a01f4a730e53bced3dfcd0ef29fbecc80330/src/App/Model/CSS_Block.php#L49-L71 | train |
Tecnocreaciones/ToolsBundle | Model/Exporter/ChainModel.php | ChainModel.getModel | public function getModel($name) {
if(!isset($this->models[$name])){
throw new RuntimeException(sprintf("The model document name '%s' is not added in chain model '%s'",$name,$this->id));
}
$this->models[$name]->setContainer($this->container);
return $this->models[$name];
} | php | public function getModel($name) {
if(!isset($this->models[$name])){
throw new RuntimeException(sprintf("The model document name '%s' is not added in chain model '%s'",$name,$this->id));
}
$this->models[$name]->setContainer($this->container);
return $this->models[$name];
} | [
"public",
"function",
"getModel",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"models",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"\"The model document name '%s' is not a... | Retorna el modelo de un documento por su nombre
@param type $name
@return ModelDocument
@throws RuntimeException | [
"Retorna",
"el",
"modelo",
"de",
"un",
"documento",
"por",
"su",
"nombre"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Exporter/ChainModel.php#L77-L83 | train |
Tecnocreaciones/ToolsBundle | Model/Exporter/ChainModel.php | ChainModel.getDirOutput | public function getDirOutput() {
$ds = DIRECTORY_SEPARATOR;
$id = $this->getId();
$documentsPath = $this->exporterManager->getOption("documents_path");
$env = $this->exporterManager->getOption("env");
if($this->basePath === null){
$fullPath = $documentsPath.$ds.$env.$ds.$id;
}else{
$fullPath = $this->basePath;
}
if($this->subPath !== null){
$fullPath .= $ds.$this->subPath;
}
if(!$this->exporterManager->getFs()->exists($fullPath)){
$this->exporterManager->getFs()->mkdir($fullPath);
}
return $fullPath;
} | php | public function getDirOutput() {
$ds = DIRECTORY_SEPARATOR;
$id = $this->getId();
$documentsPath = $this->exporterManager->getOption("documents_path");
$env = $this->exporterManager->getOption("env");
if($this->basePath === null){
$fullPath = $documentsPath.$ds.$env.$ds.$id;
}else{
$fullPath = $this->basePath;
}
if($this->subPath !== null){
$fullPath .= $ds.$this->subPath;
}
if(!$this->exporterManager->getFs()->exists($fullPath)){
$this->exporterManager->getFs()->mkdir($fullPath);
}
return $fullPath;
} | [
"public",
"function",
"getDirOutput",
"(",
")",
"{",
"$",
"ds",
"=",
"DIRECTORY_SEPARATOR",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"$",
"documentsPath",
"=",
"$",
"this",
"->",
"exporterManager",
"->",
"getOption",
"(",
"\"docume... | Retorna el directorio de salida de los documentos del model
@return string | [
"Retorna",
"el",
"directorio",
"de",
"salida",
"de",
"los",
"documentos",
"del",
"model"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Exporter/ChainModel.php#L114-L132 | train |
Tecnocreaciones/ToolsBundle | Model/Exporter/ChainModel.php | ChainModel.getFiles | public function getFiles() {
$dir = $this->getDirOutput();
$finder = new \Symfony\Component\Finder\Finder();
$finder->files()->in($dir);
return $finder;
} | php | public function getFiles() {
$dir = $this->getDirOutput();
$finder = new \Symfony\Component\Finder\Finder();
$finder->files()->in($dir);
return $finder;
} | [
"public",
"function",
"getFiles",
"(",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"getDirOutput",
"(",
")",
";",
"$",
"finder",
"=",
"new",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"Finder",
"\\",
"Finder",
"(",
")",
";",
"$",
"finder",
"->",
"... | Obtiene los archivos en la carpeta del chain en el modulo
@return \AppBundle\Model\Core\Exporter\Finder | [
"Obtiene",
"los",
"archivos",
"en",
"la",
"carpeta",
"del",
"chain",
"en",
"el",
"modulo"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Exporter/ChainModel.php#L138-L143 | train |
Tecnocreaciones/ToolsBundle | Model/Exporter/ChainModel.php | ChainModel.deleteFile | public function deleteFile($fileName) {
$files = $this->getFiles();
$success = false;
foreach ($files as $file) {
if($file->getRelativePathname() === $fileName){
if(!$file->isWritable()){
throw new RuntimeException(sprintf("The file '%s' is not writable and can not be deleted.",$fileName));
}
unlink($file->getRealPath());
if($file->isReadable()){
throw new RuntimeException(sprintf("The file '%s' could not be deleted",$fileName));
}
$success = true;
}
}
return $success;
} | php | public function deleteFile($fileName) {
$files = $this->getFiles();
$success = false;
foreach ($files as $file) {
if($file->getRelativePathname() === $fileName){
if(!$file->isWritable()){
throw new RuntimeException(sprintf("The file '%s' is not writable and can not be deleted.",$fileName));
}
unlink($file->getRealPath());
if($file->isReadable()){
throw new RuntimeException(sprintf("The file '%s' could not be deleted",$fileName));
}
$success = true;
}
}
return $success;
} | [
"public",
"function",
"deleteFile",
"(",
"$",
"fileName",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getFiles",
"(",
")",
";",
"$",
"success",
"=",
"false",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"fi... | Elimina un archivo dentro del modulo con su nombre
@param type $fileName
@throws RuntimeException | [
"Elimina",
"un",
"archivo",
"dentro",
"del",
"modulo",
"con",
"su",
"nombre"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Exporter/ChainModel.php#L150-L166 | train |
Tecnocreaciones/ToolsBundle | Model/Exporter/ChainModel.php | ChainModel.getFile | public function getFile($fileName) {
$files = $this->getFiles();
$found = null;
foreach ($files as $file) {
if($file->getRelativePathname() === $fileName){
if(!$file->isReadable()){
throw new RuntimeException(sprintf("The file '%s' could not be read.",$fileName));
}
$found = $file;
break;
}
}
return $found;
} | php | public function getFile($fileName) {
$files = $this->getFiles();
$found = null;
foreach ($files as $file) {
if($file->getRelativePathname() === $fileName){
if(!$file->isReadable()){
throw new RuntimeException(sprintf("The file '%s' could not be read.",$fileName));
}
$found = $file;
break;
}
}
return $found;
} | [
"public",
"function",
"getFile",
"(",
"$",
"fileName",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getFiles",
"(",
")",
";",
"$",
"found",
"=",
"null",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
... | Busca un archivo por su nombre en la carpeta del exportador
@param type $fileName
@return \Symfony\Component\Finder\SplFileInfo
@throws RuntimeException | [
"Busca",
"un",
"archivo",
"por",
"su",
"nombre",
"en",
"la",
"carpeta",
"del",
"exportador"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Exporter/ChainModel.php#L174-L187 | train |
droath/project-x | src/Config/ConfigBase.php | ConfigBase.createFromFile | public static function createFromFile(\SplFileInfo $file_info)
{
$contents = file_get_contents($file_info);
if (!$contents) {
throw new \RuntimeException(
sprintf(
'Unable to retrieve contents from file (%s).',
$file_info->getRealPath()
)
);
}
return self::createFromString($contents);
} | php | public static function createFromFile(\SplFileInfo $file_info)
{
$contents = file_get_contents($file_info);
if (!$contents) {
throw new \RuntimeException(
sprintf(
'Unable to retrieve contents from file (%s).',
$file_info->getRealPath()
)
);
}
return self::createFromString($contents);
} | [
"public",
"static",
"function",
"createFromFile",
"(",
"\\",
"SplFileInfo",
"$",
"file_info",
")",
"{",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"file_info",
")",
";",
"if",
"(",
"!",
"$",
"contents",
")",
"{",
"throw",
"new",
"\\",
"RuntimeExc... | Create configuration object from file.
@param \SplFileInfo $file_info
@return self | [
"Create",
"configuration",
"object",
"from",
"file",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Config/ConfigBase.php#L47-L61 | train |
krystal-framework/krystal.framework | src/Krystal/Image/Tool/Upload/UploaderFactory.php | UploaderFactory.build | public static function build($dir, array $plugins)
{
if (count($plugins) === 0) {
throw new InvalidArgumentException('There must be at least one provided plugin for image uploader');
}
// Default image's quality
$quality = 75;
$collection = array();
foreach ($plugins as $plugin => $options) {
switch ($plugin) {
case 'thumb':
$thumb = new ThumbFactory();
$collection[] = $thumb->build($dir, $quality, $options);
break;
case 'original':
$original = new OriginalSizeFactory();
$collection[] = $original->build($dir, $quality, $options);
break;
}
}
return new UploadChain($collection);
} | php | public static function build($dir, array $plugins)
{
if (count($plugins) === 0) {
throw new InvalidArgumentException('There must be at least one provided plugin for image uploader');
}
// Default image's quality
$quality = 75;
$collection = array();
foreach ($plugins as $plugin => $options) {
switch ($plugin) {
case 'thumb':
$thumb = new ThumbFactory();
$collection[] = $thumb->build($dir, $quality, $options);
break;
case 'original':
$original = new OriginalSizeFactory();
$collection[] = $original->build($dir, $quality, $options);
break;
}
}
return new UploadChain($collection);
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"dir",
",",
"array",
"$",
"plugins",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"plugins",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'There must be at least one provided plugin ... | Builds image uploader chain
@param string $dir
@param array $plugins
@throws \InvalidArgumentException when failing to load any of plugins
@return \Krystal\Http\FileTransfer\UploadChain | [
"Builds",
"image",
"uploader",
"chain"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/Upload/UploaderFactory.php#L29-L54 | train |
solspace/craft3-commons | src/Helpers/PermissionHelper.php | PermissionHelper.checkPermission | public static function checkPermission(string $permissionName, bool $checkForNested = false): bool
{
if (self::isAdmin()) {
return true;
}
$user = \Craft::$app->getUser();
$permissionName = strtolower($permissionName);
if (self::permissionsEnabled()) {
if ($checkForNested) {
if (!$user->getId()) {
return false;
}
$permissionList = \Craft::$app->userPermissions->getPermissionsByUserId($user->getId());
foreach ($permissionList as $permission) {
if (strpos($permission, $permissionName) === 0) {
return true;
}
}
}
return $user->checkPermission($permissionName);
}
return false;
} | php | public static function checkPermission(string $permissionName, bool $checkForNested = false): bool
{
if (self::isAdmin()) {
return true;
}
$user = \Craft::$app->getUser();
$permissionName = strtolower($permissionName);
if (self::permissionsEnabled()) {
if ($checkForNested) {
if (!$user->getId()) {
return false;
}
$permissionList = \Craft::$app->userPermissions->getPermissionsByUserId($user->getId());
foreach ($permissionList as $permission) {
if (strpos($permission, $permissionName) === 0) {
return true;
}
}
}
return $user->checkPermission($permissionName);
}
return false;
} | [
"public",
"static",
"function",
"checkPermission",
"(",
"string",
"$",
"permissionName",
",",
"bool",
"$",
"checkForNested",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"self",
"::",
"isAdmin",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"... | Checks a given permission for the currently logged in user
@param string $permissionName
@param bool $checkForNested - see nested permissions for matching permission name root
@return bool | [
"Checks",
"a",
"given",
"permission",
"for",
"the",
"currently",
"logged",
"in",
"user"
] | 2de20a76e83efe3ed615a2a102dfef18e2295420 | https://github.com/solspace/craft3-commons/blob/2de20a76e83efe3ed615a2a102dfef18e2295420/src/Helpers/PermissionHelper.php#L17-L44 | train |
solspace/craft3-commons | src/Helpers/PermissionHelper.php | PermissionHelper.getNestedPermissionIds | public static function getNestedPermissionIds(string $permissionName)
{
if (self::isAdmin()) {
return true;
}
$user = \Craft::$app->getUser();
$permissionName = strtolower($permissionName);
$idList = [];
if (self::permissionsEnabled()) {
if (!$user->getId()) {
return [];
}
$permissionList = \Craft::$app->userPermissions->getPermissionsByUserId($user->getId());
foreach ($permissionList as $permission) {
if (strpos($permission, $permissionName) === 0) {
if (strpos($permission, ':') === false) {
continue;
}
list($name, $id) = explode(':', $permission);
$idList[] = $id;
}
}
return $idList;
}
return self::isAdmin();
} | php | public static function getNestedPermissionIds(string $permissionName)
{
if (self::isAdmin()) {
return true;
}
$user = \Craft::$app->getUser();
$permissionName = strtolower($permissionName);
$idList = [];
if (self::permissionsEnabled()) {
if (!$user->getId()) {
return [];
}
$permissionList = \Craft::$app->userPermissions->getPermissionsByUserId($user->getId());
foreach ($permissionList as $permission) {
if (strpos($permission, $permissionName) === 0) {
if (strpos($permission, ':') === false) {
continue;
}
list($name, $id) = explode(':', $permission);
$idList[] = $id;
}
}
return $idList;
}
return self::isAdmin();
} | [
"public",
"static",
"function",
"getNestedPermissionIds",
"(",
"string",
"$",
"permissionName",
")",
"{",
"if",
"(",
"self",
"::",
"isAdmin",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"user",
"=",
"\\",
"Craft",
"::",
"$",
"app",
"->",
"getU... | Fetches all nested allowed permission IDs from a nested permission set
@param string $permissionName
@return array|bool | [
"Fetches",
"all",
"nested",
"allowed",
"permission",
"IDs",
"from",
"a",
"nested",
"permission",
"set"
] | 2de20a76e83efe3ed615a2a102dfef18e2295420 | https://github.com/solspace/craft3-commons/blob/2de20a76e83efe3ed615a2a102dfef18e2295420/src/Helpers/PermissionHelper.php#L73-L105 | train |
droath/project-x | src/Template/TemplateManager.php | TemplateManager.loadTemplate | public function loadTemplate($filename, $format = null)
{
$contents = $this->getTemplateContent($filename);
switch ($format) {
case 'json':
$contents = json_decode($contents, true);
break;
}
return $contents;
} | php | public function loadTemplate($filename, $format = null)
{
$contents = $this->getTemplateContent($filename);
switch ($format) {
case 'json':
$contents = json_decode($contents, true);
break;
}
return $contents;
} | [
"public",
"function",
"loadTemplate",
"(",
"$",
"filename",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"contents",
"=",
"$",
"this",
"->",
"getTemplateContent",
"(",
"$",
"filename",
")",
";",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"'json... | Load template file contents.
@param string $filename
The template filename.
@param string $format
The format to use to decode the contents.
@return string|array
The templates raw contents; if format was provided the decoded contents
is returned. | [
"Load",
"template",
"file",
"contents",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Template/TemplateManager.php#L36-L48 | train |
droath/project-x | src/Template/TemplateManager.php | TemplateManager.getTemplateFilePath | public function getTemplateFilePath($filename)
{
$filepath = $this->locateTemplateFilePath($filename);
if (!file_exists($filepath)) {
return false;
}
return $filepath;
} | php | public function getTemplateFilePath($filename)
{
$filepath = $this->locateTemplateFilePath($filename);
if (!file_exists($filepath)) {
return false;
}
return $filepath;
} | [
"public",
"function",
"getTemplateFilePath",
"(",
"$",
"filename",
")",
"{",
"$",
"filepath",
"=",
"$",
"this",
"->",
"locateTemplateFilePath",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filepath",
")",
")",
"{",
"return",
... | Get template file path.
@param string $filename
The file name.
@return string|bool
The path to the particular template file; otherwise false if the
path doesn't exist. | [
"Get",
"template",
"file",
"path",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Template/TemplateManager.php#L60-L69 | train |
droath/project-x | src/Template/TemplateManager.php | TemplateManager.locateTemplateFilePath | protected function locateTemplateFilePath($filename)
{
// Search project root template directory if defined.
if ($this->hasProjectTemplateDirectory()) {
$filepath = $this->templateProjectPath() . "/{$filename}";
if (file_exists($filepath)) {
return $filepath;
}
}
// Search defined directories for template files.
foreach ($this->searchDirectories as $directory) {
if (!file_exists($directory)) {
continue;
}
$filepath = "{$directory}/{$filename}";
if (file_exists($filepath)) {
return $filepath;
}
}
return null;
} | php | protected function locateTemplateFilePath($filename)
{
// Search project root template directory if defined.
if ($this->hasProjectTemplateDirectory()) {
$filepath = $this->templateProjectPath() . "/{$filename}";
if (file_exists($filepath)) {
return $filepath;
}
}
// Search defined directories for template files.
foreach ($this->searchDirectories as $directory) {
if (!file_exists($directory)) {
continue;
}
$filepath = "{$directory}/{$filename}";
if (file_exists($filepath)) {
return $filepath;
}
}
return null;
} | [
"protected",
"function",
"locateTemplateFilePath",
"(",
"$",
"filename",
")",
"{",
"// Search project root template directory if defined.",
"if",
"(",
"$",
"this",
"->",
"hasProjectTemplateDirectory",
"(",
")",
")",
"{",
"$",
"filepath",
"=",
"$",
"this",
"->",
"tem... | Locate the template file path.
It checks different template directories for a specific filename to see
if the template file was overridden before returning the default.
@param string $filename
The name of the template file.
@return string
The path to the template file. | [
"Locate",
"the",
"template",
"file",
"path",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Template/TemplateManager.php#L122-L146 | train |
krystal-framework/krystal.framework | src/Krystal/Application/Module/CoreBag.php | CoreBag.getMissingCoreModules | public function getMissingCoreModules()
{
$modules = array();
foreach ($this->coreModules as $module) {
if (!$this->isLoadedModule($module)) {
array_push($modules, $module);
}
}
return $modules;
} | php | public function getMissingCoreModules()
{
$modules = array();
foreach ($this->coreModules as $module) {
if (!$this->isLoadedModule($module)) {
array_push($modules, $module);
}
}
return $modules;
} | [
"public",
"function",
"getMissingCoreModules",
"(",
")",
"{",
"$",
"modules",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"coreModules",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isLoadedModule",
"(",
"$",
... | Returns a collection of missing modules
@return array | [
"Returns",
"a",
"collection",
"of",
"missing",
"modules"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Module/CoreBag.php#L62-L73 | train |
krystal-framework/krystal.framework | src/Krystal/Application/Module/CoreBag.php | CoreBag.isCoreModule | public function isCoreModule($module)
{
if (!is_string($module)) {
throw new InvalidArgumentException(sprintf(
'Module name must be a string, not "%s"', gettype($module)
));
}
return in_array($module, $this->coreModules);
} | php | public function isCoreModule($module)
{
if (!is_string($module)) {
throw new InvalidArgumentException(sprintf(
'Module name must be a string, not "%s"', gettype($module)
));
}
return in_array($module, $this->coreModules);
} | [
"public",
"function",
"isCoreModule",
"(",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"module",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Module name must be a string, not \"%s\"'",
",",
"gettype",
"("... | Checks whether target module
@param string $module Module name
@throws \InvalidArgumentException If $module isn't a string
@return boolean | [
"Checks",
"whether",
"target",
"module"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Module/CoreBag.php#L93-L102 | train |
krystal-framework/krystal.framework | src/Krystal/Application/Module/CoreBag.php | CoreBag.isCoreModules | public function isCoreModules(array $modules)
{
foreach ($modules as $module) {
if (!$this->isCoreModule($module)) {
return false;
}
}
return true;
} | php | public function isCoreModules(array $modules)
{
foreach ($modules as $module) {
if (!$this->isCoreModule($module)) {
return false;
}
}
return true;
} | [
"public",
"function",
"isCoreModules",
"(",
"array",
"$",
"modules",
")",
"{",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isCoreModule",
"(",
"$",
"module",
")",
")",
"{",
"return",
"false",
";"... | Checks whether all collection consists of core modules
@param string $modules A collection of module names
@throws \InvalidArgumentException If $module isn't a string
@return boolean | [
"Checks",
"whether",
"all",
"collection",
"consists",
"of",
"core",
"modules"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Module/CoreBag.php#L111-L120 | train |
droath/project-x | src/Platform/PlatformTypeFactory.php | PlatformTypeFactory.createInstance | public function createInstance()
{
$classname = $this->getPlatformClassname();
if (!class_exists($classname)) {
throw new \Exception(
sprintf('Unable to locate class %s', $classname)
);
}
return new $classname();
} | php | public function createInstance()
{
$classname = $this->getPlatformClassname();
if (!class_exists($classname)) {
throw new \Exception(
sprintf('Unable to locate class %s', $classname)
);
}
return new $classname();
} | [
"public",
"function",
"createInstance",
"(",
")",
"{",
"$",
"classname",
"=",
"$",
"this",
"->",
"getPlatformClassname",
"(",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf... | Create a class instance.
@return object.
@throws \Exception | [
"Create",
"a",
"class",
"instance",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Platform/PlatformTypeFactory.php#L37-L48 | train |
fxpio/fxp-form-extensions | Doctrine/Form/ChoiceList/AjaxORMFilter.php | AjaxORMFilter.filter | public function filter(QueryBuilder $qb, $alias, $identifier, $search)
{
$qb->andWhere("LOWER({$alias}.{$identifier}) LIKE LOWER(:{$identifier})");
$qb->setParameter($identifier, "%{$search}%");
} | php | public function filter(QueryBuilder $qb, $alias, $identifier, $search)
{
$qb->andWhere("LOWER({$alias}.{$identifier}) LIKE LOWER(:{$identifier})");
$qb->setParameter($identifier, "%{$search}%");
} | [
"public",
"function",
"filter",
"(",
"QueryBuilder",
"$",
"qb",
",",
"$",
"alias",
",",
"$",
"identifier",
",",
"$",
"search",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"\"LOWER({$alias}.{$identifier}) LIKE LOWER(:{$identifier})\"",
")",
";",
"$",
"qb",
"->"... | Apply the filter in query builder.
@param QueryBuilder $qb The query builder
@param string $alias The entity alias
@param string $identifier The field identifier
@param string $search The search | [
"Apply",
"the",
"filter",
"in",
"query",
"builder",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Doctrine/Form/ChoiceList/AjaxORMFilter.php#L29-L33 | train |
austinheap/php-security-txt | src/Directives/Acknowledgement.php | Acknowledgement.setAcknowledgement | public function setAcknowledgement(string $acknowledgement): SecurityTxt
{
if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) {
throw new Exception('Acknowledgement must be a well-formed URL.');
}
$this->acknowledgement = $acknowledgement;
return $this;
} | php | public function setAcknowledgement(string $acknowledgement): SecurityTxt
{
if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) {
throw new Exception('Acknowledgement must be a well-formed URL.');
}
$this->acknowledgement = $acknowledgement;
return $this;
} | [
"public",
"function",
"setAcknowledgement",
"(",
"string",
"$",
"acknowledgement",
")",
":",
"SecurityTxt",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"acknowledgement",
",",
"FILTER_VALIDATE_URL",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
... | Set the acknowledgement URL.
@param string $acknowledgement
@return SecurityTxt | [
"Set",
"the",
"acknowledgement",
"URL",
"."
] | 01c4f32858b2a0d020fe0232467f0900833c0ff3 | https://github.com/austinheap/php-security-txt/blob/01c4f32858b2a0d020fe0232467f0900833c0ff3/src/Directives/Acknowledgement.php#L42-L51 | train |
krystal-framework/krystal.framework | src/Krystal/Debug/Exception/Handler.php | Handler.handle | public function handle($exception)
{
$file = $exception->getFile();
$line = $exception->getLine();
$message = $exception->getMessage();
$trace = $exception->getTrace();
// Reverse and reset default order
$trace = array_reverse($trace);
// The name of thrown exception
$class = get_class($exception);
// Above variables will be available in the template
require($this->templateFile);
} | php | public function handle($exception)
{
$file = $exception->getFile();
$line = $exception->getLine();
$message = $exception->getMessage();
$trace = $exception->getTrace();
// Reverse and reset default order
$trace = array_reverse($trace);
// The name of thrown exception
$class = get_class($exception);
// Above variables will be available in the template
require($this->templateFile);
} | [
"public",
"function",
"handle",
"(",
"$",
"exception",
")",
"{",
"$",
"file",
"=",
"$",
"exception",
"->",
"getFile",
"(",
")",
";",
"$",
"line",
"=",
"$",
"exception",
"->",
"getLine",
"(",
")",
";",
"$",
"message",
"=",
"$",
"exception",
"->",
"g... | Custom exception handler
@param \Exception $exception
@return void | [
"Custom",
"exception",
"handler"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Debug/Exception/Handler.php#L44-L59 | train |
jer-lim/Telegram-Bot-Core | src/TelegramBotCore.php | TelegramBotCore.webhook | public function webhook(): void
{
//$log = new Logger('botlog');
//$log->pushHandler(new StreamHandler(__DIR__ . "/../log/botlog.log", Logger::DEBUG));
if ($data = BotApi::jsonValidate(file_get_contents('php://input'), true)) {
//$log->debug(file_get_contents('php://input'));
$update = Update::fromResponse($data);
$this->processUpdate($update);
}
} | php | public function webhook(): void
{
//$log = new Logger('botlog');
//$log->pushHandler(new StreamHandler(__DIR__ . "/../log/botlog.log", Logger::DEBUG));
if ($data = BotApi::jsonValidate(file_get_contents('php://input'), true)) {
//$log->debug(file_get_contents('php://input'));
$update = Update::fromResponse($data);
$this->processUpdate($update);
}
} | [
"public",
"function",
"webhook",
"(",
")",
":",
"void",
"{",
"//$log = new Logger('botlog');",
"//$log->pushHandler(new StreamHandler(__DIR__ . \"/../log/botlog.log\", Logger::DEBUG));",
"if",
"(",
"$",
"data",
"=",
"BotApi",
"::",
"jsonValidate",
"(",
"file_get_contents",
"(... | Call this function to turn on the bot when processing via webhooks. | [
"Call",
"this",
"function",
"to",
"turn",
"on",
"the",
"bot",
"when",
"processing",
"via",
"webhooks",
"."
] | 49a184aef0922d1b70ade91204738fe40a1ea5ae | https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/TelegramBotCore.php#L78-L88 | train |
jer-lim/Telegram-Bot-Core | src/TelegramBotCore.php | TelegramBotCore.addCommand | protected function addCommand(Command $handler): void
{
$handler->setBot($this);
$command = $handler->getName();
$this->commands[strtoupper($command)] = $handler;
} | php | protected function addCommand(Command $handler): void
{
$handler->setBot($this);
$command = $handler->getName();
$this->commands[strtoupper($command)] = $handler;
} | [
"protected",
"function",
"addCommand",
"(",
"Command",
"$",
"handler",
")",
":",
"void",
"{",
"$",
"handler",
"->",
"setBot",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"handler",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"command... | Add a command to the list of commands.
@param Command $handler Handler for the command. | [
"Add",
"a",
"command",
"to",
"the",
"list",
"of",
"commands",
"."
] | 49a184aef0922d1b70ade91204738fe40a1ea5ae | https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/TelegramBotCore.php#L292-L297 | train |
jer-lim/Telegram-Bot-Core | src/TelegramBotCore.php | TelegramBotCore.setCallbackQueryHandler | protected function setCallbackQueryHandler(CallbackQueryHandler $handler): void
{
$handler->setBot($this);
$this->cqHandler = $handler;
} | php | protected function setCallbackQueryHandler(CallbackQueryHandler $handler): void
{
$handler->setBot($this);
$this->cqHandler = $handler;
} | [
"protected",
"function",
"setCallbackQueryHandler",
"(",
"CallbackQueryHandler",
"$",
"handler",
")",
":",
"void",
"{",
"$",
"handler",
"->",
"setBot",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"cqHandler",
"=",
"$",
"handler",
";",
"}"
] | Set the handler to handle callback queries.
@param CallbackQueryHandler $handler CallbackQuery handler. | [
"Set",
"the",
"handler",
"to",
"handle",
"callback",
"queries",
"."
] | 49a184aef0922d1b70ade91204738fe40a1ea5ae | https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/TelegramBotCore.php#L303-L307 | train |
jer-lim/Telegram-Bot-Core | src/TelegramBotCore.php | TelegramBotCore.setGenericMessageHandler | protected function setGenericMessageHandler(GenericMessageHandler $handler): void
{
$handler->setBot($this);
$this->genericMessageHandler = $handler;
} | php | protected function setGenericMessageHandler(GenericMessageHandler $handler): void
{
$handler->setBot($this);
$this->genericMessageHandler = $handler;
} | [
"protected",
"function",
"setGenericMessageHandler",
"(",
"GenericMessageHandler",
"$",
"handler",
")",
":",
"void",
"{",
"$",
"handler",
"->",
"setBot",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"genericMessageHandler",
"=",
"$",
"handler",
";",
"}"
] | Set the handler to handle plaintext messages.
@param PlaintextHandler $handler Plaintext handler. | [
"Set",
"the",
"handler",
"to",
"handle",
"plaintext",
"messages",
"."
] | 49a184aef0922d1b70ade91204738fe40a1ea5ae | https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/TelegramBotCore.php#L313-L317 | train |
krystal-framework/krystal.framework | src/Krystal/Cache/MemoryCache.php | MemoryCache.increment | public function increment($key, $step = 1)
{
$value = $this->get($key);
$this->set($key, $value + $step);
} | php | public function increment($key, $step = 1)
{
$value = $this->get($key);
$this->set($key, $value + $step);
} | [
"public",
"function",
"increment",
"(",
"$",
"key",
",",
"$",
"step",
"=",
"1",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"+",
"$",
"step",
... | Increments a numeric value
@param string $key
@param integer $step
@return void | [
"Increments",
"a",
"numeric",
"value"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/MemoryCache.php#L32-L36 | train |
krystal-framework/krystal.framework | src/Krystal/Cache/MemoryCache.php | MemoryCache.decrement | public function decrement($key, $step = 1)
{
$value = $this->get($key);
$this->set($key, $value - $step);
} | php | public function decrement($key, $step = 1)
{
$value = $this->get($key);
$this->set($key, $value - $step);
} | [
"public",
"function",
"decrement",
"(",
"$",
"key",
",",
"$",
"step",
"=",
"1",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"-",
"$",
"step",
... | Decrements a numeric value
@param string $string $key
@param integer $step
@return void | [
"Decrements",
"a",
"numeric",
"value"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/MemoryCache.php#L45-L49 | train |
krystal-framework/krystal.framework | src/Krystal/Cache/MemoryCache.php | MemoryCache.get | public function get($key, $default = false)
{
if ($this->has($key) !== false) {
return $this->cache[$key];
} else {
return $default;
}
} | php | public function get($key, $default = false)
{
if ($this->has($key) !== false) {
return $this->cache[$key];
} else {
return $default;
}
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"... | Reads key's value from a cache if present
@param string $key
@param boolean $default Default value to be returned if required key doesn't exist
@return mixed | [
"Reads",
"key",
"s",
"value",
"from",
"a",
"cache",
"if",
"present"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/MemoryCache.php#L72-L79 | train |
krystal-framework/krystal.framework | src/Krystal/Cache/MemoryCache.php | MemoryCache.remove | public function remove($key)
{
if ($this->has($key)) {
unset($this->cache[$key]);
return true;
} else {
return false;
}
} | php | public function remove($key)
{
if ($this->has($key)) {
unset($this->cache[$key]);
return true;
} else {
return false;
}
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",... | Removes a key from the memory
@param string $key
@return boolean True if removed, false if could not | [
"Removes",
"a",
"key",
"from",
"the",
"memory"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/MemoryCache.php#L87-L95 | train |
Tecnocreaciones/ToolsBundle | Model/Data/DataTableData.php | DataTableData.buildColumns | private function buildColumns(array $columns)
{
$this->columns = [];
foreach ($columns as $key => $column)
{
$column = new DataTableColumn($column);
$this->columns[$key] = $column;
if($column->getName() != ""){
$this->columns[$column->getName()] = $column;
}
if($column->getData() != ""){
$this->columns[$column->getData()] = $column;
}
}
} | php | private function buildColumns(array $columns)
{
$this->columns = [];
foreach ($columns as $key => $column)
{
$column = new DataTableColumn($column);
$this->columns[$key] = $column;
if($column->getName() != ""){
$this->columns[$column->getName()] = $column;
}
if($column->getData() != ""){
$this->columns[$column->getData()] = $column;
}
}
} | [
"private",
"function",
"buildColumns",
"(",
"array",
"$",
"columns",
")",
"{",
"$",
"this",
"->",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"key",
"=>",
"$",
"column",
")",
"{",
"$",
"column",
"=",
"new",
"DataTableCol... | Construye una columna
@param array $columns | [
"Construye",
"una",
"columna"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Data/DataTableData.php#L43-L57 | train |
Tecnocreaciones/ToolsBundle | Model/Data/DataTableData.php | DataTableData.getColumnByIndex | public function getColumnByIndex($index)
{
if(!isset($this->columns[$index])){
throw new Exception(sprintf("Column index %s is not valid",$index));
}
return $this->columns[$index];
} | php | public function getColumnByIndex($index)
{
if(!isset($this->columns[$index])){
throw new Exception(sprintf("Column index %s is not valid",$index));
}
return $this->columns[$index];
} | [
"public",
"function",
"getColumnByIndex",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"columns",
"[",
"$",
"index",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"\"Column index %s is not valid\"",
... | Retorna una columna por el indice
@param type $index
@return DataTableColumn
@throws Exception | [
"Retorna",
"una",
"columna",
"por",
"el",
"indice"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Data/DataTableData.php#L64-L70 | train |
droath/project-x | src/Engine/EngineTypeFactory.php | EngineTypeFactory.createInstance | public function createInstance()
{
$classname = $this->getEngineClassname();
if (!class_exists($classname)) {
throw new \Exception(
sprintf('Unable to locate class %s', $classname)
);
}
return new $classname();
} | php | public function createInstance()
{
$classname = $this->getEngineClassname();
if (!class_exists($classname)) {
throw new \Exception(
sprintf('Unable to locate class %s', $classname)
);
}
return new $classname();
} | [
"public",
"function",
"createInstance",
"(",
")",
"{",
"$",
"classname",
"=",
"$",
"this",
"->",
"getEngineClassname",
"(",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",... | Create engine type instance.
@return \Droath\ProjectX\Engine\EngineTypeInterface | [
"Create",
"engine",
"type",
"instance",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/EngineTypeFactory.php#L34-L45 | train |
Droeftoeter/pokapi | src/Pokapi/Hashing/Pogodev.php | Pogodev.supportsVersion | public function supportsVersion(Version $version) : bool
{
try {
$this->getVersionUrl($version);
} catch (UnsupportedVersionException $e) {
return false;
}
return true;
} | php | public function supportsVersion(Version $version) : bool
{
try {
$this->getVersionUrl($version);
} catch (UnsupportedVersionException $e) {
return false;
}
return true;
} | [
"public",
"function",
"supportsVersion",
"(",
"Version",
"$",
"version",
")",
":",
"bool",
"{",
"try",
"{",
"$",
"this",
"->",
"getVersionUrl",
"(",
"$",
"version",
")",
";",
"}",
"catch",
"(",
"UnsupportedVersionException",
"$",
"e",
")",
"{",
"return",
... | Check if provider supports a specific version of the game.
@param Version $version
@return bool
@throws InvalidResponseException | [
"Check",
"if",
"provider",
"supports",
"a",
"specific",
"version",
"of",
"the",
"game",
"."
] | 3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3 | https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Hashing/Pogodev.php#L62-L71 | train |
i-lateral/silverstripe-checkout | code/control/payment/PayPalHandler.php | PayPalHandler.callback | public function callback($request)
{
$this->extend('onBeforeCallback');
$data = $this->request->postVars();
$status = "error";
$order_id = 0;
$payment_id = 0;
$error_url = Controller::join_links(
Director::absoluteBaseURL(),
Payment_Controller::config()->url_segment,
'complete',
'error'
);
// Check if CallBack data exists and install id matches the saved ID
if (isset($data) && isset($data['custom']) && isset($data['payment_status'])) {
$order_id = $data['custom'];
$paypal_request = 'cmd=_notify-validate';
$final_response = "";
// If the transaction ID is set, keep it
if (array_key_exists("txn_id", $data)) {
$payment_id = $data["txn_id"];
}
$listener = new PaypalIPN();
if (Director::isDev()) {
$listener->useSandbox();
}
try {
$verified = $listener->verifyIPN();
} catch (Exception $e) {
error_log("Unable to verify IPN: " . $e->getMessage());
return $this->httpError(500);
}
if ($verified) {
// IPN response was "VERIFIED"
switch ($data['payment_status']) {
case 'Canceled_Reversal':
$status = "canceled";
break;
case 'Completed':
$status = "paid";
break;
case 'Denied':
$status = "failed";
break;
case 'Expired':
$status = "failed";
break;
case 'Failed':
$status = "failed";
break;
case 'Pending':
$status = "pending";
break;
case 'Processed':
$status = "pending";
break;
case 'Refunded':
$status = "refunded";
break;
case 'Reversed':
$status = "canceled";
break;
case 'Voided':
$status = "canceled";
break;
}
} else {
error_log("Invalid payment status");
return $this->httpError(500);
}
} else {
error_log("No payment details set");
return $this->httpError(500);
}
$payment_data = ArrayData::array_to_object(array(
"OrderID" => $order_id,
"PaymentProvider" => "PayPal",
"PaymentID" => $payment_id,
"Status" => $status,
"GatewayData" => $data
));
$this->setPaymentData($payment_data);
$this->extend('onAfterCallback');
return $this->httpError(200);
} | php | public function callback($request)
{
$this->extend('onBeforeCallback');
$data = $this->request->postVars();
$status = "error";
$order_id = 0;
$payment_id = 0;
$error_url = Controller::join_links(
Director::absoluteBaseURL(),
Payment_Controller::config()->url_segment,
'complete',
'error'
);
// Check if CallBack data exists and install id matches the saved ID
if (isset($data) && isset($data['custom']) && isset($data['payment_status'])) {
$order_id = $data['custom'];
$paypal_request = 'cmd=_notify-validate';
$final_response = "";
// If the transaction ID is set, keep it
if (array_key_exists("txn_id", $data)) {
$payment_id = $data["txn_id"];
}
$listener = new PaypalIPN();
if (Director::isDev()) {
$listener->useSandbox();
}
try {
$verified = $listener->verifyIPN();
} catch (Exception $e) {
error_log("Unable to verify IPN: " . $e->getMessage());
return $this->httpError(500);
}
if ($verified) {
// IPN response was "VERIFIED"
switch ($data['payment_status']) {
case 'Canceled_Reversal':
$status = "canceled";
break;
case 'Completed':
$status = "paid";
break;
case 'Denied':
$status = "failed";
break;
case 'Expired':
$status = "failed";
break;
case 'Failed':
$status = "failed";
break;
case 'Pending':
$status = "pending";
break;
case 'Processed':
$status = "pending";
break;
case 'Refunded':
$status = "refunded";
break;
case 'Reversed':
$status = "canceled";
break;
case 'Voided':
$status = "canceled";
break;
}
} else {
error_log("Invalid payment status");
return $this->httpError(500);
}
} else {
error_log("No payment details set");
return $this->httpError(500);
}
$payment_data = ArrayData::array_to_object(array(
"OrderID" => $order_id,
"PaymentProvider" => "PayPal",
"PaymentID" => $payment_id,
"Status" => $status,
"GatewayData" => $data
));
$this->setPaymentData($payment_data);
$this->extend('onAfterCallback');
return $this->httpError(200);
} | [
"public",
"function",
"callback",
"(",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"extend",
"(",
"'onBeforeCallback'",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"request",
"->",
"postVars",
"(",
")",
";",
"$",
"status",
"=",
"\"error\"",
";",
... | Process the callback data from the payment provider | [
"Process",
"the",
"callback",
"data",
"from",
"the",
"payment",
"provider"
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/payment/PayPalHandler.php#L149-L245 | train |
Larium/larium_creditcard | src/CreditCard/CreditCardValidator.php | CreditCardValidator.setContext | public function setContext($context)
{
$contexts = array(self::CONTEXT_CREDITCARD, self::CONTEXT_TOKEN);
if (!in_array($context, $contexts)) {
throw new RuntimeException(
sprintf("Invalid validation context '%s'", $context)
);
}
$this->context = $context;
} | php | public function setContext($context)
{
$contexts = array(self::CONTEXT_CREDITCARD, self::CONTEXT_TOKEN);
if (!in_array($context, $contexts)) {
throw new RuntimeException(
sprintf("Invalid validation context '%s'", $context)
);
}
$this->context = $context;
} | [
"public",
"function",
"setContext",
"(",
"$",
"context",
")",
"{",
"$",
"contexts",
"=",
"array",
"(",
"self",
"::",
"CONTEXT_CREDITCARD",
",",
"self",
"::",
"CONTEXT_TOKEN",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"context",
",",
"$",
"contexts"... | Sets the context that the validator will validate a CreditCard.
@param string $context
@return void | [
"Sets",
"the",
"context",
"that",
"the",
"validator",
"will",
"validate",
"a",
"CreditCard",
"."
] | ea1957bbe28e2448498abe7bb5a5b6ff0020bb2d | https://github.com/Larium/larium_creditcard/blob/ea1957bbe28e2448498abe7bb5a5b6ff0020bb2d/src/CreditCard/CreditCardValidator.php#L46-L56 | train |
Larium/larium_creditcard | src/CreditCard/CreditCardValidator.php | CreditCardValidator.validate | public function validate(CreditCard $creditCard)
{
$this->errors = array();
$this->creditCard = $creditCard;
if ($this->context == self::CONTEXT_CREDITCARD) {
$this->validateNumber();
$this->validateExpiration();
$this->validateVerificationValue();
$this->validateBrand();
$this->validateCardHolder();
} elseif ($this->context == self::CONTEXT_TOKEN) {
$this->validateToken();
}
return $this->errors;
} | php | public function validate(CreditCard $creditCard)
{
$this->errors = array();
$this->creditCard = $creditCard;
if ($this->context == self::CONTEXT_CREDITCARD) {
$this->validateNumber();
$this->validateExpiration();
$this->validateVerificationValue();
$this->validateBrand();
$this->validateCardHolder();
} elseif ($this->context == self::CONTEXT_TOKEN) {
$this->validateToken();
}
return $this->errors;
} | [
"public",
"function",
"validate",
"(",
"CreditCard",
"$",
"creditCard",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"creditCard",
"=",
"$",
"creditCard",
";",
"if",
"(",
"$",
"this",
"->",
"context",
"==",
"... | Validates a CreditCard object.
@param CreditCard $creditCard
@return array | [
"Validates",
"a",
"CreditCard",
"object",
"."
] | ea1957bbe28e2448498abe7bb5a5b6ff0020bb2d | https://github.com/Larium/larium_creditcard/blob/ea1957bbe28e2448498abe7bb5a5b6ff0020bb2d/src/CreditCard/CreditCardValidator.php#L64-L80 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Paginator.php | Paginator.tweak | public function tweak($totalAmount, $itemsPerPage, $page)
{
$this->totalAmount = (int) $totalAmount;
$this->itemsPerPage = (int) $itemsPerPage;
$this->setCurrentPage($page);
return $this;
} | php | public function tweak($totalAmount, $itemsPerPage, $page)
{
$this->totalAmount = (int) $totalAmount;
$this->itemsPerPage = (int) $itemsPerPage;
$this->setCurrentPage($page);
return $this;
} | [
"public",
"function",
"tweak",
"(",
"$",
"totalAmount",
",",
"$",
"itemsPerPage",
",",
"$",
"page",
")",
"{",
"$",
"this",
"->",
"totalAmount",
"=",
"(",
"int",
")",
"$",
"totalAmount",
";",
"$",
"this",
"->",
"itemsPerPage",
"=",
"(",
"int",
")",
"$... | Tweaks the service before it can be used
@param integer $totalAmount Total amount of records
@param integer $itemsPerPage Per page count
@param integer $page Current page
@return \Krystal\Paginate\Paginator | [
"Tweaks",
"the",
"service",
"before",
"it",
"can",
"be",
"used"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Paginator.php#L76-L83 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Paginator.php | Paginator.getUrl | public function getUrl($page)
{
if (is_null($this->url)) {
throw new RuntimeException('URL template must be defined');
}
if (strpos($this->url, $this->placeholder) !== false) {
return str_replace($this->placeholder, $page, $this->url);
} else {
// Without placeholder, no substitution is done, therefore pagination links won't work
throw new LogicException('The URL string must contain at least one placeholder to make pagination links work');
}
} | php | public function getUrl($page)
{
if (is_null($this->url)) {
throw new RuntimeException('URL template must be defined');
}
if (strpos($this->url, $this->placeholder) !== false) {
return str_replace($this->placeholder, $page, $this->url);
} else {
// Without placeholder, no substitution is done, therefore pagination links won't work
throw new LogicException('The URL string must contain at least one placeholder to make pagination links work');
}
} | [
"public",
"function",
"getUrl",
"(",
"$",
"page",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"url",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'URL template must be defined'",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"th... | Returns permanent URL substituting a placeholder with current page number
@param integer $page Current page number
@throws \RuntimeException If URL isn't defined
@throws \LogicException In case the URL string hasn't a placeholder
@return string | [
"Returns",
"permanent",
"URL",
"substituting",
"a",
"placeholder",
"with",
"current",
"page",
"number"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Paginator.php#L105-L117 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Paginator.php | Paginator.getSummary | public function getSummary($separator = '-')
{
if ($this->getTotalAmount() == 0) {
return (string) 0;
} else {
return $this->getStart() . $separator . $this->getEnd();
}
} | php | public function getSummary($separator = '-')
{
if ($this->getTotalAmount() == 0) {
return (string) 0;
} else {
return $this->getStart() . $separator . $this->getEnd();
}
} | [
"public",
"function",
"getSummary",
"(",
"$",
"separator",
"=",
"'-'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getTotalAmount",
"(",
")",
"==",
"0",
")",
"{",
"return",
"(",
"string",
")",
"0",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
... | Returns a summary
@param string $separator
@return string | [
"Returns",
"a",
"summary"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Paginator.php#L156-L163 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Paginator.php | Paginator.reset | public function reset()
{
$this->itemsPerPage = null;
$this->currentPage = null;
$this->totalAmount = null;
$this->url = null;
return $this;
} | php | public function reset()
{
$this->itemsPerPage = null;
$this->currentPage = null;
$this->totalAmount = null;
$this->url = null;
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"itemsPerPage",
"=",
"null",
";",
"$",
"this",
"->",
"currentPage",
"=",
"null",
";",
"$",
"this",
"->",
"totalAmount",
"=",
"null",
";",
"$",
"this",
"->",
"url",
"=",
"null",
";",
"... | Resets the paginator's instance
@return \Krystal\Paginate\Paginator | [
"Resets",
"the",
"paginator",
"s",
"instance"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Paginator.php#L190-L198 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Paginator.php | Paginator.getPageNumbers | public function getPageNumbers()
{
$pages = range(1, $this->getPagesCount());
// And has an styling adapter
if ($this->getPagesCount() > 10 && $this->hasAdapter()) {
return $this->style->getPageNumbers($pages, $this->getCurrentPage());
} else {
return $pages;
}
} | php | public function getPageNumbers()
{
$pages = range(1, $this->getPagesCount());
// And has an styling adapter
if ($this->getPagesCount() > 10 && $this->hasAdapter()) {
return $this->style->getPageNumbers($pages, $this->getCurrentPage());
} else {
return $pages;
}
} | [
"public",
"function",
"getPageNumbers",
"(",
")",
"{",
"$",
"pages",
"=",
"range",
"(",
"1",
",",
"$",
"this",
"->",
"getPagesCount",
"(",
")",
")",
";",
"// And has an styling adapter",
"if",
"(",
"$",
"this",
"->",
"getPagesCount",
"(",
")",
">",
"10",... | Returns total page numbers
Style-adapter aware method
@return array | [
"Returns",
"total",
"page",
"numbers",
"Style",
"-",
"adapter",
"aware",
"method"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Paginator.php#L237-L247 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Paginator.php | Paginator.setCurrentPage | private function setCurrentPage($currentPage, $fixRange = true)
{
if ($fixRange === true) {
if (!$this->pageInRange($currentPage)) {
$currentPage = 1;
}
}
$this->currentPage = (int) $currentPage;
return $this;
} | php | private function setCurrentPage($currentPage, $fixRange = true)
{
if ($fixRange === true) {
if (!$this->pageInRange($currentPage)) {
$currentPage = 1;
}
}
$this->currentPage = (int) $currentPage;
return $this;
} | [
"private",
"function",
"setCurrentPage",
"(",
"$",
"currentPage",
",",
"$",
"fixRange",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"fixRange",
"===",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pageInRange",
"(",
"$",
"currentPage",
")",
")",
"... | Defines current page
@param integer|string $currentPage
@param boolean $fixRange Whether page range should be fixed if wrong one supplied
@return \Krystal\Paginate\Paginator | [
"Defines",
"current",
"page"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Paginator.php#L304-L314 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Paginator.php | Paginator.getPagesCount | private function getPagesCount()
{
if ($this->getItemsPerPage() != 0) {
return (int) abs(ceil($this->getTotalAmount() / $this->getItemsPerPage()));
} else {
return 0;
}
} | php | private function getPagesCount()
{
if ($this->getItemsPerPage() != 0) {
return (int) abs(ceil($this->getTotalAmount() / $this->getItemsPerPage()));
} else {
return 0;
}
} | [
"private",
"function",
"getPagesCount",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getItemsPerPage",
"(",
")",
"!=",
"0",
")",
"{",
"return",
"(",
"int",
")",
"abs",
"(",
"ceil",
"(",
"$",
"this",
"->",
"getTotalAmount",
"(",
")",
"/",
"$",
"thi... | Count total amount of pages
@return integer | [
"Count",
"total",
"amount",
"of",
"pages"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Paginator.php#L321-L328 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Paginator.php | Paginator.toArray | public function toArray()
{
return array(
'firstPage' => $this->getFirstPage(),
'lastPage' => $this->getLastPage(),
'offset' => $this->countOffset(),
'summary' => $this->getSummary(),
'hasPages' => $this->hasPages(),
'hasAdapter' => $this->hasAdapter(),
'hasNextPage' => $this->hasNextPage(),
'hasPreviousPage' => $this->hasPreviousPage(),
'nextPage' => $this->getNextPage(),
'previousPage' => $this->getPreviousPage(),
'nextPageUrl' => $this->getNextPageUrl(),
'previousPageUrl' => $this->getPreviousPageUrl(),
'currentPage' => $this->getCurrentPage(),
'perPageCount' => $this->getItemsPerPage(),
'total' => $this->getTotalAmount(),
'pageNumbers' => $this->getPageNumbers()
);
} | php | public function toArray()
{
return array(
'firstPage' => $this->getFirstPage(),
'lastPage' => $this->getLastPage(),
'offset' => $this->countOffset(),
'summary' => $this->getSummary(),
'hasPages' => $this->hasPages(),
'hasAdapter' => $this->hasAdapter(),
'hasNextPage' => $this->hasNextPage(),
'hasPreviousPage' => $this->hasPreviousPage(),
'nextPage' => $this->getNextPage(),
'previousPage' => $this->getPreviousPage(),
'nextPageUrl' => $this->getNextPageUrl(),
'previousPageUrl' => $this->getPreviousPageUrl(),
'currentPage' => $this->getCurrentPage(),
'perPageCount' => $this->getItemsPerPage(),
'total' => $this->getTotalAmount(),
'pageNumbers' => $this->getPageNumbers()
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'firstPage'",
"=>",
"$",
"this",
"->",
"getFirstPage",
"(",
")",
",",
"'lastPage'",
"=>",
"$",
"this",
"->",
"getLastPage",
"(",
")",
",",
"'offset'",
"=>",
"$",
"this",
"->",
"co... | Returns current state as array representation
@return array | [
"Returns",
"current",
"state",
"as",
"array",
"representation"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Paginator.php#L397-L417 | train |
droath/project-x | src/Platform/PlatformType.php | PlatformType.getPlatformOptions | protected function getPlatformOptions()
{
$config = $this->getConfigs();
$options = $config->getOptions();
$platform = $config->getPlatform();
return isset($options[$platform])
? $options[$platform]
: [];
} | php | protected function getPlatformOptions()
{
$config = $this->getConfigs();
$options = $config->getOptions();
$platform = $config->getPlatform();
return isset($options[$platform])
? $options[$platform]
: [];
} | [
"protected",
"function",
"getPlatformOptions",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfigs",
"(",
")",
";",
"$",
"options",
"=",
"$",
"config",
"->",
"getOptions",
"(",
")",
";",
"$",
"platform",
"=",
"$",
"config",
"->",
"getPlat... | Get platform options.
@return array | [
"Get",
"platform",
"options",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Platform/PlatformType.php#L22-L31 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCartItem.php | ShoppingCartItem.getPrice | public function getPrice()
{
$price = $this->BasePrice;
// Check for customisations that modify price
foreach ($this->getCustomisations() as $item) {
$price += ($item->Price) ? $item->Price : 0;
}
return $price;
} | php | public function getPrice()
{
$price = $this->BasePrice;
// Check for customisations that modify price
foreach ($this->getCustomisations() as $item) {
$price += ($item->Price) ? $item->Price : 0;
}
return $price;
} | [
"public",
"function",
"getPrice",
"(",
")",
"{",
"$",
"price",
"=",
"$",
"this",
"->",
"BasePrice",
";",
"// Check for customisations that modify price",
"foreach",
"(",
"$",
"this",
"->",
"getCustomisations",
"(",
")",
"as",
"$",
"item",
")",
"{",
"$",
"pri... | Find the cost of all items in this line, without any tax.
@return Currency | [
"Find",
"the",
"cost",
"of",
"all",
"items",
"in",
"this",
"line",
"without",
"any",
"tax",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCartItem.php#L151-L161 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCartItem.php | ShoppingCartItem.getDiscount | public function getDiscount()
{
$amount = 0;
$cart = ShoppingCart::get();
$items = $cart->TotalItems;
$discount = $cart->getDiscount();
if ($this->BasePrice && $discount && $discount->Amount) {
if ($discount->Type == "Fixed") {
$amount = ($discount->Amount / $items) * $this->Quantity;
} elseif ($discount->Type == "Percentage") {
$amount = (($this->Price / 100) * $discount->Amount) * $this->Quantity;
}
}
return $amount;
} | php | public function getDiscount()
{
$amount = 0;
$cart = ShoppingCart::get();
$items = $cart->TotalItems;
$discount = $cart->getDiscount();
if ($this->BasePrice && $discount && $discount->Amount) {
if ($discount->Type == "Fixed") {
$amount = ($discount->Amount / $items) * $this->Quantity;
} elseif ($discount->Type == "Percentage") {
$amount = (($this->Price / 100) * $discount->Amount) * $this->Quantity;
}
}
return $amount;
} | [
"public",
"function",
"getDiscount",
"(",
")",
"{",
"$",
"amount",
"=",
"0",
";",
"$",
"cart",
"=",
"ShoppingCart",
"::",
"get",
"(",
")",
";",
"$",
"items",
"=",
"$",
"cart",
"->",
"TotalItems",
";",
"$",
"discount",
"=",
"$",
"cart",
"->",
"getDi... | Find the total discount amount for this line item
@return Float | [
"Find",
"the",
"total",
"discount",
"amount",
"for",
"this",
"line",
"item"
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCartItem.php#L168-L184 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCartItem.php | ShoppingCartItem.getTax | public function getTax()
{
$amount = 0;
if ($this->Price && $this->TaxRate) {
$amount = (($this->Price - $this->Discount) / 100) * $this->TaxRate;
}
return $amount;
} | php | public function getTax()
{
$amount = 0;
if ($this->Price && $this->TaxRate) {
$amount = (($this->Price - $this->Discount) / 100) * $this->TaxRate;
}
return $amount;
} | [
"public",
"function",
"getTax",
"(",
")",
"{",
"$",
"amount",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"Price",
"&&",
"$",
"this",
"->",
"TaxRate",
")",
"{",
"$",
"amount",
"=",
"(",
"(",
"$",
"this",
"->",
"Price",
"-",
"$",
"this",
"->",
... | Find the tax cost for one instance of this item.
@return Currency | [
"Find",
"the",
"tax",
"cost",
"for",
"one",
"instance",
"of",
"this",
"item",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCartItem.php#L224-L233 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCartItem.php | ShoppingCartItem.getTotalTax | public function getTotalTax()
{
$amount = 0;
if ($this->Price && $this->TaxRate && $this->Quantity) {
$amount = ((($this->Price * $this->Quantity) - $this->Discount) / 100) * $this->TaxRate;
}
return $amount;
} | php | public function getTotalTax()
{
$amount = 0;
if ($this->Price && $this->TaxRate && $this->Quantity) {
$amount = ((($this->Price * $this->Quantity) - $this->Discount) / 100) * $this->TaxRate;
}
return $amount;
} | [
"public",
"function",
"getTotalTax",
"(",
")",
"{",
"$",
"amount",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"Price",
"&&",
"$",
"this",
"->",
"TaxRate",
"&&",
"$",
"this",
"->",
"Quantity",
")",
"{",
"$",
"amount",
"=",
"(",
"(",
"(",
"$",
... | Find the tax cost for all of the items in this line.
@return Currency | [
"Find",
"the",
"tax",
"cost",
"for",
"all",
"of",
"the",
"items",
"in",
"this",
"line",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCartItem.php#L240-L249 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCartItem.php | ShoppingCartItem.checkStockLevel | public function checkStockLevel($qty)
{
$stock_param = $this->config()->stock_param;
$item = $this->FindStockItem();
$stock = ($item->$stock_param) ? $item->$stock_param : 0;
// if not enough stock, throw an exception
if($stock < $qty) {
throw new ValidationException(_t(
"Checkout.NotEnoughStock",
"There are not enough '{title}' in stock",
"Message to show that an item hasn't got enough stock",
array('title' => $item->Title)
));
}
} | php | public function checkStockLevel($qty)
{
$stock_param = $this->config()->stock_param;
$item = $this->FindStockItem();
$stock = ($item->$stock_param) ? $item->$stock_param : 0;
// if not enough stock, throw an exception
if($stock < $qty) {
throw new ValidationException(_t(
"Checkout.NotEnoughStock",
"There are not enough '{title}' in stock",
"Message to show that an item hasn't got enough stock",
array('title' => $item->Title)
));
}
} | [
"public",
"function",
"checkStockLevel",
"(",
"$",
"qty",
")",
"{",
"$",
"stock_param",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"stock_param",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"FindStockItem",
"(",
")",
";",
"$",
"stock",
"=",
"(",... | Check stock levels for this item.
If stock levels are too low, throws an exception
@param $qty The quantity we want to check against
@return null | [
"Check",
"stock",
"levels",
"for",
"this",
"item",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCartItem.php#L288-L303 | train |
krystal-framework/krystal.framework | src/Krystal/Http/FileTransfer/FileUploader.php | FileUploader.upload | public function upload($destination, array $files)
{
foreach ($files as $file) {
if (!($file instanceof FileEntity)) {
// This should never occur, but it's always better not to rely on framework users
throw new LogicException(sprintf(
'Each file entity must be an instance of \Krystal\Http\FileTransfer\FileInfoInterface, but received "%s"', gettype($file)
));
}
// Gotta ensure again, UPLOAD_ERR_OK means there are no errors
if ($file->getError() == \UPLOAD_ERR_OK) {
// Start trying to move a file
if (!$this->move($destination, $file->getTmpName(), $file->getUniqueName())) {
return false;
}
} else {
// Invalid file, so that cannot be uploaded. That actually should be reported before inside validator
return false;
}
}
return true;
} | php | public function upload($destination, array $files)
{
foreach ($files as $file) {
if (!($file instanceof FileEntity)) {
// This should never occur, but it's always better not to rely on framework users
throw new LogicException(sprintf(
'Each file entity must be an instance of \Krystal\Http\FileTransfer\FileInfoInterface, but received "%s"', gettype($file)
));
}
// Gotta ensure again, UPLOAD_ERR_OK means there are no errors
if ($file->getError() == \UPLOAD_ERR_OK) {
// Start trying to move a file
if (!$this->move($destination, $file->getTmpName(), $file->getUniqueName())) {
return false;
}
} else {
// Invalid file, so that cannot be uploaded. That actually should be reported before inside validator
return false;
}
}
return true;
} | [
"public",
"function",
"upload",
"(",
"$",
"destination",
",",
"array",
"$",
"files",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"file",
"instanceof",
"FileEntity",
")",
")",
"{",
"// This should never... | Upload files from the input
@param string $destination
@param array $files
@throws \LogicException if at least one value in $files is not an instance of \Krystal\Http\FileTransfer\FileEntityInterface
@return boolean | [
"Upload",
"files",
"from",
"the",
"input"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/FileTransfer/FileUploader.php#L53-L76 | train |
krystal-framework/krystal.framework | src/Krystal/Http/FileTransfer/FileUploader.php | FileUploader.move | private function move($destination, $tmp, $filename)
{
if (!is_dir($destination)) {
// We can either create it automatically
if ($this->destinationAutoCreate === true) {
// Then make a directory (recursively if needed)
@mkdir($destination, 0777, true);
} else {
// Destination doesn't exist, and we shouldn't be creating it
throw new RuntimeException(sprintf(
'Destination folder does not exist', $destination
));
}
}
$target = sprintf('%s/%s', $destination, $filename);
// If Remote file exists and we don't want to override it, so let's stop here
if (is_file($target)) {
if (!$this->override) {
return true;
}
}
return move_uploaded_file($tmp, $target);
} | php | private function move($destination, $tmp, $filename)
{
if (!is_dir($destination)) {
// We can either create it automatically
if ($this->destinationAutoCreate === true) {
// Then make a directory (recursively if needed)
@mkdir($destination, 0777, true);
} else {
// Destination doesn't exist, and we shouldn't be creating it
throw new RuntimeException(sprintf(
'Destination folder does not exist', $destination
));
}
}
$target = sprintf('%s/%s', $destination, $filename);
// If Remote file exists and we don't want to override it, so let's stop here
if (is_file($target)) {
if (!$this->override) {
return true;
}
}
return move_uploaded_file($tmp, $target);
} | [
"private",
"function",
"move",
"(",
"$",
"destination",
",",
"$",
"tmp",
",",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"destination",
")",
")",
"{",
"// We can either create it automatically",
"if",
"(",
"$",
"this",
"->",
"destinatio... | Moves a singular file
@param string $destination
@param string $tmp
@param string $filename
@return boolean Depending on success | [
"Moves",
"a",
"singular",
"file"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/FileTransfer/FileUploader.php#L86-L112 | train |
Koc/Sphinxy | Escaper.php | Escaper.quoteIdentifier | public function quoteIdentifier($value)
{
if ($value instanceof Expr) {
return $value->getValue();
}
if ($value === '*') {
return $value;
}
$pieces = explode('.', $value);
foreach ($pieces as $key => $piece) {
$pieces[$key] = '`'.$piece.'`';
}
return implode('.', $pieces);
} | php | public function quoteIdentifier($value)
{
if ($value instanceof Expr) {
return $value->getValue();
}
if ($value === '*') {
return $value;
}
$pieces = explode('.', $value);
foreach ($pieces as $key => $piece) {
$pieces[$key] = '`'.$piece.'`';
}
return implode('.', $pieces);
} | [
"public",
"function",
"quoteIdentifier",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Expr",
")",
"{",
"return",
"$",
"value",
"->",
"getValue",
"(",
")",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"'*'",
")",
"{",
"return",
... | Wraps the input with identifiers when necessary.
@param Expr|string $value The string to be quoted, or an Expression to leave it untouched
@return string The untouched Expression or the quoted string | [
"Wraps",
"the",
"input",
"with",
"identifiers",
"when",
"necessary",
"."
] | e16ba027af42f529e8d1a01b7a974b9d22be9bef | https://github.com/Koc/Sphinxy/blob/e16ba027af42f529e8d1a01b7a974b9d22be9bef/Escaper.php#L26-L43 | train |
Koc/Sphinxy | Escaper.php | Escaper.quote | public function quote($value)
{
switch (true) {
case $value === null:
return 'null';
case $value === true:
return '1';
case $value === false:
return '0';
case $value instanceof Expr:
return $value->getValue();
case is_int($value) || ctype_digit($value):
return (int) $value;
case is_float($value):
// Convert to non-locale aware float to prevent possible commas
return sprintf('%F', $value);
case is_array($value):
// Supports MVA attributes
if (!count($value)) {
return '()';
}
return '('.implode(',', $this->quoteArr($value)).')';
}
return $this->conn->quote($value);
} | php | public function quote($value)
{
switch (true) {
case $value === null:
return 'null';
case $value === true:
return '1';
case $value === false:
return '0';
case $value instanceof Expr:
return $value->getValue();
case is_int($value) || ctype_digit($value):
return (int) $value;
case is_float($value):
// Convert to non-locale aware float to prevent possible commas
return sprintf('%F', $value);
case is_array($value):
// Supports MVA attributes
if (!count($value)) {
return '()';
}
return '('.implode(',', $this->quoteArr($value)).')';
}
return $this->conn->quote($value);
} | [
"public",
"function",
"quote",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
"value",
"===",
"null",
":",
"return",
"'null'",
";",
"case",
"$",
"value",
"===",
"true",
":",
"return",
"'1'",
";",
"case",
"$",
"value",
"=... | Adds quotes around values when necessary.
Based on FuelPHP's quoting function.
@param Expr|mixed $value The input string, eventually wrapped in an expression to leave it untouched
@return string The untouched Expression or the quoted string | [
"Adds",
"quotes",
"around",
"values",
"when",
"necessary",
".",
"Based",
"on",
"FuelPHP",
"s",
"quoting",
"function",
"."
] | e16ba027af42f529e8d1a01b7a974b9d22be9bef | https://github.com/Koc/Sphinxy/blob/e16ba027af42f529e8d1a01b7a974b9d22be9bef/Escaper.php#L71-L103 | train |
Riimu/Kit-BaseConversion | src/DigitList/AbstractDigitList.php | AbstractDigitList.setValueMap | protected function setValueMap(array $map)
{
$lower = array_change_key_case($map);
$this->caseSensitive = count($lower) !== count($map);
$this->valueMap = $this->caseSensitive ? $map : $lower;
} | php | protected function setValueMap(array $map)
{
$lower = array_change_key_case($map);
$this->caseSensitive = count($lower) !== count($map);
$this->valueMap = $this->caseSensitive ? $map : $lower;
} | [
"protected",
"function",
"setValueMap",
"(",
"array",
"$",
"map",
")",
"{",
"$",
"lower",
"=",
"array_change_key_case",
"(",
"$",
"map",
")",
";",
"$",
"this",
"->",
"caseSensitive",
"=",
"count",
"(",
"$",
"lower",
")",
"!==",
"count",
"(",
"$",
"map"... | Sets the value map and determines if it's case sensitive.
@param int[] $map List of values for digits | [
"Sets",
"the",
"value",
"map",
"and",
"determines",
"if",
"it",
"s",
"case",
"sensitive",
"."
] | e0f486759590b69126c83622edd309217f783324 | https://github.com/Riimu/Kit-BaseConversion/blob/e0f486759590b69126c83622edd309217f783324/src/DigitList/AbstractDigitList.php#L29-L34 | train |
stefk/JVal | src/Walker.php | Walker.resolveReferences | public function resolveReferences(stdClass $schema, Uri $uri)
{
$this->resolver->initialize($schema, $uri);
return $this->doResolveReferences($schema, $uri);
} | php | public function resolveReferences(stdClass $schema, Uri $uri)
{
$this->resolver->initialize($schema, $uri);
return $this->doResolveReferences($schema, $uri);
} | [
"public",
"function",
"resolveReferences",
"(",
"stdClass",
"$",
"schema",
",",
"Uri",
"$",
"uri",
")",
"{",
"$",
"this",
"->",
"resolver",
"->",
"initialize",
"(",
"$",
"schema",
",",
"$",
"uri",
")",
";",
"return",
"$",
"this",
"->",
"doResolveReferenc... | Recursively resolves JSON pointer references within a given schema.
@param stdClass $schema The schema to resolve
@param Uri $uri The URI of the schema
@return stdClass | [
"Recursively",
"resolves",
"JSON",
"pointer",
"references",
"within",
"a",
"given",
"schema",
"."
] | 1c26dd2c16e5273d1c0565ff6c9dc51e6316c564 | https://github.com/stefk/JVal/blob/1c26dd2c16e5273d1c0565ff6c9dc51e6316c564/src/Walker.php#L72-L77 | train |
stefk/JVal | src/Walker.php | Walker.applyConstraints | public function applyConstraints($instance, stdClass $schema, Context $context)
{
$cacheKey = gettype($instance).spl_object_hash($schema);
$constraints = & $this->constraintsCache[$cacheKey];
if ($constraints === null) {
$version = $this->getVersion($schema);
$instanceType = Types::getPrimitiveTypeOf($instance);
$constraints = $this->registry->getConstraintsForType($version, $instanceType);
$constraints = $this->filterConstraintsForSchema($constraints, $schema);
}
foreach ($constraints as $constraint) {
$constraint->apply($instance, $schema, $context, $this);
}
} | php | public function applyConstraints($instance, stdClass $schema, Context $context)
{
$cacheKey = gettype($instance).spl_object_hash($schema);
$constraints = & $this->constraintsCache[$cacheKey];
if ($constraints === null) {
$version = $this->getVersion($schema);
$instanceType = Types::getPrimitiveTypeOf($instance);
$constraints = $this->registry->getConstraintsForType($version, $instanceType);
$constraints = $this->filterConstraintsForSchema($constraints, $schema);
}
foreach ($constraints as $constraint) {
$constraint->apply($instance, $schema, $context, $this);
}
} | [
"public",
"function",
"applyConstraints",
"(",
"$",
"instance",
",",
"stdClass",
"$",
"schema",
",",
"Context",
"$",
"context",
")",
"{",
"$",
"cacheKey",
"=",
"gettype",
"(",
"$",
"instance",
")",
".",
"spl_object_hash",
"(",
"$",
"schema",
")",
";",
"$... | Validates an instance against a given schema, populating a context
with encountered violations.
@param mixed $instance
@param stdClass $schema
@param Context $context | [
"Validates",
"an",
"instance",
"against",
"a",
"given",
"schema",
"populating",
"a",
"context",
"with",
"encountered",
"violations",
"."
] | 1c26dd2c16e5273d1c0565ff6c9dc51e6316c564 | https://github.com/stefk/JVal/blob/1c26dd2c16e5273d1c0565ff6c9dc51e6316c564/src/Walker.php#L162-L177 | train |
stefk/JVal | src/Walker.php | Walker.isProcessed | private function isProcessed(stdClass $schema, SplObjectStorage $storage)
{
if ($storage->contains($schema)) {
return true;
}
$storage->attach($schema);
return false;
} | php | private function isProcessed(stdClass $schema, SplObjectStorage $storage)
{
if ($storage->contains($schema)) {
return true;
}
$storage->attach($schema);
return false;
} | [
"private",
"function",
"isProcessed",
"(",
"stdClass",
"$",
"schema",
",",
"SplObjectStorage",
"$",
"storage",
")",
"{",
"if",
"(",
"$",
"storage",
"->",
"contains",
"(",
"$",
"schema",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"storage",
"->",
"... | Returns whether a schema has already been processed and stored in
a given collection. This acts as an infinite recursion check.
@param stdClass $schema
@param SplObjectStorage $storage
@return bool | [
"Returns",
"whether",
"a",
"schema",
"has",
"already",
"been",
"processed",
"and",
"stored",
"in",
"a",
"given",
"collection",
".",
"This",
"acts",
"as",
"an",
"infinite",
"recursion",
"check",
"."
] | 1c26dd2c16e5273d1c0565ff6c9dc51e6316c564 | https://github.com/stefk/JVal/blob/1c26dd2c16e5273d1c0565ff6c9dc51e6316c564/src/Walker.php#L188-L197 | train |
stefk/JVal | src/Walker.php | Walker.filterConstraintsForSchema | private function filterConstraintsForSchema(array $constraints, stdClass $schema)
{
$filtered = [];
foreach ($constraints as $constraint) {
foreach ($constraint->keywords() as $keyword) {
if (property_exists($schema, $keyword)) {
$filtered[] = $constraint;
break;
}
}
}
return $filtered;
} | php | private function filterConstraintsForSchema(array $constraints, stdClass $schema)
{
$filtered = [];
foreach ($constraints as $constraint) {
foreach ($constraint->keywords() as $keyword) {
if (property_exists($schema, $keyword)) {
$filtered[] = $constraint;
break;
}
}
}
return $filtered;
} | [
"private",
"function",
"filterConstraintsForSchema",
"(",
"array",
"$",
"constraints",
",",
"stdClass",
"$",
"schema",
")",
"{",
"$",
"filtered",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"constraints",
"as",
"$",
"constraint",
")",
"{",
"foreach",
"(",
"$"... | Filters constraints which should be triggered for given schema.
@param Constraint[] $constraints
@param stdClass $schema
@return Constraint[] | [
"Filters",
"constraints",
"which",
"should",
"be",
"triggered",
"for",
"given",
"schema",
"."
] | 1c26dd2c16e5273d1c0565ff6c9dc51e6316c564 | https://github.com/stefk/JVal/blob/1c26dd2c16e5273d1c0565ff6c9dc51e6316c564/src/Walker.php#L221-L235 | train |
krystal-framework/krystal.framework | src/Krystal/Text/SlugGenerator.php | SlugGenerator.createUniqueNumericSlug | private function createUniqueNumericSlug($slug)
{
if ($this->isNumericSlug($slug)) {
// Extract last number and increment it
$number = substr($slug, -1, 1);
$number++;
// Replace with new number
$string = substr($slug, 0, strlen($slug) - 1) . $number;
return $string;
} else {
return $slug;
}
} | php | private function createUniqueNumericSlug($slug)
{
if ($this->isNumericSlug($slug)) {
// Extract last number and increment it
$number = substr($slug, -1, 1);
$number++;
// Replace with new number
$string = substr($slug, 0, strlen($slug) - 1) . $number;
return $string;
} else {
return $slug;
}
} | [
"private",
"function",
"createUniqueNumericSlug",
"(",
"$",
"slug",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNumericSlug",
"(",
"$",
"slug",
")",
")",
"{",
"// Extract last number and increment it",
"$",
"number",
"=",
"substr",
"(",
"$",
"slug",
",",
"-",... | Creates unique slug
@param string $slug
@return string | [
"Creates",
"unique",
"slug"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/SlugGenerator.php#L130-L144 | train |
krystal-framework/krystal.framework | src/Krystal/Text/SlugGenerator.php | SlugGenerator.getUniqueSlug | public function getUniqueSlug($callback, $slug, array $args = array())
{
if (!is_callable($callback)) {
throw new InvalidArgumentException(
sprintf('First argument must be callable, received "%s"', gettype($callback))
);
}
$count = 0;
while (true) {
$count++;
if (call_user_func_array($callback, array_merge(array($slug), $args))) {
// If dash can't be found, then add first
if (!$this->isNumericSlug($slug)) {
$slug = sprintf('%s-%s', $slug, $count);
} else {
$slug = $this->createUniqueNumericSlug($slug);
}
} else {
break;
}
}
return $slug;
} | php | public function getUniqueSlug($callback, $slug, array $args = array())
{
if (!is_callable($callback)) {
throw new InvalidArgumentException(
sprintf('First argument must be callable, received "%s"', gettype($callback))
);
}
$count = 0;
while (true) {
$count++;
if (call_user_func_array($callback, array_merge(array($slug), $args))) {
// If dash can't be found, then add first
if (!$this->isNumericSlug($slug)) {
$slug = sprintf('%s-%s', $slug, $count);
} else {
$slug = $this->createUniqueNumericSlug($slug);
}
} else {
break;
}
}
return $slug;
} | [
"public",
"function",
"getUniqueSlug",
"(",
"$",
"callback",
",",
"$",
"slug",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
... | Returns unique slug
@param callable $callback Callback function
@param string $slug
@param array $args Extra arguments to be passed to callback function
@throws \InvalidArgumentException If $callback isn't callable
@return string | [
"Returns",
"unique",
"slug"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/SlugGenerator.php#L155-L182 | train |
krystal-framework/krystal.framework | src/Krystal/Text/SlugGenerator.php | SlugGenerator.generate | public function generate($string)
{
if ($this->romanization === true) {
$string = $this->romanize($string);
}
$string = $this->lowercase($string);
$string = $this->removeUndesiredChars($string);
$string = $this->trim($string);
$string = $this->replaceWt($string);
$string = $this->removeExtraDashes($string);
return $string;
} | php | public function generate($string)
{
if ($this->romanization === true) {
$string = $this->romanize($string);
}
$string = $this->lowercase($string);
$string = $this->removeUndesiredChars($string);
$string = $this->trim($string);
$string = $this->replaceWt($string);
$string = $this->removeExtraDashes($string);
return $string;
} | [
"public",
"function",
"generate",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"romanization",
"===",
"true",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"romanize",
"(",
"$",
"string",
")",
";",
"}",
"$",
"string",
"=",
"$",
... | Generates a slug
@param string $string Target string
@return string | [
"Generates",
"a",
"slug"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/SlugGenerator.php#L190-L203 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Client/Curl.php | Curl.init | public function init(array $options = array())
{
$this->ch = curl_init();
if (!empty($options)) {
$this->setOptions($options);
}
} | php | public function init(array $options = array())
{
$this->ch = curl_init();
if (!empty($options)) {
$this->setOptions($options);
}
} | [
"public",
"function",
"init",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"ch",
"=",
"curl_init",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"this",
"->",
"setOptions",
... | Inits the cURL
@param array $options
@return void | [
"Inits",
"the",
"cURL"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Client/Curl.php#L89-L96 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Client/Curl.php | Curl.exec | public function exec()
{
$result = curl_exec($this->ch);
if ($result === false) {
$this->appendError();
return false;
} else {
return $result;
}
} | php | public function exec()
{
$result = curl_exec($this->ch);
if ($result === false) {
$this->appendError();
return false;
} else {
return $result;
}
} | [
"public",
"function",
"exec",
"(",
")",
"{",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"ch",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"appendError",
"(",
")",
";",
"return",
"false",
";",
"}"... | Perform a cURL session
This method should be called after initializing a cURL session
and all the options for the session are set.
@return mixed, False on failure | [
"Perform",
"a",
"cURL",
"session",
"This",
"method",
"should",
"be",
"called",
"after",
"initializing",
"a",
"cURL",
"session",
"and",
"all",
"the",
"options",
"for",
"the",
"session",
"are",
"set",
"."
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Client/Curl.php#L125-L135 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Client/Curl.php | Curl.appendError | private function appendError()
{
$this->errors[(string) curl_errno($this->ch)] = curl_error($this->ch);
} | php | private function appendError()
{
$this->errors[(string) curl_errno($this->ch)] = curl_error($this->ch);
} | [
"private",
"function",
"appendError",
"(",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"(",
"string",
")",
"curl_errno",
"(",
"$",
"this",
"->",
"ch",
")",
"]",
"=",
"curl_error",
"(",
"$",
"this",
"->",
"ch",
")",
";",
"}"
] | Appends an error with its own code
@return void | [
"Appends",
"an",
"error",
"with",
"its",
"own",
"code"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Client/Curl.php#L142-L145 | train |
krystal-framework/krystal.framework | src/Krystal/Date/TimeHelper.php | TimeHelper.getMonthSequence | private static function getMonthSequence(array $months, $target, $withCurrent)
{
if (!in_array($target, $months)) {
throw new LogicException(
sprintf('Target month "%s" is out of range. The range must be from 01 up to 12', $target)
);
}
$collection = array();
foreach ($months as $month) {
if ($month == $target) {
if ($withCurrent === true) {
$collection[] = $month;
}
break;
} else {
$collection[] = $month;
}
}
return $collection;
} | php | private static function getMonthSequence(array $months, $target, $withCurrent)
{
if (!in_array($target, $months)) {
throw new LogicException(
sprintf('Target month "%s" is out of range. The range must be from 01 up to 12', $target)
);
}
$collection = array();
foreach ($months as $month) {
if ($month == $target) {
if ($withCurrent === true) {
$collection[] = $month;
}
break;
} else {
$collection[] = $month;
}
}
return $collection;
} | [
"private",
"static",
"function",
"getMonthSequence",
"(",
"array",
"$",
"months",
",",
"$",
"target",
",",
"$",
"withCurrent",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"target",
",",
"$",
"months",
")",
")",
"{",
"throw",
"new",
"LogicException",
... | Returns months sequence
@param array $months
@param string $target Target months
@param boolean $withCurrent Whether to include target months in resultset
@throws \LogicException if $target is out of range
@return array | [
"Returns",
"months",
"sequence"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/TimeHelper.php#L110-L132 | train |
krystal-framework/krystal.framework | src/Krystal/Date/TimeHelper.php | TimeHelper.getPreviousMonths | public static function getPreviousMonths($target, $withCurrent = true)
{
return self::getMonthSequence(array_keys(self::getMonths()), $target, $withCurrent);
} | php | public static function getPreviousMonths($target, $withCurrent = true)
{
return self::getMonthSequence(array_keys(self::getMonths()), $target, $withCurrent);
} | [
"public",
"static",
"function",
"getPreviousMonths",
"(",
"$",
"target",
",",
"$",
"withCurrent",
"=",
"true",
")",
"{",
"return",
"self",
"::",
"getMonthSequence",
"(",
"array_keys",
"(",
"self",
"::",
"getMonths",
"(",
")",
")",
",",
"$",
"target",
",",
... | Returns a collection of previous months
@param string $target
@param string $withCurrent Whether to include $target in resultset
@return array | [
"Returns",
"a",
"collection",
"of",
"previous",
"months"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/TimeHelper.php#L141-L144 | train |
krystal-framework/krystal.framework | src/Krystal/Date/TimeHelper.php | TimeHelper.getNextMonths | public static function getNextMonths($target, $withCurrent = true)
{
$months = array_keys(self::getMonths());
$months = array_reverse($months);
$result = self::getMonthSequence($months, $target, $withCurrent);
return array_reverse($result);
} | php | public static function getNextMonths($target, $withCurrent = true)
{
$months = array_keys(self::getMonths());
$months = array_reverse($months);
$result = self::getMonthSequence($months, $target, $withCurrent);
return array_reverse($result);
} | [
"public",
"static",
"function",
"getNextMonths",
"(",
"$",
"target",
",",
"$",
"withCurrent",
"=",
"true",
")",
"{",
"$",
"months",
"=",
"array_keys",
"(",
"self",
"::",
"getMonths",
"(",
")",
")",
";",
"$",
"months",
"=",
"array_reverse",
"(",
"$",
"m... | Returns a collection of next months
@param string $target
@param string $withCurrent Whether to include $target in resultset
@return array | [
"Returns",
"a",
"collection",
"of",
"next",
"months"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/TimeHelper.php#L153-L160 | train |
krystal-framework/krystal.framework | src/Krystal/Date/TimeHelper.php | TimeHelper.getAllMonthsByQuarter | public static function getAllMonthsByQuarter($quarter)
{
switch ($quarter) {
case 1:
return self::getMonthsByQuarter(1);
case 2:
return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2));
case 3:
return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2), self::getMonthsByQuarter(3));
case 4:
return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2), self::getMonthsByQuarter(3), self::getMonthsByQuarter(4));
default:
throw new LogicException(sprintf('Invalid quarter supplied - %s', $quarter));
}
} | php | public static function getAllMonthsByQuarter($quarter)
{
switch ($quarter) {
case 1:
return self::getMonthsByQuarter(1);
case 2:
return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2));
case 3:
return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2), self::getMonthsByQuarter(3));
case 4:
return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2), self::getMonthsByQuarter(3), self::getMonthsByQuarter(4));
default:
throw new LogicException(sprintf('Invalid quarter supplied - %s', $quarter));
}
} | [
"public",
"static",
"function",
"getAllMonthsByQuarter",
"(",
"$",
"quarter",
")",
"{",
"switch",
"(",
"$",
"quarter",
")",
"{",
"case",
"1",
":",
"return",
"self",
"::",
"getMonthsByQuarter",
"(",
"1",
")",
";",
"case",
"2",
":",
"return",
"array_merge",
... | Returns a collection of months by associated quarter
@param integer $quarter
@throws \LogicException If invalid quarter supplied
@return array | [
"Returns",
"a",
"collection",
"of",
"months",
"by",
"associated",
"quarter"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/TimeHelper.php#L202-L216 | train |
krystal-framework/krystal.framework | src/Krystal/Date/TimeHelper.php | TimeHelper.getQuarter | public static function getQuarter($month = null)
{
if ($month === null) {
$month = date('n', abs(time()));
}
if (in_array($month, range(1, 3))) {
return 1;
}
if (in_array($month, range(4, 6))) {
return 2;
}
if (in_array($month, range(7, 9))) {
return 3;
}
if (in_array($month, range(10, 12))) {
return 4;
}
} | php | public static function getQuarter($month = null)
{
if ($month === null) {
$month = date('n', abs(time()));
}
if (in_array($month, range(1, 3))) {
return 1;
}
if (in_array($month, range(4, 6))) {
return 2;
}
if (in_array($month, range(7, 9))) {
return 3;
}
if (in_array($month, range(10, 12))) {
return 4;
}
} | [
"public",
"static",
"function",
"getQuarter",
"(",
"$",
"month",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"month",
"===",
"null",
")",
"{",
"$",
"month",
"=",
"date",
"(",
"'n'",
",",
"abs",
"(",
"time",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
... | Returns current quarter
@param integer $month Month number without leading zeros
@return integer | [
"Returns",
"current",
"quarter"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/TimeHelper.php#L247-L268 | train |
aphiria/serialization | src/Encoding/EncoderRegistry.php | EncoderRegistry.getEncoderForType | public function getEncoderForType(string $type): IEncoder
{
$normalizedType = self::normalizeType($type);
if (isset($this->encodersByType[$normalizedType])) {
return $this->encodersByType[$normalizedType];
}
if (class_exists($type)) {
if ($this->defaultObjectEncoder === null) {
throw new OutOfBoundsException('No default object encoder is registered');
}
return $this->defaultObjectEncoder;
}
if ($this->defaultScalarEncoder === null) {
throw new OutOfBoundsException('No default scalar encoder is registered');
}
return $this->defaultScalarEncoder;
} | php | public function getEncoderForType(string $type): IEncoder
{
$normalizedType = self::normalizeType($type);
if (isset($this->encodersByType[$normalizedType])) {
return $this->encodersByType[$normalizedType];
}
if (class_exists($type)) {
if ($this->defaultObjectEncoder === null) {
throw new OutOfBoundsException('No default object encoder is registered');
}
return $this->defaultObjectEncoder;
}
if ($this->defaultScalarEncoder === null) {
throw new OutOfBoundsException('No default scalar encoder is registered');
}
return $this->defaultScalarEncoder;
} | [
"public",
"function",
"getEncoderForType",
"(",
"string",
"$",
"type",
")",
":",
"IEncoder",
"{",
"$",
"normalizedType",
"=",
"self",
"::",
"normalizeType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"encodersByType",
"[",
"$... | Gets the encoder for a type
@param string $type The type whose encoder we want
@return IEncoder The encoder for the input type | [
"Gets",
"the",
"encoder",
"for",
"a",
"type"
] | ae9144ce24a810f1c546421b18829f80826c70e0 | https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/EncoderRegistry.php#L36-L57 | train |
aphiria/serialization | src/Encoding/EncoderRegistry.php | EncoderRegistry.registerEncoder | public function registerEncoder(string $type, IEncoder $encoder): void
{
$normalizedType = self::normalizeType($type);
$this->encodersByType[$normalizedType] = $encoder;
} | php | public function registerEncoder(string $type, IEncoder $encoder): void
{
$normalizedType = self::normalizeType($type);
$this->encodersByType[$normalizedType] = $encoder;
} | [
"public",
"function",
"registerEncoder",
"(",
"string",
"$",
"type",
",",
"IEncoder",
"$",
"encoder",
")",
":",
"void",
"{",
"$",
"normalizedType",
"=",
"self",
"::",
"normalizeType",
"(",
"$",
"type",
")",
";",
"$",
"this",
"->",
"encodersByType",
"[",
... | Registers an encoder
@param string $type The type that the encoder is for
@param IEncoder $encoder The encoder to register | [
"Registers",
"an",
"encoder"
] | ae9144ce24a810f1c546421b18829f80826c70e0 | https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/EncoderRegistry.php#L98-L102 | train |
austinheap/php-security-txt | src/Directives/Disclosure.php | Disclosure.setDisclosure | public function setDisclosure(string $disclosure): SecurityTxt
{
if (!$this->validDisclosure($disclosure)) {
throw new Exception('Disclosure policy must be either "full", "partial", or "none".');
}
$this->disclosure = $disclosure;
return $this;
} | php | public function setDisclosure(string $disclosure): SecurityTxt
{
if (!$this->validDisclosure($disclosure)) {
throw new Exception('Disclosure policy must be either "full", "partial", or "none".');
}
$this->disclosure = $disclosure;
return $this;
} | [
"public",
"function",
"setDisclosure",
"(",
"string",
"$",
"disclosure",
")",
":",
"SecurityTxt",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validDisclosure",
"(",
"$",
"disclosure",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Disclosure policy must be ei... | Set the disclosure policy.
@param string $disclosure
@return \AustinHeap\Security\Txt\SecurityTxt | [
"Set",
"the",
"disclosure",
"policy",
"."
] | 01c4f32858b2a0d020fe0232467f0900833c0ff3 | https://github.com/austinheap/php-security-txt/blob/01c4f32858b2a0d020fe0232467f0900833c0ff3/src/Directives/Disclosure.php#L42-L51 | train |
droath/project-x | src/Service/HostChecker.php | HostChecker.isPortOpenRepeater | public function isPortOpenRepeater($seconds = 15)
{
$start = time();
$instance = $this->getPingInstance();
do {
$current = time() - $start;
$latency = $instance->ping('fsockopen');
if ($latency !== false) {
return true;
}
} while ($current <= $seconds);
return false;
} | php | public function isPortOpenRepeater($seconds = 15)
{
$start = time();
$instance = $this->getPingInstance();
do {
$current = time() - $start;
$latency = $instance->ping('fsockopen');
if ($latency !== false) {
return true;
}
} while ($current <= $seconds);
return false;
} | [
"public",
"function",
"isPortOpenRepeater",
"(",
"$",
"seconds",
"=",
"15",
")",
"{",
"$",
"start",
"=",
"time",
"(",
")",
";",
"$",
"instance",
"=",
"$",
"this",
"->",
"getPingInstance",
"(",
")",
";",
"do",
"{",
"$",
"current",
"=",
"time",
"(",
... | Check if the host port is opened within a timeframe.
@param int $seconds
The amount of seconds it should continuously check.
@return bool
Return true if the host port is open; otherwise false. | [
"Check",
"if",
"the",
"host",
"port",
"is",
"opened",
"within",
"a",
"timeframe",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Service/HostChecker.php#L106-L121 | train |
droath/project-x | src/Service/HostChecker.php | HostChecker.getPingInstance | protected function getPingInstance()
{
if (empty($this->port)) {
throw new \InvalidArgumentException(
'Missing host port, ensure you called setPort().'
);
}
$instance = $this->createPing();
$instance
->setPort($this->port);
return $instance;
} | php | protected function getPingInstance()
{
if (empty($this->port)) {
throw new \InvalidArgumentException(
'Missing host port, ensure you called setPort().'
);
}
$instance = $this->createPing();
$instance
->setPort($this->port);
return $instance;
} | [
"protected",
"function",
"getPingInstance",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"port",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Missing host port, ensure you called setPort().'",
")",
";",
"}",
"$",
"instanc... | Get the ping instance.
@throws \InvalidArgumentException
@return \JJG\Ping
Return the ping instance. | [
"Get",
"the",
"ping",
"instance",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Service/HostChecker.php#L131-L143 | train |
droath/project-x | src/Service/HostChecker.php | HostChecker.createPing | protected function createPing()
{
if (!isset($this->host)) {
throw new \InvalidArgumentException(
'Missing hostname, unable to conduct a ping request.'
);
}
return new Ping($this->host, $this->ttl, $this->timeout);
} | php | protected function createPing()
{
if (!isset($this->host)) {
throw new \InvalidArgumentException(
'Missing hostname, unable to conduct a ping request.'
);
}
return new Ping($this->host, $this->ttl, $this->timeout);
} | [
"protected",
"function",
"createPing",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"host",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Missing hostname, unable to conduct a ping request.'",
")",
";",
"}",
"return",... | Create a ping instance.
@throws \InvalidArgumentException
@return \JJG\Ping
Return the ping instance. | [
"Create",
"a",
"ping",
"instance",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Service/HostChecker.php#L153-L162 | train |
droath/project-x | src/Task/GitHubTaskBase.php | GitHubTaskBase.getUser | public function getUser()
{
$info = $this
->gitHubUserAuth()
->getStoreData();
$user = isset($info['user'])
? $info['user']
: getenv('PROJECTX_GITHUB_USER') ?: null;
if (!isset($user)) {
throw new \RuntimeException(
"GitHub authentication user is required. \r\n\n " .
'[info] Run vendor/bin/project-x github::auth to get started.'
);
}
return $user;
} | php | public function getUser()
{
$info = $this
->gitHubUserAuth()
->getStoreData();
$user = isset($info['user'])
? $info['user']
: getenv('PROJECTX_GITHUB_USER') ?: null;
if (!isset($user)) {
throw new \RuntimeException(
"GitHub authentication user is required. \r\n\n " .
'[info] Run vendor/bin/project-x github::auth to get started.'
);
}
return $user;
} | [
"public",
"function",
"getUser",
"(",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"gitHubUserAuth",
"(",
")",
"->",
"getStoreData",
"(",
")",
";",
"$",
"user",
"=",
"isset",
"(",
"$",
"info",
"[",
"'user'",
"]",
")",
"?",
"$",
"info",
"[",
"'u... | Get GitHub authentication user.
@throws RuntimeException
@return string | [
"Get",
"GitHub",
"authentication",
"user",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/GitHubTaskBase.php#L20-L38 | train |
droath/project-x | src/Task/GitHubTaskBase.php | GitHubTaskBase.getToken | public function getToken()
{
$info = $this
->gitHubUserAuth()
->getStoreData();
$token = isset($info['token'])
? $info['token']
: getenv('PROJECTX_GITHUB_TOKEN') ?: null;
if (!isset($token)) {
throw new \RuntimeException(
"GitHub user authentication token is required. \r\n\n " .
'[info] Run vendor/bin/project-x github::auth to get started.'
);
}
return $token;
} | php | public function getToken()
{
$info = $this
->gitHubUserAuth()
->getStoreData();
$token = isset($info['token'])
? $info['token']
: getenv('PROJECTX_GITHUB_TOKEN') ?: null;
if (!isset($token)) {
throw new \RuntimeException(
"GitHub user authentication token is required. \r\n\n " .
'[info] Run vendor/bin/project-x github::auth to get started.'
);
}
return $token;
} | [
"public",
"function",
"getToken",
"(",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"gitHubUserAuth",
"(",
")",
"->",
"getStoreData",
"(",
")",
";",
"$",
"token",
"=",
"isset",
"(",
"$",
"info",
"[",
"'token'",
"]",
")",
"?",
"$",
"info",
"[",
... | Get GitHub user authentication token.
@throws RuntimeException
@return string | [
"Get",
"GitHub",
"user",
"authentication",
"token",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/GitHubTaskBase.php#L47-L65 | train |
droath/project-x | src/Task/GitHubTaskBase.php | GitHubTaskBase.getGitHubUrlInfo | public function getGitHubUrlInfo()
{
$info = $this->getGithubInfo();
if (isset($info['url'])) {
$matches = [];
$pattern = '/(?:https?:\/\/github.com\/|git\@.+\:)([\w\/\-\_]+)/';
if (preg_match($pattern, $info['url'], $matches)) {
list($account, $repo) = explode(
DIRECTORY_SEPARATOR,
$matches[1]
);
return [
'account' => $account,
'repository' => $repo,
];
}
}
return [];
} | php | public function getGitHubUrlInfo()
{
$info = $this->getGithubInfo();
if (isset($info['url'])) {
$matches = [];
$pattern = '/(?:https?:\/\/github.com\/|git\@.+\:)([\w\/\-\_]+)/';
if (preg_match($pattern, $info['url'], $matches)) {
list($account, $repo) = explode(
DIRECTORY_SEPARATOR,
$matches[1]
);
return [
'account' => $account,
'repository' => $repo,
];
}
}
return [];
} | [
"public",
"function",
"getGitHubUrlInfo",
"(",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"getGithubInfo",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"info",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"$",
"patter... | Get GitHub information for URL.
@return array
An array of account and repository values. | [
"Get",
"GitHub",
"information",
"for",
"URL",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/GitHubTaskBase.php#L114-L136 | train |
droath/project-x | src/Task/GitHubTaskBase.php | GitHubTaskBase.hasGitFlow | protected function hasGitFlow()
{
$config = $this->gitConfig();
if (isset($config['gitflow prefix'])
&& !empty($config['gitflow prefix'])) {
return true;
}
return false;
} | php | protected function hasGitFlow()
{
$config = $this->gitConfig();
if (isset($config['gitflow prefix'])
&& !empty($config['gitflow prefix'])) {
return true;
}
return false;
} | [
"protected",
"function",
"hasGitFlow",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"gitConfig",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'gitflow prefix'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"config",
"[",
"'gitflow... | Has Git-flow enabled.
@return bool | [
"Has",
"Git",
"-",
"flow",
"enabled",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/GitHubTaskBase.php#L166-L176 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.