id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
3,400 | phramework/database | src/PostgreSQL.php | PostgreSQL.executeAndFetch | public function executeAndFetch($query, $parameters = [], $castModel = null)
{
$statement = $this->link->prepare($query);
$statement->execute($parameters);
$data = $statement->fetch(PDO::FETCH_ASSOC);
$statement->closeCursor();
return (
$castModel && $data
? $data
: $data
);
} | php | public function executeAndFetch($query, $parameters = [], $castModel = null)
{
$statement = $this->link->prepare($query);
$statement->execute($parameters);
$data = $statement->fetch(PDO::FETCH_ASSOC);
$statement->closeCursor();
return (
$castModel && $data
? $data
: $data
);
} | [
"public",
"function",
"executeAndFetch",
"(",
"$",
"query",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"castModel",
"=",
"null",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"link",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"$",
"statement",
"->",
"execute",
"(",
"$",
"parameters",
")",
";",
"$",
"data",
"=",
"$",
"statement",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"$",
"statement",
"->",
"closeCursor",
"(",
")",
";",
"return",
"(",
"$",
"castModel",
"&&",
"$",
"data",
"?",
"$",
"data",
":",
"$",
"data",
")",
";",
"}"
] | Execute a query and fetch first row as associative array
@param string $query
@param array $parameters Query parameters
@return array Returns a single row from database
@throws \Phramework\Exceptions\DatabaseException | [
"Execute",
"a",
"query",
"and",
"fetch",
"first",
"row",
"as",
"associative",
"array"
] | 12726d81917981aa447bb58b76e21762592aab8f | https://github.com/phramework/database/blob/12726d81917981aa447bb58b76e21762592aab8f/src/PostgreSQL.php#L126-L139 |
3,401 | phramework/database | src/PostgreSQL.php | PostgreSQL.bindExecuteAndFetch | public function bindExecuteAndFetch($query, $parameters = [], $castModel = null)
{
$statement = $this->link->prepare($query);
foreach ($parameters as $index => $paramProperties) {
if (is_object($paramProperties)) {
$paramProperties = (array) $paramProperties;
}
if (is_array($paramProperties)) {
$statement->bindValue(
(int) $index + 1,
$paramProperties['value'],
$paramProperties['param']
);
} else {
$statement->bindValue((int) $index + 1, $paramProperties);
}
}
$statement->execute();
$data = $statement->fetch(PDO::FETCH_ASSOC);
$statement->closeCursor();
return (
$castModel && $data
? $data
: $data
);
} | php | public function bindExecuteAndFetch($query, $parameters = [], $castModel = null)
{
$statement = $this->link->prepare($query);
foreach ($parameters as $index => $paramProperties) {
if (is_object($paramProperties)) {
$paramProperties = (array) $paramProperties;
}
if (is_array($paramProperties)) {
$statement->bindValue(
(int) $index + 1,
$paramProperties['value'],
$paramProperties['param']
);
} else {
$statement->bindValue((int) $index + 1, $paramProperties);
}
}
$statement->execute();
$data = $statement->fetch(PDO::FETCH_ASSOC);
$statement->closeCursor();
return (
$castModel && $data
? $data
: $data
);
} | [
"public",
"function",
"bindExecuteAndFetch",
"(",
"$",
"query",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"castModel",
"=",
"null",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"link",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"index",
"=>",
"$",
"paramProperties",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"paramProperties",
")",
")",
"{",
"$",
"paramProperties",
"=",
"(",
"array",
")",
"$",
"paramProperties",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"paramProperties",
")",
")",
"{",
"$",
"statement",
"->",
"bindValue",
"(",
"(",
"int",
")",
"$",
"index",
"+",
"1",
",",
"$",
"paramProperties",
"[",
"'value'",
"]",
",",
"$",
"paramProperties",
"[",
"'param'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"statement",
"->",
"bindValue",
"(",
"(",
"int",
")",
"$",
"index",
"+",
"1",
",",
"$",
"paramProperties",
")",
";",
"}",
"}",
"$",
"statement",
"->",
"execute",
"(",
")",
";",
"$",
"data",
"=",
"$",
"statement",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"$",
"statement",
"->",
"closeCursor",
"(",
")",
";",
"return",
"(",
"$",
"castModel",
"&&",
"$",
"data",
"?",
"$",
"data",
":",
"$",
"data",
")",
";",
"}"
] | Bind Execute a query and fetch first row as associative array
@param string $query Query string
@param array $parameters Query parameters
@return array
@throws \Phramework\Exceptions\DatabaseException | [
"Bind",
"Execute",
"a",
"query",
"and",
"fetch",
"first",
"row",
"as",
"associative",
"array"
] | 12726d81917981aa447bb58b76e21762592aab8f | https://github.com/phramework/database/blob/12726d81917981aa447bb58b76e21762592aab8f/src/PostgreSQL.php#L274-L302 |
3,402 | phramework/database | src/PostgreSQL.php | PostgreSQL.bindExecuteAndFetchAll | public function bindExecuteAndFetchAll($query, $parameters = [], $castModel = null)
{
$statement = $this->link->prepare($query);
foreach ($parameters as $index => $paramProperties) {
if (is_object($paramProperties)) {
$paramProperties = (array) $paramProperties;
}
if (is_array($paramProperties)) {
$statement->bindValue(
(int) $index + 1,
$paramProperties['value'],
$paramProperties['param']
);
} else {
$statement->bindValue((int) $index + 1, $paramProperties);
}
}
$statement->execute();
$data = $statement->fetchAll(PDO::FETCH_ASSOC);
return (
$castModel && $data
? $data
: $data
);
} | php | public function bindExecuteAndFetchAll($query, $parameters = [], $castModel = null)
{
$statement = $this->link->prepare($query);
foreach ($parameters as $index => $paramProperties) {
if (is_object($paramProperties)) {
$paramProperties = (array) $paramProperties;
}
if (is_array($paramProperties)) {
$statement->bindValue(
(int) $index + 1,
$paramProperties['value'],
$paramProperties['param']
);
} else {
$statement->bindValue((int) $index + 1, $paramProperties);
}
}
$statement->execute();
$data = $statement->fetchAll(PDO::FETCH_ASSOC);
return (
$castModel && $data
? $data
: $data
);
} | [
"public",
"function",
"bindExecuteAndFetchAll",
"(",
"$",
"query",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"castModel",
"=",
"null",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"link",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"index",
"=>",
"$",
"paramProperties",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"paramProperties",
")",
")",
"{",
"$",
"paramProperties",
"=",
"(",
"array",
")",
"$",
"paramProperties",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"paramProperties",
")",
")",
"{",
"$",
"statement",
"->",
"bindValue",
"(",
"(",
"int",
")",
"$",
"index",
"+",
"1",
",",
"$",
"paramProperties",
"[",
"'value'",
"]",
",",
"$",
"paramProperties",
"[",
"'param'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"statement",
"->",
"bindValue",
"(",
"(",
"int",
")",
"$",
"index",
"+",
"1",
",",
"$",
"paramProperties",
")",
";",
"}",
"}",
"$",
"statement",
"->",
"execute",
"(",
")",
";",
"$",
"data",
"=",
"$",
"statement",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"return",
"(",
"$",
"castModel",
"&&",
"$",
"data",
"?",
"$",
"data",
":",
"$",
"data",
")",
";",
"}"
] | Bind Execute a query and fetch all rows as associative array
@param string $query Query string
@param array $parameters Query parameters
@return array[]
@throws \Phramework\Exceptions\DatabaseException | [
"Bind",
"Execute",
"a",
"query",
"and",
"fetch",
"all",
"rows",
"as",
"associative",
"array"
] | 12726d81917981aa447bb58b76e21762592aab8f | https://github.com/phramework/database/blob/12726d81917981aa447bb58b76e21762592aab8f/src/PostgreSQL.php#L312-L339 |
3,403 | uthando-cms/uthando-common | src/UthandoCommon/Db/Table/AbstractTable.php | AbstractTable.getById | public function getById($id)
{
$id = (int) $id;
$rowSet = $this->getTableGateway()->select([$this->getPrimaryKey() => $id]);
$row = $rowSet->current();
return $row;
} | php | public function getById($id)
{
$id = (int) $id;
$rowSet = $this->getTableGateway()->select([$this->getPrimaryKey() => $id]);
$row = $rowSet->current();
return $row;
} | [
"public",
"function",
"getById",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"$",
"rowSet",
"=",
"$",
"this",
"->",
"getTableGateway",
"(",
")",
"->",
"select",
"(",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"=>",
"$",
"id",
"]",
")",
";",
"$",
"row",
"=",
"$",
"rowSet",
"->",
"current",
"(",
")",
";",
"return",
"$",
"row",
";",
"}"
] | Get one row by it's id
@param $id
@return array|\ArrayObject|ModelInterface|null | [
"Get",
"one",
"row",
"by",
"it",
"s",
"id"
] | feb915da5d26b60f536282e1bc3ad5c22e53f485 | https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Db/Table/AbstractTable.php#L58-L64 |
3,404 | uthando-cms/uthando-common | src/UthandoCommon/Db/Table/AbstractTable.php | AbstractTable.fetchAll | public function fetchAll($paginated = false)
{
if ($paginated) {
$paginatorAdapter = new DbTableGateway($this->tableGateway);
$paginator = new Paginator($paginatorAdapter);
return $paginator;
}
$resultSet = $this->getTableGateway()->select();
return $resultSet;
} | php | public function fetchAll($paginated = false)
{
if ($paginated) {
$paginatorAdapter = new DbTableGateway($this->tableGateway);
$paginator = new Paginator($paginatorAdapter);
return $paginator;
}
$resultSet = $this->getTableGateway()->select();
return $resultSet;
} | [
"public",
"function",
"fetchAll",
"(",
"$",
"paginated",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"paginated",
")",
"{",
"$",
"paginatorAdapter",
"=",
"new",
"DbTableGateway",
"(",
"$",
"this",
"->",
"tableGateway",
")",
";",
"$",
"paginator",
"=",
"new",
"Paginator",
"(",
"$",
"paginatorAdapter",
")",
";",
"return",
"$",
"paginator",
";",
"}",
"$",
"resultSet",
"=",
"$",
"this",
"->",
"getTableGateway",
"(",
")",
"->",
"select",
"(",
")",
";",
"return",
"$",
"resultSet",
";",
"}"
] | Fetch all records.
@param bool $paginated
@return ResultSet | [
"Fetch",
"all",
"records",
"."
] | feb915da5d26b60f536282e1bc3ad5c22e53f485 | https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Db/Table/AbstractTable.php#L72-L84 |
3,405 | phplegends/routes | src/Router.php | Router.findByUri | public function findByUri($uri)
{
return $this->routes->first(function ($route) use($uri) {
return $route->match($uri);
});
} | php | public function findByUri($uri)
{
return $this->routes->first(function ($route) use($uri) {
return $route->match($uri);
});
} | [
"public",
"function",
"findByUri",
"(",
"$",
"uri",
")",
"{",
"return",
"$",
"this",
"->",
"routes",
"->",
"first",
"(",
"function",
"(",
"$",
"route",
")",
"use",
"(",
"$",
"uri",
")",
"{",
"return",
"$",
"route",
"->",
"match",
"(",
"$",
"uri",
")",
";",
"}",
")",
";",
"}"
] | Finds the route via uri
@param string $uri
@return \PHPLegends\Routes\Route | null | [
"Finds",
"the",
"route",
"via",
"uri"
] | 7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec | https://github.com/phplegends/routes/blob/7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec/src/Router.php#L82-L88 |
3,406 | phplegends/routes | src/Router.php | Router.findByName | public function findByName($name)
{
return $this->routes->first(function ($route) use($name)
{
return $route->getName() === $name;
});
} | php | public function findByName($name)
{
return $this->routes->first(function ($route) use($name)
{
return $route->getName() === $name;
});
} | [
"public",
"function",
"findByName",
"(",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"routes",
"->",
"first",
"(",
"function",
"(",
"$",
"route",
")",
"use",
"(",
"$",
"name",
")",
"{",
"return",
"$",
"route",
"->",
"getName",
"(",
")",
"===",
"$",
"name",
";",
"}",
")",
";",
"}"
] | Returns route by given name
@param string $name
@return \PHPLegends\Routes\Route | null | [
"Returns",
"route",
"by",
"given",
"name"
] | 7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec | https://github.com/phplegends/routes/blob/7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec/src/Router.php#L144-L150 |
3,407 | phplegends/routes | src/Router.php | Router.group | public function group(array $options, \Closure $closure)
{
$group = new static(null, $options);
$closure->bindTo($group)->__invoke($group);
$this->getCollection()->addAll($group->getCollection());
return $this;
} | php | public function group(array $options, \Closure $closure)
{
$group = new static(null, $options);
$closure->bindTo($group)->__invoke($group);
$this->getCollection()->addAll($group->getCollection());
return $this;
} | [
"public",
"function",
"group",
"(",
"array",
"$",
"options",
",",
"\\",
"Closure",
"$",
"closure",
")",
"{",
"$",
"group",
"=",
"new",
"static",
"(",
"null",
",",
"$",
"options",
")",
";",
"$",
"closure",
"->",
"bindTo",
"(",
"$",
"group",
")",
"->",
"__invoke",
"(",
"$",
"group",
")",
";",
"$",
"this",
"->",
"getCollection",
"(",
")",
"->",
"addAll",
"(",
"$",
"group",
"->",
"getCollection",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Create a group with specific options
@param array $options
@param \Closure $closure | [
"Create",
"a",
"group",
"with",
"specific",
"options"
] | 7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec | https://github.com/phplegends/routes/blob/7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec/src/Router.php#L324-L334 |
3,408 | phplegends/routes | src/Router.php | Router.routable | public function routable($class, $prefix = null)
{
$class = $this->resolveRoutableClassValue($class);
$router = (new RoutableInspector($class))->generateRoutables(null, $prefix);
$this->mergeRouter($router);
return $this;
} | php | public function routable($class, $prefix = null)
{
$class = $this->resolveRoutableClassValue($class);
$router = (new RoutableInspector($class))->generateRoutables(null, $prefix);
$this->mergeRouter($router);
return $this;
} | [
"public",
"function",
"routable",
"(",
"$",
"class",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"resolveRoutableClassValue",
"(",
"$",
"class",
")",
";",
"$",
"router",
"=",
"(",
"new",
"RoutableInspector",
"(",
"$",
"class",
")",
")",
"->",
"generateRoutables",
"(",
"null",
",",
"$",
"prefix",
")",
";",
"$",
"this",
"->",
"mergeRouter",
"(",
"$",
"router",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Import all routable method for a class
@param string $class
@return self | [
"Import",
"all",
"routable",
"method",
"for",
"a",
"class"
] | 7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec | https://github.com/phplegends/routes/blob/7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec/src/Router.php#L342-L351 |
3,409 | phplegends/routes | src/Router.php | Router.resolveNameValue | protected function resolveNameValue($name)
{
if ($name === null) return null;
if ($prefixName = $this->getPrefixName()) {
$name = $prefixName . $name;
}
return $name;
} | php | protected function resolveNameValue($name)
{
if ($name === null) return null;
if ($prefixName = $this->getPrefixName()) {
$name = $prefixName . $name;
}
return $name;
} | [
"protected",
"function",
"resolveNameValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"return",
"null",
";",
"if",
"(",
"$",
"prefixName",
"=",
"$",
"this",
"->",
"getPrefixName",
"(",
")",
")",
"{",
"$",
"name",
"=",
"$",
"prefixName",
".",
"$",
"name",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Result value of name
@param string|null $name
@return string|null | [
"Result",
"value",
"of",
"name"
] | 7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec | https://github.com/phplegends/routes/blob/7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec/src/Router.php#L424-L434 |
3,410 | phplegends/routes | src/Router.php | Router.setOptions | public function setOptions(array $args)
{
$this->options = $args += [
'filters' => [],
'name' => null,
'namespace' => null,
'prefix' => null,
];
$args['namespace'] && $this->setNamespace($args['namespace']);
$args['prefix'] && $this->setPrefixPath($args['prefix']);
$args['name'] && $this->setPrefixName($args['name']);
$args['filters'] && $this->setDefaultFilters($args['filters']);
return $this;
} | php | public function setOptions(array $args)
{
$this->options = $args += [
'filters' => [],
'name' => null,
'namespace' => null,
'prefix' => null,
];
$args['namespace'] && $this->setNamespace($args['namespace']);
$args['prefix'] && $this->setPrefixPath($args['prefix']);
$args['name'] && $this->setPrefixName($args['name']);
$args['filters'] && $this->setDefaultFilters($args['filters']);
return $this;
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"args",
"+=",
"[",
"'filters'",
"=>",
"[",
"]",
",",
"'name'",
"=>",
"null",
",",
"'namespace'",
"=>",
"null",
",",
"'prefix'",
"=>",
"null",
",",
"]",
";",
"$",
"args",
"[",
"'namespace'",
"]",
"&&",
"$",
"this",
"->",
"setNamespace",
"(",
"$",
"args",
"[",
"'namespace'",
"]",
")",
";",
"$",
"args",
"[",
"'prefix'",
"]",
"&&",
"$",
"this",
"->",
"setPrefixPath",
"(",
"$",
"args",
"[",
"'prefix'",
"]",
")",
";",
"$",
"args",
"[",
"'name'",
"]",
"&&",
"$",
"this",
"->",
"setPrefixName",
"(",
"$",
"args",
"[",
"'name'",
"]",
")",
";",
"$",
"args",
"[",
"'filters'",
"]",
"&&",
"$",
"this",
"->",
"setDefaultFilters",
"(",
"$",
"args",
"[",
"'filters'",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set value via array options
@param array $args
@return self | [
"Set",
"value",
"via",
"array",
"options"
] | 7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec | https://github.com/phplegends/routes/blob/7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec/src/Router.php#L524-L543 |
3,411 | helsingborg-stad/easy-to-read-alternative | source/php/Admin/Options.php | Options.acfLocationRulesMatch | public function acfLocationRulesMatch($match, $rule, $options)
{
$post_types = get_field('easy_reading_posttypes', 'option');
if ($post_types) {
if ($rule['operator'] == "==") {
$match = (isset($options['post_type']) && in_array($options['post_type'], $post_types) && $options['post_id'] > 0);
} elseif ($rule['operator'] == "!=") {
$match = (isset($options['post_type']) && !in_array($options['post_type'], $post_types) && $options['post_id'] > 0);
}
}
return $match;
} | php | public function acfLocationRulesMatch($match, $rule, $options)
{
$post_types = get_field('easy_reading_posttypes', 'option');
if ($post_types) {
if ($rule['operator'] == "==") {
$match = (isset($options['post_type']) && in_array($options['post_type'], $post_types) && $options['post_id'] > 0);
} elseif ($rule['operator'] == "!=") {
$match = (isset($options['post_type']) && !in_array($options['post_type'], $post_types) && $options['post_id'] > 0);
}
}
return $match;
} | [
"public",
"function",
"acfLocationRulesMatch",
"(",
"$",
"match",
",",
"$",
"rule",
",",
"$",
"options",
")",
"{",
"$",
"post_types",
"=",
"get_field",
"(",
"'easy_reading_posttypes'",
",",
"'option'",
")",
";",
"if",
"(",
"$",
"post_types",
")",
"{",
"if",
"(",
"$",
"rule",
"[",
"'operator'",
"]",
"==",
"\"==\"",
")",
"{",
"$",
"match",
"=",
"(",
"isset",
"(",
"$",
"options",
"[",
"'post_type'",
"]",
")",
"&&",
"in_array",
"(",
"$",
"options",
"[",
"'post_type'",
"]",
",",
"$",
"post_types",
")",
"&&",
"$",
"options",
"[",
"'post_id'",
"]",
">",
"0",
")",
";",
"}",
"elseif",
"(",
"$",
"rule",
"[",
"'operator'",
"]",
"==",
"\"!=\"",
")",
"{",
"$",
"match",
"=",
"(",
"isset",
"(",
"$",
"options",
"[",
"'post_type'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"$",
"options",
"[",
"'post_type'",
"]",
",",
"$",
"post_types",
")",
"&&",
"$",
"options",
"[",
"'post_id'",
"]",
">",
"0",
")",
";",
"}",
"}",
"return",
"$",
"match",
";",
"}"
] | Matching custom location rule
@param boolean $match If rule match or not
@param array $rule Current rule that to match against
@param array $options Data about the current edit screen
@return boolean | [
"Matching",
"custom",
"location",
"rule"
] | 0dfd7ea9168cbbde145d8b9e58a69ded3fa82ae0 | https://github.com/helsingborg-stad/easy-to-read-alternative/blob/0dfd7ea9168cbbde145d8b9e58a69ded3fa82ae0/source/php/Admin/Options.php#L54-L67 |
3,412 | williamespindola/abstract-http-client | src/QueryString/ExtraQueryString.php | ExtraQueryString.getUriWithExtraString | public function getUriWithExtraString(string $uri): String
{
if (!$this->queryString) {
return $uri;
}
return $uri . '?' . implode('&', $this->queryString);
} | php | public function getUriWithExtraString(string $uri): String
{
if (!$this->queryString) {
return $uri;
}
return $uri . '?' . implode('&', $this->queryString);
} | [
"public",
"function",
"getUriWithExtraString",
"(",
"string",
"$",
"uri",
")",
":",
"String",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"queryString",
")",
"{",
"return",
"$",
"uri",
";",
"}",
"return",
"$",
"uri",
".",
"'?'",
".",
"implode",
"(",
"'&'",
",",
"$",
"this",
"->",
"queryString",
")",
";",
"}"
] | Get uri with extra query strings
@param String $uri String uri
@return String Uri concatenated with extra query string | [
"Get",
"uri",
"with",
"extra",
"query",
"strings"
] | 92eedeb6084dd9a6934c24bccd0b88039ce482dd | https://github.com/williamespindola/abstract-http-client/blob/92eedeb6084dd9a6934c24bccd0b88039ce482dd/src/QueryString/ExtraQueryString.php#L87-L94 |
3,413 | sellerlabs/nucleus | src/SellerLabs/Nucleus/Support/Flick.php | Flick.go | public function go($input)
{
Arguments::define(Boa::readMap())->define($input);
$map = ComplexFactory::toReadMap($this->functions);
if ($map->member($input)) {
/** @var callable $function */
$function = Maybe::fromJust($map->lookup($input));
return $function();
} elseif ($map->member($this->default)) {
/** @var callable $function */
$function = Maybe::fromJust($map->lookup($this->default));
return $function();
}
throw new UnknownKeyException();
} | php | public function go($input)
{
Arguments::define(Boa::readMap())->define($input);
$map = ComplexFactory::toReadMap($this->functions);
if ($map->member($input)) {
/** @var callable $function */
$function = Maybe::fromJust($map->lookup($input));
return $function();
} elseif ($map->member($this->default)) {
/** @var callable $function */
$function = Maybe::fromJust($map->lookup($this->default));
return $function();
}
throw new UnknownKeyException();
} | [
"public",
"function",
"go",
"(",
"$",
"input",
")",
"{",
"Arguments",
"::",
"define",
"(",
"Boa",
"::",
"readMap",
"(",
")",
")",
"->",
"define",
"(",
"$",
"input",
")",
";",
"$",
"map",
"=",
"ComplexFactory",
"::",
"toReadMap",
"(",
"$",
"this",
"->",
"functions",
")",
";",
"if",
"(",
"$",
"map",
"->",
"member",
"(",
"$",
"input",
")",
")",
"{",
"/** @var callable $function */",
"$",
"function",
"=",
"Maybe",
"::",
"fromJust",
"(",
"$",
"map",
"->",
"lookup",
"(",
"$",
"input",
")",
")",
";",
"return",
"$",
"function",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"map",
"->",
"member",
"(",
"$",
"this",
"->",
"default",
")",
")",
"{",
"/** @var callable $function */",
"$",
"function",
"=",
"Maybe",
"::",
"fromJust",
"(",
"$",
"map",
"->",
"lookup",
"(",
"$",
"this",
"->",
"default",
")",
")",
";",
"return",
"$",
"function",
"(",
")",
";",
"}",
"throw",
"new",
"UnknownKeyException",
"(",
")",
";",
"}"
] | Run the flick on input.
@param string|int $input
@throws UnknownKeyException
@return mixed | [
"Run",
"the",
"flick",
"on",
"input",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Flick.php#L88-L107 |
3,414 | AthensFramework/Core | src/etc/StringUtils.php | StringUtils.slugify | public static function slugify($string)
{
// Replace non-alpha-numerics with dashes
$string = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/','/[ -]+/','/^-|-$/'), array('','-',''), $string));
// Trim dashes from the left side of the string
$string = ltrim($string, "-");
// Trim dashes from the right side of the string
$string = rtrim($string, '-');
return $string;
} | php | public static function slugify($string)
{
// Replace non-alpha-numerics with dashes
$string = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/','/[ -]+/','/^-|-$/'), array('','-',''), $string));
// Trim dashes from the left side of the string
$string = ltrim($string, "-");
// Trim dashes from the right side of the string
$string = rtrim($string, '-');
return $string;
} | [
"public",
"static",
"function",
"slugify",
"(",
"$",
"string",
")",
"{",
"// Replace non-alpha-numerics with dashes",
"$",
"string",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"array",
"(",
"'/[^a-zA-Z0-9 -]/'",
",",
"'/[ -]+/'",
",",
"'/^-|-$/'",
")",
",",
"array",
"(",
"''",
",",
"'-'",
",",
"''",
")",
",",
"$",
"string",
")",
")",
";",
"// Trim dashes from the left side of the string",
"$",
"string",
"=",
"ltrim",
"(",
"$",
"string",
",",
"\"-\"",
")",
";",
"// Trim dashes from the right side of the string",
"$",
"string",
"=",
"rtrim",
"(",
"$",
"string",
",",
"'-'",
")",
";",
"return",
"$",
"string",
";",
"}"
] | Turn a string into a slug
@param string $string
@return string | [
"Turn",
"a",
"string",
"into",
"a",
"slug"
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/etc/StringUtils.php#L28-L40 |
3,415 | AthensFramework/Core | src/etc/StringUtils.php | StringUtils.toTitleCase | public static function toTitleCase($string)
{
// Replace underscores, dashes with spaces
$string = str_replace(["_", "-"], " ", $string);
// Break the string into an array of words
$name_array = explode(" ", $string);
// Words not-to capitalize
$smallWords = [
'of','a','the','and','an','or','nor','but','is','if','then','else','when',
'at','from','by','on','off','for','in','out','over','to','into','with'
];
$acronyms = Settings::getInstance()->getAcronyms();
foreach ($name_array as $index => $value) {
if (in_array($value, $acronyms) === true) {
$name_array[$index] = strtoupper($value);
} elseif ($index === 0 || $index === sizeof($name_array) - 1) {
$name_array[$index] = ucfirst($value);
} elseif (in_array($value, $smallWords) === true) {
// do nothing
} else {
$name_array[$index] = ucfirst($value);
}
}
// Recombine the array into a single string, and convert to capital case
$string = implode(" ", $name_array);
return $string;
} | php | public static function toTitleCase($string)
{
// Replace underscores, dashes with spaces
$string = str_replace(["_", "-"], " ", $string);
// Break the string into an array of words
$name_array = explode(" ", $string);
// Words not-to capitalize
$smallWords = [
'of','a','the','and','an','or','nor','but','is','if','then','else','when',
'at','from','by','on','off','for','in','out','over','to','into','with'
];
$acronyms = Settings::getInstance()->getAcronyms();
foreach ($name_array as $index => $value) {
if (in_array($value, $acronyms) === true) {
$name_array[$index] = strtoupper($value);
} elseif ($index === 0 || $index === sizeof($name_array) - 1) {
$name_array[$index] = ucfirst($value);
} elseif (in_array($value, $smallWords) === true) {
// do nothing
} else {
$name_array[$index] = ucfirst($value);
}
}
// Recombine the array into a single string, and convert to capital case
$string = implode(" ", $name_array);
return $string;
} | [
"public",
"static",
"function",
"toTitleCase",
"(",
"$",
"string",
")",
"{",
"// Replace underscores, dashes with spaces",
"$",
"string",
"=",
"str_replace",
"(",
"[",
"\"_\"",
",",
"\"-\"",
"]",
",",
"\" \"",
",",
"$",
"string",
")",
";",
"// Break the string into an array of words",
"$",
"name_array",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"string",
")",
";",
"// Words not-to capitalize",
"$",
"smallWords",
"=",
"[",
"'of'",
",",
"'a'",
",",
"'the'",
",",
"'and'",
",",
"'an'",
",",
"'or'",
",",
"'nor'",
",",
"'but'",
",",
"'is'",
",",
"'if'",
",",
"'then'",
",",
"'else'",
",",
"'when'",
",",
"'at'",
",",
"'from'",
",",
"'by'",
",",
"'on'",
",",
"'off'",
",",
"'for'",
",",
"'in'",
",",
"'out'",
",",
"'over'",
",",
"'to'",
",",
"'into'",
",",
"'with'",
"]",
";",
"$",
"acronyms",
"=",
"Settings",
"::",
"getInstance",
"(",
")",
"->",
"getAcronyms",
"(",
")",
";",
"foreach",
"(",
"$",
"name_array",
"as",
"$",
"index",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"$",
"acronyms",
")",
"===",
"true",
")",
"{",
"$",
"name_array",
"[",
"$",
"index",
"]",
"=",
"strtoupper",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"index",
"===",
"0",
"||",
"$",
"index",
"===",
"sizeof",
"(",
"$",
"name_array",
")",
"-",
"1",
")",
"{",
"$",
"name_array",
"[",
"$",
"index",
"]",
"=",
"ucfirst",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"value",
",",
"$",
"smallWords",
")",
"===",
"true",
")",
"{",
"// do nothing",
"}",
"else",
"{",
"$",
"name_array",
"[",
"$",
"index",
"]",
"=",
"ucfirst",
"(",
"$",
"value",
")",
";",
"}",
"}",
"// Recombine the array into a single string, and convert to capital case",
"$",
"string",
"=",
"implode",
"(",
"\" \"",
",",
"$",
"name_array",
")",
";",
"return",
"$",
"string",
";",
"}"
] | Format a string into title case
@param string $string
@return string | [
"Format",
"a",
"string",
"into",
"title",
"case"
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/etc/StringUtils.php#L48-L81 |
3,416 | orchestral/studio | src/Traits/PublishRoutes.php | PublishRoutes.publishRoute | protected function publishRoute(Filesystem $filesystem, $route)
{
if (is_null($route)) {
return ;
}
$routeFile = app_path('Http/routes.php');
if ($filesystem->exists($routeFile) && $filesystem->exists($route)) {
$filesystem->append($routeFile, $filesystem->get($route));
$this->line('<info>Append routes from</info> <comment>['.$route.']</comment>');
}
} | php | protected function publishRoute(Filesystem $filesystem, $route)
{
if (is_null($route)) {
return ;
}
$routeFile = app_path('Http/routes.php');
if ($filesystem->exists($routeFile) && $filesystem->exists($route)) {
$filesystem->append($routeFile, $filesystem->get($route));
$this->line('<info>Append routes from</info> <comment>['.$route.']</comment>');
}
} | [
"protected",
"function",
"publishRoute",
"(",
"Filesystem",
"$",
"filesystem",
",",
"$",
"route",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"route",
")",
")",
"{",
"return",
";",
"}",
"$",
"routeFile",
"=",
"app_path",
"(",
"'Http/routes.php'",
")",
";",
"if",
"(",
"$",
"filesystem",
"->",
"exists",
"(",
"$",
"routeFile",
")",
"&&",
"$",
"filesystem",
"->",
"exists",
"(",
"$",
"route",
")",
")",
"{",
"$",
"filesystem",
"->",
"append",
"(",
"$",
"routeFile",
",",
"$",
"filesystem",
"->",
"get",
"(",
"$",
"route",
")",
")",
";",
"$",
"this",
"->",
"line",
"(",
"'<info>Append routes from</info> <comment>['",
".",
"$",
"route",
".",
"']</comment>'",
")",
";",
"}",
"}"
] | Appends routes.
@param \Illuminate\Filesystem\Filesystem $filesystem
@param string|null $route
@return void | [
"Appends",
"routes",
"."
] | 254d0d3296ff8b52cdb7f4eab2423fea2bcced3b | https://github.com/orchestral/studio/blob/254d0d3296ff8b52cdb7f4eab2423fea2bcced3b/src/Traits/PublishRoutes.php#L17-L30 |
3,417 | theluckyteam/php-jira | src/jira/Entity/ReadonlyIssue.php | ReadonlyIssue.getProperty | private function getProperty($name)
{
if (!Property::exists($this->properties, $name)) {
throw new \Exception();
}
return Property::get($this->properties, $name);
} | php | private function getProperty($name)
{
if (!Property::exists($this->properties, $name)) {
throw new \Exception();
}
return Property::get($this->properties, $name);
} | [
"private",
"function",
"getProperty",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"Property",
"::",
"exists",
"(",
"$",
"this",
"->",
"properties",
",",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
")",
";",
"}",
"return",
"Property",
"::",
"get",
"(",
"$",
"this",
"->",
"properties",
",",
"$",
"name",
")",
";",
"}"
] | Returns value of property
@param string $name Name of property
@return mixed Value of property
@throws \Exception If unknown property | [
"Returns",
"value",
"of",
"property"
] | 5a50ab4fc57dd77239f1b7e9c87738318c258c38 | https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Entity/ReadonlyIssue.php#L102-L109 |
3,418 | sgoendoer/json | src/JSONTools.php | JSONTools.getJSONErrorAsString | public static function getJSONErrorAsString()
{
switch(json_last_error())
{
case JSON_ERROR_NONE:
$error = NULL;
break;
case JSON_ERROR_DEPTH:
$error = 'The maximum stack depth has been exceeded.';
break;
case JSON_ERROR_STATE_MISMATCH:
$error = 'Invalid or malformed JSON.';
break;
case JSON_ERROR_CTRL_CHAR:
$error = 'Control character error, possibly incorrectly encoded.';
break;
case JSON_ERROR_SYNTAX:
$error = 'Syntax error, malformed JSON.';
break;
// PHP >= 5.3.3
case JSON_ERROR_UTF8:
$error = 'Malformed UTF-8 characters, possibly incorrectly encoded.';
break;
// PHP >= 5.5.0
case JSON_ERROR_RECURSION:
$error = 'One or more recursive references in the value to be encoded.';
break;
// PHP >= 5.5.0
case JSON_ERROR_INF_OR_NAN:
$error = 'One or more NAN or INF values in the value to be encoded.';
break;
case JSON_ERROR_UNSUPPORTED_TYPE:
$error = 'A value of a type that cannot be encoded was given.';
break;
default:
$error = NULL;
break;
}
return $error;
} | php | public static function getJSONErrorAsString()
{
switch(json_last_error())
{
case JSON_ERROR_NONE:
$error = NULL;
break;
case JSON_ERROR_DEPTH:
$error = 'The maximum stack depth has been exceeded.';
break;
case JSON_ERROR_STATE_MISMATCH:
$error = 'Invalid or malformed JSON.';
break;
case JSON_ERROR_CTRL_CHAR:
$error = 'Control character error, possibly incorrectly encoded.';
break;
case JSON_ERROR_SYNTAX:
$error = 'Syntax error, malformed JSON.';
break;
// PHP >= 5.3.3
case JSON_ERROR_UTF8:
$error = 'Malformed UTF-8 characters, possibly incorrectly encoded.';
break;
// PHP >= 5.5.0
case JSON_ERROR_RECURSION:
$error = 'One or more recursive references in the value to be encoded.';
break;
// PHP >= 5.5.0
case JSON_ERROR_INF_OR_NAN:
$error = 'One or more NAN or INF values in the value to be encoded.';
break;
case JSON_ERROR_UNSUPPORTED_TYPE:
$error = 'A value of a type that cannot be encoded was given.';
break;
default:
$error = NULL;
break;
}
return $error;
} | [
"public",
"static",
"function",
"getJSONErrorAsString",
"(",
")",
"{",
"switch",
"(",
"json_last_error",
"(",
")",
")",
"{",
"case",
"JSON_ERROR_NONE",
":",
"$",
"error",
"=",
"NULL",
";",
"break",
";",
"case",
"JSON_ERROR_DEPTH",
":",
"$",
"error",
"=",
"'The maximum stack depth has been exceeded.'",
";",
"break",
";",
"case",
"JSON_ERROR_STATE_MISMATCH",
":",
"$",
"error",
"=",
"'Invalid or malformed JSON.'",
";",
"break",
";",
"case",
"JSON_ERROR_CTRL_CHAR",
":",
"$",
"error",
"=",
"'Control character error, possibly incorrectly encoded.'",
";",
"break",
";",
"case",
"JSON_ERROR_SYNTAX",
":",
"$",
"error",
"=",
"'Syntax error, malformed JSON.'",
";",
"break",
";",
"// PHP >= 5.3.3",
"case",
"JSON_ERROR_UTF8",
":",
"$",
"error",
"=",
"'Malformed UTF-8 characters, possibly incorrectly encoded.'",
";",
"break",
";",
"// PHP >= 5.5.0",
"case",
"JSON_ERROR_RECURSION",
":",
"$",
"error",
"=",
"'One or more recursive references in the value to be encoded.'",
";",
"break",
";",
"// PHP >= 5.5.0",
"case",
"JSON_ERROR_INF_OR_NAN",
":",
"$",
"error",
"=",
"'One or more NAN or INF values in the value to be encoded.'",
";",
"break",
";",
"case",
"JSON_ERROR_UNSUPPORTED_TYPE",
":",
"$",
"error",
"=",
"'A value of a type that cannot be encoded was given.'",
";",
"break",
";",
"default",
":",
"$",
"error",
"=",
"NULL",
";",
"break",
";",
"}",
"return",
"$",
"error",
";",
"}"
] | returns a string representation of the last JSON error
@return string The error string. NULL, if no error was found | [
"returns",
"a",
"string",
"representation",
"of",
"the",
"last",
"JSON",
"error"
] | 31fb7330d185e6f91bb260c4bf55050982f0bad1 | https://github.com/sgoendoer/json/blob/31fb7330d185e6f91bb260c4bf55050982f0bad1/src/JSONTools.php#L18-L67 |
3,419 | sgoendoer/json | src/JSONTools.php | JSONTools.containsValidJSON | public static function containsValidJSON($string)
{
try
{
$result = json_decode($string);
}
catch(\Exception $e)
{}
if(self::getJSONError() === NULL)
return true;
else
return false;
} | php | public static function containsValidJSON($string)
{
try
{
$result = json_decode($string);
}
catch(\Exception $e)
{}
if(self::getJSONError() === NULL)
return true;
else
return false;
} | [
"public",
"static",
"function",
"containsValidJSON",
"(",
"$",
"string",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"string",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"if",
"(",
"self",
"::",
"getJSONError",
"(",
")",
"===",
"NULL",
")",
"return",
"true",
";",
"else",
"return",
"false",
";",
"}"
] | Determines if a string contains a valid, decodable JSON object.
@param $string string to be tested
@return true, if given string contains valid JSON, else false | [
"Determines",
"if",
"a",
"string",
"contains",
"a",
"valid",
"decodable",
"JSON",
"object",
"."
] | 31fb7330d185e6f91bb260c4bf55050982f0bad1 | https://github.com/sgoendoer/json/blob/31fb7330d185e6f91bb260c4bf55050982f0bad1/src/JSONTools.php#L76-L89 |
3,420 | joaogl/base | src/Base.php | Base.getSettingsMethods | protected function getSettingsMethods()
{
if (empty($this->settingsMethods)) {
$settings = $this->getSettingsRepository();
$methods = get_class_methods($settings);
$this->settingsMethods = array_diff($methods, ['__construct']);
}
return $this->settingsMethods;
} | php | protected function getSettingsMethods()
{
if (empty($this->settingsMethods)) {
$settings = $this->getSettingsRepository();
$methods = get_class_methods($settings);
$this->settingsMethods = array_diff($methods, ['__construct']);
}
return $this->settingsMethods;
} | [
"protected",
"function",
"getSettingsMethods",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"settingsMethods",
")",
")",
"{",
"$",
"settings",
"=",
"$",
"this",
"->",
"getSettingsRepository",
"(",
")",
";",
"$",
"methods",
"=",
"get_class_methods",
"(",
"$",
"settings",
")",
";",
"$",
"this",
"->",
"settingsMethods",
"=",
"array_diff",
"(",
"$",
"methods",
",",
"[",
"'__construct'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"settingsMethods",
";",
"}"
] | Returns all accessible methods on the associated settings repository.
@return array | [
"Returns",
"all",
"accessible",
"methods",
"on",
"the",
"associated",
"settings",
"repository",
"."
] | e6a4e9f4d3c75efc92545941ea5c9810d3291b56 | https://github.com/joaogl/base/blob/e6a4e9f4d3c75efc92545941ea5c9810d3291b56/src/Base.php#L186-L197 |
3,421 | joaogl/base | src/Base.php | Base.Log | public function Log($logMessage)
{
$target = null;
if ($user = Sentinel::getUser())
if ($user != null)
$target = $user->id;
$log = $this->getLogsRepository()->create(['log' => $logMessage, 'ip' => Request::ip(), 'target' => $target]);
} | php | public function Log($logMessage)
{
$target = null;
if ($user = Sentinel::getUser())
if ($user != null)
$target = $user->id;
$log = $this->getLogsRepository()->create(['log' => $logMessage, 'ip' => Request::ip(), 'target' => $target]);
} | [
"public",
"function",
"Log",
"(",
"$",
"logMessage",
")",
"{",
"$",
"target",
"=",
"null",
";",
"if",
"(",
"$",
"user",
"=",
"Sentinel",
"::",
"getUser",
"(",
")",
")",
"if",
"(",
"$",
"user",
"!=",
"null",
")",
"$",
"target",
"=",
"$",
"user",
"->",
"id",
";",
"$",
"log",
"=",
"$",
"this",
"->",
"getLogsRepository",
"(",
")",
"->",
"create",
"(",
"[",
"'log'",
"=>",
"$",
"logMessage",
",",
"'ip'",
"=>",
"Request",
"::",
"ip",
"(",
")",
",",
"'target'",
"=>",
"$",
"target",
"]",
")",
";",
"}"
] | Create a log
@param $logMessage | [
"Create",
"a",
"log"
] | e6a4e9f4d3c75efc92545941ea5c9810d3291b56 | https://github.com/joaogl/base/blob/e6a4e9f4d3c75efc92545941ea5c9810d3291b56/src/Base.php#L225-L234 |
3,422 | joaogl/base | src/Base.php | Base.TargettedLog | public function TargettedLog($logMessage, $userTarget)
{
$log = $this->getLogsRepository()->create(['log' => $logMessage, 'target' => $userTarget, 'ip' => Request::ip()]);
} | php | public function TargettedLog($logMessage, $userTarget)
{
$log = $this->getLogsRepository()->create(['log' => $logMessage, 'target' => $userTarget, 'ip' => Request::ip()]);
} | [
"public",
"function",
"TargettedLog",
"(",
"$",
"logMessage",
",",
"$",
"userTarget",
")",
"{",
"$",
"log",
"=",
"$",
"this",
"->",
"getLogsRepository",
"(",
")",
"->",
"create",
"(",
"[",
"'log'",
"=>",
"$",
"logMessage",
",",
"'target'",
"=>",
"$",
"userTarget",
",",
"'ip'",
"=>",
"Request",
"::",
"ip",
"(",
")",
"]",
")",
";",
"}"
] | Create a log and associates it to a user
@param $logMessage
@param $userTarget | [
"Create",
"a",
"log",
"and",
"associates",
"it",
"to",
"a",
"user"
] | e6a4e9f4d3c75efc92545941ea5c9810d3291b56 | https://github.com/joaogl/base/blob/e6a4e9f4d3c75efc92545941ea5c9810d3291b56/src/Base.php#L242-L245 |
3,423 | frogsystem/legacy-bridge | src/Services/Config/ConfigData.php | ConfigData.setConfigByFile | public function setConfigByFile($name)
{
$file = "/{$name}.cfg.php";
if ('production' !== FS2_ENV) {
$file_env = "/{$name}-{FS2_ENV}.cfg.php";
if (file_exists(FS2CONFIG . $file_env)) {
$file = $file_env;
}
}
$config = array();
if (file_exists(FS2CONFIG . "/" . $file)) {
include(FS2CONFIG . "/" . $file);
}
return $this->setConfigByArray($config);
} | php | public function setConfigByFile($name)
{
$file = "/{$name}.cfg.php";
if ('production' !== FS2_ENV) {
$file_env = "/{$name}-{FS2_ENV}.cfg.php";
if (file_exists(FS2CONFIG . $file_env)) {
$file = $file_env;
}
}
$config = array();
if (file_exists(FS2CONFIG . "/" . $file)) {
include(FS2CONFIG . "/" . $file);
}
return $this->setConfigByArray($config);
} | [
"public",
"function",
"setConfigByFile",
"(",
"$",
"name",
")",
"{",
"$",
"file",
"=",
"\"/{$name}.cfg.php\"",
";",
"if",
"(",
"'production'",
"!==",
"FS2_ENV",
")",
"{",
"$",
"file_env",
"=",
"\"/{$name}-{FS2_ENV}.cfg.php\"",
";",
"if",
"(",
"file_exists",
"(",
"FS2CONFIG",
".",
"$",
"file_env",
")",
")",
"{",
"$",
"file",
"=",
"$",
"file_env",
";",
"}",
"}",
"$",
"config",
"=",
"array",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"FS2CONFIG",
".",
"\"/\"",
".",
"$",
"file",
")",
")",
"{",
"include",
"(",
"FS2CONFIG",
".",
"\"/\"",
".",
"$",
"file",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setConfigByArray",
"(",
"$",
"config",
")",
";",
"}"
] | set multiple config entries from a config file
does not change any database data
@param $name
@return ConfigData | [
"set",
"multiple",
"config",
"entries",
"from",
"a",
"config",
"file",
"does",
"not",
"change",
"any",
"database",
"data"
] | a4ea3bea701e2b737c119a5d89b7778e8745658c | https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Config/ConfigData.php#L76-L91 |
3,424 | vutran/wpmvc-core | src/Common/Bootstrap.php | Bootstrap.autoloadPath | public function autoloadPath($path)
{
$files = glob($path);
if ($files && count($files)) {
foreach ($files as $file) {
if (file_exists($file) && is_dir($file)) {
$this->autoloadPath($file . "/*");
}
if (file_exists($file) && is_file($file)) {
require_once($file);
}
}
}
} | php | public function autoloadPath($path)
{
$files = glob($path);
if ($files && count($files)) {
foreach ($files as $file) {
if (file_exists($file) && is_dir($file)) {
$this->autoloadPath($file . "/*");
}
if (file_exists($file) && is_file($file)) {
require_once($file);
}
}
}
} | [
"public",
"function",
"autoloadPath",
"(",
"$",
"path",
")",
"{",
"$",
"files",
"=",
"glob",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"files",
"&&",
"count",
"(",
"$",
"files",
")",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"is_dir",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"autoloadPath",
"(",
"$",
"file",
".",
"\"/*\"",
")",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"require_once",
"(",
"$",
"file",
")",
";",
"}",
"}",
"}",
"}"
] | Autoloads all files in the given path
@access public
@param string $path
@return void | [
"Autoloads",
"all",
"files",
"in",
"the",
"given",
"path"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Common/Bootstrap.php#L82-L95 |
3,425 | vutran/wpmvc-core | src/Common/Bootstrap.php | Bootstrap.createView | public function createView($file = null)
{
$view = new View($this->getTemplatePath() . '/app/views/');
if ($file) {
$view->setFile($file);
}
return $view;
} | php | public function createView($file = null)
{
$view = new View($this->getTemplatePath() . '/app/views/');
if ($file) {
$view->setFile($file);
}
return $view;
} | [
"public",
"function",
"createView",
"(",
"$",
"file",
"=",
"null",
")",
"{",
"$",
"view",
"=",
"new",
"View",
"(",
"$",
"this",
"->",
"getTemplatePath",
"(",
")",
".",
"'/app/views/'",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"$",
"view",
"->",
"setFile",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"view",
";",
"}"
] | Create a new View instance
@access public
@param string $file (default : null)
@return \WPMVC\Models\View | [
"Create",
"a",
"new",
"View",
"instance"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Common/Bootstrap.php#L200-L207 |
3,426 | vutran/wpmvc-core | src/Common/Bootstrap.php | Bootstrap.init | public function init()
{
$coreViewPath = WP::applyFilters('wpmvc_core_views_path', $this->getCorePath() . '/Views/');
$appViewPath = WP::applyFilters('wpmvc_app_views_path', $this->getTemplatePath() . '/app/views/');
// Create a new view and set the default path as the current path
$theHeader = new View($coreViewPath);
$theBody = new View($appViewPath);
$theFooter = new View($coreViewPath);
// Set the header view
$theHeader->setFile(WP::applyFilters('wpmvc_header_file', 'header'));
$theHeader->setVar('app', $this);
// Set the footer view
$theFooter->setFile(WP::applyFilters('wpmvc_footer_file', 'footer'));
$theFooter->setVar('app', $this);
// If the front page is requested
if (WP::isFrontPage() || WP::isHome()) {
$theBody->setFile('home');
$theBody->setVar('app', $this);
} else {
// Retrieve the requested post type
$postType = WP::getQueryVar('post_type');
if (WP::is404()) {
// 404 view
$theBody->setFile('404');
} elseif (WP::isSearch()) {
// Search index
$theBody->setFile('search/index');
} elseif (WP::isTax()) {
// Taxonomy archive
$taxonomy = WP::getQueryVar('taxonomy');
$theBody->setFile(sprintf('taxonomy/%s/index', $taxonomy));
} elseif (WP::isTag()) {
// Tag archive
$theBody->setFile('tag/index');
} elseif (WP::isCategory()) {
// Category archive
$theBody->setFile('category/index');
} elseif (WP::isPage()) {
// Page view
$theBody->setFile(WP::getCurrentPageName());
// If view file doesn't exist, fallback to the page.php view
if (!$theBody->hasFile()) {
$theBody->setFile('page');
}
} elseif (WP::isPostTypeArchive()) {
// Post type archive
$theBody->setFile(sprintf('%s/index', $postType));
} elseif (WP::isSingle()) {
// Retrieve the current requested post type (applies to pages, and post single and archive views)
$postType = WP::getPostType();
// Post permalink
$theBody->setFile(sprintf('%s/single', $postType));
}
}
// Apply the body file filter
$theBody->setFile(WP::applyFilters('wpmvc_body_file', $theBody->getFile()));
echo WP::applyFilters('wpmvc_header_output', $theHeader->output());
echo WP::applyFilters('wpmvc_body_output', $theBody->output());
echo WP::applyFilters('wpmvc_footer_output', $theFooter->output());
} | php | public function init()
{
$coreViewPath = WP::applyFilters('wpmvc_core_views_path', $this->getCorePath() . '/Views/');
$appViewPath = WP::applyFilters('wpmvc_app_views_path', $this->getTemplatePath() . '/app/views/');
// Create a new view and set the default path as the current path
$theHeader = new View($coreViewPath);
$theBody = new View($appViewPath);
$theFooter = new View($coreViewPath);
// Set the header view
$theHeader->setFile(WP::applyFilters('wpmvc_header_file', 'header'));
$theHeader->setVar('app', $this);
// Set the footer view
$theFooter->setFile(WP::applyFilters('wpmvc_footer_file', 'footer'));
$theFooter->setVar('app', $this);
// If the front page is requested
if (WP::isFrontPage() || WP::isHome()) {
$theBody->setFile('home');
$theBody->setVar('app', $this);
} else {
// Retrieve the requested post type
$postType = WP::getQueryVar('post_type');
if (WP::is404()) {
// 404 view
$theBody->setFile('404');
} elseif (WP::isSearch()) {
// Search index
$theBody->setFile('search/index');
} elseif (WP::isTax()) {
// Taxonomy archive
$taxonomy = WP::getQueryVar('taxonomy');
$theBody->setFile(sprintf('taxonomy/%s/index', $taxonomy));
} elseif (WP::isTag()) {
// Tag archive
$theBody->setFile('tag/index');
} elseif (WP::isCategory()) {
// Category archive
$theBody->setFile('category/index');
} elseif (WP::isPage()) {
// Page view
$theBody->setFile(WP::getCurrentPageName());
// If view file doesn't exist, fallback to the page.php view
if (!$theBody->hasFile()) {
$theBody->setFile('page');
}
} elseif (WP::isPostTypeArchive()) {
// Post type archive
$theBody->setFile(sprintf('%s/index', $postType));
} elseif (WP::isSingle()) {
// Retrieve the current requested post type (applies to pages, and post single and archive views)
$postType = WP::getPostType();
// Post permalink
$theBody->setFile(sprintf('%s/single', $postType));
}
}
// Apply the body file filter
$theBody->setFile(WP::applyFilters('wpmvc_body_file', $theBody->getFile()));
echo WP::applyFilters('wpmvc_header_output', $theHeader->output());
echo WP::applyFilters('wpmvc_body_output', $theBody->output());
echo WP::applyFilters('wpmvc_footer_output', $theFooter->output());
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"coreViewPath",
"=",
"WP",
"::",
"applyFilters",
"(",
"'wpmvc_core_views_path'",
",",
"$",
"this",
"->",
"getCorePath",
"(",
")",
".",
"'/Views/'",
")",
";",
"$",
"appViewPath",
"=",
"WP",
"::",
"applyFilters",
"(",
"'wpmvc_app_views_path'",
",",
"$",
"this",
"->",
"getTemplatePath",
"(",
")",
".",
"'/app/views/'",
")",
";",
"// Create a new view and set the default path as the current path",
"$",
"theHeader",
"=",
"new",
"View",
"(",
"$",
"coreViewPath",
")",
";",
"$",
"theBody",
"=",
"new",
"View",
"(",
"$",
"appViewPath",
")",
";",
"$",
"theFooter",
"=",
"new",
"View",
"(",
"$",
"coreViewPath",
")",
";",
"// Set the header view",
"$",
"theHeader",
"->",
"setFile",
"(",
"WP",
"::",
"applyFilters",
"(",
"'wpmvc_header_file'",
",",
"'header'",
")",
")",
";",
"$",
"theHeader",
"->",
"setVar",
"(",
"'app'",
",",
"$",
"this",
")",
";",
"// Set the footer view",
"$",
"theFooter",
"->",
"setFile",
"(",
"WP",
"::",
"applyFilters",
"(",
"'wpmvc_footer_file'",
",",
"'footer'",
")",
")",
";",
"$",
"theFooter",
"->",
"setVar",
"(",
"'app'",
",",
"$",
"this",
")",
";",
"// If the front page is requested",
"if",
"(",
"WP",
"::",
"isFrontPage",
"(",
")",
"||",
"WP",
"::",
"isHome",
"(",
")",
")",
"{",
"$",
"theBody",
"->",
"setFile",
"(",
"'home'",
")",
";",
"$",
"theBody",
"->",
"setVar",
"(",
"'app'",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"// Retrieve the requested post type",
"$",
"postType",
"=",
"WP",
"::",
"getQueryVar",
"(",
"'post_type'",
")",
";",
"if",
"(",
"WP",
"::",
"is404",
"(",
")",
")",
"{",
"// 404 view",
"$",
"theBody",
"->",
"setFile",
"(",
"'404'",
")",
";",
"}",
"elseif",
"(",
"WP",
"::",
"isSearch",
"(",
")",
")",
"{",
"// Search index",
"$",
"theBody",
"->",
"setFile",
"(",
"'search/index'",
")",
";",
"}",
"elseif",
"(",
"WP",
"::",
"isTax",
"(",
")",
")",
"{",
"// Taxonomy archive",
"$",
"taxonomy",
"=",
"WP",
"::",
"getQueryVar",
"(",
"'taxonomy'",
")",
";",
"$",
"theBody",
"->",
"setFile",
"(",
"sprintf",
"(",
"'taxonomy/%s/index'",
",",
"$",
"taxonomy",
")",
")",
";",
"}",
"elseif",
"(",
"WP",
"::",
"isTag",
"(",
")",
")",
"{",
"// Tag archive",
"$",
"theBody",
"->",
"setFile",
"(",
"'tag/index'",
")",
";",
"}",
"elseif",
"(",
"WP",
"::",
"isCategory",
"(",
")",
")",
"{",
"// Category archive",
"$",
"theBody",
"->",
"setFile",
"(",
"'category/index'",
")",
";",
"}",
"elseif",
"(",
"WP",
"::",
"isPage",
"(",
")",
")",
"{",
"// Page view",
"$",
"theBody",
"->",
"setFile",
"(",
"WP",
"::",
"getCurrentPageName",
"(",
")",
")",
";",
"// If view file doesn't exist, fallback to the page.php view",
"if",
"(",
"!",
"$",
"theBody",
"->",
"hasFile",
"(",
")",
")",
"{",
"$",
"theBody",
"->",
"setFile",
"(",
"'page'",
")",
";",
"}",
"}",
"elseif",
"(",
"WP",
"::",
"isPostTypeArchive",
"(",
")",
")",
"{",
"// Post type archive",
"$",
"theBody",
"->",
"setFile",
"(",
"sprintf",
"(",
"'%s/index'",
",",
"$",
"postType",
")",
")",
";",
"}",
"elseif",
"(",
"WP",
"::",
"isSingle",
"(",
")",
")",
"{",
"// Retrieve the current requested post type (applies to pages, and post single and archive views)",
"$",
"postType",
"=",
"WP",
"::",
"getPostType",
"(",
")",
";",
"// Post permalink",
"$",
"theBody",
"->",
"setFile",
"(",
"sprintf",
"(",
"'%s/single'",
",",
"$",
"postType",
")",
")",
";",
"}",
"}",
"// Apply the body file filter",
"$",
"theBody",
"->",
"setFile",
"(",
"WP",
"::",
"applyFilters",
"(",
"'wpmvc_body_file'",
",",
"$",
"theBody",
"->",
"getFile",
"(",
")",
")",
")",
";",
"echo",
"WP",
"::",
"applyFilters",
"(",
"'wpmvc_header_output'",
",",
"$",
"theHeader",
"->",
"output",
"(",
")",
")",
";",
"echo",
"WP",
"::",
"applyFilters",
"(",
"'wpmvc_body_output'",
",",
"$",
"theBody",
"->",
"output",
"(",
")",
")",
";",
"echo",
"WP",
"::",
"applyFilters",
"(",
"'wpmvc_footer_output'",
",",
"$",
"theFooter",
"->",
"output",
"(",
")",
")",
";",
"}"
] | Begin the routing
@access public
@return void | [
"Begin",
"the",
"routing"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Common/Bootstrap.php#L215-L278 |
3,427 | CodeCollab/Theme | src/Theme.php | Theme.setTheme | public function setTheme(string $theme)
{
if (!$this->isPathValid($theme)) {
throw new NotFoundException('The theme cannot be found.');
}
$this->validateTheme($theme);
$themeInfo = $this->getThemeInfo($theme);
if (array_key_exists('parent', $themeInfo)) {
$this->childTheme = $themeInfo;
$this->setTheme($themeInfo['parent']);
} else {
$this->theme = $themeInfo;
}
} | php | public function setTheme(string $theme)
{
if (!$this->isPathValid($theme)) {
throw new NotFoundException('The theme cannot be found.');
}
$this->validateTheme($theme);
$themeInfo = $this->getThemeInfo($theme);
if (array_key_exists('parent', $themeInfo)) {
$this->childTheme = $themeInfo;
$this->setTheme($themeInfo['parent']);
} else {
$this->theme = $themeInfo;
}
} | [
"public",
"function",
"setTheme",
"(",
"string",
"$",
"theme",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPathValid",
"(",
"$",
"theme",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"'The theme cannot be found.'",
")",
";",
"}",
"$",
"this",
"->",
"validateTheme",
"(",
"$",
"theme",
")",
";",
"$",
"themeInfo",
"=",
"$",
"this",
"->",
"getThemeInfo",
"(",
"$",
"theme",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'parent'",
",",
"$",
"themeInfo",
")",
")",
"{",
"$",
"this",
"->",
"childTheme",
"=",
"$",
"themeInfo",
";",
"$",
"this",
"->",
"setTheme",
"(",
"$",
"themeInfo",
"[",
"'parent'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"theme",
"=",
"$",
"themeInfo",
";",
"}",
"}"
] | Sets a theme
@param string $theme The name of the theme to set
@throws \CodeCollab\Theme\NotFoundException When the theme cannot be found
@throws \CodeCollab\Theme\InvalidException When the theme is not valid | [
"Sets",
"a",
"theme"
] | 6e3a3fde06f0ca8e26c947e28010c53f569393d7 | https://github.com/CodeCollab/Theme/blob/6e3a3fde06f0ca8e26c947e28010c53f569393d7/src/Theme.php#L62-L79 |
3,428 | CodeCollab/Theme | src/Theme.php | Theme.isPathValid | private function isPathValid(string $theme): bool
{
if (!is_dir(rtrim($this->themePath, '/') . '/' . $theme)) {
return false;
}
return true;
} | php | private function isPathValid(string $theme): bool
{
if (!is_dir(rtrim($this->themePath, '/') . '/' . $theme)) {
return false;
}
return true;
} | [
"private",
"function",
"isPathValid",
"(",
"string",
"$",
"theme",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"rtrim",
"(",
"$",
"this",
"->",
"themePath",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"theme",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Checks whether the theme directory exists
@param string $theme The name of the theme
@return bool True when the directory of the theme exists | [
"Checks",
"whether",
"the",
"theme",
"directory",
"exists"
] | 6e3a3fde06f0ca8e26c947e28010c53f569393d7 | https://github.com/CodeCollab/Theme/blob/6e3a3fde06f0ca8e26c947e28010c53f569393d7/src/Theme.php#L100-L107 |
3,429 | CodeCollab/Theme | src/Theme.php | Theme.validateTheme | private function validateTheme(string $theme)
{
if (!file_exists($this->themePath . '/' . $theme . '/info.json')) {
throw new InvalidException('The theme (`' . $theme . '`) is missing the configuration file (`info.json`).');
}
try {
$themeInfo = $this->getThemeInfo($theme);
} catch (\Throwable $e) {
throw new InvalidException('The theme\'s (`' . $theme . '`) configuration file (`info.json`) does not contain valid json or could not be read.');
}
foreach (self::CONFIG_REQUIRED_FIELDS as $requiredField) {
if (!array_key_exists($requiredField, $themeInfo)) {
throw new InvalidException('The theme\'s (`' . $theme . '`) configuration file (`info.json`) is missing the required theme ' . $requiredField . ' property.');
}
}
} | php | private function validateTheme(string $theme)
{
if (!file_exists($this->themePath . '/' . $theme . '/info.json')) {
throw new InvalidException('The theme (`' . $theme . '`) is missing the configuration file (`info.json`).');
}
try {
$themeInfo = $this->getThemeInfo($theme);
} catch (\Throwable $e) {
throw new InvalidException('The theme\'s (`' . $theme . '`) configuration file (`info.json`) does not contain valid json or could not be read.');
}
foreach (self::CONFIG_REQUIRED_FIELDS as $requiredField) {
if (!array_key_exists($requiredField, $themeInfo)) {
throw new InvalidException('The theme\'s (`' . $theme . '`) configuration file (`info.json`) is missing the required theme ' . $requiredField . ' property.');
}
}
} | [
"private",
"function",
"validateTheme",
"(",
"string",
"$",
"theme",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"theme",
".",
"'/info.json'",
")",
")",
"{",
"throw",
"new",
"InvalidException",
"(",
"'The theme (`'",
".",
"$",
"theme",
".",
"'`) is missing the configuration file (`info.json`).'",
")",
";",
"}",
"try",
"{",
"$",
"themeInfo",
"=",
"$",
"this",
"->",
"getThemeInfo",
"(",
"$",
"theme",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidException",
"(",
"'The theme\\'s (`'",
".",
"$",
"theme",
".",
"'`) configuration file (`info.json`) does not contain valid json or could not be read.'",
")",
";",
"}",
"foreach",
"(",
"self",
"::",
"CONFIG_REQUIRED_FIELDS",
"as",
"$",
"requiredField",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"requiredField",
",",
"$",
"themeInfo",
")",
")",
"{",
"throw",
"new",
"InvalidException",
"(",
"'The theme\\'s (`'",
".",
"$",
"theme",
".",
"'`) configuration file (`info.json`) is missing the required theme '",
".",
"$",
"requiredField",
".",
"' property.'",
")",
";",
"}",
"}",
"}"
] | Checks whether the layout of the theme directory is valid
@param string $theme The name of the theme
@throws \CodeCollab\Theme\InvalidException When the theme is not valid | [
"Checks",
"whether",
"the",
"layout",
"of",
"the",
"theme",
"directory",
"is",
"valid"
] | 6e3a3fde06f0ca8e26c947e28010c53f569393d7 | https://github.com/CodeCollab/Theme/blob/6e3a3fde06f0ca8e26c947e28010c53f569393d7/src/Theme.php#L116-L133 |
3,430 | CodeCollab/Theme | src/Theme.php | Theme.load | public function load(string $file): string
{
if ($this->childTheme && file_exists($this->themePath . '/' . $this->childTheme['name'] . $file)) {
$this->preventDirectoryTraversal(
$this->themePath . '/' . $this->childTheme['name'],
$this->themePath . '/' . $this->childTheme['name'] . $file
);
return $this->themePath . '/' . $this->childTheme['name'] . $file;
}
if (!file_exists($this->themePath . '/' . $this->theme['name'] . $file)) {
throw new NotFoundException('The template file (`' . $file . '`) could not be found in the theme.');
}
$this->preventDirectoryTraversal(
$this->themePath . '/' . $this->theme['name'],
$this->themePath . '/' . $this->theme['name'] . $file
);
return $this->themePath . '/' . $this->theme['name'] . $file;
} | php | public function load(string $file): string
{
if ($this->childTheme && file_exists($this->themePath . '/' . $this->childTheme['name'] . $file)) {
$this->preventDirectoryTraversal(
$this->themePath . '/' . $this->childTheme['name'],
$this->themePath . '/' . $this->childTheme['name'] . $file
);
return $this->themePath . '/' . $this->childTheme['name'] . $file;
}
if (!file_exists($this->themePath . '/' . $this->theme['name'] . $file)) {
throw new NotFoundException('The template file (`' . $file . '`) could not be found in the theme.');
}
$this->preventDirectoryTraversal(
$this->themePath . '/' . $this->theme['name'],
$this->themePath . '/' . $this->theme['name'] . $file
);
return $this->themePath . '/' . $this->theme['name'] . $file;
} | [
"public",
"function",
"load",
"(",
"string",
"$",
"file",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"childTheme",
"&&",
"file_exists",
"(",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"this",
"->",
"childTheme",
"[",
"'name'",
"]",
".",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"preventDirectoryTraversal",
"(",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"this",
"->",
"childTheme",
"[",
"'name'",
"]",
",",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"this",
"->",
"childTheme",
"[",
"'name'",
"]",
".",
"$",
"file",
")",
";",
"return",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"this",
"->",
"childTheme",
"[",
"'name'",
"]",
".",
"$",
"file",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"this",
"->",
"theme",
"[",
"'name'",
"]",
".",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"'The template file (`'",
".",
"$",
"file",
".",
"'`) could not be found in the theme.'",
")",
";",
"}",
"$",
"this",
"->",
"preventDirectoryTraversal",
"(",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"this",
"->",
"theme",
"[",
"'name'",
"]",
",",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"this",
"->",
"theme",
"[",
"'name'",
"]",
".",
"$",
"file",
")",
";",
"return",
"$",
"this",
"->",
"themePath",
".",
"'/'",
".",
"$",
"this",
"->",
"theme",
"[",
"'name'",
"]",
".",
"$",
"file",
";",
"}"
] | Loads a file from the theme
This method will first try to load the file from the child theme (if available)
@param string $file The file to load (relative to the theme directory)
@return string The filename to load
@throws \CodeCollab\Theme\NotFoundException When the file cannot be found in either the theme or the child theme | [
"Loads",
"a",
"file",
"from",
"the",
"theme"
] | 6e3a3fde06f0ca8e26c947e28010c53f569393d7 | https://github.com/CodeCollab/Theme/blob/6e3a3fde06f0ca8e26c947e28010c53f569393d7/src/Theme.php#L146-L167 |
3,431 | CodeCollab/Theme | src/Theme.php | Theme.preventDirectoryTraversal | private function preventDirectoryTraversal(string $themePath, string $filePath)
{
$themePath = realpath($themePath);
$filePath = realpath($filePath);
if ($filePath === false || strpos($filePath, $themePath) !== 0) {
throw new DirectoryTraversalException('Trying to load a file outside of the theme directory.');
}
} | php | private function preventDirectoryTraversal(string $themePath, string $filePath)
{
$themePath = realpath($themePath);
$filePath = realpath($filePath);
if ($filePath === false || strpos($filePath, $themePath) !== 0) {
throw new DirectoryTraversalException('Trying to load a file outside of the theme directory.');
}
} | [
"private",
"function",
"preventDirectoryTraversal",
"(",
"string",
"$",
"themePath",
",",
"string",
"$",
"filePath",
")",
"{",
"$",
"themePath",
"=",
"realpath",
"(",
"$",
"themePath",
")",
";",
"$",
"filePath",
"=",
"realpath",
"(",
"$",
"filePath",
")",
";",
"if",
"(",
"$",
"filePath",
"===",
"false",
"||",
"strpos",
"(",
"$",
"filePath",
",",
"$",
"themePath",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"DirectoryTraversalException",
"(",
"'Trying to load a file outside of the theme directory.'",
")",
";",
"}",
"}"
] | Validates the file path to prevent directory traversal
@param string $themePath The base path of the theme
@param string $filePath The file path
@throws DirectoryTraversalException | [
"Validates",
"the",
"file",
"path",
"to",
"prevent",
"directory",
"traversal"
] | 6e3a3fde06f0ca8e26c947e28010c53f569393d7 | https://github.com/CodeCollab/Theme/blob/6e3a3fde06f0ca8e26c947e28010c53f569393d7/src/Theme.php#L177-L185 |
3,432 | HustleWorks/chute | src/DTO/TransferObject.php | TransferObject.throwUnlessCorrectSubclass | private function throwUnlessCorrectSubclass($property, $value)
{
$typeUsedToBe = $this->getTypeUsedToBe($property);
if ($typeUsedToBe === "object") {
$classUsedToBe = $this->getClassUsedToBe($property);
if (!is_subclass_of($value, $classUsedToBe)) {
throw new Exception();
}
}
} | php | private function throwUnlessCorrectSubclass($property, $value)
{
$typeUsedToBe = $this->getTypeUsedToBe($property);
if ($typeUsedToBe === "object") {
$classUsedToBe = $this->getClassUsedToBe($property);
if (!is_subclass_of($value, $classUsedToBe)) {
throw new Exception();
}
}
} | [
"private",
"function",
"throwUnlessCorrectSubclass",
"(",
"$",
"property",
",",
"$",
"value",
")",
"{",
"$",
"typeUsedToBe",
"=",
"$",
"this",
"->",
"getTypeUsedToBe",
"(",
"$",
"property",
")",
";",
"if",
"(",
"$",
"typeUsedToBe",
"===",
"\"object\"",
")",
"{",
"$",
"classUsedToBe",
"=",
"$",
"this",
"->",
"getClassUsedToBe",
"(",
"$",
"property",
")",
";",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"value",
",",
"$",
"classUsedToBe",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
")",
";",
"}",
"}",
"}"
] | Throw Unless Correct Subclass
@param $property
@param $value
@throws Exception | [
"Throw",
"Unless",
"Correct",
"Subclass"
] | ede5a83dd74925e734b9b0063502c7e4b9085cb2 | https://github.com/HustleWorks/chute/blob/ede5a83dd74925e734b9b0063502c7e4b9085cb2/src/DTO/TransferObject.php#L117-L128 |
3,433 | HustleWorks/chute | src/DTO/TransferObject.php | TransferObject.throwUnlessCorrectType | private function throwUnlessCorrectType($property, $value)
{
$typeUsedToBe = $this->getTypeUsedToBe($property);
if ($typeUsedToBe !== "null") {
$typeWantsToBe = $this->getTypeWantsToBe($value);
if ($typeUsedToBe !== $typeWantsToBe) {
throw new Exception();
}
}
} | php | private function throwUnlessCorrectType($property, $value)
{
$typeUsedToBe = $this->getTypeUsedToBe($property);
if ($typeUsedToBe !== "null") {
$typeWantsToBe = $this->getTypeWantsToBe($value);
if ($typeUsedToBe !== $typeWantsToBe) {
throw new Exception();
}
}
} | [
"private",
"function",
"throwUnlessCorrectType",
"(",
"$",
"property",
",",
"$",
"value",
")",
"{",
"$",
"typeUsedToBe",
"=",
"$",
"this",
"->",
"getTypeUsedToBe",
"(",
"$",
"property",
")",
";",
"if",
"(",
"$",
"typeUsedToBe",
"!==",
"\"null\"",
")",
"{",
"$",
"typeWantsToBe",
"=",
"$",
"this",
"->",
"getTypeWantsToBe",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"typeUsedToBe",
"!==",
"$",
"typeWantsToBe",
")",
"{",
"throw",
"new",
"Exception",
"(",
")",
";",
"}",
"}",
"}"
] | Throw Unless Correct Type
@param $property
@param $value
@throws Exception | [
"Throw",
"Unless",
"Correct",
"Type"
] | ede5a83dd74925e734b9b0063502c7e4b9085cb2 | https://github.com/HustleWorks/chute/blob/ede5a83dd74925e734b9b0063502c7e4b9085cb2/src/DTO/TransferObject.php#L137-L148 |
3,434 | phramework/database | src/Operations/Create.php | Create.create | public static function create(
$attributes,
$table,
$schema = null,
$return = self::RETURN_ID
) {
if (is_object($attributes)) {
$attributes = (array) $attributes;
}
$driver = Database::getAdapterName();
//prepare query
$query_keys = implode('" , "', array_keys($attributes));
$query_parameter_string = trim(str_repeat('?,', count($attributes)), ',');
$query_values = array_values($attributes);
if ($driver == 'postgresql') {
//Make sure boolean are strings
foreach ($query_values as &$queryValue) {
if (is_bool($queryValue)) {
$queryValue = (
$queryValue
? 'true'
: 'false'
);
}
}
}
$query = 'INSERT INTO ';
if ($schema !== null) {
$query .= sprintf('"%s"."%s"', $schema, $table);
} else {
$query .= sprintf('"%s"', $table);
}
$query .= sprintf(
' ("%s") VALUES (%s)',
$query_keys,
$query_parameter_string
);
if ($return == self::RETURN_ID) {
//Return inserted id
if ($driver == 'postgresql') {
$query .= ' RETURNING id';
$id = Database::executeAndFetch($query, $query_values);
return $id['id'];
}
return Database::executeLastInsertId($query, $query_values);
} elseif ($return == self::RETURN_RECORDS) {
//Return records
if ($driver != 'postgresql') {
throw new ServerExcetion(
'RETURN_RECORDS works only with postgresql adapter'
);
}
$query .= 'RETURNING *';
return Database::executeAndFetch($query, $query_values);
} else {
//Return number of records affected
return Database::execute($query, $query_values);
}
} | php | public static function create(
$attributes,
$table,
$schema = null,
$return = self::RETURN_ID
) {
if (is_object($attributes)) {
$attributes = (array) $attributes;
}
$driver = Database::getAdapterName();
//prepare query
$query_keys = implode('" , "', array_keys($attributes));
$query_parameter_string = trim(str_repeat('?,', count($attributes)), ',');
$query_values = array_values($attributes);
if ($driver == 'postgresql') {
//Make sure boolean are strings
foreach ($query_values as &$queryValue) {
if (is_bool($queryValue)) {
$queryValue = (
$queryValue
? 'true'
: 'false'
);
}
}
}
$query = 'INSERT INTO ';
if ($schema !== null) {
$query .= sprintf('"%s"."%s"', $schema, $table);
} else {
$query .= sprintf('"%s"', $table);
}
$query .= sprintf(
' ("%s") VALUES (%s)',
$query_keys,
$query_parameter_string
);
if ($return == self::RETURN_ID) {
//Return inserted id
if ($driver == 'postgresql') {
$query .= ' RETURNING id';
$id = Database::executeAndFetch($query, $query_values);
return $id['id'];
}
return Database::executeLastInsertId($query, $query_values);
} elseif ($return == self::RETURN_RECORDS) {
//Return records
if ($driver != 'postgresql') {
throw new ServerExcetion(
'RETURN_RECORDS works only with postgresql adapter'
);
}
$query .= 'RETURNING *';
return Database::executeAndFetch($query, $query_values);
} else {
//Return number of records affected
return Database::execute($query, $query_values);
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"attributes",
",",
"$",
"table",
",",
"$",
"schema",
"=",
"null",
",",
"$",
"return",
"=",
"self",
"::",
"RETURN_ID",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"attributes",
")",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"}",
"$",
"driver",
"=",
"Database",
"::",
"getAdapterName",
"(",
")",
";",
"//prepare query",
"$",
"query_keys",
"=",
"implode",
"(",
"'\" , \"'",
",",
"array_keys",
"(",
"$",
"attributes",
")",
")",
";",
"$",
"query_parameter_string",
"=",
"trim",
"(",
"str_repeat",
"(",
"'?,'",
",",
"count",
"(",
"$",
"attributes",
")",
")",
",",
"','",
")",
";",
"$",
"query_values",
"=",
"array_values",
"(",
"$",
"attributes",
")",
";",
"if",
"(",
"$",
"driver",
"==",
"'postgresql'",
")",
"{",
"//Make sure boolean are strings",
"foreach",
"(",
"$",
"query_values",
"as",
"&",
"$",
"queryValue",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"queryValue",
")",
")",
"{",
"$",
"queryValue",
"=",
"(",
"$",
"queryValue",
"?",
"'true'",
":",
"'false'",
")",
";",
"}",
"}",
"}",
"$",
"query",
"=",
"'INSERT INTO '",
";",
"if",
"(",
"$",
"schema",
"!==",
"null",
")",
"{",
"$",
"query",
".=",
"sprintf",
"(",
"'\"%s\".\"%s\"'",
",",
"$",
"schema",
",",
"$",
"table",
")",
";",
"}",
"else",
"{",
"$",
"query",
".=",
"sprintf",
"(",
"'\"%s\"'",
",",
"$",
"table",
")",
";",
"}",
"$",
"query",
".=",
"sprintf",
"(",
"' (\"%s\") VALUES (%s)'",
",",
"$",
"query_keys",
",",
"$",
"query_parameter_string",
")",
";",
"if",
"(",
"$",
"return",
"==",
"self",
"::",
"RETURN_ID",
")",
"{",
"//Return inserted id",
"if",
"(",
"$",
"driver",
"==",
"'postgresql'",
")",
"{",
"$",
"query",
".=",
"' RETURNING id'",
";",
"$",
"id",
"=",
"Database",
"::",
"executeAndFetch",
"(",
"$",
"query",
",",
"$",
"query_values",
")",
";",
"return",
"$",
"id",
"[",
"'id'",
"]",
";",
"}",
"return",
"Database",
"::",
"executeLastInsertId",
"(",
"$",
"query",
",",
"$",
"query_values",
")",
";",
"}",
"elseif",
"(",
"$",
"return",
"==",
"self",
"::",
"RETURN_RECORDS",
")",
"{",
"//Return records",
"if",
"(",
"$",
"driver",
"!=",
"'postgresql'",
")",
"{",
"throw",
"new",
"ServerExcetion",
"(",
"'RETURN_RECORDS works only with postgresql adapter'",
")",
";",
"}",
"$",
"query",
".=",
"'RETURNING *'",
";",
"return",
"Database",
"::",
"executeAndFetch",
"(",
"$",
"query",
",",
"$",
"query_values",
")",
";",
"}",
"else",
"{",
"//Return number of records affected",
"return",
"Database",
"::",
"execute",
"(",
"$",
"query",
",",
"$",
"query_values",
")",
";",
"}",
"}"
] | Create a new record in database
@param array|object $attributes Key-value array or object with records's attributes
@param string $table Table's name
@param string|null $schema *[Optional]* Table's schema, default is null for no schema
@param integer $return Return method type
- if **`RETURN_ID`** will return the id of last inserted record
- if **`RETURN_RECORDS`** will return the inserted record
- if **`RETURN_NUMBER_OF_RECORDS`** will return the number of records affected
@return integer|array
@throws ServerException
@todo Check RETURNING id for another primary key attribute | [
"Create",
"a",
"new",
"record",
"in",
"database"
] | 12726d81917981aa447bb58b76e21762592aab8f | https://github.com/phramework/database/blob/12726d81917981aa447bb58b76e21762592aab8f/src/Operations/Create.php#L48-L116 |
3,435 | lucidphp/resource | src/Loader/ChainedLoader.php | ChainedLoader.resolve | public function resolve($resource)
{
foreach ($this->loaders() as $loader) {
if ($loader->supports($resource)) {
return $loader;
}
}
throw new LoaderException('No matching loader found.');
} | php | public function resolve($resource)
{
foreach ($this->loaders() as $loader) {
if ($loader->supports($resource)) {
return $loader;
}
}
throw new LoaderException('No matching loader found.');
} | [
"public",
"function",
"resolve",
"(",
"$",
"resource",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loaders",
"(",
")",
"as",
"$",
"loader",
")",
"{",
"if",
"(",
"$",
"loader",
"->",
"supports",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"$",
"loader",
";",
"}",
"}",
"throw",
"new",
"LoaderException",
"(",
"'No matching loader found.'",
")",
";",
"}"
] | Resolve a loader.
@param mixed $resource
@return LoaderInterface | [
"Resolve",
"a",
"loader",
"."
] | 49120588d399fbffa5ce4dd471bedb93f5da7780 | https://github.com/lucidphp/resource/blob/49120588d399fbffa5ce4dd471bedb93f5da7780/src/Loader/ChainedLoader.php#L49-L58 |
3,436 | cgTag/php-exceptions | src/ValueException.php | ValueException.describe | public static function describe($value): string
{
if (is_array($value)) {
$value = '<array>';
} elseif (is_object($value) || is_callable($value) || is_iterable($value)) {
$value = sprintf('<%s>', get_class($value));
} else {
$value = (string)$value;
if (strlen($value) > 30) {
$value = substr($value, 0, -3) . '...';
}
$value = sprintf('"%s"', $value);
}
return $value;
} | php | public static function describe($value): string
{
if (is_array($value)) {
$value = '<array>';
} elseif (is_object($value) || is_callable($value) || is_iterable($value)) {
$value = sprintf('<%s>', get_class($value));
} else {
$value = (string)$value;
if (strlen($value) > 30) {
$value = substr($value, 0, -3) . '...';
}
$value = sprintf('"%s"', $value);
}
return $value;
} | [
"public",
"static",
"function",
"describe",
"(",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"'<array>'",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"value",
")",
"||",
"is_callable",
"(",
"$",
"value",
")",
"||",
"is_iterable",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"sprintf",
"(",
"'<%s>'",
",",
"get_class",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
">",
"30",
")",
"{",
"$",
"value",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"-",
"3",
")",
".",
"'...'",
";",
"}",
"$",
"value",
"=",
"sprintf",
"(",
"'\"%s\"'",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Converts any value into a short descriptive label.
@param $value
@return string | [
"Converts",
"any",
"value",
"into",
"a",
"short",
"descriptive",
"label",
"."
] | cc7b232b029e00a1b2d4deb65aa00d88f9bd0e3e | https://github.com/cgTag/php-exceptions/blob/cc7b232b029e00a1b2d4deb65aa00d88f9bd0e3e/src/ValueException.php#L18-L32 |
3,437 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._copy | public function _copy( $srcFilePath, $dstFilePath, $fname = false )
{
if ( $fname )
$fname .= "::_copy($srcFilePath, $dstFilePath)";
else
$fname = "_copy($srcFilePath, $dstFilePath)";
// fetch source file metadata
$metaData = $this->_fetchMetadata( $srcFilePath, $fname );
// if source file does not exist then do nothing.
// @todo Throw an exception here.
// Info: $srcFilePath
if ( !$metaData )
{
return false;
}
return $this->_protect( array( $this, "_copyInner" ), $fname,
$srcFilePath, $dstFilePath, $fname, $metaData );
} | php | public function _copy( $srcFilePath, $dstFilePath, $fname = false )
{
if ( $fname )
$fname .= "::_copy($srcFilePath, $dstFilePath)";
else
$fname = "_copy($srcFilePath, $dstFilePath)";
// fetch source file metadata
$metaData = $this->_fetchMetadata( $srcFilePath, $fname );
// if source file does not exist then do nothing.
// @todo Throw an exception here.
// Info: $srcFilePath
if ( !$metaData )
{
return false;
}
return $this->_protect( array( $this, "_copyInner" ), $fname,
$srcFilePath, $dstFilePath, $fname, $metaData );
} | [
"public",
"function",
"_copy",
"(",
"$",
"srcFilePath",
",",
"$",
"dstFilePath",
",",
"$",
"fname",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"fname",
")",
"$",
"fname",
".=",
"\"::_copy($srcFilePath, $dstFilePath)\"",
";",
"else",
"$",
"fname",
"=",
"\"_copy($srcFilePath, $dstFilePath)\"",
";",
"// fetch source file metadata",
"$",
"metaData",
"=",
"$",
"this",
"->",
"_fetchMetadata",
"(",
"$",
"srcFilePath",
",",
"$",
"fname",
")",
";",
"// if source file does not exist then do nothing.",
"// @todo Throw an exception here.",
"// Info: $srcFilePath",
"if",
"(",
"!",
"$",
"metaData",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"_protect",
"(",
"array",
"(",
"$",
"this",
",",
"\"_copyInner\"",
")",
",",
"$",
"fname",
",",
"$",
"srcFilePath",
",",
"$",
"dstFilePath",
",",
"$",
"fname",
",",
"$",
"metaData",
")",
";",
"}"
] | Creates a copy of a file in DB+DFS
@see eZDFSFileHandler::fileCopy
@see _copyInner
@param string $srcFilePath Source file
@param string $dstFilePath Destination file
@param bool|string $fname Optional caller name for debugging
@return bool | [
"Creates",
"a",
"copy",
"of",
"a",
"file",
"in",
"DB",
"+",
"DFS"
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L171-L189 |
3,438 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._purge | public function _purge( $filePath, $onlyExpired = false, $expiry = false, $fname = false )
{
if ( $fname )
$fname .= "::_purge($filePath)";
else
$fname = "_purge($filePath)";
$sql = "DELETE FROM " . $this->dbTable( $filePath ) . " WHERE name_hash=" . $this->_md5( $filePath );
if ( $expiry !== false )
{
$sql .= " AND mtime<" . (int)$expiry;
}
elseif ( $onlyExpired )
{
$sql .= " AND expired=1";
}
if ( !$stmt = $this->_query( $sql, $fname ) )
{
$this->_fail( "Purging file metadata for $filePath failed" );
}
if ( $stmt->rowCount() == 1 )
{
$this->dfsbackend->delete( $filePath );
}
return true;
} | php | public function _purge( $filePath, $onlyExpired = false, $expiry = false, $fname = false )
{
if ( $fname )
$fname .= "::_purge($filePath)";
else
$fname = "_purge($filePath)";
$sql = "DELETE FROM " . $this->dbTable( $filePath ) . " WHERE name_hash=" . $this->_md5( $filePath );
if ( $expiry !== false )
{
$sql .= " AND mtime<" . (int)$expiry;
}
elseif ( $onlyExpired )
{
$sql .= " AND expired=1";
}
if ( !$stmt = $this->_query( $sql, $fname ) )
{
$this->_fail( "Purging file metadata for $filePath failed" );
}
if ( $stmt->rowCount() == 1 )
{
$this->dfsbackend->delete( $filePath );
}
return true;
} | [
"public",
"function",
"_purge",
"(",
"$",
"filePath",
",",
"$",
"onlyExpired",
"=",
"false",
",",
"$",
"expiry",
"=",
"false",
",",
"$",
"fname",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"fname",
")",
"$",
"fname",
".=",
"\"::_purge($filePath)\"",
";",
"else",
"$",
"fname",
"=",
"\"_purge($filePath)\"",
";",
"$",
"sql",
"=",
"\"DELETE FROM \"",
".",
"$",
"this",
"->",
"dbTable",
"(",
"$",
"filePath",
")",
".",
"\" WHERE name_hash=\"",
".",
"$",
"this",
"->",
"_md5",
"(",
"$",
"filePath",
")",
";",
"if",
"(",
"$",
"expiry",
"!==",
"false",
")",
"{",
"$",
"sql",
".=",
"\" AND mtime<\"",
".",
"(",
"int",
")",
"$",
"expiry",
";",
"}",
"elseif",
"(",
"$",
"onlyExpired",
")",
"{",
"$",
"sql",
".=",
"\" AND expired=1\"",
";",
"}",
"if",
"(",
"!",
"$",
"stmt",
"=",
"$",
"this",
"->",
"_query",
"(",
"$",
"sql",
",",
"$",
"fname",
")",
")",
"{",
"$",
"this",
"->",
"_fail",
"(",
"\"Purging file metadata for $filePath failed\"",
")",
";",
"}",
"if",
"(",
"$",
"stmt",
"->",
"rowCount",
"(",
")",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"dfsbackend",
"->",
"delete",
"(",
"$",
"filePath",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Purges meta-data and file-data for a file entry
Will only expire a single file. Use _purgeByLike to purge multiple files
@see eZDFSFileHandler::purge
@see _purgeByLike
@param string $filePath Path of the file to purge
@param bool $onlyExpired Only purges expired files
@param bool|int $expiry
@param bool|string $fname Optional caller name for debugging
@return bool | [
"Purges",
"meta",
"-",
"data",
"and",
"file",
"-",
"data",
"for",
"a",
"file",
"entry",
"Will",
"only",
"expire",
"a",
"single",
"file",
".",
"Use",
"_purgeByLike",
"to",
"purge",
"multiple",
"files"
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L251-L275 |
3,439 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._purgeByLike | public function _purgeByLike( $like, $onlyExpired = false, $limit = 50, $expiry = false, $fname = false )
{
if ( $fname )
$fname .= "::_purgeByLike($like, $onlyExpired)";
else
$fname = "_purgeByLike($like, $onlyExpired)";
// common query part used for both DELETE and SELECT
$where = " WHERE name LIKE " . $this->_quote( $like );
if ( $expiry !== false )
$where .= " AND mtime < " . (int)$expiry;
elseif ( $onlyExpired )
$where .= " AND expired = 1";
if ( $limit )
$sqlLimit = " LIMIT $limit";
else
$sqlLimit = "";
$this->_begin( $fname );
// select query, in FOR UPDATE mode
$selectSQL = "SELECT name FROM " . $this->dbTable( $like ) .
"{$where} {$sqlLimit} FOR UPDATE";
if ( !$stmt = $this->_query( $selectSQL, $fname ) )
{
$this->_rollback( $fname );
$this->_fail( "Selecting file metadata by like statement $like failed" );
}
$files = array();
// if there are no results, we can just return 0 and stop right here
if ( $stmt->rowCount() == 0 )
{
$this->_rollback( $fname );
return 0;
}
// the candidate for purge are indexed in an array
else
{
while( $row = $stmt->fetch( PDO::FETCH_ASSOC ) )
{
$files[] = $row['name'];
}
}
// delete query
$deleteSQL = "DELETE FROM " . $this->dbTable( $like ) . " WHERE name_hash IN " .
"(SELECT name_hash FROM ". $this->dbTable( $like ) . " $where $sqlLimit)";
if ( !$stmt = $this->_query( $deleteSQL, $fname ) )
{
$this->_rollback( $fname );
$this->_fail( "Purging file metadata by like statement $like failed" );
}
$deletedDBFiles = $stmt->rowCount();
$this->dfsbackend->delete( $files );
$this->_commit( $fname );
return $deletedDBFiles;
} | php | public function _purgeByLike( $like, $onlyExpired = false, $limit = 50, $expiry = false, $fname = false )
{
if ( $fname )
$fname .= "::_purgeByLike($like, $onlyExpired)";
else
$fname = "_purgeByLike($like, $onlyExpired)";
// common query part used for both DELETE and SELECT
$where = " WHERE name LIKE " . $this->_quote( $like );
if ( $expiry !== false )
$where .= " AND mtime < " . (int)$expiry;
elseif ( $onlyExpired )
$where .= " AND expired = 1";
if ( $limit )
$sqlLimit = " LIMIT $limit";
else
$sqlLimit = "";
$this->_begin( $fname );
// select query, in FOR UPDATE mode
$selectSQL = "SELECT name FROM " . $this->dbTable( $like ) .
"{$where} {$sqlLimit} FOR UPDATE";
if ( !$stmt = $this->_query( $selectSQL, $fname ) )
{
$this->_rollback( $fname );
$this->_fail( "Selecting file metadata by like statement $like failed" );
}
$files = array();
// if there are no results, we can just return 0 and stop right here
if ( $stmt->rowCount() == 0 )
{
$this->_rollback( $fname );
return 0;
}
// the candidate for purge are indexed in an array
else
{
while( $row = $stmt->fetch( PDO::FETCH_ASSOC ) )
{
$files[] = $row['name'];
}
}
// delete query
$deleteSQL = "DELETE FROM " . $this->dbTable( $like ) . " WHERE name_hash IN " .
"(SELECT name_hash FROM ". $this->dbTable( $like ) . " $where $sqlLimit)";
if ( !$stmt = $this->_query( $deleteSQL, $fname ) )
{
$this->_rollback( $fname );
$this->_fail( "Purging file metadata by like statement $like failed" );
}
$deletedDBFiles = $stmt->rowCount();
$this->dfsbackend->delete( $files );
$this->_commit( $fname );
return $deletedDBFiles;
} | [
"public",
"function",
"_purgeByLike",
"(",
"$",
"like",
",",
"$",
"onlyExpired",
"=",
"false",
",",
"$",
"limit",
"=",
"50",
",",
"$",
"expiry",
"=",
"false",
",",
"$",
"fname",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"fname",
")",
"$",
"fname",
".=",
"\"::_purgeByLike($like, $onlyExpired)\"",
";",
"else",
"$",
"fname",
"=",
"\"_purgeByLike($like, $onlyExpired)\"",
";",
"// common query part used for both DELETE and SELECT",
"$",
"where",
"=",
"\" WHERE name LIKE \"",
".",
"$",
"this",
"->",
"_quote",
"(",
"$",
"like",
")",
";",
"if",
"(",
"$",
"expiry",
"!==",
"false",
")",
"$",
"where",
".=",
"\" AND mtime < \"",
".",
"(",
"int",
")",
"$",
"expiry",
";",
"elseif",
"(",
"$",
"onlyExpired",
")",
"$",
"where",
".=",
"\" AND expired = 1\"",
";",
"if",
"(",
"$",
"limit",
")",
"$",
"sqlLimit",
"=",
"\" LIMIT $limit\"",
";",
"else",
"$",
"sqlLimit",
"=",
"\"\"",
";",
"$",
"this",
"->",
"_begin",
"(",
"$",
"fname",
")",
";",
"// select query, in FOR UPDATE mode",
"$",
"selectSQL",
"=",
"\"SELECT name FROM \"",
".",
"$",
"this",
"->",
"dbTable",
"(",
"$",
"like",
")",
".",
"\"{$where} {$sqlLimit} FOR UPDATE\"",
";",
"if",
"(",
"!",
"$",
"stmt",
"=",
"$",
"this",
"->",
"_query",
"(",
"$",
"selectSQL",
",",
"$",
"fname",
")",
")",
"{",
"$",
"this",
"->",
"_rollback",
"(",
"$",
"fname",
")",
";",
"$",
"this",
"->",
"_fail",
"(",
"\"Selecting file metadata by like statement $like failed\"",
")",
";",
"}",
"$",
"files",
"=",
"array",
"(",
")",
";",
"// if there are no results, we can just return 0 and stop right here",
"if",
"(",
"$",
"stmt",
"->",
"rowCount",
"(",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"_rollback",
"(",
"$",
"fname",
")",
";",
"return",
"0",
";",
"}",
"// the candidate for purge are indexed in an array",
"else",
"{",
"while",
"(",
"$",
"row",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"$",
"row",
"[",
"'name'",
"]",
";",
"}",
"}",
"// delete query",
"$",
"deleteSQL",
"=",
"\"DELETE FROM \"",
".",
"$",
"this",
"->",
"dbTable",
"(",
"$",
"like",
")",
".",
"\" WHERE name_hash IN \"",
".",
"\"(SELECT name_hash FROM \"",
".",
"$",
"this",
"->",
"dbTable",
"(",
"$",
"like",
")",
".",
"\" $where $sqlLimit)\"",
";",
"if",
"(",
"!",
"$",
"stmt",
"=",
"$",
"this",
"->",
"_query",
"(",
"$",
"deleteSQL",
",",
"$",
"fname",
")",
")",
"{",
"$",
"this",
"->",
"_rollback",
"(",
"$",
"fname",
")",
";",
"$",
"this",
"->",
"_fail",
"(",
"\"Purging file metadata by like statement $like failed\"",
")",
";",
"}",
"$",
"deletedDBFiles",
"=",
"$",
"stmt",
"->",
"rowCount",
"(",
")",
";",
"$",
"this",
"->",
"dfsbackend",
"->",
"delete",
"(",
"$",
"files",
")",
";",
"$",
"this",
"->",
"_commit",
"(",
"$",
"fname",
")",
";",
"return",
"$",
"deletedDBFiles",
";",
"}"
] | Purges meta-data and file-data for files matching a pattern using a SQL
LIKE syntax.
This method should also remove the files from disk
@see eZDFSFileHandler::purge
@see _purge
@param string $like
SQL LIKE string applied to ezdfsfile.name to look for files to
purge
@param bool $onlyExpired
Only purge expired files (ezdfsfile.expired = 1)
@param integer $limit Maximum number of items to purge in one call
@param integer|bool $expiry
Timestamp used to limit deleted files: only files older than this
date will be deleted
@param bool|string $fname Optional caller name for debugging
@return bool|int false if it fails, number of affected rows otherwise | [
"Purges",
"meta",
"-",
"data",
"and",
"file",
"-",
"data",
"for",
"files",
"matching",
"a",
"pattern",
"using",
"a",
"SQL",
"LIKE",
"syntax",
".",
"This",
"method",
"should",
"also",
"remove",
"the",
"files",
"from",
"disk"
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L298-L359 |
3,440 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._delete | public function _delete( $filePath, $insideOfTransaction = false, $fname = false )
{
if ( $fname )
$fname .= "::_delete($filePath)";
else
$fname = "_delete($filePath)";
// @todo Check if this is required: _protect will already take care of
// checking if a transaction is running. But leave it like this
// for now.
if ( $insideOfTransaction )
{
return $this->_deleteInner( $filePath, $fname );
}
else
{
return $this->_protect( array( $this, '_deleteInner' ), $fname,
$filePath, $insideOfTransaction, $fname );
}
} | php | public function _delete( $filePath, $insideOfTransaction = false, $fname = false )
{
if ( $fname )
$fname .= "::_delete($filePath)";
else
$fname = "_delete($filePath)";
// @todo Check if this is required: _protect will already take care of
// checking if a transaction is running. But leave it like this
// for now.
if ( $insideOfTransaction )
{
return $this->_deleteInner( $filePath, $fname );
}
else
{
return $this->_protect( array( $this, '_deleteInner' ), $fname,
$filePath, $insideOfTransaction, $fname );
}
} | [
"public",
"function",
"_delete",
"(",
"$",
"filePath",
",",
"$",
"insideOfTransaction",
"=",
"false",
",",
"$",
"fname",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"fname",
")",
"$",
"fname",
".=",
"\"::_delete($filePath)\"",
";",
"else",
"$",
"fname",
"=",
"\"_delete($filePath)\"",
";",
"// @todo Check if this is required: _protect will already take care of",
"// checking if a transaction is running. But leave it like this",
"// for now.",
"if",
"(",
"$",
"insideOfTransaction",
")",
"{",
"return",
"$",
"this",
"->",
"_deleteInner",
"(",
"$",
"filePath",
",",
"$",
"fname",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_protect",
"(",
"array",
"(",
"$",
"this",
",",
"'_deleteInner'",
")",
",",
"$",
"fname",
",",
"$",
"filePath",
",",
"$",
"insideOfTransaction",
",",
"$",
"fname",
")",
";",
"}",
"}"
] | Deletes a file from DB
The file won't be removed from disk, _purge has to be used for this.
Only single files will be deleted, to delete multiple files,
_deleteByLike has to be used.
@see eZDFSFileHandler::fileDelete
@see eZDFSFileHandler::delete
@see _deleteInner
@see _deleteByLike
@param string $filePath Path of the file to delete
@param bool $insideOfTransaction
Wether or not a transaction is already started
@param bool|string $fname Optional caller name for debugging
@return bool | [
"Deletes",
"a",
"file",
"from",
"DB",
"The",
"file",
"won",
"t",
"be",
"removed",
"from",
"disk",
"_purge",
"has",
"to",
"be",
"used",
"for",
"this",
".",
"Only",
"single",
"files",
"will",
"be",
"deleted",
"to",
"delete",
"multiple",
"files",
"_deleteByLike",
"has",
"to",
"be",
"used",
"."
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L379-L398 |
3,441 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._deleteInner | protected function _deleteInner( $filePath, $fname )
{
if ( !$this->_query( "UPDATE " . $this->dbTable( $filePath ) . " SET mtime=-ABS(mtime), expired=1 WHERE name_hash=" . $this->_md5( $filePath ), $fname ) )
$this->_fail( "Deleting file $filePath failed" );
return true;
} | php | protected function _deleteInner( $filePath, $fname )
{
if ( !$this->_query( "UPDATE " . $this->dbTable( $filePath ) . " SET mtime=-ABS(mtime), expired=1 WHERE name_hash=" . $this->_md5( $filePath ), $fname ) )
$this->_fail( "Deleting file $filePath failed" );
return true;
} | [
"protected",
"function",
"_deleteInner",
"(",
"$",
"filePath",
",",
"$",
"fname",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_query",
"(",
"\"UPDATE \"",
".",
"$",
"this",
"->",
"dbTable",
"(",
"$",
"filePath",
")",
".",
"\" SET mtime=-ABS(mtime), expired=1 WHERE name_hash=\"",
".",
"$",
"this",
"->",
"_md5",
"(",
"$",
"filePath",
")",
",",
"$",
"fname",
")",
")",
"$",
"this",
"->",
"_fail",
"(",
"\"Deleting file $filePath failed\"",
")",
";",
"return",
"true",
";",
"}"
] | Callback method used by by _delete to delete a single file
@param string $filePath Path of the file to delete
@param string $fname Optional caller name for debugging
@return bool | [
"Callback",
"method",
"used",
"by",
"by",
"_delete",
"to",
"delete",
"a",
"single",
"file"
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L407-L412 |
3,442 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._deleteByLike | public function _deleteByLike( $like, $fname = false )
{
if ( $fname )
$fname .= "::_deleteByLike($like)";
else
$fname = "_deleteByLike($like)";
return $this->_protect( array( $this, '_deleteByLikeInner' ), $fname,
$like, $fname );
} | php | public function _deleteByLike( $like, $fname = false )
{
if ( $fname )
$fname .= "::_deleteByLike($like)";
else
$fname = "_deleteByLike($like)";
return $this->_protect( array( $this, '_deleteByLikeInner' ), $fname,
$like, $fname );
} | [
"public",
"function",
"_deleteByLike",
"(",
"$",
"like",
",",
"$",
"fname",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"fname",
")",
"$",
"fname",
".=",
"\"::_deleteByLike($like)\"",
";",
"else",
"$",
"fname",
"=",
"\"_deleteByLike($like)\"",
";",
"return",
"$",
"this",
"->",
"_protect",
"(",
"array",
"(",
"$",
"this",
",",
"'_deleteByLikeInner'",
")",
",",
"$",
"fname",
",",
"$",
"like",
",",
"$",
"fname",
")",
";",
"}"
] | Deletes multiple files using a SQL LIKE statement
Use _delete if you need to delete single files
@see eZDFSFileHandler::fileDelete
@see _deleteByLikeInner
@see _delete
@param string $like
SQL LIKE condition applied to ezdfsfile.name to look for files
to delete. Will use name_trunk if the LIKE string matches a
filetype that supports name_trunk.
@param bool|string $fname Optional caller name for debugging
@return bool | [
"Deletes",
"multiple",
"files",
"using",
"a",
"SQL",
"LIKE",
"statement",
"Use",
"_delete",
"if",
"you",
"need",
"to",
"delete",
"single",
"files"
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L430-L438 |
3,443 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._storeInner | function _storeInner( $filePath, $datatype, $scope, $fname )
{
// Insert file metadata.
clearstatcache();
$fileMTime = filemtime( $filePath );
$contentLength = filesize( $filePath );
$filePathHash = md5( $filePath );
$nameTrunk = self::nameTrunk( $filePath, $scope );
if ( $this->_insertUpdate( $this->dbTable( $filePath ),
array( 'datatype' => $datatype,
'name' => $filePath,
'name_trunk' => $nameTrunk,
'name_hash' => $filePathHash,
'scope' => $scope,
'size' => $contentLength,
'mtime' => $fileMTime,
'expired' => ( $fileMTime < 0 ) ? 1 : 0 ),
array( 'datatype', 'scope', 'size', 'mtime', 'expired' ),
$fname ) === false )
{
$this->_fail( "Failed to insert file metadata while storing. Possible race condition" );
}
// copy given $filePath to DFS
if ( !$this->dfsbackend->copyToDFS( $filePath ) )
{
$this->_fail( "Failed to copy FS://$filePath to DFS://$filePath" );
}
return true;
} | php | function _storeInner( $filePath, $datatype, $scope, $fname )
{
// Insert file metadata.
clearstatcache();
$fileMTime = filemtime( $filePath );
$contentLength = filesize( $filePath );
$filePathHash = md5( $filePath );
$nameTrunk = self::nameTrunk( $filePath, $scope );
if ( $this->_insertUpdate( $this->dbTable( $filePath ),
array( 'datatype' => $datatype,
'name' => $filePath,
'name_trunk' => $nameTrunk,
'name_hash' => $filePathHash,
'scope' => $scope,
'size' => $contentLength,
'mtime' => $fileMTime,
'expired' => ( $fileMTime < 0 ) ? 1 : 0 ),
array( 'datatype', 'scope', 'size', 'mtime', 'expired' ),
$fname ) === false )
{
$this->_fail( "Failed to insert file metadata while storing. Possible race condition" );
}
// copy given $filePath to DFS
if ( !$this->dfsbackend->copyToDFS( $filePath ) )
{
$this->_fail( "Failed to copy FS://$filePath to DFS://$filePath" );
}
return true;
} | [
"function",
"_storeInner",
"(",
"$",
"filePath",
",",
"$",
"datatype",
",",
"$",
"scope",
",",
"$",
"fname",
")",
"{",
"// Insert file metadata.",
"clearstatcache",
"(",
")",
";",
"$",
"fileMTime",
"=",
"filemtime",
"(",
"$",
"filePath",
")",
";",
"$",
"contentLength",
"=",
"filesize",
"(",
"$",
"filePath",
")",
";",
"$",
"filePathHash",
"=",
"md5",
"(",
"$",
"filePath",
")",
";",
"$",
"nameTrunk",
"=",
"self",
"::",
"nameTrunk",
"(",
"$",
"filePath",
",",
"$",
"scope",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_insertUpdate",
"(",
"$",
"this",
"->",
"dbTable",
"(",
"$",
"filePath",
")",
",",
"array",
"(",
"'datatype'",
"=>",
"$",
"datatype",
",",
"'name'",
"=>",
"$",
"filePath",
",",
"'name_trunk'",
"=>",
"$",
"nameTrunk",
",",
"'name_hash'",
"=>",
"$",
"filePathHash",
",",
"'scope'",
"=>",
"$",
"scope",
",",
"'size'",
"=>",
"$",
"contentLength",
",",
"'mtime'",
"=>",
"$",
"fileMTime",
",",
"'expired'",
"=>",
"(",
"$",
"fileMTime",
"<",
"0",
")",
"?",
"1",
":",
"0",
")",
",",
"array",
"(",
"'datatype'",
",",
"'scope'",
",",
"'size'",
",",
"'mtime'",
",",
"'expired'",
")",
",",
"$",
"fname",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"_fail",
"(",
"\"Failed to insert file metadata while storing. Possible race condition\"",
")",
";",
"}",
"// copy given $filePath to DFS",
"if",
"(",
"!",
"$",
"this",
"->",
"dfsbackend",
"->",
"copyToDFS",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"this",
"->",
"_fail",
"(",
"\"Failed to copy FS://$filePath to DFS://$filePath\"",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Callback function used to perform the actual file store operation
@param string $filePath
@param string $datatype
@param string $scope
@param string $fname
@see eZDFSFileHandlerMySQLBackend::_store()
@return bool | [
"Callback",
"function",
"used",
"to",
"perform",
"the",
"actual",
"file",
"store",
"operation"
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L956-L987 |
3,444 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._getFileList | public function _getFileList(
$scopes = false,
$excludeScopes = false,
$limit = false,
$path = false
)
{
$filePathList = array();
$tables = array_unique( array( $this->metaDataTable, $this->metaDataTableCache ) );
foreach ( $tables as $table )
{
$query = 'SELECT name FROM ' . $table;
if ( is_array( $scopes ) && count( $scopes ) > 0 )
{
$query .= ' WHERE scope ';
if ( $excludeScopes )
$query .= 'NOT ';
$query .= "IN ('" . implode( "', '", $scopes ) . "')";
}
$stmt = $this->_query( $query, "_getFileList( array( " . implode( ', ', $scopes ) . " ), $excludeScopes )" );
if ( !$stmt )
{
eZDebug::writeDebug( 'Unable to get file list', __METHOD__ );
// @todo Throw an exception
return false;
}
$filePathList = array();
while ( $row = $stmt->fetch( PDO::FETCH_NUM ) )
$filePathList[] = $row[0];
unset( $stmt );
}
return $filePathList;
} | php | public function _getFileList(
$scopes = false,
$excludeScopes = false,
$limit = false,
$path = false
)
{
$filePathList = array();
$tables = array_unique( array( $this->metaDataTable, $this->metaDataTableCache ) );
foreach ( $tables as $table )
{
$query = 'SELECT name FROM ' . $table;
if ( is_array( $scopes ) && count( $scopes ) > 0 )
{
$query .= ' WHERE scope ';
if ( $excludeScopes )
$query .= 'NOT ';
$query .= "IN ('" . implode( "', '", $scopes ) . "')";
}
$stmt = $this->_query( $query, "_getFileList( array( " . implode( ', ', $scopes ) . " ), $excludeScopes )" );
if ( !$stmt )
{
eZDebug::writeDebug( 'Unable to get file list', __METHOD__ );
// @todo Throw an exception
return false;
}
$filePathList = array();
while ( $row = $stmt->fetch( PDO::FETCH_NUM ) )
$filePathList[] = $row[0];
unset( $stmt );
}
return $filePathList;
} | [
"public",
"function",
"_getFileList",
"(",
"$",
"scopes",
"=",
"false",
",",
"$",
"excludeScopes",
"=",
"false",
",",
"$",
"limit",
"=",
"false",
",",
"$",
"path",
"=",
"false",
")",
"{",
"$",
"filePathList",
"=",
"array",
"(",
")",
";",
"$",
"tables",
"=",
"array_unique",
"(",
"array",
"(",
"$",
"this",
"->",
"metaDataTable",
",",
"$",
"this",
"->",
"metaDataTableCache",
")",
")",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"$",
"query",
"=",
"'SELECT name FROM '",
".",
"$",
"table",
";",
"if",
"(",
"is_array",
"(",
"$",
"scopes",
")",
"&&",
"count",
"(",
"$",
"scopes",
")",
">",
"0",
")",
"{",
"$",
"query",
".=",
"' WHERE scope '",
";",
"if",
"(",
"$",
"excludeScopes",
")",
"$",
"query",
".=",
"'NOT '",
";",
"$",
"query",
".=",
"\"IN ('\"",
".",
"implode",
"(",
"\"', '\"",
",",
"$",
"scopes",
")",
".",
"\"')\"",
";",
"}",
"$",
"stmt",
"=",
"$",
"this",
"->",
"_query",
"(",
"$",
"query",
",",
"\"_getFileList( array( \"",
".",
"implode",
"(",
"', '",
",",
"$",
"scopes",
")",
".",
"\" ), $excludeScopes )\"",
")",
";",
"if",
"(",
"!",
"$",
"stmt",
")",
"{",
"eZDebug",
"::",
"writeDebug",
"(",
"'Unable to get file list'",
",",
"__METHOD__",
")",
";",
"// @todo Throw an exception",
"return",
"false",
";",
"}",
"$",
"filePathList",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_NUM",
")",
")",
"$",
"filePathList",
"[",
"]",
"=",
"$",
"row",
"[",
"0",
"]",
";",
"unset",
"(",
"$",
"stmt",
")",
";",
"}",
"return",
"$",
"filePathList",
";",
"}"
] | Gets the list of cluster files, filtered by the optional params
@see eZDFSFileHandler::getFileList
@param array|bool $scopes filter by array of scopes to include in the list
@param bool $excludeScopes if true, $scopes param acts as an exclude filter
@param array|bool $limit limits the search to offset limit[0], limit limit[1]
@param string|bool $path filter to include entries only including $path
@return array|false the db list of entries of false if none found | [
"Gets",
"the",
"list",
"of",
"cluster",
"files",
"filtered",
"by",
"the",
"optional",
"params"
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L1063-L1100 |
3,445 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._selectOneRow | protected function _selectOneRow( $query, $fname, $error = false, $debug = false )
{
return $this->_selectOne( $query, $fname, $error, $debug, PDO::FETCH_NUM );
} | php | protected function _selectOneRow( $query, $fname, $error = false, $debug = false )
{
return $this->_selectOne( $query, $fname, $error, $debug, PDO::FETCH_NUM );
} | [
"protected",
"function",
"_selectOneRow",
"(",
"$",
"query",
",",
"$",
"fname",
",",
"$",
"error",
"=",
"false",
",",
"$",
"debug",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"_selectOne",
"(",
"$",
"query",
",",
"$",
"fname",
",",
"$",
"error",
",",
"$",
"debug",
",",
"PDO",
"::",
"FETCH_NUM",
")",
";",
"}"
] | Runs a select query and returns one numeric indexed row from the result
If there are more than one row it will fail and exit, if 0 it returns
false.
@param string $query
@param string $fname The function name that started the query, should
contain relevant arguments in the text.
@param bool|string $error Sent to _error() in case of errors
@param bool $debug If true it will display the fetched row in addition
to the SQL.
@return array|false | [
"Runs",
"a",
"select",
"query",
"and",
"returns",
"one",
"numeric",
"indexed",
"row",
"from",
"the",
"result",
"If",
"there",
"are",
"more",
"than",
"one",
"row",
"it",
"will",
"fail",
"and",
"exit",
"if",
"0",
"it",
"returns",
"false",
"."
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L1234-L1237 |
3,446 | informaticatrentina/ezpostgresqlcluster | clustering/dfs/ezpostsgresqlbackend.php | eZDFSFileHandlerPostgresqlBackend._selectOneAssoc | protected function _selectOneAssoc( $query, $fname, $error = false, $debug = false )
{
return $this->_selectOne( $query, $fname, $error, $debug, PDO::FETCH_ASSOC );
} | php | protected function _selectOneAssoc( $query, $fname, $error = false, $debug = false )
{
return $this->_selectOne( $query, $fname, $error, $debug, PDO::FETCH_ASSOC );
} | [
"protected",
"function",
"_selectOneAssoc",
"(",
"$",
"query",
",",
"$",
"fname",
",",
"$",
"error",
"=",
"false",
",",
"$",
"debug",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"_selectOne",
"(",
"$",
"query",
",",
"$",
"fname",
",",
"$",
"error",
",",
"$",
"debug",
",",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"}"
] | Runs a select query and returns one associative row from the result.
If there are more than one row it will fail and exit, if 0 it returns
false.
@param string $query
@param string $fname The function name that started the query, should
contain relevant arguments in the text.
@param bool|string $error Sent to _error() in case of errors
@param bool $debug If true it will display the fetched row in addition
to the SQL.
@return array|false | [
"Runs",
"a",
"select",
"query",
"and",
"returns",
"one",
"associative",
"row",
"from",
"the",
"result",
"."
] | 18da29f32703360b2457abd82e385b47fb140ae9 | https://github.com/informaticatrentina/ezpostgresqlcluster/blob/18da29f32703360b2457abd82e385b47fb140ae9/clustering/dfs/ezpostsgresqlbackend.php#L1253-L1256 |
3,447 | adrianyg7/Acl | src/Console/Commands/RegisterPermissions.php | RegisterPermissions.permissionsToRegister | public function permissionsToRegister()
{
$config = config('acl');
$permissionPlaceholders = array_get($config, 'permission_placeholders');
$additionalPermissions = array_get($config, 'additional');
$permissionsToRegister = [];
$routes = array_filter($this->router->getRoutes()->getRoutes(), function ($route) {
return $route->getName() and ! in_array($route->getName(), AclPolicy::getExcept());
});
foreach ($routes as $route) {
if (array_key_exists($route->getName(), $permissionPlaceholders)) {
$permissionsToRegister[$route->getName()] = $permissionPlaceholders[$route->getName()];
} else {
$permissionsToRegister[$route->getName()] = $route->getName();
}
}
return array_merge($permissionsToRegister, $additionalPermissions);
} | php | public function permissionsToRegister()
{
$config = config('acl');
$permissionPlaceholders = array_get($config, 'permission_placeholders');
$additionalPermissions = array_get($config, 'additional');
$permissionsToRegister = [];
$routes = array_filter($this->router->getRoutes()->getRoutes(), function ($route) {
return $route->getName() and ! in_array($route->getName(), AclPolicy::getExcept());
});
foreach ($routes as $route) {
if (array_key_exists($route->getName(), $permissionPlaceholders)) {
$permissionsToRegister[$route->getName()] = $permissionPlaceholders[$route->getName()];
} else {
$permissionsToRegister[$route->getName()] = $route->getName();
}
}
return array_merge($permissionsToRegister, $additionalPermissions);
} | [
"public",
"function",
"permissionsToRegister",
"(",
")",
"{",
"$",
"config",
"=",
"config",
"(",
"'acl'",
")",
";",
"$",
"permissionPlaceholders",
"=",
"array_get",
"(",
"$",
"config",
",",
"'permission_placeholders'",
")",
";",
"$",
"additionalPermissions",
"=",
"array_get",
"(",
"$",
"config",
",",
"'additional'",
")",
";",
"$",
"permissionsToRegister",
"=",
"[",
"]",
";",
"$",
"routes",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"router",
"->",
"getRoutes",
"(",
")",
"->",
"getRoutes",
"(",
")",
",",
"function",
"(",
"$",
"route",
")",
"{",
"return",
"$",
"route",
"->",
"getName",
"(",
")",
"and",
"!",
"in_array",
"(",
"$",
"route",
"->",
"getName",
"(",
")",
",",
"AclPolicy",
"::",
"getExcept",
"(",
")",
")",
";",
"}",
")",
";",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"route",
"->",
"getName",
"(",
")",
",",
"$",
"permissionPlaceholders",
")",
")",
"{",
"$",
"permissionsToRegister",
"[",
"$",
"route",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"permissionPlaceholders",
"[",
"$",
"route",
"->",
"getName",
"(",
")",
"]",
";",
"}",
"else",
"{",
"$",
"permissionsToRegister",
"[",
"$",
"route",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"route",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"return",
"array_merge",
"(",
"$",
"permissionsToRegister",
",",
"$",
"additionalPermissions",
")",
";",
"}"
] | Retreives the permissions to be registered.
@return array | [
"Retreives",
"the",
"permissions",
"to",
"be",
"registered",
"."
] | b3d69199405ca7406b33991884f6bb2e6f85f4e5 | https://github.com/adrianyg7/Acl/blob/b3d69199405ca7406b33991884f6bb2e6f85f4e5/src/Console/Commands/RegisterPermissions.php#L89-L109 |
3,448 | flavorzyb/wechat | src/XmlParser.php | XmlParser.load | public function load($xmlString)
{
$data = $this->parserXml($xmlString);
if (!isset($data['MsgType'])) {
throw new \RuntimeException("can not found MsgType");
}
// event message
if (WxReceive::MSG_TYPE_EVENT == $data['MsgType']) {
$parser = new Event\Parser();
return $parser->load($data);
}
// other message
$parser = new Message\Parser();
return $parser->load($data);
} | php | public function load($xmlString)
{
$data = $this->parserXml($xmlString);
if (!isset($data['MsgType'])) {
throw new \RuntimeException("can not found MsgType");
}
// event message
if (WxReceive::MSG_TYPE_EVENT == $data['MsgType']) {
$parser = new Event\Parser();
return $parser->load($data);
}
// other message
$parser = new Message\Parser();
return $parser->load($data);
} | [
"public",
"function",
"load",
"(",
"$",
"xmlString",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"parserXml",
"(",
"$",
"xmlString",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'MsgType'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"can not found MsgType\"",
")",
";",
"}",
"// event message",
"if",
"(",
"WxReceive",
"::",
"MSG_TYPE_EVENT",
"==",
"$",
"data",
"[",
"'MsgType'",
"]",
")",
"{",
"$",
"parser",
"=",
"new",
"Event",
"\\",
"Parser",
"(",
")",
";",
"return",
"$",
"parser",
"->",
"load",
"(",
"$",
"data",
")",
";",
"}",
"// other message",
"$",
"parser",
"=",
"new",
"Message",
"\\",
"Parser",
"(",
")",
";",
"return",
"$",
"parser",
"->",
"load",
"(",
"$",
"data",
")",
";",
"}"
] | parse xml string which come from WeChat server
to WxReceiveMsg or WxReceiveEvent
@param $xmlString
@return WxReceive | [
"parse",
"xml",
"string",
"which",
"come",
"from",
"WeChat",
"server",
"to",
"WxReceiveMsg",
"or",
"WxReceiveEvent"
] | e7854a193c4d23cc9b84afa465f4706c09e7e7c5 | https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/XmlParser.php#L12-L29 |
3,449 | flavorzyb/wechat | src/XmlParser.php | XmlParser.parserXml | protected function parserXml($xmlString)
{
libxml_disable_entity_loader(true);
return json_decode(json_encode(simplexml_load_string($xmlString,'SimpleXMLElement', LIBXML_NOCDATA), true), true);
} | php | protected function parserXml($xmlString)
{
libxml_disable_entity_loader(true);
return json_decode(json_encode(simplexml_load_string($xmlString,'SimpleXMLElement', LIBXML_NOCDATA), true), true);
} | [
"protected",
"function",
"parserXml",
"(",
"$",
"xmlString",
")",
"{",
"libxml_disable_entity_loader",
"(",
"true",
")",
";",
"return",
"json_decode",
"(",
"json_encode",
"(",
"simplexml_load_string",
"(",
"$",
"xmlString",
",",
"'SimpleXMLElement'",
",",
"LIBXML_NOCDATA",
")",
",",
"true",
")",
",",
"true",
")",
";",
"}"
] | parse xml to array
@param $xmlString
@return array | [
"parse",
"xml",
"to",
"array"
] | e7854a193c4d23cc9b84afa465f4706c09e7e7c5 | https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/XmlParser.php#L37-L41 |
3,450 | jhorlima/wp-mocabonita | src/view/MbView.php | MbView.getAttribute | public function getAttribute($name = null)
{
return is_null($name) ? $this->attributes : Arr::get($this->attributes, $name);
} | php | public function getAttribute($name = null)
{
return is_null($name) ? $this->attributes : Arr::get($this->attributes, $name);
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"is_null",
"(",
"$",
"name",
")",
"?",
"$",
"this",
"->",
"attributes",
":",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"name",
")",
";",
"}"
] | Get variables for view
@param null $name
@return mixed[] | [
"Get",
"variables",
"for",
"view"
] | a864b40d5452bc9b892f02a6bb28c02639f25fa8 | https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/view/MbView.php#L363-L366 |
3,451 | jhorlima/wp-mocabonita | src/view/MbView.php | MbView.setView | public function setView($templateName, $page, $action, array $attributes = [], $extension = "phtml")
{
$this->setTemplate($templateName);
$this->setPage($page);
$this->setAction($action);
$this->setAttributes($attributes);
$this->setExtension($extension);
return $this;
} | php | public function setView($templateName, $page, $action, array $attributes = [], $extension = "phtml")
{
$this->setTemplate($templateName);
$this->setPage($page);
$this->setAction($action);
$this->setAttributes($attributes);
$this->setExtension($extension);
return $this;
} | [
"public",
"function",
"setView",
"(",
"$",
"templateName",
",",
"$",
"page",
",",
"$",
"action",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"extension",
"=",
"\"phtml\"",
")",
"{",
"$",
"this",
"->",
"setTemplate",
"(",
"$",
"templateName",
")",
";",
"$",
"this",
"->",
"setPage",
"(",
"$",
"page",
")",
";",
"$",
"this",
"->",
"setAction",
"(",
"$",
"action",
")",
";",
"$",
"this",
"->",
"setAttributes",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"setExtension",
"(",
"$",
"extension",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set parameters for view
@param string $templateName
@param string $page
@param string $action
@param array $attributes
@param string $extension
@return MbView | [
"Set",
"parameters",
"for",
"view"
] | a864b40d5452bc9b892f02a6bb28c02639f25fa8 | https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/view/MbView.php#L528-L537 |
3,452 | jhorlima/wp-mocabonita | src/view/MbView.php | MbView.piece | public function piece($filePiece)
{
$filePiece = $this->viewPath . "{$filePiece}.{$this->extension}";
if (file_exists($filePiece)) {
include $filePiece;
} else {
MbException::registerError(new \Exception("The file {$filePiece} not found!"));
}
} | php | public function piece($filePiece)
{
$filePiece = $this->viewPath . "{$filePiece}.{$this->extension}";
if (file_exists($filePiece)) {
include $filePiece;
} else {
MbException::registerError(new \Exception("The file {$filePiece} not found!"));
}
} | [
"public",
"function",
"piece",
"(",
"$",
"filePiece",
")",
"{",
"$",
"filePiece",
"=",
"$",
"this",
"->",
"viewPath",
".",
"\"{$filePiece}.{$this->extension}\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filePiece",
")",
")",
"{",
"include",
"$",
"filePiece",
";",
"}",
"else",
"{",
"MbException",
"::",
"registerError",
"(",
"new",
"\\",
"Exception",
"(",
"\"The file {$filePiece} not found!\"",
")",
")",
";",
"}",
"}"
] | Get a piece to include in the view
@param string $filePiece File part address
@return void | [
"Get",
"a",
"piece",
"to",
"include",
"in",
"the",
"view"
] | a864b40d5452bc9b892f02a6bb28c02639f25fa8 | https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/view/MbView.php#L562-L571 |
3,453 | artkonekt/sylius-sync-bundle | Model/Translation/TranslatableTrait.php | TranslatableTrait.getTranslation | public function getTranslation($lang, $create = false)
{
foreach ($this->translations as $translation) {
if ($lang == $translation->getLang()) {
return $translation;
}
}
if ($create) {
$class = $this->getTranslationClass();
/** @var TranslationInterface $translation */
$translation = new $class();
$translation->setLang($lang);
$this->addTranslation($translation);
return $translation;
}
return null;
} | php | public function getTranslation($lang, $create = false)
{
foreach ($this->translations as $translation) {
if ($lang == $translation->getLang()) {
return $translation;
}
}
if ($create) {
$class = $this->getTranslationClass();
/** @var TranslationInterface $translation */
$translation = new $class();
$translation->setLang($lang);
$this->addTranslation($translation);
return $translation;
}
return null;
} | [
"public",
"function",
"getTranslation",
"(",
"$",
"lang",
",",
"$",
"create",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"translations",
"as",
"$",
"translation",
")",
"{",
"if",
"(",
"$",
"lang",
"==",
"$",
"translation",
"->",
"getLang",
"(",
")",
")",
"{",
"return",
"$",
"translation",
";",
"}",
"}",
"if",
"(",
"$",
"create",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getTranslationClass",
"(",
")",
";",
"/** @var TranslationInterface $translation */",
"$",
"translation",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"translation",
"->",
"setLang",
"(",
"$",
"lang",
")",
";",
"$",
"this",
"->",
"addTranslation",
"(",
"$",
"translation",
")",
";",
"return",
"$",
"translation",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the translation in a given language
@param string $lang The language code (eg. 'en')
@param bool $create Whether or not to create if it doesn't exists
@return TranslationInterface|null | [
"Returns",
"the",
"translation",
"in",
"a",
"given",
"language"
] | fe2864c648971fc058994d8554549061a3a2a0c0 | https://github.com/artkonekt/sylius-sync-bundle/blob/fe2864c648971fc058994d8554549061a3a2a0c0/Model/Translation/TranslatableTrait.php#L47-L67 |
3,454 | colorium/runtime | src/Colorium/Runtime/Resolver.php | Resolver.ofStaticMethod | public static function ofStaticMethod($callable)
{
// parse class::method to [class, method]
if(is_string($callable) and strpos($callable, '::') !== false) {
$callable = explode('::', $callable);
}
// resolve [class, method]
if(is_array($callable) and count($callable) === 2) {
$reflector = new \ReflectionMethod($callable[0], $callable[1]);
if($reflector->isPublic() and $reflector->isStatic()) {
$annotations = array_merge(
Annotation::ofClass($callable[0]),
Annotation::ofMethod($callable[0], $callable[1])
);
return new Invokable($callable, Invokable::STATIC_METHOD, $annotations, $reflector);
}
}
} | php | public static function ofStaticMethod($callable)
{
// parse class::method to [class, method]
if(is_string($callable) and strpos($callable, '::') !== false) {
$callable = explode('::', $callable);
}
// resolve [class, method]
if(is_array($callable) and count($callable) === 2) {
$reflector = new \ReflectionMethod($callable[0], $callable[1]);
if($reflector->isPublic() and $reflector->isStatic()) {
$annotations = array_merge(
Annotation::ofClass($callable[0]),
Annotation::ofMethod($callable[0], $callable[1])
);
return new Invokable($callable, Invokable::STATIC_METHOD, $annotations, $reflector);
}
}
} | [
"public",
"static",
"function",
"ofStaticMethod",
"(",
"$",
"callable",
")",
"{",
"// parse class::method to [class, method]",
"if",
"(",
"is_string",
"(",
"$",
"callable",
")",
"and",
"strpos",
"(",
"$",
"callable",
",",
"'::'",
")",
"!==",
"false",
")",
"{",
"$",
"callable",
"=",
"explode",
"(",
"'::'",
",",
"$",
"callable",
")",
";",
"}",
"// resolve [class, method]",
"if",
"(",
"is_array",
"(",
"$",
"callable",
")",
"and",
"count",
"(",
"$",
"callable",
")",
"===",
"2",
")",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"callable",
"[",
"0",
"]",
",",
"$",
"callable",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"reflector",
"->",
"isPublic",
"(",
")",
"and",
"$",
"reflector",
"->",
"isStatic",
"(",
")",
")",
"{",
"$",
"annotations",
"=",
"array_merge",
"(",
"Annotation",
"::",
"ofClass",
"(",
"$",
"callable",
"[",
"0",
"]",
")",
",",
"Annotation",
"::",
"ofMethod",
"(",
"$",
"callable",
"[",
"0",
"]",
",",
"$",
"callable",
"[",
"1",
"]",
")",
")",
";",
"return",
"new",
"Invokable",
"(",
"$",
"callable",
",",
"Invokable",
"::",
"STATIC_METHOD",
",",
"$",
"annotations",
",",
"$",
"reflector",
")",
";",
"}",
"}",
"}"
] | Resolve if callable is static method
@param $callable
@return Invokable | [
"Resolve",
"if",
"callable",
"is",
"static",
"method"
] | 8905bb7370aa6aa5c89494aa020a2922d8feb32d | https://github.com/colorium/runtime/blob/8905bb7370aa6aa5c89494aa020a2922d8feb32d/src/Colorium/Runtime/Resolver.php#L14-L32 |
3,455 | colorium/runtime | src/Colorium/Runtime/Resolver.php | Resolver.ofClassMethod | public static function ofClassMethod($callable)
{
// parse class::method to [class, method]
if(is_string($callable) and strpos($callable, '::') !== false) {
$callable = explode('::', $callable);
}
// resolve [class, method]
if(is_array($callable) and count($callable) === 2) {
$reflector = new \ReflectionMethod($callable[0], $callable[1]);
if($reflector->isPublic() and !$reflector->isStatic() and !$reflector->isAbstract()) {
$annotations = array_merge(
Annotation::ofClass($callable[0]),
Annotation::ofMethod($callable[0], $callable[1])
);
return new Invokable($callable, Invokable::CLASS_METHOD, $annotations, $reflector);
}
}
} | php | public static function ofClassMethod($callable)
{
// parse class::method to [class, method]
if(is_string($callable) and strpos($callable, '::') !== false) {
$callable = explode('::', $callable);
}
// resolve [class, method]
if(is_array($callable) and count($callable) === 2) {
$reflector = new \ReflectionMethod($callable[0], $callable[1]);
if($reflector->isPublic() and !$reflector->isStatic() and !$reflector->isAbstract()) {
$annotations = array_merge(
Annotation::ofClass($callable[0]),
Annotation::ofMethod($callable[0], $callable[1])
);
return new Invokable($callable, Invokable::CLASS_METHOD, $annotations, $reflector);
}
}
} | [
"public",
"static",
"function",
"ofClassMethod",
"(",
"$",
"callable",
")",
"{",
"// parse class::method to [class, method]",
"if",
"(",
"is_string",
"(",
"$",
"callable",
")",
"and",
"strpos",
"(",
"$",
"callable",
",",
"'::'",
")",
"!==",
"false",
")",
"{",
"$",
"callable",
"=",
"explode",
"(",
"'::'",
",",
"$",
"callable",
")",
";",
"}",
"// resolve [class, method]",
"if",
"(",
"is_array",
"(",
"$",
"callable",
")",
"and",
"count",
"(",
"$",
"callable",
")",
"===",
"2",
")",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"callable",
"[",
"0",
"]",
",",
"$",
"callable",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"reflector",
"->",
"isPublic",
"(",
")",
"and",
"!",
"$",
"reflector",
"->",
"isStatic",
"(",
")",
"and",
"!",
"$",
"reflector",
"->",
"isAbstract",
"(",
")",
")",
"{",
"$",
"annotations",
"=",
"array_merge",
"(",
"Annotation",
"::",
"ofClass",
"(",
"$",
"callable",
"[",
"0",
"]",
")",
",",
"Annotation",
"::",
"ofMethod",
"(",
"$",
"callable",
"[",
"0",
"]",
",",
"$",
"callable",
"[",
"1",
"]",
")",
")",
";",
"return",
"new",
"Invokable",
"(",
"$",
"callable",
",",
"Invokable",
"::",
"CLASS_METHOD",
",",
"$",
"annotations",
",",
"$",
"reflector",
")",
";",
"}",
"}",
"}"
] | Resolve if callable is class method
@param $callable
@return Invokable | [
"Resolve",
"if",
"callable",
"is",
"class",
"method"
] | 8905bb7370aa6aa5c89494aa020a2922d8feb32d | https://github.com/colorium/runtime/blob/8905bb7370aa6aa5c89494aa020a2922d8feb32d/src/Colorium/Runtime/Resolver.php#L41-L59 |
3,456 | colorium/runtime | src/Colorium/Runtime/Resolver.php | Resolver.ofFunction | public static function ofFunction($callable)
{
if($callable instanceof \Closure or (is_string($callable) and function_exists($callable))) {
$annotations = Annotation::ofFunction($callable);
$reflector = new \ReflectionFunction($callable);
return new Invokable($callable, Invokable::CLOSURE, $annotations, $reflector);
}
} | php | public static function ofFunction($callable)
{
if($callable instanceof \Closure or (is_string($callable) and function_exists($callable))) {
$annotations = Annotation::ofFunction($callable);
$reflector = new \ReflectionFunction($callable);
return new Invokable($callable, Invokable::CLOSURE, $annotations, $reflector);
}
} | [
"public",
"static",
"function",
"ofFunction",
"(",
"$",
"callable",
")",
"{",
"if",
"(",
"$",
"callable",
"instanceof",
"\\",
"Closure",
"or",
"(",
"is_string",
"(",
"$",
"callable",
")",
"and",
"function_exists",
"(",
"$",
"callable",
")",
")",
")",
"{",
"$",
"annotations",
"=",
"Annotation",
"::",
"ofFunction",
"(",
"$",
"callable",
")",
";",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"callable",
")",
";",
"return",
"new",
"Invokable",
"(",
"$",
"callable",
",",
"Invokable",
"::",
"CLOSURE",
",",
"$",
"annotations",
",",
"$",
"reflector",
")",
";",
"}",
"}"
] | Resolve if callable is closure or function
@param $callable
@return Invokable | [
"Resolve",
"if",
"callable",
"is",
"closure",
"or",
"function"
] | 8905bb7370aa6aa5c89494aa020a2922d8feb32d | https://github.com/colorium/runtime/blob/8905bb7370aa6aa5c89494aa020a2922d8feb32d/src/Colorium/Runtime/Resolver.php#L82-L89 |
3,457 | Opifer/ContentBundle | Model/Content.php | Content.replaceMissingAttributes | public function replaceMissingAttributes()
{
// collect persisted attributevalues
$persistedAttributes = array();
foreach ($this->getValueSet()->getValues() as $value) {
$persistedAttributes[] = $value->getAttribute();
}
$newValues = array();
// Create empty entities for missing attributes
$missingAttributes = array_diff($this->getValueSet()->getAttributes()->toArray(), $persistedAttributes);
foreach ($missingAttributes as $attribute) {
$valueClass = $attribute->getValueType();
$value = new $valueClass();
$this->getValueSet()->addValue($value);
$value->setValueSet($this->getValueSet());
$value->setAttribute($attribute);
$newValues[] = $value;
}
return $newValues;
} | php | public function replaceMissingAttributes()
{
// collect persisted attributevalues
$persistedAttributes = array();
foreach ($this->getValueSet()->getValues() as $value) {
$persistedAttributes[] = $value->getAttribute();
}
$newValues = array();
// Create empty entities for missing attributes
$missingAttributes = array_diff($this->getValueSet()->getAttributes()->toArray(), $persistedAttributes);
foreach ($missingAttributes as $attribute) {
$valueClass = $attribute->getValueType();
$value = new $valueClass();
$this->getValueSet()->addValue($value);
$value->setValueSet($this->getValueSet());
$value->setAttribute($attribute);
$newValues[] = $value;
}
return $newValues;
} | [
"public",
"function",
"replaceMissingAttributes",
"(",
")",
"{",
"// collect persisted attributevalues",
"$",
"persistedAttributes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getValueSet",
"(",
")",
"->",
"getValues",
"(",
")",
"as",
"$",
"value",
")",
"{",
"$",
"persistedAttributes",
"[",
"]",
"=",
"$",
"value",
"->",
"getAttribute",
"(",
")",
";",
"}",
"$",
"newValues",
"=",
"array",
"(",
")",
";",
"// Create empty entities for missing attributes",
"$",
"missingAttributes",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"getValueSet",
"(",
")",
"->",
"getAttributes",
"(",
")",
"->",
"toArray",
"(",
")",
",",
"$",
"persistedAttributes",
")",
";",
"foreach",
"(",
"$",
"missingAttributes",
"as",
"$",
"attribute",
")",
"{",
"$",
"valueClass",
"=",
"$",
"attribute",
"->",
"getValueType",
"(",
")",
";",
"$",
"value",
"=",
"new",
"$",
"valueClass",
"(",
")",
";",
"$",
"this",
"->",
"getValueSet",
"(",
")",
"->",
"addValue",
"(",
"$",
"value",
")",
";",
"$",
"value",
"->",
"setValueSet",
"(",
"$",
"this",
"->",
"getValueSet",
"(",
")",
")",
";",
"$",
"value",
"->",
"setAttribute",
"(",
"$",
"attribute",
")",
";",
"$",
"newValues",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"newValues",
";",
"}"
] | Creates fake values for non-persisted attributes
@return array new Values which can be persisted through an EntityManager | [
"Creates",
"fake",
"values",
"for",
"non",
"-",
"persisted",
"attributes"
] | df44ef36b81a839ce87ea9a92f7728618111541f | https://github.com/Opifer/ContentBundle/blob/df44ef36b81a839ce87ea9a92f7728618111541f/Model/Content.php#L709-L732 |
3,458 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.getDirectoryParts | public function getDirectoryParts(): array
{
return $this->myAboveBaseLevel === 0 ? $this->myDirectoryParts : array_merge(array_fill(0, $this->myAboveBaseLevel, '..'), $this->myDirectoryParts);
} | php | public function getDirectoryParts(): array
{
return $this->myAboveBaseLevel === 0 ? $this->myDirectoryParts : array_merge(array_fill(0, $this->myAboveBaseLevel, '..'), $this->myDirectoryParts);
} | [
"public",
"function",
"getDirectoryParts",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"myAboveBaseLevel",
"===",
"0",
"?",
"$",
"this",
"->",
"myDirectoryParts",
":",
"array_merge",
"(",
"array_fill",
"(",
"0",
",",
"$",
"this",
"->",
"myAboveBaseLevel",
",",
"'..'",
")",
",",
"$",
"this",
"->",
"myDirectoryParts",
")",
";",
"}"
] | Returns the directory parts.
@since 1.0.0
@return string[] The directory parts. | [
"Returns",
"the",
"directory",
"parts",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L39-L42 |
3,459 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myToString | private function myToString(string $directorySeparator, ?callable $stringEncoder = null): string
{
return $this->myDirectoryToString($directorySeparator, $stringEncoder) . $this->myFilenameToString($stringEncoder);
} | php | private function myToString(string $directorySeparator, ?callable $stringEncoder = null): string
{
return $this->myDirectoryToString($directorySeparator, $stringEncoder) . $this->myFilenameToString($stringEncoder);
} | [
"private",
"function",
"myToString",
"(",
"string",
"$",
"directorySeparator",
",",
"?",
"callable",
"$",
"stringEncoder",
"=",
"null",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"myDirectoryToString",
"(",
"$",
"directorySeparator",
",",
"$",
"stringEncoder",
")",
".",
"$",
"this",
"->",
"myFilenameToString",
"(",
"$",
"stringEncoder",
")",
";",
"}"
] | Returns the path as a string.
@param string $directorySeparator The directory separator.
@param callable|null $stringEncoder The string encoding function or null if parts should not be encoded.
@return string The path as a string. | [
"Returns",
"the",
"path",
"as",
"a",
"string",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L124-L127 |
3,460 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myDirectoryToString | private function myDirectoryToString(string $directorySeparator, ?callable $stringEncoder = null): string
{
$result = '';
if ($this->myAboveBaseLevel > 0) {
$result .= str_repeat('..' . $directorySeparator, $this->myAboveBaseLevel);
}
if ($this->myIsAbsolute) {
$result .= $directorySeparator;
}
$result .= implode($directorySeparator, $stringEncoder !== null ?
array_map($stringEncoder, $this->myDirectoryParts) :
$this->myDirectoryParts);
if (count($this->myDirectoryParts) > 0) {
$result .= $directorySeparator;
}
return $result;
} | php | private function myDirectoryToString(string $directorySeparator, ?callable $stringEncoder = null): string
{
$result = '';
if ($this->myAboveBaseLevel > 0) {
$result .= str_repeat('..' . $directorySeparator, $this->myAboveBaseLevel);
}
if ($this->myIsAbsolute) {
$result .= $directorySeparator;
}
$result .= implode($directorySeparator, $stringEncoder !== null ?
array_map($stringEncoder, $this->myDirectoryParts) :
$this->myDirectoryParts);
if (count($this->myDirectoryParts) > 0) {
$result .= $directorySeparator;
}
return $result;
} | [
"private",
"function",
"myDirectoryToString",
"(",
"string",
"$",
"directorySeparator",
",",
"?",
"callable",
"$",
"stringEncoder",
"=",
"null",
")",
":",
"string",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"myAboveBaseLevel",
">",
"0",
")",
"{",
"$",
"result",
".=",
"str_repeat",
"(",
"'..'",
".",
"$",
"directorySeparator",
",",
"$",
"this",
"->",
"myAboveBaseLevel",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"myIsAbsolute",
")",
"{",
"$",
"result",
".=",
"$",
"directorySeparator",
";",
"}",
"$",
"result",
".=",
"implode",
"(",
"$",
"directorySeparator",
",",
"$",
"stringEncoder",
"!==",
"null",
"?",
"array_map",
"(",
"$",
"stringEncoder",
",",
"$",
"this",
"->",
"myDirectoryParts",
")",
":",
"$",
"this",
"->",
"myDirectoryParts",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"myDirectoryParts",
")",
">",
"0",
")",
"{",
"$",
"result",
".=",
"$",
"directorySeparator",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the directory as a string.
@param string $directorySeparator The directory separator.
@param callable|null $stringEncoder The string encoding function or null if parts should not be encoded.
@return string The directory as a string. | [
"Returns",
"the",
"directory",
"as",
"a",
"string",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L137-L158 |
3,461 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myFilenameToString | private function myFilenameToString(?callable $stringEncoder = null): string
{
if ($this->myFilename === null) {
return '';
}
if ($stringEncoder !== null) {
return $stringEncoder($this->myFilename);
}
return $this->myFilename;
} | php | private function myFilenameToString(?callable $stringEncoder = null): string
{
if ($this->myFilename === null) {
return '';
}
if ($stringEncoder !== null) {
return $stringEncoder($this->myFilename);
}
return $this->myFilename;
} | [
"private",
"function",
"myFilenameToString",
"(",
"?",
"callable",
"$",
"stringEncoder",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"myFilename",
"===",
"null",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"stringEncoder",
"!==",
"null",
")",
"{",
"return",
"$",
"stringEncoder",
"(",
"$",
"this",
"->",
"myFilename",
")",
";",
"}",
"return",
"$",
"this",
"->",
"myFilename",
";",
"}"
] | Returns the filename as a string.
@param callable|null $stringEncoder The string encoding function or null if parts should not be encoded.
@return string The filename as a string. | [
"Returns",
"the",
"filename",
"as",
"a",
"string",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L167-L178 |
3,462 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myCombine | private function myCombine(PathTraitInterface $other, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
{
// If other path is absolute, current path is overridden.
if ($other->isAbsolute()) {
$isAbsolute = $other->isAbsolute();
$aboveBaseLevel = 0;
$directoryParts = $other->getDirectoryParts();
$filename = $other->getFilename();
return true;
}
$isAbsolute = $this->myIsAbsolute;
$aboveBaseLevel = $this->myAboveBaseLevel;
$directoryParts = $this->myDirectoryParts;
$filename = $other->getFilename();
foreach ($other->getDirectoryParts() as $otherDirectoryPart) {
if (!$this->myCombineDirectoryPart($otherDirectoryPart, $aboveBaseLevel, $directoryParts, $error)) {
return false;
}
}
return true;
} | php | private function myCombine(PathTraitInterface $other, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
{
// If other path is absolute, current path is overridden.
if ($other->isAbsolute()) {
$isAbsolute = $other->isAbsolute();
$aboveBaseLevel = 0;
$directoryParts = $other->getDirectoryParts();
$filename = $other->getFilename();
return true;
}
$isAbsolute = $this->myIsAbsolute;
$aboveBaseLevel = $this->myAboveBaseLevel;
$directoryParts = $this->myDirectoryParts;
$filename = $other->getFilename();
foreach ($other->getDirectoryParts() as $otherDirectoryPart) {
if (!$this->myCombineDirectoryPart($otherDirectoryPart, $aboveBaseLevel, $directoryParts, $error)) {
return false;
}
}
return true;
} | [
"private",
"function",
"myCombine",
"(",
"PathTraitInterface",
"$",
"other",
",",
"?",
"bool",
"&",
"$",
"isAbsolute",
"=",
"null",
",",
"?",
"int",
"&",
"$",
"aboveBaseLevel",
"=",
"null",
",",
"?",
"array",
"&",
"$",
"directoryParts",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"filename",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"// If other path is absolute, current path is overridden.",
"if",
"(",
"$",
"other",
"->",
"isAbsolute",
"(",
")",
")",
"{",
"$",
"isAbsolute",
"=",
"$",
"other",
"->",
"isAbsolute",
"(",
")",
";",
"$",
"aboveBaseLevel",
"=",
"0",
";",
"$",
"directoryParts",
"=",
"$",
"other",
"->",
"getDirectoryParts",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"other",
"->",
"getFilename",
"(",
")",
";",
"return",
"true",
";",
"}",
"$",
"isAbsolute",
"=",
"$",
"this",
"->",
"myIsAbsolute",
";",
"$",
"aboveBaseLevel",
"=",
"$",
"this",
"->",
"myAboveBaseLevel",
";",
"$",
"directoryParts",
"=",
"$",
"this",
"->",
"myDirectoryParts",
";",
"$",
"filename",
"=",
"$",
"other",
"->",
"getFilename",
"(",
")",
";",
"foreach",
"(",
"$",
"other",
"->",
"getDirectoryParts",
"(",
")",
"as",
"$",
"otherDirectoryPart",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"myCombineDirectoryPart",
"(",
"$",
"otherDirectoryPart",
",",
"$",
"aboveBaseLevel",
",",
"$",
"directoryParts",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Tries to combine this path with another path.
@param PathTraitInterface $other The other path.
@param bool|null $isAbsolute Whether the path is absolute or relative is combining was successful, undefined otherwise.
@param int|null $aboveBaseLevel The number of directory parts above base level if combining was successful, undefined otherwise.
@param string[]|null $directoryParts The directory parts if combining was successful, undefined otherwise.
@param string|null $filename The file if combining was not successful, undefined otherwise.
@param string|null $error The error text if combining was not successful, undefined otherwise.
@return bool True if combining was successful, false otherwise. | [
"Tries",
"to",
"combine",
"this",
"path",
"with",
"another",
"path",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L192-L216 |
3,463 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myCombineDirectoryPart | private function myCombineDirectoryPart(string $part, ?int &$aboveBaseLevel = null, ?array &$directoryParts = null, ?string &$error = null): bool
{
if ($part === '..') {
if (count($directoryParts) === 0) {
if ($this->myIsAbsolute) {
$error = 'Absolute path is above root level.';
return false;
}
$aboveBaseLevel++;
return true;
}
array_pop($directoryParts);
return true;
}
$directoryParts[] = $part;
return true;
} | php | private function myCombineDirectoryPart(string $part, ?int &$aboveBaseLevel = null, ?array &$directoryParts = null, ?string &$error = null): bool
{
if ($part === '..') {
if (count($directoryParts) === 0) {
if ($this->myIsAbsolute) {
$error = 'Absolute path is above root level.';
return false;
}
$aboveBaseLevel++;
return true;
}
array_pop($directoryParts);
return true;
}
$directoryParts[] = $part;
return true;
} | [
"private",
"function",
"myCombineDirectoryPart",
"(",
"string",
"$",
"part",
",",
"?",
"int",
"&",
"$",
"aboveBaseLevel",
"=",
"null",
",",
"?",
"array",
"&",
"$",
"directoryParts",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"part",
"===",
"'..'",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"directoryParts",
")",
"===",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"myIsAbsolute",
")",
"{",
"$",
"error",
"=",
"'Absolute path is above root level.'",
";",
"return",
"false",
";",
"}",
"$",
"aboveBaseLevel",
"++",
";",
"return",
"true",
";",
"}",
"array_pop",
"(",
"$",
"directoryParts",
")",
";",
"return",
"true",
";",
"}",
"$",
"directoryParts",
"[",
"]",
"=",
"$",
"part",
";",
"return",
"true",
";",
"}"
] | Tries to combine a directory part with another path.
@param string $part The part.
@param int|null $aboveBaseLevel The number of directory parts above base level if combining was successful, undefined otherwise.
@param string[]|null $directoryParts The directory parts if combining was successful, undefined otherwise.
@param string|null $error The error text if combining was not successful, undefined otherwise.
@return bool True if combining was successful, false otherwise. | [
"Tries",
"to",
"combine",
"a",
"directory",
"part",
"with",
"another",
"path",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L228-L251 |
3,464 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myParentDirectory | private function myParentDirectory(?int &$aboveBaseLevel = null, ?array &$directoryParts = null): bool
{
if (count($this->myDirectoryParts) > 0) {
$aboveBaseLevel = $this->myAboveBaseLevel;
$directoryParts = array_slice($this->myDirectoryParts, 0, -1);
return true;
}
if ($this->myIsAbsolute) {
return false;
}
$aboveBaseLevel = $this->myAboveBaseLevel + 1;
$directoryParts = $this->myDirectoryParts;
return true;
} | php | private function myParentDirectory(?int &$aboveBaseLevel = null, ?array &$directoryParts = null): bool
{
if (count($this->myDirectoryParts) > 0) {
$aboveBaseLevel = $this->myAboveBaseLevel;
$directoryParts = array_slice($this->myDirectoryParts, 0, -1);
return true;
}
if ($this->myIsAbsolute) {
return false;
}
$aboveBaseLevel = $this->myAboveBaseLevel + 1;
$directoryParts = $this->myDirectoryParts;
return true;
} | [
"private",
"function",
"myParentDirectory",
"(",
"?",
"int",
"&",
"$",
"aboveBaseLevel",
"=",
"null",
",",
"?",
"array",
"&",
"$",
"directoryParts",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"myDirectoryParts",
")",
">",
"0",
")",
"{",
"$",
"aboveBaseLevel",
"=",
"$",
"this",
"->",
"myAboveBaseLevel",
";",
"$",
"directoryParts",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"myDirectoryParts",
",",
"0",
",",
"-",
"1",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"myIsAbsolute",
")",
"{",
"return",
"false",
";",
"}",
"$",
"aboveBaseLevel",
"=",
"$",
"this",
"->",
"myAboveBaseLevel",
"+",
"1",
";",
"$",
"directoryParts",
"=",
"$",
"this",
"->",
"myDirectoryParts",
";",
"return",
"true",
";",
"}"
] | Tries to calculate the parent directory for this path and return the result.
@param int|null $aboveBaseLevel The number of directory parts above base level if parsing was successful, undefined otherwise.
@param string[]|null $directoryParts The directory parts if parsing was successful, undefined otherwise.
@return bool True if this path has a parent directory, false otherwise. | [
"Tries",
"to",
"calculate",
"the",
"parent",
"directory",
"for",
"this",
"path",
"and",
"return",
"the",
"result",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L261-L278 |
3,465 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myParse | private static function myParse(string $directorySeparator, string $path, callable $partValidator, ?callable $stringDecoder = null, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
{
$parts = explode($directorySeparator, $path);
$partsCount = count($parts);
$directoryParts = [];
$filename = null;
$isAbsolute = false;
$aboveBaseLevel = 0;
$index = 0;
// If the first part is empty and other parts follow, the path begins with directory separator and is therefore absolute.
if ($partsCount > 1 && $parts[0] === '') {
$isAbsolute = true;
$index++;
}
// Go through all parts.
for (; $index < $partsCount; $index++) {
if (!self::myParsePart($parts[$index], $index === $partsCount - 1, $partValidator, $stringDecoder, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) {
return false;
}
}
return true;
} | php | private static function myParse(string $directorySeparator, string $path, callable $partValidator, ?callable $stringDecoder = null, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
{
$parts = explode($directorySeparator, $path);
$partsCount = count($parts);
$directoryParts = [];
$filename = null;
$isAbsolute = false;
$aboveBaseLevel = 0;
$index = 0;
// If the first part is empty and other parts follow, the path begins with directory separator and is therefore absolute.
if ($partsCount > 1 && $parts[0] === '') {
$isAbsolute = true;
$index++;
}
// Go through all parts.
for (; $index < $partsCount; $index++) {
if (!self::myParsePart($parts[$index], $index === $partsCount - 1, $partValidator, $stringDecoder, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) {
return false;
}
}
return true;
} | [
"private",
"static",
"function",
"myParse",
"(",
"string",
"$",
"directorySeparator",
",",
"string",
"$",
"path",
",",
"callable",
"$",
"partValidator",
",",
"?",
"callable",
"$",
"stringDecoder",
"=",
"null",
",",
"?",
"bool",
"&",
"$",
"isAbsolute",
"=",
"null",
",",
"?",
"int",
"&",
"$",
"aboveBaseLevel",
"=",
"null",
",",
"?",
"array",
"&",
"$",
"directoryParts",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"filename",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"parts",
"=",
"explode",
"(",
"$",
"directorySeparator",
",",
"$",
"path",
")",
";",
"$",
"partsCount",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"$",
"directoryParts",
"=",
"[",
"]",
";",
"$",
"filename",
"=",
"null",
";",
"$",
"isAbsolute",
"=",
"false",
";",
"$",
"aboveBaseLevel",
"=",
"0",
";",
"$",
"index",
"=",
"0",
";",
"// If the first part is empty and other parts follow, the path begins with directory separator and is therefore absolute.",
"if",
"(",
"$",
"partsCount",
">",
"1",
"&&",
"$",
"parts",
"[",
"0",
"]",
"===",
"''",
")",
"{",
"$",
"isAbsolute",
"=",
"true",
";",
"$",
"index",
"++",
";",
"}",
"// Go through all parts.",
"for",
"(",
";",
"$",
"index",
"<",
"$",
"partsCount",
";",
"$",
"index",
"++",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"myParsePart",
"(",
"$",
"parts",
"[",
"$",
"index",
"]",
",",
"$",
"index",
"===",
"$",
"partsCount",
"-",
"1",
",",
"$",
"partValidator",
",",
"$",
"stringDecoder",
",",
"$",
"isAbsolute",
",",
"$",
"aboveBaseLevel",
",",
"$",
"directoryParts",
",",
"$",
"filename",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Tries to parse a path and returns the result or error text.
@param string $directorySeparator The directory separator.
@param string $path The path.
@param callable $partValidator The part validator.
@param callable|null $stringDecoder The string decoding function or null if parts should not be decoded.
@param bool|null $isAbsolute Whether the path is absolute or relative if parsing was successful, undefined otherwise.
@param int|null $aboveBaseLevel The number of directory parts above base level if parsing was successful, undefined otherwise.
@param string[]|null $directoryParts The directory parts if parsing was successful, undefined otherwise.
@param string|null $filename The file if parsing was not successful, undefined otherwise.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Tries",
"to",
"parse",
"a",
"path",
"and",
"returns",
"the",
"result",
"or",
"error",
"text",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L295-L320 |
3,466 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myParsePart | private static function myParsePart(string $part, bool $isLastPart, callable $partValidator, ?callable $stringDecoder, ?bool $isAbsolute, ?int &$aboveBaseLevel, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
{
// Skip empty and current directory parts.
if ($part === '' || $part === '.') {
return true;
}
// Handle parent directory-part.
if ($part === '..') {
return self::myHandleParentDirectoryPart($isAbsolute, $aboveBaseLevel, $directoryParts, $error);
}
// Handle directory part.
if (!$isLastPart) {
return self::myHandleDirectoryPart($part, $partValidator, $stringDecoder, $directoryParts, $error);
}
// Handle last (i.e. filename) part.
return self::myHandleFilenamePart($part, $partValidator, $stringDecoder, $filename, $error);
} | php | private static function myParsePart(string $part, bool $isLastPart, callable $partValidator, ?callable $stringDecoder, ?bool $isAbsolute, ?int &$aboveBaseLevel, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
{
// Skip empty and current directory parts.
if ($part === '' || $part === '.') {
return true;
}
// Handle parent directory-part.
if ($part === '..') {
return self::myHandleParentDirectoryPart($isAbsolute, $aboveBaseLevel, $directoryParts, $error);
}
// Handle directory part.
if (!$isLastPart) {
return self::myHandleDirectoryPart($part, $partValidator, $stringDecoder, $directoryParts, $error);
}
// Handle last (i.e. filename) part.
return self::myHandleFilenamePart($part, $partValidator, $stringDecoder, $filename, $error);
} | [
"private",
"static",
"function",
"myParsePart",
"(",
"string",
"$",
"part",
",",
"bool",
"$",
"isLastPart",
",",
"callable",
"$",
"partValidator",
",",
"?",
"callable",
"$",
"stringDecoder",
",",
"?",
"bool",
"$",
"isAbsolute",
",",
"?",
"int",
"&",
"$",
"aboveBaseLevel",
",",
"?",
"array",
"&",
"$",
"directoryParts",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"filename",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"// Skip empty and current directory parts.",
"if",
"(",
"$",
"part",
"===",
"''",
"||",
"$",
"part",
"===",
"'.'",
")",
"{",
"return",
"true",
";",
"}",
"// Handle parent directory-part.",
"if",
"(",
"$",
"part",
"===",
"'..'",
")",
"{",
"return",
"self",
"::",
"myHandleParentDirectoryPart",
"(",
"$",
"isAbsolute",
",",
"$",
"aboveBaseLevel",
",",
"$",
"directoryParts",
",",
"$",
"error",
")",
";",
"}",
"// Handle directory part.",
"if",
"(",
"!",
"$",
"isLastPart",
")",
"{",
"return",
"self",
"::",
"myHandleDirectoryPart",
"(",
"$",
"part",
",",
"$",
"partValidator",
",",
"$",
"stringDecoder",
",",
"$",
"directoryParts",
",",
"$",
"error",
")",
";",
"}",
"// Handle last (i.e. filename) part.",
"return",
"self",
"::",
"myHandleFilenamePart",
"(",
"$",
"part",
",",
"$",
"partValidator",
",",
"$",
"stringDecoder",
",",
"$",
"filename",
",",
"$",
"error",
")",
";",
"}"
] | Tries to parse a part of a path and returns the result or error text.
@param string $part The part of the path.
@param bool $isLastPart True if this is the last part, false otherwise.
@param callable $partValidator The part validator.
@param callable|null $stringDecoder The string decoding function or null if parts should not be decoded.
@param bool|null $isAbsolute Whether the path is absolute or relative if parsing was successful, undefined otherwise.
@param int|null $aboveBaseLevel The number of directory parts above base level if parsing was successful, undefined otherwise.
@param string[]|null $directoryParts The directory parts if parsing was successful, undefined otherwise.
@param string|null $filename The file if parsing was not successful, undefined otherwise.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Tries",
"to",
"parse",
"a",
"part",
"of",
"a",
"path",
"and",
"returns",
"the",
"result",
"or",
"error",
"text",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L337-L356 |
3,467 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myHandleParentDirectoryPart | private static function myHandleParentDirectoryPart(bool $isAbsolute, int &$aboveBaseLevel, array &$directoryParts, ?string &$error = null): bool
{
if (count($directoryParts) > 0) {
array_pop($directoryParts);
return true;
}
if ($isAbsolute) {
$error = 'Absolute path is above root level.';
return false;
}
$aboveBaseLevel++;
return true;
} | php | private static function myHandleParentDirectoryPart(bool $isAbsolute, int &$aboveBaseLevel, array &$directoryParts, ?string &$error = null): bool
{
if (count($directoryParts) > 0) {
array_pop($directoryParts);
return true;
}
if ($isAbsolute) {
$error = 'Absolute path is above root level.';
return false;
}
$aboveBaseLevel++;
return true;
} | [
"private",
"static",
"function",
"myHandleParentDirectoryPart",
"(",
"bool",
"$",
"isAbsolute",
",",
"int",
"&",
"$",
"aboveBaseLevel",
",",
"array",
"&",
"$",
"directoryParts",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"count",
"(",
"$",
"directoryParts",
")",
">",
"0",
")",
"{",
"array_pop",
"(",
"$",
"directoryParts",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"isAbsolute",
")",
"{",
"$",
"error",
"=",
"'Absolute path is above root level.'",
";",
"return",
"false",
";",
"}",
"$",
"aboveBaseLevel",
"++",
";",
"return",
"true",
";",
"}"
] | Handles a parent directory part.
@param bool $isAbsolute Whether the path is absolute or relative.
@param int $aboveBaseLevel The number of directory parts above base level.
@param array $directoryParts The directory parts.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Handles",
"a",
"parent",
"directory",
"part",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L368-L385 |
3,468 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myHandleFilenamePart | private static function myHandleFilenamePart(string $part, callable $partValidator, ?callable $stringDecoder = null, ?string &$filename = null, ?string &$error = null): bool
{
if (!$partValidator($part, false, $error)) {
return false;
}
if ($stringDecoder !== null) {
$part = $stringDecoder($part);
}
$filename = $part;
return true;
} | php | private static function myHandleFilenamePart(string $part, callable $partValidator, ?callable $stringDecoder = null, ?string &$filename = null, ?string &$error = null): bool
{
if (!$partValidator($part, false, $error)) {
return false;
}
if ($stringDecoder !== null) {
$part = $stringDecoder($part);
}
$filename = $part;
return true;
} | [
"private",
"static",
"function",
"myHandleFilenamePart",
"(",
"string",
"$",
"part",
",",
"callable",
"$",
"partValidator",
",",
"?",
"callable",
"$",
"stringDecoder",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"filename",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"partValidator",
"(",
"$",
"part",
",",
"false",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"stringDecoder",
"!==",
"null",
")",
"{",
"$",
"part",
"=",
"$",
"stringDecoder",
"(",
"$",
"part",
")",
";",
"}",
"$",
"filename",
"=",
"$",
"part",
";",
"return",
"true",
";",
"}"
] | Handles the file name part.
@param string $part The file name part.
@param callable $partValidator The part validator.
@param callable|null $stringDecoder The string decoding function or null if parts should not be decoded.
@param string|null $filename The file if parsing was not successful, undefined otherwise.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Handles",
"the",
"file",
"name",
"part",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L398-L411 |
3,469 | themichaelhall/datatypes | src/Traits/PathTrait.php | PathTrait.myHandleDirectoryPart | private static function myHandleDirectoryPart(string $part, callable $partValidator, ?callable $stringDecoder = null, ?array &$directoryParts, ?string &$error = null): bool
{
if (!$partValidator($part, true, $error)) {
return false;
}
if ($stringDecoder !== null) {
$part = $stringDecoder($part);
}
$directoryParts[] = $part;
return true;
} | php | private static function myHandleDirectoryPart(string $part, callable $partValidator, ?callable $stringDecoder = null, ?array &$directoryParts, ?string &$error = null): bool
{
if (!$partValidator($part, true, $error)) {
return false;
}
if ($stringDecoder !== null) {
$part = $stringDecoder($part);
}
$directoryParts[] = $part;
return true;
} | [
"private",
"static",
"function",
"myHandleDirectoryPart",
"(",
"string",
"$",
"part",
",",
"callable",
"$",
"partValidator",
",",
"?",
"callable",
"$",
"stringDecoder",
"=",
"null",
",",
"?",
"array",
"&",
"$",
"directoryParts",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"partValidator",
"(",
"$",
"part",
",",
"true",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"stringDecoder",
"!==",
"null",
")",
"{",
"$",
"part",
"=",
"$",
"stringDecoder",
"(",
"$",
"part",
")",
";",
"}",
"$",
"directoryParts",
"[",
"]",
"=",
"$",
"part",
";",
"return",
"true",
";",
"}"
] | Handles the directory part.
@param string $part The file name part.
@param callable $partValidator The part validator.
@param callable|null $stringDecoder The string decoding function or null if parts should not be decoded.
@param array $directoryParts The directory parts.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Handles",
"the",
"directory",
"part",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Traits/PathTrait.php#L424-L437 |
3,470 | lembarek/core | src/Repositories/Repository.php | Repository.create | public function create($inputs)
{
$record = $this->model->create($inputs);
$record->save();
return $record;
} | php | public function create($inputs)
{
$record = $this->model->create($inputs);
$record->save();
return $record;
} | [
"public",
"function",
"create",
"(",
"$",
"inputs",
")",
"{",
"$",
"record",
"=",
"$",
"this",
"->",
"model",
"->",
"create",
"(",
"$",
"inputs",
")",
";",
"$",
"record",
"->",
"save",
"(",
")",
";",
"return",
"$",
"record",
";",
"}"
] | create a new record
@param array $input
@return Models | [
"create",
"a",
"new",
"record"
] | 7d325ad9b7a81610a07a2f109306fb91b89ab215 | https://github.com/lembarek/core/blob/7d325ad9b7a81610a07a2f109306fb91b89ab215/src/Repositories/Repository.php#L13-L18 |
3,471 | lembarek/core | src/Repositories/Repository.php | Repository.all | public function all($limit = null)
{
if($limit){
return $this->model->limit($limit)->get();
}
return $this->model->all();
} | php | public function all($limit = null)
{
if($limit){
return $this->model->limit($limit)->get();
}
return $this->model->all();
} | [
"public",
"function",
"all",
"(",
"$",
"limit",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"limit",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"limit",
"(",
"$",
"limit",
")",
"->",
"get",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"model",
"->",
"all",
"(",
")",
";",
"}"
] | get all records in database
@param integer $limit
@return Model | [
"get",
"all",
"records",
"in",
"database"
] | 7d325ad9b7a81610a07a2f109306fb91b89ab215 | https://github.com/lembarek/core/blob/7d325ad9b7a81610a07a2f109306fb91b89ab215/src/Repositories/Repository.php#L26-L33 |
3,472 | lembarek/core | src/Repositories/Repository.php | Repository.allWith | public function allWith($with, $limit = null)
{
if ($limit) {
return $this->model->with($with)->limit($limit)->get();
}
return $this->model->with($with)->get();
} | php | public function allWith($with, $limit = null)
{
if ($limit) {
return $this->model->with($with)->limit($limit)->get();
}
return $this->model->with($with)->get();
} | [
"public",
"function",
"allWith",
"(",
"$",
"with",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"limit",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"with",
"(",
"$",
"with",
")",
"->",
"limit",
"(",
"$",
"limit",
")",
"->",
"get",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"model",
"->",
"with",
"(",
"$",
"with",
")",
"->",
"get",
"(",
")",
";",
"}"
] | get all records in database with withs
@param string $with
@param integer $limit
@return void | [
"get",
"all",
"records",
"in",
"database",
"with",
"withs"
] | 7d325ad9b7a81610a07a2f109306fb91b89ab215 | https://github.com/lembarek/core/blob/7d325ad9b7a81610a07a2f109306fb91b89ab215/src/Repositories/Repository.php#L42-L50 |
3,473 | lembarek/core | src/Repositories/Repository.php | Repository.getForUser | public function getForUser($user_id = null)
{
if ($user_id) {
return $this->model->whereUserId($user_id)->get()->first()->toArray();
}
if(auth()->user()){
return $this->model->whereUserId(auth()->user()->id)->first()->toArray();
}
return null;
} | php | public function getForUser($user_id = null)
{
if ($user_id) {
return $this->model->whereUserId($user_id)->get()->first()->toArray();
}
if(auth()->user()){
return $this->model->whereUserId(auth()->user()->id)->first()->toArray();
}
return null;
} | [
"public",
"function",
"getForUser",
"(",
"$",
"user_id",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"user_id",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"whereUserId",
"(",
"$",
"user_id",
")",
"->",
"get",
"(",
")",
"->",
"first",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"auth",
"(",
")",
"->",
"user",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"whereUserId",
"(",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"id",
")",
"->",
"first",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | get the columns for a users
@param int $user
@return Model | [
"get",
"the",
"columns",
"for",
"a",
"users"
] | 7d325ad9b7a81610a07a2f109306fb91b89ab215 | https://github.com/lembarek/core/blob/7d325ad9b7a81610a07a2f109306fb91b89ab215/src/Repositories/Repository.php#L58-L70 |
3,474 | lembarek/core | src/Repositories/Repository.php | Repository.where | public function where($key, $value=null)
{
if($value)
return $this->model->where($key, $value);
if(is_array($key))
return $this->model->where($key);
return null;
} | php | public function where($key, $value=null)
{
if($value)
return $this->model->where($key, $value);
if(is_array($key))
return $this->model->where($key);
return null;
} | [
"public",
"function",
"where",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
")",
"return",
"$",
"this",
"->",
"model",
"->",
"where",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"return",
"$",
"this",
"->",
"model",
"->",
"where",
"(",
"$",
"key",
")",
";",
"return",
"null",
";",
"}"
] | try to simulate the where of Eloquent
@param string $key
@param string $value
@return this | [
"try",
"to",
"simulate",
"the",
"where",
"of",
"Eloquent"
] | 7d325ad9b7a81610a07a2f109306fb91b89ab215 | https://github.com/lembarek/core/blob/7d325ad9b7a81610a07a2f109306fb91b89ab215/src/Repositories/Repository.php#L79-L86 |
3,475 | lembarek/core | src/Repositories/Repository.php | Repository.getPaginatedAndOrdered | public function getPaginatedAndOrdered()
{
$direction = request()->get('direction');
$orderBy = request()->get('orderby');
$p = config('admin.paginate');
if($orderBy)
return $this->orderBy($orderBy, $direction)->paginate($p);
return $this->paginate();
} | php | public function getPaginatedAndOrdered()
{
$direction = request()->get('direction');
$orderBy = request()->get('orderby');
$p = config('admin.paginate');
if($orderBy)
return $this->orderBy($orderBy, $direction)->paginate($p);
return $this->paginate();
} | [
"public",
"function",
"getPaginatedAndOrdered",
"(",
")",
"{",
"$",
"direction",
"=",
"request",
"(",
")",
"->",
"get",
"(",
"'direction'",
")",
";",
"$",
"orderBy",
"=",
"request",
"(",
")",
"->",
"get",
"(",
"'orderby'",
")",
";",
"$",
"p",
"=",
"config",
"(",
"'admin.paginate'",
")",
";",
"if",
"(",
"$",
"orderBy",
")",
"return",
"$",
"this",
"->",
"orderBy",
"(",
"$",
"orderBy",
",",
"$",
"direction",
")",
"->",
"paginate",
"(",
"$",
"p",
")",
";",
"return",
"$",
"this",
"->",
"paginate",
"(",
")",
";",
"}"
] | get a record paginated and ordered
@return Model | [
"get",
"a",
"record",
"paginated",
"and",
"ordered"
] | 7d325ad9b7a81610a07a2f109306fb91b89ab215 | https://github.com/lembarek/core/blob/7d325ad9b7a81610a07a2f109306fb91b89ab215/src/Repositories/Repository.php#L164-L174 |
3,476 | lembarek/core | src/Repositories/Repository.php | Repository.update | public function update($id, $key, $value=null)
{
$model = $this->model->find($id);
if (is_array($key))
$model->update($key);
else
$model->{$key}= $value;
$model->save();
} | php | public function update($id, $key, $value=null)
{
$model = $this->model->find($id);
if (is_array($key))
$model->update($key);
else
$model->{$key}= $value;
$model->save();
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"$",
"model",
"->",
"update",
"(",
"$",
"key",
")",
";",
"else",
"$",
"model",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"value",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"}"
] | update the status of the model
@param integer $id
@param string $key
@param string $value
@return Model | [
"update",
"the",
"status",
"of",
"the",
"model"
] | 7d325ad9b7a81610a07a2f109306fb91b89ab215 | https://github.com/lembarek/core/blob/7d325ad9b7a81610a07a2f109306fb91b89ab215/src/Repositories/Repository.php#L195-L205 |
3,477 | uthando-cms/uthando-mail | src/UthandoMail/Form/Element/MailTransportList.php | MailTransportList.init | public function init()
{
/* @var $options MailOptions */
$options = $this->getServiceLocator()
->getServiceLocator()
->get(MailOptions::class);
$emailAddresses = $options->getAddressList();
$addressList = [];
foreach ($emailAddresses as $transport => $address) {
$addressList[] = [
'label' => $address['name'] . ' <' . $address['address'] . '>',
'value' => $transport,
];
}
$this->setValueOptions($addressList);
} | php | public function init()
{
/* @var $options MailOptions */
$options = $this->getServiceLocator()
->getServiceLocator()
->get(MailOptions::class);
$emailAddresses = $options->getAddressList();
$addressList = [];
foreach ($emailAddresses as $transport => $address) {
$addressList[] = [
'label' => $address['name'] . ' <' . $address['address'] . '>',
'value' => $transport,
];
}
$this->setValueOptions($addressList);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"/* @var $options MailOptions */",
"$",
"options",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"MailOptions",
"::",
"class",
")",
";",
"$",
"emailAddresses",
"=",
"$",
"options",
"->",
"getAddressList",
"(",
")",
";",
"$",
"addressList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"emailAddresses",
"as",
"$",
"transport",
"=>",
"$",
"address",
")",
"{",
"$",
"addressList",
"[",
"]",
"=",
"[",
"'label'",
"=>",
"$",
"address",
"[",
"'name'",
"]",
".",
"' <'",
".",
"$",
"address",
"[",
"'address'",
"]",
".",
"'>'",
",",
"'value'",
"=>",
"$",
"transport",
",",
"]",
";",
"}",
"$",
"this",
"->",
"setValueOptions",
"(",
"$",
"addressList",
")",
";",
"}"
] | Set up value options | [
"Set",
"up",
"value",
"options"
] | fcccca7d880ebdbc120b8a7956a397ed7c905afd | https://github.com/uthando-cms/uthando-mail/blob/fcccca7d880ebdbc120b8a7956a397ed7c905afd/src/UthandoMail/Form/Element/MailTransportList.php#L32-L52 |
3,478 | a2c/BaconLanguageBundle | Controller/Backend/LanguageController.php | LanguageController.indexAction | public function indexAction($page,$sort,$direction)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => '',
));
$breadcumbs->addItem(array(
'title' => 'List',
'route' => '',
));
$entity = new Language();
$query = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->getQueryPagination($entity,$sort,$direction);
if ($this->get('session')->has('language_search_session')) {
$objSerialize = $this->get('session')->get('language_search_session');
$entity = unserialize($objSerialize);
$query = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->getQueryPagination($entity,$sort,$direction);
}
$paginator = $this->getPagination($query,$page,Language::PER_PAGE);
$paginator->setUsedRoute('admin_language_pagination');
$form = $this->createForm(new LanguageFormType(),$entity,array(
'search' => true,
));
return array(
'pagination' => $paginator,
'form_search' => $form->createView(),
'form_delete' => $this->createDeleteForm()->createView(),
);
} | php | public function indexAction($page,$sort,$direction)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => '',
));
$breadcumbs->addItem(array(
'title' => 'List',
'route' => '',
));
$entity = new Language();
$query = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->getQueryPagination($entity,$sort,$direction);
if ($this->get('session')->has('language_search_session')) {
$objSerialize = $this->get('session')->get('language_search_session');
$entity = unserialize($objSerialize);
$query = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->getQueryPagination($entity,$sort,$direction);
}
$paginator = $this->getPagination($query,$page,Language::PER_PAGE);
$paginator->setUsedRoute('admin_language_pagination');
$form = $this->createForm(new LanguageFormType(),$entity,array(
'search' => true,
));
return array(
'pagination' => $paginator,
'form_search' => $form->createView(),
'form_delete' => $this->createDeleteForm()->createView(),
);
} | [
"public",
"function",
"indexAction",
"(",
"$",
"page",
",",
"$",
"sort",
",",
"$",
"direction",
")",
"{",
"$",
"breadcumbs",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'bacon_breadcrumbs'",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Language'",
",",
"'route'",
"=>",
"''",
",",
")",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'List'",
",",
"'route'",
"=>",
"''",
",",
")",
")",
";",
"$",
"entity",
"=",
"new",
"Language",
"(",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'BaconLanguageBundle:Language'",
")",
"->",
"getQueryPagination",
"(",
"$",
"entity",
",",
"$",
"sort",
",",
"$",
"direction",
")",
";",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"has",
"(",
"'language_search_session'",
")",
")",
"{",
"$",
"objSerialize",
"=",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"get",
"(",
"'language_search_session'",
")",
";",
"$",
"entity",
"=",
"unserialize",
"(",
"$",
"objSerialize",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'BaconLanguageBundle:Language'",
")",
"->",
"getQueryPagination",
"(",
"$",
"entity",
",",
"$",
"sort",
",",
"$",
"direction",
")",
";",
"}",
"$",
"paginator",
"=",
"$",
"this",
"->",
"getPagination",
"(",
"$",
"query",
",",
"$",
"page",
",",
"Language",
"::",
"PER_PAGE",
")",
";",
"$",
"paginator",
"->",
"setUsedRoute",
"(",
"'admin_language_pagination'",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"LanguageFormType",
"(",
")",
",",
"$",
"entity",
",",
"array",
"(",
"'search'",
"=>",
"true",
",",
")",
")",
";",
"return",
"array",
"(",
"'pagination'",
"=>",
"$",
"paginator",
",",
"'form_search'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'form_delete'",
"=>",
"$",
"this",
"->",
"createDeleteForm",
"(",
")",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Lists all Language entities.
@Route("/",defaults={"page"=1, "sort"="id", "direction"="asc"}, name="admin_language")
@Route("/page/{page}/sort/{sort}/direction/{direction}/", defaults={"page"=1, "sort"="id", "direction"="asc"}, name="admin_language_pagination")
@Method("GET")
@Security("has_role('ROLE_ADMIN')")
@Template() | [
"Lists",
"all",
"Language",
"entities",
"."
] | 250a477666786c1471b59a477bb35cd85867e686 | https://github.com/a2c/BaconLanguageBundle/blob/250a477666786c1471b59a477bb35cd85867e686/Controller/Backend/LanguageController.php#L32-L67 |
3,479 | a2c/BaconLanguageBundle | Controller/Backend/LanguageController.php | LanguageController.searchAction | public function searchAction(Request $request)
{
$this->get('session')->remove('language_search_session');
if ($request->getMethod() === Request::METHOD_POST) {
$form = $this->createForm(new LanguageFormType(),new Language(),array(
'search' => true,
));
$form->handleRequest($request);
$this->get('session')->set('language_search_session',serialize($form->getData()));
}
return $this->redirect($this->generateUrl('admin_language'));
} | php | public function searchAction(Request $request)
{
$this->get('session')->remove('language_search_session');
if ($request->getMethod() === Request::METHOD_POST) {
$form = $this->createForm(new LanguageFormType(),new Language(),array(
'search' => true,
));
$form->handleRequest($request);
$this->get('session')->set('language_search_session',serialize($form->getData()));
}
return $this->redirect($this->generateUrl('admin_language'));
} | [
"public",
"function",
"searchAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"remove",
"(",
"'language_search_session'",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"===",
"Request",
"::",
"METHOD_POST",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"LanguageFormType",
"(",
")",
",",
"new",
"Language",
"(",
")",
",",
"array",
"(",
"'search'",
"=>",
"true",
",",
")",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"set",
"(",
"'language_search_session'",
",",
"serialize",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_language'",
")",
")",
";",
"}"
] | Search filter Language entities.
@Route("/search", name="admin_language_search")
@Method({"POST","GET"})
@Security("has_role('ROLE_ADMIN')")
@Template() | [
"Search",
"filter",
"Language",
"entities",
"."
] | 250a477666786c1471b59a477bb35cd85867e686 | https://github.com/a2c/BaconLanguageBundle/blob/250a477666786c1471b59a477bb35cd85867e686/Controller/Backend/LanguageController.php#L77-L93 |
3,480 | a2c/BaconLanguageBundle | Controller/Backend/LanguageController.php | LanguageController.newAction | public function newAction()
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'New',
'route' => '',
));
$form = $this->createForm(new LanguageFormType(), new Language());
return array(
'form' => $form->createView(),
);
} | php | public function newAction()
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'New',
'route' => '',
));
$form = $this->createForm(new LanguageFormType(), new Language());
return array(
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"breadcumbs",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'bacon_breadcrumbs'",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Language'",
",",
"'route'",
"=>",
"'admin_language'",
",",
")",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'New'",
",",
"'route'",
"=>",
"''",
",",
")",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"LanguageFormType",
"(",
")",
",",
"new",
"Language",
"(",
")",
")",
";",
"return",
"array",
"(",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to create a new Language entity.
@Route("/new", name="admin_language_new")
@Method("GET")
@Security("has_role('ROLE_ADMIN')")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Language",
"entity",
"."
] | 250a477666786c1471b59a477bb35cd85867e686 | https://github.com/a2c/BaconLanguageBundle/blob/250a477666786c1471b59a477bb35cd85867e686/Controller/Backend/LanguageController.php#L103-L122 |
3,481 | a2c/BaconLanguageBundle | Controller/Backend/LanguageController.php | LanguageController.createAction | public function createAction(Request $request)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'New',
'route' => '',
));
$form = $this->createForm(new LanguageFormType(),new Language());
$handler = new LanguageFormHandler(
$form,
$request,
$this->getDoctrine()->getManager(),
$this->get('session')->getFlashBag()
);
if ($handler->save()) {
return $this->redirect($this->generateUrl('admin_language'));
}
return array(
'form' => $form->createView(),
);
} | php | public function createAction(Request $request)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'New',
'route' => '',
));
$form = $this->createForm(new LanguageFormType(),new Language());
$handler = new LanguageFormHandler(
$form,
$request,
$this->getDoctrine()->getManager(),
$this->get('session')->getFlashBag()
);
if ($handler->save()) {
return $this->redirect($this->generateUrl('admin_language'));
}
return array(
'form' => $form->createView(),
);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"breadcumbs",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'bacon_breadcrumbs'",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Language'",
",",
"'route'",
"=>",
"'admin_language'",
",",
")",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'New'",
",",
"'route'",
"=>",
"''",
",",
")",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"LanguageFormType",
"(",
")",
",",
"new",
"Language",
"(",
")",
")",
";",
"$",
"handler",
"=",
"new",
"LanguageFormHandler",
"(",
"$",
"form",
",",
"$",
"request",
",",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
",",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
")",
";",
"if",
"(",
"$",
"handler",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_language'",
")",
")",
";",
"}",
"return",
"array",
"(",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Creates a new Language entity.
@Route("/", name="admin_language_create")
@Method("POST")
@Security("has_role('ROLE_ADMIN')")
@Template("BaconLanguageBundle:Backend/Language:new.html.twig") | [
"Creates",
"a",
"new",
"Language",
"entity",
"."
] | 250a477666786c1471b59a477bb35cd85867e686 | https://github.com/a2c/BaconLanguageBundle/blob/250a477666786c1471b59a477bb35cd85867e686/Controller/Backend/LanguageController.php#L131-L161 |
3,482 | a2c/BaconLanguageBundle | Controller/Backend/LanguageController.php | LanguageController.editAction | public function editAction($id)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'Edit',
'route' => '',
));
$entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);
if (!$entity) {
$this->get('session')->getFlashBag()->add('message', array(
'type' => 'error',
'message' => 'The registry not Found',
));
return $this->redirect($this->generateUrl('admin_language'));
}
$form = $this->createForm(new LanguageFormType(), $entity);
$deleteForm = $this->createDeleteForm($id);
return array(
'entity' => $entity,
'form' => $form->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function editAction($id)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'Edit',
'route' => '',
));
$entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);
if (!$entity) {
$this->get('session')->getFlashBag()->add('message', array(
'type' => 'error',
'message' => 'The registry not Found',
));
return $this->redirect($this->generateUrl('admin_language'));
}
$form = $this->createForm(new LanguageFormType(), $entity);
$deleteForm = $this->createDeleteForm($id);
return array(
'entity' => $entity,
'form' => $form->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"editAction",
"(",
"$",
"id",
")",
"{",
"$",
"breadcumbs",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'bacon_breadcrumbs'",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Language'",
",",
"'route'",
"=>",
"'admin_language'",
",",
")",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Edit'",
",",
"'route'",
"=>",
"''",
",",
")",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'BaconLanguageBundle:Language'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'message'",
",",
"array",
"(",
"'type'",
"=>",
"'error'",
",",
"'message'",
"=>",
"'The registry not Found'",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_language'",
")",
")",
";",
"}",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"LanguageFormType",
"(",
")",
",",
"$",
"entity",
")",
";",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to edit an existing Language entity.
@Route("/{id}/edit", name="admin_language_edit")
@Method("GET")
@Security("has_role('ROLE_ADMIN')")
@Template() | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"Language",
"entity",
"."
] | 250a477666786c1471b59a477bb35cd85867e686 | https://github.com/a2c/BaconLanguageBundle/blob/250a477666786c1471b59a477bb35cd85867e686/Controller/Backend/LanguageController.php#L172-L206 |
3,483 | a2c/BaconLanguageBundle | Controller/Backend/LanguageController.php | LanguageController.updateAction | public function updateAction(Request $request, $id)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'Edit',
'route' => '',
));
$entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);
if (!$entity) {
$this->get('session')->getFlashBag()->add('message', array(
'type' => 'error',
'message' => 'Registry not Found',
));
return $this->redirect($this->generateUrl('admin_language'));
}
$form = $this->createForm(new LanguageFormType(), $entity);
$deleteForm = $this->createDeleteForm($id);
$handler = new LanguageFormHandler(
$form,
$request,
$this->getDoctrine()->getManager(),
$this->get('session')->getFlashBag()
);
if ($handler->save()) {
return $this->redirect($this->generateUrl('admin_language'));
}
return array(
'entity' => $entity,
'form' => $form->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function updateAction(Request $request, $id)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'Edit',
'route' => '',
));
$entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);
if (!$entity) {
$this->get('session')->getFlashBag()->add('message', array(
'type' => 'error',
'message' => 'Registry not Found',
));
return $this->redirect($this->generateUrl('admin_language'));
}
$form = $this->createForm(new LanguageFormType(), $entity);
$deleteForm = $this->createDeleteForm($id);
$handler = new LanguageFormHandler(
$form,
$request,
$this->getDoctrine()->getManager(),
$this->get('session')->getFlashBag()
);
if ($handler->save()) {
return $this->redirect($this->generateUrl('admin_language'));
}
return array(
'entity' => $entity,
'form' => $form->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"updateAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"breadcumbs",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'bacon_breadcrumbs'",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Language'",
",",
"'route'",
"=>",
"'admin_language'",
",",
")",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Edit'",
",",
"'route'",
"=>",
"''",
",",
")",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'BaconLanguageBundle:Language'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'message'",
",",
"array",
"(",
"'type'",
"=>",
"'error'",
",",
"'message'",
"=>",
"'Registry not Found'",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_language'",
")",
")",
";",
"}",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"LanguageFormType",
"(",
")",
",",
"$",
"entity",
")",
";",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
";",
"$",
"handler",
"=",
"new",
"LanguageFormHandler",
"(",
"$",
"form",
",",
"$",
"request",
",",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
",",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
")",
";",
"if",
"(",
"$",
"handler",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_language'",
")",
")",
";",
"}",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Edits an existing Language entity.
@Route("/{id}", name="admin_language_update")
@Method("PUT")
@Security("has_role('ROLE_ADMIN')")
@Template("BaconLanguageBundle:Backend/Language:edit.html.twig") | [
"Edits",
"an",
"existing",
"Language",
"entity",
"."
] | 250a477666786c1471b59a477bb35cd85867e686 | https://github.com/a2c/BaconLanguageBundle/blob/250a477666786c1471b59a477bb35cd85867e686/Controller/Backend/LanguageController.php#L216-L261 |
3,484 | a2c/BaconLanguageBundle | Controller/Backend/LanguageController.php | LanguageController.showAction | public function showAction($id)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'Details',
'route' => '',
));
$entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);
if (!$entity) {
$this->get('session')->getFlashBag()->add('message', array(
'type' => 'error',
'message' => 'The registry not Found',
));
return $this->redirect($this->generateUrl('admin_language'));
}
$deleteForm = $this->createDeleteForm($id);
return array(
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
);
} | php | public function showAction($id)
{
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem(array(
'title' => 'Language',
'route' => 'admin_language',
));
$breadcumbs->addItem(array(
'title' => 'Details',
'route' => '',
));
$entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);
if (!$entity) {
$this->get('session')->getFlashBag()->add('message', array(
'type' => 'error',
'message' => 'The registry not Found',
));
return $this->redirect($this->generateUrl('admin_language'));
}
$deleteForm = $this->createDeleteForm($id);
return array(
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"showAction",
"(",
"$",
"id",
")",
"{",
"$",
"breadcumbs",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'bacon_breadcrumbs'",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Language'",
",",
"'route'",
"=>",
"'admin_language'",
",",
")",
")",
";",
"$",
"breadcumbs",
"->",
"addItem",
"(",
"array",
"(",
"'title'",
"=>",
"'Details'",
",",
"'route'",
"=>",
"''",
",",
")",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'BaconLanguageBundle:Language'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'message'",
",",
"array",
"(",
"'type'",
"=>",
"'error'",
",",
"'message'",
"=>",
"'The registry not Found'",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_language'",
")",
")",
";",
"}",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Finds and displays a Language entity.
@Route("/{id}", name="admin_language_show")
@Method("GET")
@Security("has_role('ROLE_ADMIN')")
@Template() | [
"Finds",
"and",
"displays",
"a",
"Language",
"entity",
"."
] | 250a477666786c1471b59a477bb35cd85867e686 | https://github.com/a2c/BaconLanguageBundle/blob/250a477666786c1471b59a477bb35cd85867e686/Controller/Backend/LanguageController.php#L271-L303 |
3,485 | a2c/BaconLanguageBundle | Controller/Backend/LanguageController.php | LanguageController.deleteAction | public function deleteAction(Request $request, $id)
{
$handler = new LanguageFormHandler(
$this->createDeleteForm(),
$request,
$this->get('doctrine')->getManager(),
$this->get('session')->getFlashBag()
);
$entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);
if ($handler->delete($entity)) {
return $this->redirect($this->generateUrl('admin_language'));
}
return $this->redirect($this->generateUrl('admin_language_show', array('id' => $id)));
} | php | public function deleteAction(Request $request, $id)
{
$handler = new LanguageFormHandler(
$this->createDeleteForm(),
$request,
$this->get('doctrine')->getManager(),
$this->get('session')->getFlashBag()
);
$entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);
if ($handler->delete($entity)) {
return $this->redirect($this->generateUrl('admin_language'));
}
return $this->redirect($this->generateUrl('admin_language_show', array('id' => $id)));
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"handler",
"=",
"new",
"LanguageFormHandler",
"(",
"$",
"this",
"->",
"createDeleteForm",
"(",
")",
",",
"$",
"request",
",",
"$",
"this",
"->",
"get",
"(",
"'doctrine'",
")",
"->",
"getManager",
"(",
")",
",",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'BaconLanguageBundle:Language'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"handler",
"->",
"delete",
"(",
"$",
"entity",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_language'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_language_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
")",
")",
";",
"}"
] | Deletes a Language entity.
@Route("/{id}", name="admin_language_delete")
@Security("has_role('ROLE_ADMIN')")
@Method("DELETE") | [
"Deletes",
"a",
"Language",
"entity",
"."
] | 250a477666786c1471b59a477bb35cd85867e686 | https://github.com/a2c/BaconLanguageBundle/blob/250a477666786c1471b59a477bb35cd85867e686/Controller/Backend/LanguageController.php#L311-L329 |
3,486 | vinala/kernel | src/Atomium/Compiler/AtomiumCompileCapture.php | AtomiumCompileCapture.get | protected static function get($script, $openTag)
{
$data = Strings::splite($script, $openTag);
//
$output = '';
//
for ($i = 1; $i < Collection::count($data); $i++) {
$next = Strings::splite($data[$i], self::$endOpenTag);
$rest = '';
//
for ($j = 0; $j < Collection::count($next); $j++) {
$rest .= $next[$j]."\n";
}
//
$next = Strings::splite($rest, self::$closeTag);
//
$output = $next[0];
}
//
return $output;
} | php | protected static function get($script, $openTag)
{
$data = Strings::splite($script, $openTag);
//
$output = '';
//
for ($i = 1; $i < Collection::count($data); $i++) {
$next = Strings::splite($data[$i], self::$endOpenTag);
$rest = '';
//
for ($j = 0; $j < Collection::count($next); $j++) {
$rest .= $next[$j]."\n";
}
//
$next = Strings::splite($rest, self::$closeTag);
//
$output = $next[0];
}
//
return $output;
} | [
"protected",
"static",
"function",
"get",
"(",
"$",
"script",
",",
"$",
"openTag",
")",
"{",
"$",
"data",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"script",
",",
"$",
"openTag",
")",
";",
"//",
"$",
"output",
"=",
"''",
";",
"//",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"Collection",
"::",
"count",
"(",
"$",
"data",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"next",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"data",
"[",
"$",
"i",
"]",
",",
"self",
"::",
"$",
"endOpenTag",
")",
";",
"$",
"rest",
"=",
"''",
";",
"//",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"Collection",
"::",
"count",
"(",
"$",
"next",
")",
";",
"$",
"j",
"++",
")",
"{",
"$",
"rest",
".=",
"$",
"next",
"[",
"$",
"j",
"]",
".",
"\"\\n\"",
";",
"}",
"//",
"$",
"next",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"rest",
",",
"self",
"::",
"$",
"closeTag",
")",
";",
"//",
"$",
"output",
"=",
"$",
"next",
"[",
"0",
"]",
";",
"}",
"//",
"return",
"$",
"output",
";",
"}"
] | Complie the opening tag.
@var string | [
"Complie",
"the",
"opening",
"tag",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Atomium/Compiler/AtomiumCompileCapture.php#L50-L70 |
3,487 | znframework/package-image | MimeTypeFinder.php | MimeTypeFinder.get | public static function get($file)
{
$type = str_replace('image/', NULL, Singleton::class('ZN\Helpers\Mime')->type($file));
return $type === 'jpg' ? 'jpeg' : $type;
} | php | public static function get($file)
{
$type = str_replace('image/', NULL, Singleton::class('ZN\Helpers\Mime')->type($file));
return $type === 'jpg' ? 'jpeg' : $type;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"file",
")",
"{",
"$",
"type",
"=",
"str_replace",
"(",
"'image/'",
",",
"NULL",
",",
"Singleton",
"::",
"class",
"(",
"'ZN\\Helpers\\Mime'",
")",
"->",
"type",
"(",
"$",
"file",
")",
")",
";",
"return",
"$",
"type",
"===",
"'jpg'",
"?",
"'jpeg'",
":",
"$",
"type",
";",
"}"
] | Finder mime type.
@param string $file | [
"Finder",
"mime",
"type",
"."
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/MimeTypeFinder.php#L21-L26 |
3,488 | ntentan/ntentan | src/Controller.php | Controller.getRedirect | protected function getRedirect() : Redirect
{
$context = Context::getInstance();
$redirect = new Redirect($context->getUrl($context->getParameter('controller_path')));
return $redirect;
} | php | protected function getRedirect() : Redirect
{
$context = Context::getInstance();
$redirect = new Redirect($context->getUrl($context->getParameter('controller_path')));
return $redirect;
} | [
"protected",
"function",
"getRedirect",
"(",
")",
":",
"Redirect",
"{",
"$",
"context",
"=",
"Context",
"::",
"getInstance",
"(",
")",
";",
"$",
"redirect",
"=",
"new",
"Redirect",
"(",
"$",
"context",
"->",
"getUrl",
"(",
"$",
"context",
"->",
"getParameter",
"(",
"'controller_path'",
")",
")",
")",
";",
"return",
"$",
"redirect",
";",
"}"
] | Get an instance of the Redirect object that is setup with this controller as its base URL.
@return Redirect | [
"Get",
"an",
"instance",
"of",
"the",
"Redirect",
"object",
"that",
"is",
"setup",
"with",
"this",
"controller",
"as",
"its",
"base",
"URL",
"."
] | a6e89de5999bfafe5be9152bcd51ecfef3e928fb | https://github.com/ntentan/ntentan/blob/a6e89de5999bfafe5be9152bcd51ecfef3e928fb/src/Controller.php#L77-L82 |
3,489 | ntentan/ntentan | src/Controller.php | Controller.getActionUrl | protected function getActionUrl($action) : string
{
$context = Context::getInstance();
return $context->getUrl($context->getParameter('controller_path') . $action);
} | php | protected function getActionUrl($action) : string
{
$context = Context::getInstance();
return $context->getUrl($context->getParameter('controller_path') . $action);
} | [
"protected",
"function",
"getActionUrl",
"(",
"$",
"action",
")",
":",
"string",
"{",
"$",
"context",
"=",
"Context",
"::",
"getInstance",
"(",
")",
";",
"return",
"$",
"context",
"->",
"getUrl",
"(",
"$",
"context",
"->",
"getParameter",
"(",
"'controller_path'",
")",
".",
"$",
"action",
")",
";",
"}"
] | Returns a URL to an action in this controller.
@param string $action The name of the action
@return string A URL to the action | [
"Returns",
"a",
"URL",
"to",
"an",
"action",
"in",
"this",
"controller",
"."
] | a6e89de5999bfafe5be9152bcd51ecfef3e928fb | https://github.com/ntentan/ntentan/blob/a6e89de5999bfafe5be9152bcd51ecfef3e928fb/src/Controller.php#L90-L94 |
3,490 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php | ArrayUtils.hasStringKeys | public static function hasStringKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return count(array_filter(array_keys($value), 'is_string')) > 0;
} | php | public static function hasStringKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return count(array_filter(array_keys($value), 'is_string')) > 0;
} | [
"public",
"static",
"function",
"hasStringKeys",
"(",
"$",
"value",
",",
"$",
"allowEmpty",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"$",
"allowEmpty",
";",
"}",
"return",
"count",
"(",
"array_filter",
"(",
"array_keys",
"(",
"$",
"value",
")",
",",
"'is_string'",
")",
")",
">",
"0",
";",
"}"
] | Test whether an array contains one or more string keys
@param mixed $value
@param bool $allowEmpty Should an empty array() return true
@return bool | [
"Test",
"whether",
"an",
"array",
"contains",
"one",
"or",
"more",
"string",
"keys"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php#L40-L51 |
3,491 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php | ArrayUtils.hasIntegerKeys | public static function hasIntegerKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return count(array_filter(array_keys($value), 'is_int')) > 0;
} | php | public static function hasIntegerKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return count(array_filter(array_keys($value), 'is_int')) > 0;
} | [
"public",
"static",
"function",
"hasIntegerKeys",
"(",
"$",
"value",
",",
"$",
"allowEmpty",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"$",
"allowEmpty",
";",
"}",
"return",
"count",
"(",
"array_filter",
"(",
"array_keys",
"(",
"$",
"value",
")",
",",
"'is_int'",
")",
")",
">",
"0",
";",
"}"
] | Test whether an array contains one or more integer keys
@param mixed $value
@param bool $allowEmpty Should an empty array() return true
@return bool | [
"Test",
"whether",
"an",
"array",
"contains",
"one",
"or",
"more",
"integer",
"keys"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php#L60-L71 |
3,492 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php | ArrayUtils.hasNumericKeys | public static function hasNumericKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return count(array_filter(array_keys($value), 'is_numeric')) > 0;
} | php | public static function hasNumericKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return count(array_filter(array_keys($value), 'is_numeric')) > 0;
} | [
"public",
"static",
"function",
"hasNumericKeys",
"(",
"$",
"value",
",",
"$",
"allowEmpty",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"$",
"allowEmpty",
";",
"}",
"return",
"count",
"(",
"array_filter",
"(",
"array_keys",
"(",
"$",
"value",
")",
",",
"'is_numeric'",
")",
")",
">",
"0",
";",
"}"
] | Test whether an array contains one or more numeric keys.
A numeric key can be one of the following:
- an integer 1,
- a string with a number '20'
- a string with negative number: '-1000'
- a float: 2.2120, -78.150999
- a string with float: '4000.99999', '-10.10'
@param mixed $value
@param bool $allowEmpty Should an empty array() return true
@return bool | [
"Test",
"whether",
"an",
"array",
"contains",
"one",
"or",
"more",
"numeric",
"keys",
"."
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php#L87-L98 |
3,493 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php | ArrayUtils.isList | public static function isList($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return (array_values($value) === $value);
} | php | public static function isList($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return (array_values($value) === $value);
} | [
"public",
"static",
"function",
"isList",
"(",
"$",
"value",
",",
"$",
"allowEmpty",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"$",
"allowEmpty",
";",
"}",
"return",
"(",
"array_values",
"(",
"$",
"value",
")",
"===",
"$",
"value",
")",
";",
"}"
] | Test whether an array is a list
A list is a collection of values assigned to continuous integer keys
starting at 0 and ending at count() - 1.
For example:
<code>
$list = array('a', 'b', 'c', 'd');
$list = array(
0 => 'foo',
1 => 'bar',
2 => array('foo' => 'baz'),
);
</code>
@param mixed $value
@param bool $allowEmpty Is an empty list a valid list?
@return bool | [
"Test",
"whether",
"an",
"array",
"is",
"a",
"list"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php#L120-L131 |
3,494 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php | ArrayUtils.isHashTable | public static function isHashTable($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return (array_values($value) !== $value);
} | php | public static function isHashTable($value, $allowEmpty = false)
{
if (!is_array($value)) {
return false;
}
if (!$value) {
return $allowEmpty;
}
return (array_values($value) !== $value);
} | [
"public",
"static",
"function",
"isHashTable",
"(",
"$",
"value",
",",
"$",
"allowEmpty",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"$",
"allowEmpty",
";",
"}",
"return",
"(",
"array_values",
"(",
"$",
"value",
")",
"!==",
"$",
"value",
")",
";",
"}"
] | Test whether an array is a hash table.
An array is a hash table if:
1. Contains one or more non-integer keys, or
2. Integer keys are non-continuous or misaligned (not starting with 0)
For example:
<code>
$hash = array(
'foo' => 15,
'bar' => false,
);
$hash = array(
1995 => 'Birth of PHP',
2009 => 'PHP 5.3.0',
2012 => 'PHP 5.4.0',
);
$hash = array(
'formElement,
'options' => array( 'debug' => true ),
);
</code>
@param mixed $value
@param bool $allowEmpty Is an empty array() a valid hash table?
@return bool | [
"Test",
"whether",
"an",
"array",
"is",
"a",
"hash",
"table",
"."
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php#L162-L173 |
3,495 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php | ArrayUtils.inArray | public static function inArray($needle, array $haystack, $strict = false)
{
if (!$strict) {
if (is_int($needle) || is_float($needle)) {
$needle = (string) $needle;
}
if (is_string($needle)) {
foreach ($haystack as &$h) {
if (is_int($h) || is_float($h)) {
$h = (string) $h;
}
}
}
}
return in_array($needle, $haystack, $strict);
} | php | public static function inArray($needle, array $haystack, $strict = false)
{
if (!$strict) {
if (is_int($needle) || is_float($needle)) {
$needle = (string) $needle;
}
if (is_string($needle)) {
foreach ($haystack as &$h) {
if (is_int($h) || is_float($h)) {
$h = (string) $h;
}
}
}
}
return in_array($needle, $haystack, $strict);
} | [
"public",
"static",
"function",
"inArray",
"(",
"$",
"needle",
",",
"array",
"$",
"haystack",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"strict",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"needle",
")",
"||",
"is_float",
"(",
"$",
"needle",
")",
")",
"{",
"$",
"needle",
"=",
"(",
"string",
")",
"$",
"needle",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"needle",
")",
")",
"{",
"foreach",
"(",
"$",
"haystack",
"as",
"&",
"$",
"h",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"h",
")",
"||",
"is_float",
"(",
"$",
"h",
")",
")",
"{",
"$",
"h",
"=",
"(",
"string",
")",
"$",
"h",
";",
"}",
"}",
"}",
"}",
"return",
"in_array",
"(",
"$",
"needle",
",",
"$",
"haystack",
",",
"$",
"strict",
")",
";",
"}"
] | Checks if a value exists in an array.
Due to "foo" == 0 === TRUE with in_array when strict = false, an option
has been added to prevent this. When $strict = 0/false, the most secure
non-strict check is implemented. if $strict = -1, the default in_array
non-strict behaviour is used.
@param mixed $needle
@param array $haystack
@param int|bool $strict
@return bool | [
"Checks",
"if",
"a",
"value",
"exists",
"in",
"an",
"array",
"."
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php#L188-L203 |
3,496 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php | ArrayUtils.iteratorToArray | public static function iteratorToArray($iterator, $recursive = true)
{
if (!is_array($iterator) && !$iterator instanceof Traversable) {
throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable object');
}
if (!$recursive) {
if (is_array($iterator)) {
return $iterator;
}
return iterator_to_array($iterator);
}
if (method_exists($iterator, 'toArray')) {
return $iterator->toArray();
}
$array = [];
foreach ($iterator as $key => $value) {
if (is_scalar($value)) {
$array[$key] = $value;
continue;
}
if ($value instanceof Traversable) {
$array[$key] = static::iteratorToArray($value, $recursive);
continue;
}
if (is_array($value)) {
$array[$key] = static::iteratorToArray($value, $recursive);
continue;
}
$array[$key] = $value;
}
return $array;
} | php | public static function iteratorToArray($iterator, $recursive = true)
{
if (!is_array($iterator) && !$iterator instanceof Traversable) {
throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable object');
}
if (!$recursive) {
if (is_array($iterator)) {
return $iterator;
}
return iterator_to_array($iterator);
}
if (method_exists($iterator, 'toArray')) {
return $iterator->toArray();
}
$array = [];
foreach ($iterator as $key => $value) {
if (is_scalar($value)) {
$array[$key] = $value;
continue;
}
if ($value instanceof Traversable) {
$array[$key] = static::iteratorToArray($value, $recursive);
continue;
}
if (is_array($value)) {
$array[$key] = static::iteratorToArray($value, $recursive);
continue;
}
$array[$key] = $value;
}
return $array;
} | [
"public",
"static",
"function",
"iteratorToArray",
"(",
"$",
"iterator",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"iterator",
")",
"&&",
"!",
"$",
"iterator",
"instanceof",
"Traversable",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"__METHOD__",
".",
"' expects an array or Traversable object'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"recursive",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"iterator",
")",
")",
"{",
"return",
"$",
"iterator",
";",
"}",
"return",
"iterator_to_array",
"(",
"$",
"iterator",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"iterator",
",",
"'toArray'",
")",
")",
"{",
"return",
"$",
"iterator",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"Traversable",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"iteratorToArray",
"(",
"$",
"value",
",",
"$",
"recursive",
")",
";",
"continue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"iteratorToArray",
"(",
"$",
"value",
",",
"$",
"recursive",
")",
";",
"continue",
";",
"}",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"array",
";",
"}"
] | Convert an iterator to an array.
Converts an iterator to an array. The $recursive flag, on by default,
hints whether or not you want to do so recursively.
@param array|Traversable $iterator The array or Traversable object to convert
@param bool $recursive Recursively check all nested structures
@throws Exception\InvalidArgumentException if $iterator is not an array or a Traversable object
@return array | [
"Convert",
"an",
"iterator",
"to",
"an",
"array",
"."
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php#L216-L255 |
3,497 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php | ArrayUtils.filter | public static function filter(array $data, $callback, $flag = null)
{
if (! is_callable($callback)) {
throw new Exception\InvalidArgumentException(sprintf(
'Second parameter of %s must be callable',
__METHOD__
));
}
if (version_compare(PHP_VERSION, '5.6.0') >= 0) {
return array_filter($data, $callback, $flag);
}
$output = [];
foreach ($data as $key => $value) {
$params = [$value];
if ($flag === static::ARRAY_FILTER_USE_BOTH) {
$params[] = $key;
}
if ($flag === static::ARRAY_FILTER_USE_KEY) {
$params = [$key];
}
$response = call_user_func_array($callback, $params);
if ($response) {
$output[$key] = $value;
}
}
return $output;
} | php | public static function filter(array $data, $callback, $flag = null)
{
if (! is_callable($callback)) {
throw new Exception\InvalidArgumentException(sprintf(
'Second parameter of %s must be callable',
__METHOD__
));
}
if (version_compare(PHP_VERSION, '5.6.0') >= 0) {
return array_filter($data, $callback, $flag);
}
$output = [];
foreach ($data as $key => $value) {
$params = [$value];
if ($flag === static::ARRAY_FILTER_USE_BOTH) {
$params[] = $key;
}
if ($flag === static::ARRAY_FILTER_USE_KEY) {
$params = [$key];
}
$response = call_user_func_array($callback, $params);
if ($response) {
$output[$key] = $value;
}
}
return $output;
} | [
"public",
"static",
"function",
"filter",
"(",
"array",
"$",
"data",
",",
"$",
"callback",
",",
"$",
"flag",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Second parameter of %s must be callable'",
",",
"__METHOD__",
")",
")",
";",
"}",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.6.0'",
")",
">=",
"0",
")",
"{",
"return",
"array_filter",
"(",
"$",
"data",
",",
"$",
"callback",
",",
"$",
"flag",
")",
";",
"}",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"params",
"=",
"[",
"$",
"value",
"]",
";",
"if",
"(",
"$",
"flag",
"===",
"static",
"::",
"ARRAY_FILTER_USE_BOTH",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"if",
"(",
"$",
"flag",
"===",
"static",
"::",
"ARRAY_FILTER_USE_KEY",
")",
"{",
"$",
"params",
"=",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"response",
"=",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"response",
")",
"{",
"$",
"output",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Compatibility Method for array_filter on <5.6 systems
@param array $data
@param callable $callback
@param null|int $flag
@return array | [
"Compatibility",
"Method",
"for",
"array_filter",
"on",
"<5",
".",
"6",
"systems"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayUtils.php#L302-L334 |
3,498 | agentmedia/phine-forms | src/Forms/Logic/Tree/RadioListProvider.php | RadioListProvider.TopMost | public function TopMost()
{
$sql = Access::SqlBuilder();
$tblOption = RadioOption::Schema()->Table();
$where = $sql->Equals($tblOption->Field('RadioField'), $sql->Value($this->radio->GetID()))
->And_($sql->IsNull($tblOption->Field('Previous')));
return RadioOption::Schema()->First($where);
} | php | public function TopMost()
{
$sql = Access::SqlBuilder();
$tblOption = RadioOption::Schema()->Table();
$where = $sql->Equals($tblOption->Field('RadioField'), $sql->Value($this->radio->GetID()))
->And_($sql->IsNull($tblOption->Field('Previous')));
return RadioOption::Schema()->First($where);
} | [
"public",
"function",
"TopMost",
"(",
")",
"{",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"tblOption",
"=",
"RadioOption",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"where",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblOption",
"->",
"Field",
"(",
"'RadioField'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"this",
"->",
"radio",
"->",
"GetID",
"(",
")",
")",
")",
"->",
"And_",
"(",
"$",
"sql",
"->",
"IsNull",
"(",
"$",
"tblOption",
"->",
"Field",
"(",
"'Previous'",
")",
")",
")",
";",
"return",
"RadioOption",
"::",
"Schema",
"(",
")",
"->",
"First",
"(",
"$",
"where",
")",
";",
"}"
] | Returns the top most option
@return RadioOption | [
"Returns",
"the",
"top",
"most",
"option"
] | cd7a92ea443756bef5885a9e8f59ad6b8d2771fc | https://github.com/agentmedia/phine-forms/blob/cd7a92ea443756bef5885a9e8f59ad6b8d2771fc/src/Forms/Logic/Tree/RadioListProvider.php#L63-L71 |
3,499 | agentmedia/phine-forms | src/Forms/Logic/Tree/RadioListProvider.php | RadioListProvider.ToArray | public function ToArray()
{
$result = array();
$option = $this->TopMost();
while ($option)
{
$result[$option->GetValue()] = $option->GetText();
$option = $this->NextOf($option);
}
return $result;
} | php | public function ToArray()
{
$result = array();
$option = $this->TopMost();
while ($option)
{
$result[$option->GetValue()] = $option->GetText();
$option = $this->NextOf($option);
}
return $result;
} | [
"public",
"function",
"ToArray",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"option",
"=",
"$",
"this",
"->",
"TopMost",
"(",
")",
";",
"while",
"(",
"$",
"option",
")",
"{",
"$",
"result",
"[",
"$",
"option",
"->",
"GetValue",
"(",
")",
"]",
"=",
"$",
"option",
"->",
"GetText",
"(",
")",
";",
"$",
"option",
"=",
"$",
"this",
"->",
"NextOf",
"(",
"$",
"option",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Gets the radio options as array
@return array Returns the options as associative value=>text array | [
"Gets",
"the",
"radio",
"options",
"as",
"array"
] | cd7a92ea443756bef5885a9e8f59ad6b8d2771fc | https://github.com/agentmedia/phine-forms/blob/cd7a92ea443756bef5885a9e8f59ad6b8d2771fc/src/Forms/Logic/Tree/RadioListProvider.php#L77-L87 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.